简体   繁体   English

无法将寄存器移动到寄存器

[英]Cannot move a register to a register

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).您收到的mov cx, dh错误消息意味着 CX 目标寄存器(16 位)的大小与 DH 源寄存器(8 位)的大小不同。 For most instructions, operands must be the same size.对于大多数指令,操作数的大小必须相同。

There are several ways to copy DH in CX.有几种方法可以在 CX 中复制 DH。

   unsigned              signed
   --------              ------

1) movzx cx, dh       1) movsx cx, dh       ; 386+

                      2) mov   ch, dh
                         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   ah, dh
   mov   cl, dh          mov   cl, 8
                         sar   ax, cl
                         mov   cx, ax

There are several ways to copy DL in DX.有几种方法可以在 DX 中复制 DL。

   unsigned              signed
   --------              ------

1) movzx dx, dl       1) movsx dx, dl       ; 386+

                      2) mov   dh, dl
                         sar   dx, 8

2) mov   dh, 0        3) mov   al, dl       ; 8086
                         cbw
                         mov   dx, ax

                      4) mov   dh, dl
                         mov   cl, 8
                         sar   dx, cl

Choose wise and stick with the simple ones!明智地选择并坚持简单的!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM