Stuck on a question while looking over my past exam papers. The question reads 'What, if anything, is wrong with the following instructions?'
.text
dadd r2,r0,10
j r3
dsub r4,r1,N(r0)
Stuck on a question while looking over my past exam papers. The question reads 'What, if anything, is wrong with the following instructions?'
.text
dadd r2,r0,10
j r3
dsub r4,r1,N(r0)
That would depend on which assembler you're using. But if we assume that you're using an assembler that looks at the instructions strictly as-is:
dadd r2,r0,10
The dadd
instructions takes three registers as its operands. For the operands r2,r0,10
you would use daddi
(doubleword add immediate).
j r3
The j
instruction expects an absolute address (i.e. j some_label
). For register-indirect jumps you'd use the jr
instruction.
dsub r4,r1,N(r0)
Like dadd
, dsub
also takes three registers as its operands. As far as I know there's no variant of dsub
that accepts a memory location as one of its operands. This instruction would have to be split in two (e.g. ld r4,N(r0)
, followed by dsub r4,r1,r4
).