为什么我可以进入EAX,斧头,但不能进入Al,甚至进入AH
Why can I mov into eax, into ax, but not into al, or even maybe into ah?
如果i mov, eax 12345
及以后的 mov var, eax
(假设var为32bit int etc.eTC ..),然后输出 var
稍后它将正确输出。
与ax
相同。mov ax, 65535
-> mov var16, ax
将正确输出。
但是,如果我将mov
转到al
甚至ah
中,则不会输出任何内容。
也许进入ah
不起作用是有道理的。但是为什么这两个呢?
typedef int int32;
typedef unsigned char int8;
typedef short int16;
int _tmain(int argc, _TCHAR* argv[])
{
int8 c1 = 0;
int8 c2 = 0;
__asm
{
mov al, 255
mov c1, al
}
cout << c1 << endl; //outputs nothing, same if I used ah
//whereas
int32 n = 0;
__asm
{
mov eax, 10000
mov n, eax
}
cout << n << endl; // works fine, well, you get the picture
return 0;
}
这个问题不是(仅)与您的汇编代码,这是您打印价值的方式:
cout << c1 << endl;
即使C1是未签名的char(又名UINT8),C iostreams也像对待普通char一样对待它。换句话说,该代码大致等于:
printf("%cn", c1);
将其施放给未签名的int,它应该可以正常工作。
btw,在某些平台上(例如Linux PowerPC),普通char实际上是未签名的。
256
等于 2^8
当您使用int8
时,它使用TWOS补体方法,因此数字在[-128 , 127]
我认为,如果您将其类型更改为 unsigned Integer ,它必须工作
相关文章:
- 结构体 S { int align; } 之间的区别;(struct 关键字后的名称)和 struct { int al
- 在 ifcondition al中 find() C++ STL 中的 == a.end() 有什么用?
- testb $1, %al 的语义是什么
- Open AL 的函数在 ubuntu 中使用 g++ 编译时给出未定义引用的错误
- 英特尔 Pin:分析例程检测 ah 寄存器而不是 RSP (REG_STACK_PTR)
- XOR AL,AL+MOVZX EAX,AL与XOR EAX,EAX相比有什么优势
- 为什么我可以进入EAX,斧头,但不能进入Al,甚至进入AH
- 打开 Al 录音并播放音频 - C++
- 是带有 RAX/EAX/AX/AL/AH 寄存器作为目的地的携带速度更快的补充
- 这个指示错了吗?(动产%al,0xe400000000004049)
- OpenMAX AL在信号6 (SIGABRT)时崩溃.媒体服务器死亡
- 编号和字符串排序Al
- OpenAL 的 AL/al.h 在 Mac OS X Lion 和 XCode 4.1 上找不到