Ron Serruya
Ron Serruya

Reputation: 4426

Divide OverFlow ASM

I'm doing a calculator project for school and all the thing work good , but Divide and Mod(%) are giving me a "Divide Overflow" error , how can i fix it?

For the full code : http://pastebin.com/a9cuL0LJ

Divide is line 158

Mod is line 166

Both Num1Int and Num2Int are numbers between 0-255

Or:

DivideDo:
push ax
mov ax , word ptr Num1Int
div Num2Int
mov ResultInt , al
pop ax
ret

ModDo:
push ax
mov ax , word ptr Num1Int
div Num2Int
mov ResultInt , ah
pop ax
ret

Upvotes: 1

Views: 1034

Answers (1)

NPE
NPE

Reputation: 500167

One obvious problem is that, while Num1Int is 8 bits wide:

    Num1Int db ?

you treat it as if it were 16 bits wide:

    mov ax , word ptr Num1Int

Upvotes: 1

Related Questions