我如何可以移动8位地址转换成x86汇编的16位寄存器? [英] How can I move an 8-bit address into a 16-bit register in x86 assembly?

查看:334
本文介绍了我如何可以移动8位地址转换成x86汇编的16位寄存器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面,我试图移动变量X(它是一个8位的变量)到寄存器BX(这是一个16位寄存器)。我如何移动X的值到寄存器BX在这种情况下?

  .686p
.MODEL平,STDCALL
.STACK 2048。数据
X字节5
ExitProcess的原型,退出code:DWORD
。code开始:
调用了ExitProcess,0MOV BX,X; 1 GT; p4.asm(13):错误A2022:指令操作数必须是相同的大小结束开始;是什么END语句呢?


解决方案

在除了拉胡尔的回答,如果您还需要清零 BH 和任何80386的工作或更高版本(由指示的 .686p )是:

  MOVZX BX,X

如果你正在使用X作为一个符号值,需要符号扩展 BX

  MOVSX BX,X

Here, I'm trying to move the variable X (which is an 8-bit variable) into the register bx (which is a 16-bit register). How can I move the value of X into the register bx in this case?

.686p
.model flat,stdcall
.stack 2048

.data
X byte 5
ExitProcess proto, exitcode:dword
.code

start:
invoke  ExitProcess, 0

mov bx, X; 1>p4.asm(13): error A2022: instruction operands must be the same size

end start ;what does the end statement do?

解决方案

In addition to Rahul's answer, if you also need to zero out bh and are working on anything 80386 or newer (as indicated by the .686p) is:

movzx bx, X

Of if you are using X as a signed value and needs to sign-extend bx:

movsx bx, X

这篇关于我如何可以移动8位地址转换成x86汇编的16位寄存器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆