从https://www.felixcloutier.com/x86/div:
...
temp ? AX / SRC;
IF temp > FFH
THEN #DE; (* Divide error *)
ELSE
AL ? temp;
AH ? AX MOD SRC;
FI;
...
Run Code Online (Sandbox Code Playgroud)
对于div ah该SRC会ah。恕我直言,temp将始终大于FFH,因此将引发异常,因为:
FFH我在这里想念什么吗?
我正在尝试计算表达式A * B + ( A + B ) / ( A - B ),其中 A 和 B 是用户输入的整数。我在 linux 内核上使用 ALong32 库。
%include "along32.inc"
section .data
msg1 db 'Enter A: ', 0
msg2 db 'Enter B: ', 0
msg3 db 'Result: ' , 0
err db 'Error: cannot divide by 0', 0
A resb 4
B resb 4
section .text
global main
main:
mov edx, msg1
call WriteString
call ReadInt
mov [A], eax ; move the input …Run Code Online (Sandbox Code Playgroud)