16 bit Assembly

Home   Feedback   Site Map   Instruction Index  


Using Addresses

16 bit assembly code can be used to access and manipulate memory addresses. These can be used for data direct data access, counters and mathematics.

In 16 bit the use of addressable registers is limited to the following. In 32 bit and above all 16 bit registers can be used.
Addressable register combinations : [BX+SI], [BX+DI], [BP+SI], [BP+DI], [SI], [DI], [BP], [BX].

Addressing [SI], [DI] or [BX] only applies to data is the DS Segment.
Addressing [BP] only applies to data is the SS Segment.
In this way it is possible to access data from different segments without a lot of register re-assignment.

To use addressing you must first give the register a start address. Data can accessed by increasing the offset value by adding [BX+2] or subtracting [BX-2] offsets in multiples of 2.
We use 2 as each 16 bit register has 2 bytes. You cannot access single bytes individually but you can increment the offsets 1 byte at time if required.

Example:
MOV BX, 0x0004 ; Set BX to a memory address
MOV AX, [BX] ; Read the value from the memory address pointed to by BX
MOV [BX+2], AX ; Writes the value in AX to the next memory address pointed to by BX+2.

Commands that can use addressing

ADD, AND, CALL, CMP, DEC, DIV, INC, JMP, MOV, MUL, NEG, NOT, OR, POP, PUSH, SCAS, SUB, XOR, XCHG.




Last Update 27/12/2022