Mostfa shma
Mostfa shma

Reputation: 213

assembly data addressing how does little endian work?

.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

Answers (1)

Joshua
Joshua

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

Related Questions