# keyboard input and arithmetic operations using assembly language

I am playing with assembly language and I can read single digits from the keyboard and perform arithmetic operations on them and get sensible answers if the result is not greater than 9 because I read the numbers as ascii characters. I would like to be able to handle larger numbers. How can I go about doing this?

My current simple program is as follows. I expect the program that would read numbers of any size  and perform arithmetic calculations on them would be different and more complex.

jmp start
msg: db "Enter first number",13,10,"\$"
msg2: db "Enter Second number",13,10,"\$"

start:
mov ah,09 ;
lea dx,msg ;display prompt
int 21h

mov ah,01 ;
int 21h
mov dl, al ;
push dx ;preserve the data in dl

;prompt for second number
mov ah,09 ;
int 21h    ;dos interrupt

mov ah,01 ;request keyboard input
int 21h

sub al,30h ;convert ascii to actual integer
pop dx

;display the sum of the two numbers
mov ah,2
int 21h
int 20h ;end program
LVL 2
###### Who is Participating?

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
Hi,
I suggest you do a buffered keyboard input and convert the input string (you may want to verify that it's a number and within a certain range) to a number.  Then you should be able to add the numbers, convert the result to a string and display it.  All I am doing here is describing the methodology (rather than providing code) -- this is to encourage you to experiment more.

Ken
0

Experts Exchange Solution brought to you by