When I write this:
mov cx,dh
mov dx,dl
It makes an error:
invalid combination of opcode and operands
I'm a beginner at assembly language so I need help!
mov cx,dh
The error message you get for mov cx, dh
means that the size of the CX destination register (16 bits) is different from the size of the DH source register (8 bits). For most instructions, operands must be the same size.
There are several ways to do mov cx, dh
.
unsigned signed
-------- ------
1) movzx cx, dh 1) movsx cx, dh ; 80386+
2) mov ch, dh ; 80186+
sar cx, 8
2) mov cl, dh 3) mov al, dh ; 8086+
mov ch, 0 cbw
mov cx, ax
3) xor cx, cx 4) mov ch, dh
mov cl, dh mov cl, 8
sar cx, cl
4) mov al, 1 5) mov al, 1
mul dh imul dh
mov cx, ax mov cx, ax
There are several ways to do mov dx, dl
.
unsigned signed
-------- ------
1) movzx dx, dl 1) movsx dx, dl ; 80386+
2) mov dh, dl ; 80186+
sar dx, 8
2) mov dh, 0 3) xchg ax, dx ; 8086+
cbw
xchg dx, ax
3) mov al, 1 4) mov dh, dl
mul dl mov cl, 8
mov dx, ax sar dx, cl
5) mov al, 1
imul dl
mov dx, ax
There are several ways to do mov cx, dh
mov dx, dl
.
unsigned signed
-------- ------
1) movzx cx, dh 1) movsx cx, dh ; 80386+
xor dh, dh movsx dx, dl
2) xor cx, cx 2) mov ch, dh ; 8086+
xchg dh, cl mov dh, dl
mov cl, 8
sar dx, cl
sar cx, cl
Choose wise and stick with the simple ones!