#### Howdy, Stranger!

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

# adding two numbers with tasm

Member Posts: 24
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

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

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
;if using td, observe register bl

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

mov ah, 4ch
int 21h

• Member Posts: 272
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 http://slicer69.tripod.com/code/

Let me know if you have any more questions,
Jesse

• USAMember Posts: 0

_____ ( http://forcoder.org ) free video tutorials and ebooks about // C++, Perl, Java, Objective-C, C#, Ruby, Swift, Delphi, PHP, JavaScript, Assembly, Visual Basic, R, Scratch, MATLAB, Python, C, Go, PL/SQL, Visual Basic .NET D, Lua, Logo, Rust, Dart, Crystal, Bash, FoxPro, Kotlin, Lisp, SAS, Prolog, ML, F#, Alice, VBScript, Clojure, ABAP, LabVIEW, Julia, COBOL, Erlang, Scala, Hack, Awk, Fortran, Transact-SQL, Apex, Scheme, Ada // ______________