i wrote a code for this c++ expression in assembly language using 32 bit unsigned operands
If (val2 ==0) then
{val2 = 1}
val1 = (val3 / val2) * (val1 + val3)
but i got error "overflow Integer"
the error is at div val2
when i enter the val1 = 600, val2= 0, val3= 1000 any higher number won't work just the smaller number... how to correct this?
https://i.imgur.com/ivcRkVI.png
INCLUDE Irvine32.inc
.data
val1 BYTE ?
val2 BYTE ?
val3 BYTE ?
prompt BYTE "Please enter 3 numbers: ",0
out1 BYTE "val1 = (val3 / val2) * (val1 + val3) = ",0
.code
main PROC
;;CLEAR ALL REGISTERS
xor eax,eax
xor ebx,ebx
xor ecx,ecx
xor edx,edx
;;DISPLAY PROMPT
mov edx,offset prompt
call writestring
;;NEWLINW
mov al,0ah
call writechar
;;READ VAL1 AND STORE
call readint
mov val1,al
;;READ VAL2 AND CHECK AND STORE
call readint
cmp al,0 ;;CHECK IF 0
jnz skip
mov val2,1 ;;IF 0, MAKE VAL1 AS 1
jmp readnext
skip:
mov val2,al ;;ELSE STORE SAME VALUE
readnext:
;;READ VAL3 AND STORE
call readint
mov val3,al
div val2 ;;CALCULATE VAL3/VAL2
mov bl,al ;;SAVE IN BL
mov al,val3
add al,val1 ;;ADD VAL3+VAL1
mul bl ;;(VAL3/VAL2)*(VAL3+VAL1)
;;DISPLAY MESSAGE
mov edx,offset out1
call writestring
;;DISPLAY ANSWER
call writedec
;;DUMP REGISTERS
call dumpregs
call waitmsg ;;WAIT FOR A KEY PRESS
INVOKE ExitProcess, 0
main ENDP
END main