`BITS 32`

extern __cprintf

extern __getch

global main

section .data

IntFormat db "%i",0

RemainderFormat db ".%i",0

AnInt1 dd 0

AnInt2 dd 0

section .text

main:

;DIV performs unsigned integer division. The explicit operand provided is the divisor; the dividend and destination operands are implicit, in the following way:

;For DIV r/m8, AX is divided by the given operand; the quotient is stored in AL and the remainder in AH.

;For DIV r/m16, DX:AX is divided by the given operand; the quotient is stored in AX and the remainder in DX.

;For DIV r/m32, EDX:EAX is divided by the given operand; the quotient is stored in EAX and the remainder in EDX.

mov edx,0

mov eax, 13

mov ebx, 2

div ebx ;ax.dx is the answer

mov [AnInt1] , eax

mov [AnInt2], edx

push dword [AnInt1]

push IntFormat

call __cprintf

push dword [AnInt2]

push RemainderFormat

call __cprintf

call __getch

yields 6.1

Although now atleast if I divide something without a remainder the result is correct.

What am i doing wrong ? ^^

I realise the e.x registers are 32 bit and I don't need to use them for such small divisions but i was too lazy to edit them XD

I am however fiddling with the code waiting for a reply !