-2

I want to swap to 8 bit variables var1 and var2, using registers, but it give me this error. What is wrong with this code?

include irvine32.inc

.data

var1 byte 20

var2 byte 30

.code 

main proc

mov al,var2

mov var2,var1

mov var1,al

call dumpregs

exit 

main endp

end main
rkhb
  • 14,159
  • 7
  • 32
  • 60
Knowledge 32
  • 9
  • 1
  • 6
  • 1
    You can't move memory to memory in one `mov` instruction. This is a problem `mov var2,var1` . You can move memory to a temporary register and then from that register to another memory location. – Michael Petch Sep 24 '16 at 14:10

1 Answers1

1

Memory to memory operation are not allowed, you can use this code:

mov al,var1

mov ah,var2

mov var1,ah

mov var2,al
Stefano Balzarotti
  • 1,760
  • 1
  • 18
  • 35