adding two numbers with tasm

have I gone too far with this program? I am doing something horribly wrong. I need to add two numbers, and have the answer displayed.
We are tasked with writing a a recursive program, adding two base-10 numbers (from 1-8), and displaying the answer. The way this is written, it must prompt you for the base-10 numbers. Here is what i have put together thus far, and I am sure it is a far cry from what it should be. Could anybody help me? Thanks

P.S., if there is an easier way of going about this (using turbo assembler) please let me know.

;;program add (a sub-procedure)
;;Stephen Madden

.model small
.stack 100h
Message DB 'Enter a base-10 numeric digit: $'
return DB, 13, 10, '$'
Addup proc

mov ax, @data
mov ds, ax; Initialize DS

mov DX,offset Message
mov ah, 9h
int 21h

mov ah, 1
int 21h; puts character in al

sub al, 30h
mov bl, al

mov dx,offset return
mov ah, 9h
int 21h; fist do carriage return/line feed
mov dx,offset message
int 21h; displays message (ah is still 9)
mov ah, 1; get character input
int 21h; puts character in al

;convert to number, store in al
sub al, 30h

;add the two numbers, result in bl
add bl, al
;if using td, observe register bl

cmp bl, 10
jl outdigit
mov ah, 2
mov dl, bl
int 21h; output the leading '1'

;return to DOS (by hand)
mov ah, 4ch
int 21h

Addup endp
end Addup


  • I think that you're on the right track. However,
    if you'd like to make it easier on yourself, break each part
    of your program (input, processing and output) into sub procedures.

    If you'd like some code for inputting and outputting numbers, I have a library of TASM functions at

    Let me know if you have any more questions,

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion