; Hello, I'm new to assembly language x8086, the problem is how can I add two negative numbers (decimal) and display them in HEX. I'm stuck at the point the code does not detect the negative numbers and I don't know how to display it in HEX. can someone help me? here my code
TITLE PROB12
PAGE 60,132
.MODEL SMALL
.STACK 64H
.DATA
NUM1 DB 8,?,8 DUP (?)
NUM2 DB 8,?,8 DUP (?)
PROMPT1 DB CR,LF,'Enter the first number','$'
PROMPT2 DB CR,LF,'Enter the second number','$'
PROMPT3 DB CR,LF,'The total sum is '
SUM DB 7 DUP (?),'$'
CR EQU 0DH
LF EQU 0AH
.CODE
MAIN: MOV AX,@DATA
MOV DS,AX
CALL CLEAR ;clear screen
MOV AH,09
MOV DX,OFFSET PROMPT1
INT 21H ;display first prompt
MOV AH,0AH
MOV DX,OFFSET NUM1
INT 21H ;get first number
MOV AH,09
MOV DX,OFFSET PROMPT2
INT 21H ;display second prompt
MOV AH,0AH
MOV DX,OFFSET NUM2
INT 21H ;get second number
MOV SI,OFFSET NUM1 + 8 ;point to LSD of number 1
MOV DI,OFFSET NUM2 + 8 ;point to LSD of number 2
MOV BX,OFFSET SUM + 6 ;point to LSD of sum
MOV CX,7 ;add 7 bytes
CLC ;clear carry
ADD_LP: MOV AL,[SI] ;get byte from number 1
ADC AL,[DI] ;add byte from number 2
PUSHF ;save any carry
AAA ;ASCII adjust
OR AL,30H ;make it ASCII
POPF ;restore flags
MOV [BX],AL ;store sum (in BCD)
DEC SI ;decrement pointers
DEC DI ;to point to next byte
DEC BX
LOOP ADD_LP ;loop through 7 bytes
MOV AH,09
MOV DX,OFFSET PROMPT3
INT 21H ;display result
MOV AH,4CH
INT 21H ;go back to DOS
;--------------------------------------------------
CLEAR PROC
MOV AH,06 ;clear screen function
MOV AL,00 ;page 0
MOV BH,07 ;normal attribute
MOV CX,0 ;entire screen
MOV DX,184FH
INT 10H
RET
CLEAR ENDP
END MAIN