Hi,
Please could someone tell me why the below code wont work, im trying to add two numbers together and display the result (both numbers are entered by the user). Im new to this, but as far as i can see ive done it correctly but it just outputs a random character that means nothing to me. Also this code will only work with single digit numbers, how would i go about allowing the user to enter a string of numbers, or anything longer than 1 digit?
Thanks alot.
Please could someone tell me why the below code wont work, im trying to add two numbers together and display the result (both numbers are entered by the user). Im new to this, but as far as i can see ive done it correctly but it just outputs a random character that means nothing to me. Also this code will only work with single digit numbers, how would i go about allowing the user to enter a string of numbers, or anything longer than 1 digit?
Code:
TITLE ADD
.model small
.stack 100h
.data
add_msga db 10,13, "Enter Number 1: $"
add_msgb db 10,13, "Enter Number 2: $"
add_num1 db ?
add_num2 db ?
add_result db ?
.code
main PROC
mov ax,@data
mov ds,ax
call AddNumbers
mov ax, 4c00h
int 21h
main ENDP
AddNumbers PROC
;get num1
mov ah, 09h
mov dx, offset add_msga
int 21h
mov ah, 1h
int 21h
mov add_num1, al
;get num2
mov ah, 09h
mov dx, offset add_msgb
int 21h
mov ah, 1h
int 21h
mov add_num2, al
;add [numbers]
mov al, add_num1
add al, add_num2
mov add_res, al
;output result
mov ah, 09h
mov dx, offset add_res
int 21h
ret
AddNumbers endp
END main
Thanks alot.