A B
A B

Reputation: 131

How to calculate base displacement addresses

I'm learning very basic assembly language stuff starting with some pseudo-code.

If the instruction "10(50)" translates to: Go to memory location [50 + 10] -- i.e., this is base displacement addresses,

and if the instruction "@50" translates to: Go to memory location[[50]], i.e., find what [50] is pointing to (call that x), and find [x]

What does "10(@50") mean? It seems to me like the instruction is ambiguous. Do you resolve the @50 part and then add the displacement? Or do you add the displacement to the @50 and then resolve @60?

Thanks for any help you can offer.

Upvotes: 1

Views: 1891

Answers (1)

Michael
Michael

Reputation: 58487

If memory serves me right, it would have to be [[50 + 10]] on IA-32. As in:

JMP DWORD PTR 10[50]  ; Jump to the 32-bit address located at address 60

The one example of post-indexed memory-indirect addressing that comes to mind is the 6502, where you'd write it as (imm8),Y. For example:

LDY #10
LDA (50),Y  ; Loads the 16-bit word at 50, adds the value of Y to it, and
            ; uses the result as the effective address for an 8-bit load
            ; into register A

Note that the index has to be in register Y; so you can't write something like LDA (50),10.
In fact, I can't recall ever having come across a processor that includes such an addressing mode. Which is not to say that one doesn't exist.

Upvotes: 1

Related Questions