[b][red]This message was edited by stevem222 at 2002-9-16 7:42:13[/red][/b][hr]
[b][red]This message was edited by stevem222 at 2002-9-16 7:37:27[/red][/b][hr]
I am very new at this. Just started taking the Assembler class at school. 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
.data
Message DB 'Enter a base-10 numeric digit: $'
return DB, 13, 10, '$'
.code
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'
outdigit:
;return to DOS (by hand)
mov ah, 4ch
int 21h
Addup endp
end Addup
[b][red]This message was edited by stevem222 at 2002-9-16 7:37:27[/red][/b][hr]
I am very new at this. Just started taking the Assembler class at school. 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
.data
Message DB 'Enter a base-10 numeric digit: $'
return DB, 13, 10, '$'
.code
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'
outdigit:
;return to DOS (by hand)
mov ah, 4ch
int 21h
Addup endp
end Addup