<Base indexed addressing>
.MODEL SMALL
.STACK
.DATA
T BYTE ' ABCDEFGHIJKLMNOPQRSTUVWXYZ$'
.CODE
MAIN:
MOV AX,@DATA
MOV DS,AX
MOV BX,01H
MOV SI,01H
MOV DL,[BX][SI]
MOV AH,02H
INT 21H
MOV AH,4CH
INT 21H
END main
Result==> L
<Register indirect addressing>
.MODEL SMALL
.STACK
.DATA
T BYTE 'ABCDEFGHIJKLMNOPQRSTUVWXYZ$'
.CODE
MAIN:
MOV AX,@DATA
MOV DS,AX
MOV BX,02H
MOV DL,[BX]
MOV AH,02H
INT 21H
MOV AH,4CH
INT 21H
END main
Result==> A
WHY they get different results ?
In my point,i think that both results are same because they addressing same address.
Address of variable is missed :
MOV DL, T[BX][SI]
MOV DL, T[BX]
Thanks sir
But if i don't interpose T,Are their address different!?
Hi,
Quote from: buli on March 23, 2016, 11:03:38 AM
But if i don't interpose T,Are their address different!?
Without the T to specify the variable address, an address of
zero will be used. If the T variable is the first variable declared
in the data segment, it will have an address of zero. If anything
is specified before T, T will not have an address of zero. The
variable's address is its offset from the beginning of the segment.
HTH,
Steve N.
deleted
deleted
Hi,
Quote from: nidud on March 24, 2016, 01:49:37 AM
The segments are calculated at a 16-byte boundary so T may not be the same as DATA. There is also a SPACE in front of A in the first sample but not the second.
Good catch, thanks. The DATA area is called a segment (using
the SEGMENT directive) but it can be byte-aligned. The segment
registers are limited to a 16 byte resolution. According to a
textbook, the default alignment of DATA is a paragraph (16 bytes)
for earlier processors, and DWORD (8 bytes) when using a .80386
directive. And presumably then, for all of the 32-bit processors.
Old textbook. And other alignment types can be specified.
So an address of a variable is its offset from the start of the DATA
area, plus the DATA area's offset from a 16-byte alignment.
Regards,
Steve
P.S. While I was typing, you added a WORD aligned example. It
is not that the CODE and DATA areas overlap as such, but that the
DATA area is not on a 16-byte boundary. The addressing of the
segment registers "overlap".
P.P.S. My code is usually set up to have the DATA area on a 16-byte
boundary. So I forgot that it need not be aligned.
SRN
SRN
deleted
Thanks FORTRANS and Nidud a lot :biggrin:
How patient you are!!
I think that i forgot a useful tool----"Debug"
Well,there some point i still can't understand(Occupy 30%). But i expected that as i finish the course,i will realize them.