I have a homework on this, the purpose of the homework is to calculate in assembly (emu8086) this f(x)=x^2+2x-3. The problem is when I divide the result in order to print it I get a divide overflow error and I don't know why or how to fix it. Can anyone help?
TITLE MYPROGRAM
DEDOMENA SEGMENT
protropimsg db "Dwsse arithmo x:",10,13,"$"
apotelesmamsg db 10,13,"to apotelesma einai",10,13,"$"
x_number db 0
tmp1 db 0
f_result dw 0
dekada db 0
monada db 0
DEDOMENA ENDS
KODIKAS SEGMENT
ARXH:MOV AX,DEDOMENA
MOV DS,AX
LEA DX,protropimsg
MOV AH,09
INT 21h
MOV AH,01h
INT 21h
SUB AH,30h
MOV x_number,AH
MOV AH,x_number
MOV BH,x_number
ADD AH,BH
MOV CH,3
SUB AH,CH
MOV tmp1,AH
MOV AL,x_number
MOV DL,x_number
MUL DL
MOV BL,tmp1
MOV BH,0
ADD AX,BX
MOV f_result,AX
MOV AX,f_result
MOV BL,10
DIV BL
MOV dekada,AL
MOV monada,AH
LEA DX,apotelesmamsg
MOV AH,09
INT 21h
MOV DL,dekada
ADD DL,30h
MOV AH,02h
INT 21h
MOV DL,monada
ADD DL,30h
MOV AH,02h
INT 21h
MOV AH,4CH
INT 21H
KODIKAS ENDS
END ARXH
This looks incorrect:
MOV AH,01h
INT 21h
SUB AH,30h
MOV x_number,AH
Interrupt 21h/AH=01h returns the character in AL
, not in AH
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.