Header Ads Widget

Ticker

6/recent/ticker-posts

What is the difference between a direct and an indirect address instruction ?

Direct addressing means the instruction refers directly to the address being accessed. That is, the instruction encoding itself contains the address of the location. Depending on the instruction set, it may also allow computing a small index relative to the address. When used that way, you can think of that as a direct-indexed mode. (Note: Some processors call ‘direct’ mode ‘absolute’, such as the 6502.)

 Indirect addressing uses an address held in a register or other location to determine what memory location to read or write. The idea here is that the instruction itself isn’t directly telling you the address to access, but rather indirectly telling the CPU where to find that address. The processor may also allow you to add a small offset to the indirect address, giving an indirect-indexed addressing mode.

Also Read : 5 Best Terminal Emulators for Linux

The 6502 one is a little quirky: The 6502 doesn’t have general-purpose registers large enough to store addresses, so its indirect addressing modes use values stored in the zero page as indirect addresses.

The second example for the 8086 is also instructive: It’s identical to the direct-indexed example! If the index and the address are the same size, they can be interchanged. It all depends on whether you think of the constant value as an address and the register as an offset, or vice-versa.

Post a Comment

0 Comments