为什么不能仅使用符号标志进行有符号数字比较



所以我做了一个程序,读取两个输入a和b,并将a与b进行比较,如果a更大,则返回1,如果b更大或相等,则仅使用符号标志返回0。我应该使用溢出标志,但我无法找到需要溢出标志的测试用例

位 32

%包括"培训"。

全球主要 外部出口

;; ====================================================== 部分 .文本

; The program begins here:

主要:

call    read_hex  ;;;this function reads an input from shell    
mov     ecx,eax 
call    read_hex
sub     eax,ecx
js      b1          

S1:

call    print_eax ;;;this function prints in shell value in eax
mov     eax,0
call    print_eax
jmp     c1

B1:

call    print_eax ;
mov     eax,1
call    print_eax
jmp c1

c1:

; Exit the process:
push    0
call    exit

我刚刚找到一个测试用例 8000 0000 和 0FFF FFFF 使设置溢出标志并且输出不是预期的

最新更新