我已经在网上搜索过了,但是我找不到一个明确的例子来理解这个指令是做什么的。
发布于 2018-03-02 15:05:15
移动符号从字节扩展到长字。在Intel语法中,该指令的助记符是MOVSX。
当一个类型的变量int8_t
需要被转换为时int
,AC编译器可以使用这个指令,这在算术和其他一些操作(整数提升)上自动发生。
由于该指令写入目标寄存器的所有32位(或64位),因此避免了只写入寄存器的低8位(或16位)可能导致的性能损失。一组类似的指令允许用零位扩展(英特尔语法中的MOVZX,AT&T语法中的MOVZst(从大小s到大小t))。
发布于 2018-03-02 16:16:45
这是一个很明显的例子:
MOVSBL and MOVZBL
* MOVSBL sign-extends a single byte, and copies it into a
double-word destination
* MOVZBL expands a single byte to 32 bits with 24 leading
zeros, and copies it into a double-word destination
Example:
%eax = 0x12345678
%edx = 0xAAAABBBB
MOVB %dh, %al %eax = 0x123456BB
MOVSBL %dh, %eax %eax = 0xFFFFFFBB
MOVZBL %dh, %eax %eax = 0x000000BB
https://stackoverflow.com/questions/-100003560
复制相似问题