我有以下32位x86汇编代码:
.text
.global _start
_start:
/* Compare 3 < 2 */
mov $2, %eax
cmp $3, %eax
/* Set the low byte of %eax according to the SF and 0F flags. */
setl %al
/* Syscall exit with the value of %eax. */
mov %eax, %ebx
mov $1, %eax
int $0x80
Run Code Online (Sandbox Code Playgroud)
如果我汇编并链接它,我会得到一个以退出代码1退出的二进制文件.如果我切换CMP操作数,我的二进制文件将退出0.
这与我的预期相反.CMP 根据x86参考:
通过从第一个操作数中减去第二个操作数,然后以与SUB指令相同的方式设置状态标志来执行比较.
第一个操作数是3,第二个操作数是2. 3-2是1,大于零,那么为什么SF(符号标志)设置?
归档时间: |
|
查看次数: |
101 次 |
最近记录: |