x86 程序集添加不同大小的操作数 [英] x86 Assembly Add operands with different sizes

查看:31
本文介绍了x86 程序集添加不同大小的操作数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我喜欢从内存位置添加一个字节到 32 位寄存器,这在 x86 汇编中可能吗?add edx, byte [ebx] 导致错误:操作数大小不匹配

I like to add a byte from a memory location to a 32bit register, is this possible in x86 assembly? add edx, byte [ebx] causes error: mismatch in operand sizes

推荐答案

您需要确保操作数的大小相同.

You need to make sure that the operands are of the same size.

不过这涉及到标志的问题.如果您使用有符号整数,您应该使用movsx,或使用 movzx 如果您使用的是无符号整数.

This involves a problem with the sign though. If you are working with signed integers you should use movsx, or use movzx if you are working with unsigned integers.

movsx/movzx eax, byte ptr [ebx]
add edx, eax

这篇关于x86 程序集添加不同大小的操作数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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