Good day to everyone
I am having some trouble with an assignment for my work at College in UK (im 17)
We have been given the task of, and the criteria of
The program should allow the user to input 4 numbers as follows:
'0' - Exit the program
'1' - Add (using iteration) all the even numbers up to and including 20
'2' - Input two numbers in the range 0 - 9 and add them together
'3' - Input two numbers in the range 0 - 9 and subtract second from first
The program should repeat until zero is selected.
I have succesfully done 0,1,3 but my Addition is slacking
I have registered to move the result to BL but when it goes there when I enter number 1 it shows 3"#"
then when i add the second number it shows 6"#" although the # is right my teacher tells me it needs to have 3"#" with the answer.. not even my teacher could figure out why this was happening so i am here to ask for a hand
something to be aware of.. if you enter AAA before line 200 would fix the error above but it would show the ascii code instead of the number entered
here is the code
please go to Sums:
Thanks
JMP BEGIN
MSG4 DB 'BTEC EXTENDED DIPLOMA in IT- SIMPLE CALCULATOR $'
JMP BEGIN
MSG5 DB 'JULY 2012 (ASSIGNMENT 3) $'
JMP START
MSG DB 'PLEASE CAN YOU ENTER NUMBER 0 TO 3 $'
MSG3 DB 10,13,'sum = $'
newline DB 10,13, ' $'
CAL1 DB 'ENTER FIRST NUMBER: $'
CAL2 DB 'ENTER SECOND NUMBER: $'
JMP START
CR EQU 13D
LF EQU 10D
NUMBER EQU 02
LIMIT EQU 20
BEGIN: MOV DX, OFFSET MSG4
MOV AH, 09
INT 21H
MOV DL, CR
MOV AH, 2H
INT 21H
MOV DL, LF
MOV AH, 2H
INT 21H
MOV DX, OFFSET MSG5
MOV AH, 09
INT 21H
MOV DL, CR
MOV AH, 2H
INT 21H
MOV DL, LF
MOV AH, 2H
INT 21H
START: MOV DX, OFFSET MSG
MOV AH, 09
INT 21H
MOV DL, CR
MOV AH, 2H
INT 21H
MOV DL, LF
MOV AH, 2H
INT 21H
MOV AH, 00 ; READ KEYBOARD
INT 16h ;
;
MOV DL, AL ;DISPLAY KEY PRESSED
MOV AH, 2H ;
INT 21H
CMP AL, '0'
JE EXIT
CMP AL, '1'
JE ITERATION
CMP AL, '2'
JE SUMS
CMP AL, '3'
JE SUBTRACTION
SUBTRACTION: MOV DL, CR
MOV AH, 2H
INT 21H
MOV DL, LF
MOV AH, 2H
INT 21H
MOV DX, OFFSET CAL1
MOV AH, 09
INT 21H ;SHOW
MOV AH, 00
INT 16h ;INPUT NUMBER
MOV DL, AL
MOV AH, 2H
INT 21H
MOV BL,AL
MOV DL, CR
MOV AH, 2H
INT 21H
MOV DL, LF
MOV AH, 2H
INT 21H
MOV DX, OFFSET CAL2
MOV AH, 09
INT 21H ; SHOW
MOV AH, 00
INT 16h ; INPUT
SUB BL, AL
MOV DL, AL
MOV AH, 2H
INT 21H
MOV DL, CR
MOV AH, 2H
INT 21H
MOV DL, LF
MOV AH, 2H
INT 21H
JMP START
ITERATION: MOV DL, CR
MOV AH, 2H
INT 21H
MOV DL, LF
MOV AH, 2H
INT 21H
MOV BH, NUMBER
REPEAT: ADD BL, BH
ADD BH, NUMBER
CMP BH, LIMIT
JNG REPEAT
JMP START
SUMS: MOV DL, CR
MOV AH, 2H
INT 21H
MOV DL, LF
MOV AH, 2H
INT 21H
MOV DX, OFFSET CAL1
MOV AH, 09
INT 21H ; SHOW WORDS
MOV AH, 00
INT 16h ; INPUT NUMBER
MOV DL, AL
MOV AH, 2H
INT 21H
MOV BL, AL
MOV DL, CR
MOV AH, 2H
INT 21H
MOV DL, LF
MOV AH, 2H
INT 21H
MOV DX, OFFSET CAL2
MOV AH, 09
INT 21H ; SHOW WORDS
MOV AH, 00
INT 16h ; INPUT NUMBER
ADD BL, AL
MOV DL, AL
MOV AH, 2H
INT 21H
MOV DL, CR
MOV AH, 2H
INT 21H
MOV DL, LF
MOV AH, 2H
INT 21H
JMP START
Exit: MOV AH, 4CH
INT 21H
END