Sample program to add two numbers using structures –
DATA SEGMENT
ORG 1000H
FOO STRUC
A DB 0FFH
B DB 0FFH
SUM DW ?
FOO ENDS
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:MOV AX,DATA
MOV DS,AX
XOR AX,AX
MOV AL,FOO.A
ADD AL,FOO.B
ADC AH,00H
MOV DS:FOO.SUM,AX
HLT
CODE ENDS
END START
No errors and warnings
but while debugging AL is assigned with 00H
Best Answer
You're using the wrong addressing mode. Your instruction
will load the (lower byte) of the address of
FOO.A
inAL
. This is called "immediate addressing mode".Change this into
to use the "direct addressing mode" which will take the expression
FOO.A
as an address to the value to be loaded.While debugging you should have watched that
adds the value "1".