1

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.

Einar Sundgren
  • 4,325
  • 9
  • 40
  • 59
aqibjr1
  • 651
  • 5
  • 21

1 Answers1

1

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
aqibjr1
  • 651
  • 5
  • 21