所以,我尝试将两个整数相除,但结果我应该得到四舍五入为零的数字。如果我做除法 3/2,那么结果是 1,不要 2。
我用过这个网站(代码)
https://cs.fit.edu/~mmahoney/cse3101/float.html
本网站末尾的代码在我的程序中不起作用。
global main
extern printf
section .data
str: db "%i", 10, 0
count: dq 3
size: dq 2
zero: dd 0x0C00
x: dw 0
section .text
main:
mov ecx, 0
start:
fninit
fnstcw x
mov ax, x
or ax, c00h
mov x, ax
fldcw x
fldcw dword [zero]
fild qword [count]
fidiv dword [size]
frndint
fist dword [count]
push dword [count]
push dword str
call printf
mov eax, 1
int 80h
我阅读了关于这个主题的不同书籍。我知道我应该使用寄存器 CR,但我不能编写代码。所以,我使用 linux 86 位。请帮帮我...这写给我终端(错误)
test.asm:22: error: invalid combination of opcode and operands
test.asm:24: error: symbol `c00h' undefined
test.asm:25: error: invalid combination of opcode and operands
test.asm:26: error: invalid combination of opcode and operands
test.asm:28: error: mismatch in operand sizes
我尝试使用普通的“div”命令,但出现错误。所以,我在互联网上搜索了一个解决方案,但它在我的代码中不起作用。也许这与操作系统的类型和位深度有关