Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Alright, I fail at this.

Name: Anonymous 2007-02-24 0:19 ID:Ap4Fgg3r

For a class I'm taking, we're working with some simplified coding, to learn how the machine handles memory.  Our assignment now seems simple: Create a program that takes in three values, and outputs the highest.  Easy in any other programming language I've ever done, but we have to do it in Visible Virtual Machine (http://www.cba.uri.edu/faculty/vvm/)

So we have the commands:
ADD (Add number)
SUB (Subtract number)

BRP (Branch if positive)
BRZ (Branch if zero)
BR  (Branch)

DAT (data)
HLT (Halt, stop)
IN (Input)
LDA (Load accumulator)
OUT (Output)
STO (Store)

So, I figure, it'll have to be something like
IN
STO 97
IN
STO 98
IN
STO 99
LDA 97
SUB 98
BRP xx
LDA 97
SUB 99
BRP xx
LDA 98
SUB 99
BRP xx

So basically, it gets three numbers, subtracts the second from the first, and branches to.. Somewhere, if it's positive (Meaning the first is bigger.)  Then the same with the first and third, then second and third.  After that, I'm completely confused.

Has anyone else here done something like this, and are possibly able to help me?  I don't need the exact program, just some direction. >_>;

Name: Anonymous 2007-02-24 1:36 ID:VvSPNaGb

THIS VMM SHIT SUCKS
FUCKING SERIOUSLY
THERE IS NO IMMEDIATE OR INDIRECT ADDRESSING MODES
WTF IS THIS, 1972????

Real machine languages aren't this demented.

Anyway, you need to allocate another location to hold the highest number 'so far'.

LDA 97 // first number
SUB 98 // second number
BRP SECOND_IS_HIGHER
// First is higher
// so load it again and store it in a temporary location
LDA 97
STA 90
JMP CHECK_NEXT
SECOND_IS_HIGHER:
LDA 98
STA 90

CHECK_NEXT:
// 90 now has the highest number between 97 and 98
// Next task is to compare 90 with 99
// whichever is highest is highest number
LDA 90
SUB 99
BRP THIRD_IS_HIGHER
// Earlier number from before is higher
// so output it
OUT 90
HLT // and GTFO

THIRD_IS_HIGHER:
OUT 99
HLT // and GTFO

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List