Saturday, 31 October 2020

Accessing variables in 8086 Assembly Language

 Consider following set of variables declared


Num dw 0x98AD

Num2 dw 0x562B

Num3 dw 0x127A


To access data from these variables, we can use any of three variables (Num, Num2, Num3) as pointer to the memory and access all data by adding or subtracting offset values to the addresses. 


For instance, if you have address of Num2 and you want to access other values using this address as pointer, we can use following instructions;


Mov ax, [Num2];. AX=562B

Mov bx, [Num2+2];. BX=127A

Mov cx, [Num2-2];. AX=98AD

Mov dx, [Num2+1];. AX=7A56


In a similar way, we can use other variables as pointers and access any memory location. 

No comments:

Post a Comment

Effect of ADD and SUB instructions on Flag register-Assembly Language for 8086 processor

Flag Register NOTE: ONE OR MORE FLAGS MAY GET SET OR RESET AFTER AN ARITHMETIC LOGIC INSTRUCTION MOV INSTRUCTION DOESN’T AF...