Reputation: 213
.data
x dw 7A6H, 30B0H
y db 20H
z dw 1, 2, 3
.code
mov ax, @data
mov ds, ax
lea si, y
mov bl, [si+2]
The value of the register bl is 0, why is that? Shouldn't it be 2 from the z dw array?
Upvotes: 0
Views: 108
Reputation: 43278
No, it should be zero. Data is laid out like
x y z
A6 07 B0 30 20 01 00 02 00 03 00
So [y+2] is 0.
In high level languages we have indexing operations that take the sizes into account. Assembly just doesn't do that.
Upvotes: 4