assemblymarie

Writing this MARIE program


For this question, I'm not sure if I've done it correctly (no solutions were provided): Consider the program segment:

 X = 3
 If(X > 0) { Y = X }
 Stop

Write the mnemonic assembly code for this program segment, using MARIE's instruction set.

I came up with this:

Load Three
Store X
If, Load X
Subt Three
Skipcond 800
Jump Endif
Then, Load X
Store Y
Endif, Halt
X, DEC ?
Y, DEC ?
Three, DEC 3

Is this solution acceptable? Also, in terms of the number of memory accesses, would that be 8 (I don't think Halt is a memory access)? Would appreciate some guidance.


Solution

  • Coming back to this after a long time, thought I'd share the answer:

      Load Three
        Store X
        If, Load X
        Skipcond 800
        Jump Endif
        Then, Load X
        Store Y
        Endif, Halt
        X, DEC ?
        Y, DEC ?
        Three, DEC 3