Category:8086 Assembly: Difference between revisions

m
→‎Other Registers: added an example of indexed addressing
m (→‎The Stack: explained how RET works)
m (→‎Other Registers: added an example of indexed addressing)
Line 37:
 
===Other Registers===
When writing to or reading from consecutive sections of memory, it is helpful to apply an offset from a base value. The Base Pointer register <code>BP</code>, Source Index <code>SI</code>, and Destination Index <code>DI</code> can point to various regions of memory. Many commands that work with these registers can auto-increment or decrement them after each load or store. In addition, they can be optionally offset by a constant, or the value stored in <code>BX</code>, or both at the same time. Unlike the data registers, <code>BP</code>,<code>DI</code>, and <code>SI</code> cannot be split in half and worked on separately. Only data registers allow you to work in 8-bit.
 
The syntax for offsetting an index register will vary depending on your assembler. Many assemblers will often accept multiple different ways of writing it, and it comes down to personal preference.
 
<lang asm>
mov si, offset MyArray
mov bx,2
 
mov al,[bx+si] ;loads decimal 30 into AL
 
MyArray:
byte 10,20,30,40,50</lang>
 
===The Stack===
1,489

edits