How does LEA instruction store address of A?

后端 未结 1 787
清酒与你
清酒与你 2020-12-22 09:27

This is based off this question LEA instruction

Here is the code segment I have a question about

.ORIG X3700
 LEA R0, A
 .....
  A .FILL X1234


        
相关标签:
1条回答
  • 2020-12-22 10:04

    Anytime you see a PCoffset as an opcode operand

    LEA R2, A    ; Loads the memory location of A into R2
                 ; LEA, DR, PCoffset9
    

    It's telling you that when your code is assembled it doesn't actually place the label 'A' into your LEA command.


    Take the following code:

    .ORIG X3700     ; Not a code line in the simulator, only used by the assembler
    LEA R0, A       ; Line 1, starting at x3700
    HALT            ; Line 2
    A .FILL X1234   ; Line 3, located at x3702
    .END            ; Not a code line in the simulator, only used by the assembler
    

    Now in the simulator the LEA line actually looks like this:

    1110 000 000000001    ; Opcode 1110 is LEA
                          ; 000 is our register R0
                          ; 000000001 gives us how many memory locations away A is
    

    And that's what the offset means. It asks the question "How many blocks of memory is A away from me?" and if our variable 'A' is too many blocks away then we will get an error because we cannot represent that value in the offset.

    0 讨论(0)
提交回复
热议问题