something simple is eluding me here can anyone help

Started by jonriba, April 25, 2006, 08:52:03 PM

Previous topic - Next topic

jonriba


How would you go about allowing the user to enter a string of numbers, or anything longer than 1 digit?


:8)
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

mnemonic

If I were you, I'd have a look into the 16 bit DOS Programming Subforum. ;)

I'm pretty sure that the question has been already answered there.

Regards

EDIT:
Hell, I'm sure that in the campus was a sticky thread called "If your code contains int 21h..."  :eek
Be kind. Everyone you meet is fighting a hard battle.--Plato
-------
How To Ask Questions The Smart Way

MichaelW

jonriba,

Double posting is not any way to get help here. One post per topic is sufficient.

You can use the Buffered Keyboard Input function (interrupt 21h function 0Ah) to read a string from standard input. You will need code to convert the input strings to number values, and code to convert the result of the addition to a string that can be displayed. Try searching this forum as mnemonic suggested.

eschew obfuscation