Trying to understand this short assembler instruction but I don't understand

后端 未结 3 1977
攒了一身酷
攒了一身酷 2021-01-18 15:15

We had a task, given was an assembler instruction of a 2-addressing machine:

mov 202, 100[r1+]

Note down a minimal ass

3条回答
  •  天命终不由人
    2021-01-18 16:12

    In mov 202, 100[r1+]:

    • The instruction is a mov
    • The source operand is the memory at address 202. In some assembly languages, you could also write [202] for clarity. There's no # on the number, so it's an absolute addressing mode, not an immediate.
    • The destination operand is the memory at address r1 + 100.
    • The side-effect of the addressing mode is r1++

    Like many flavours of assembly language, this one apparently uses # prefixes to indicate immediate constants. This is like GNU/AT&T x86 syntax, where add $4, %eax adds 4, but add 4, %eax loads a value from the absolute address 4.


    Your professor's given equivalent sequence adds 100 to r1, then subtracts 99, since it wants to avoid displacements and post-increments in addressing modes. It also clobbers r2, which the single-instruction version doesn't, so it's not a drop-in replacement.

提交回复
热议问题