So, i tried division two integer numbers, but in result i should get number with rounding to zero. If I do division 3/2, so result is 1, don't 2.
I used this site (code)
https://cs.fit.edu/~mmahoney/cse3101/float.html
Code in the end of this site don't work in my program.
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
I read diferent book on this topical. I know i should do with register CR, but write code i can't. So, i use linux 86-bit. Please, help me... This writed me terminal (Errors)
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
I tried using the normal "div" command but got an error. So, I searched the internet for a solution, but it doesn't work in my code. Perhaps this is somehow related to the type of OS and bit depth