Hello m new to assembly language. I am trying to get the memory location for variables m using DOSBOX and MASM compilor Here is the code
.model small
.stack 100H
.data
VARA BYTE 10 ;address is DS:xxxx
VARB BYTE 0BH ;address is DS:xxxx+1
VARC WORD ?
VARD SBYTE ?
VARE DWORD ?
ARR BYTE 20 DUP(?)
VARF SWORD 010B
ARRB WORD 10 DUP(?)
VARZ BYTE 0
.CODE
MAIN PROC
mov ax,@data
mov ds,ax
mov ax,offset VARA
mov ah,09
int 21h
mov ax,offset VARB
mov ah,09
int 21h
mov ax,offset VARC
mov ah,09
int 21h
mov ax,offset VARD
mov ah,09
int 21h
mov ax,offset VARE
mov ah,09
int 21h
mov ax,offset ARR
mov ah,09
int 21h
mov ax,offset VARF
mov ah,09
int 21h
mov ax,offset ARRB
mov ah,09
int 21h
mov ax,offset VARZ
mov ah,09
int 21h
mov ah,4ch
int 21h
main endp
end main
How can i find the memory address for all these variables? U can see the error in the image
Use the OFFSET
modifier, eg:
mov ax, OFFSET VARA
to load the address of VARA
into the ax
register. You can also use the LEA
instruction to achieve the same thing:
lea ax, VARA