user17341742
user17341742

Reputation: 59

From word to byte

What can I do to take only the right digits of the num ? I tried byte ptr but it changed the vale. Is it possible to delete the 2 left digits in a register?

edit: the number is written within a register so by right and left i meant the high order byte(left) and low order byte(right)

00 00

for example if I have 1203 i want to turn it into 0003 but it still has to be word sized

mov bx, [bp+6]
mov al, [byte ptr bx]

Upvotes: 0

Views: 877

Answers (1)

fuz
fuz

Reputation: 93107

Try clearing the high order byte. For example, try

mov al, [byte ptr bx] ; load low order byte
xor ah, ah            ; clear high order byte

On the 80386 or later, you can also use the movzx instruction:

movzx ax, [byte ptr bx]

Upvotes: 1

Related Questions