I'm relatively new to 8086. I was making a 4 function calculator using procedures. When I enter the input as:
first number:1
second number:1
choice:1 (1 is for addition)
I get the output as 'b'. Getting to my question, can anyone tell me why this is happening and what changes I should make to get my output as '2'?
DATA SEGMENT
MSG1 DB 'Enter a number:$'
MSG2 DB 'Enter another number:$'
MSG3 DB '1 for addition$'
MSG7 DB 'Enter choice(1-4):$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA ;initialize DS
MOV DS,AX
MOV DX,OFFSET MSG1 ;print msg1
MOV AH,09H
INT 21H
MOV AH,01H ;get user input part 1
INT 21H
MOV BL,AL ;store 1st number in BL
PRINTN
MOV DX,OFFSET MSG2 ;print msg2
MOV AH,09H
INT 21H
MOV AH,01H ;get user input part 2
INT 21H
MOV CL,AL ;store 2nd number in CL
PRINTN
MOV DX,OFFSET MSG3 ;print msg3
MOV AH,09H
INT 21H
MOV DX,OFFSET MSG7 ;print msg7
MOV AH,09H
INT 21H
MOV AH,01H ;get user input part 3 (choice for add,sub etc)
INT 21H
MOV DL,AL ;store user's choice in dl
CMP DL,1 ;basically if-else
JE L1
L1:PRINTN
CALL ADDITION ;call addition proc
HLT
ADDITION PROC
ADD BL,CL ;add the numbers and store in bl
MOV DX,OFFSET MSG8 ;print MSG8
MOV AH,09H
INT 21H
MOV DL,BL ;mov sum to dl
MOV AH,02H ;ah=2 for o/p
INT 21H ;interrupt
RET ;go back to main
ADDITION ENDP
Note: I've added the minimum code necessary, in case you want the entire code, let me know.