- For individual users
- Instant access to solutions
- Ask your tech questions
- Start your 30-day Free Trial
Main Topics
Browse All TopicsI 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:
;ask for first number
mov ah,09 ;
lea dx,msg ;display prompt
int 21h
;read first number
mov ah,01 ;
int 21h
mov dl, al ;
push dx ;preserve the data in dl
;prompt for second number
mov ah,09 ;
lea dx,msg2 ;load second message
int 21h ;dos interrupt
;read second number
mov ah,01 ;request keyboard input
int 21h
sub al,30h ;convert ascii to actual integer
pop dx
add dl, al
;display the sum of the two numbers
mov ah,2
int 21h
int 20h ;end program
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: kenspencerPosted on 2003-11-26 at 12:33:19ID: 9827449
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