Intel 8XC196MC User Manual

Page of 579
3-7
PROGRAMMING CONSIDERATIONS
ADDB AL,BL,[CX]
; AL 
 BL + MEM_BYTE(CX) 
POP
[AX]       
; MEM_WORD(AX) 
 MEM_WORD(SP) 
; SP 
 SP + 2
3.2.3.1
Indirect Addressing with Autoincrement
You can choose to automatically increment the indirect address after the current access. You spec-
ify autoincrementing by adding a plus sign (+) to the end of the indirect reference. In this case,
the instruction automatically increments the indirect address (by one if the destination is an 8-bit
register or by two if it is a 16-bit register). When your code is assembled, the assembler automat-
ically sets the least-significant bit of the indirect address register. The following instructions use
indirect addressing with autoincrement:
LD
AX,[BX]+
; AX 
 MEM_WORD(BX)
; BX 
 BX + 2 
ADDB AL,BL,[CX]+
; AL 
 BL + MEM_BYTE(CX)
; CX 
 CX + 1 
PUSH [AX]+
; SP 
 SP - 2
; MEM_WORD(SP) 
 MEM_WORD(AX)
; AX 
 AX + 2
3.2.3.2
Indirect Addressing with the Stack Pointer
You can also use indirect addressing to access the top of the stack by using the stack pointer as
the WORD register in an indirect reference. The following instruction uses indirect addressing
with the stack pointer:
PUSH [SP]
; duplicate top of stack
; SP 
← 
SP + 2
3.2.4
Indexed Addressing
Indexed addressing calculates an address by adding an offset to a base address. There are three
variations of indexed addressing: short-indexed, long-indexed, and zero-indexed. Both short- and
long-indexed addressing are used to access a specific element within a structure. Short-indexed
addressing can access up to 255 byte locations, long-indexed addressing can access up to 65,535
byte locations, and zero-indexed addressing can access a single location. An instruction can con-
tain only one indexed reference; any remaining operands must be direct references.
3.2.4.1
Short-indexed Addressing
In a short-indexed instruction, you specify the offset as an 8-bit constant and the base address as
an indirect address register (a WORD). The following instructions use short-indexed addressing.
LD
AX,12H[BX]
; AX 
← 
MEM_WORD(BX + 12H) 
MULB AX,BL,3[CX]
; AX 
 BL 
× 
MEM_BYTE(CX + 3)