I have the following assignment:
Write a complete 8086 program to perform the calculator functions: ADD/SUB/DIV/MUL.
When the user presses “=” your program should display the result. Only the numbers from 0-9 are input.
ones db ?
tens db ?
mov ah,1
int 21h
add al,30H
mov tens, al
mov ah,1
int 21H
mov dl,al
cmp dl, '+'
je addition
addition:
mov ah,1
int 21h
mov bl,al
mov ones,al
I have to do it by adding 30h to each number then subtracting it. Can someone explain how I can do this?
0x30 is the 0 sign in ASCII so if you want to print a number between 0-9 you should add 0x30 to the value to make it an ‘0’ character. If you read from the terminal you would read 0x30 instead of 0 so if you want to make calculation with it you would need to subtract 0x30 to convert an ‘0’ character to the value 0
http://en.wikipedia.org/wiki/ASCII