Input name and display it back... - Programmers Heaven

Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Input name and display it back...

sealnight5sealnight5 Posts: 12Member
Hi,

I am trying to write a simple program to ask for user's name, and display it back onto the screen.

But, I am having problem, since I can only get one input from the keyboard.

Here's my code (tasm)


DOSSEG
.MODEL TINY ; 64k segment
.STACK 200h
.DATA

MSG1 db 13, 10, "Hi, how are you? $"
MSG2 db 13, 10, "What is your name? $"
MSG3 db 13, 10, "Thanks $"
MSG4 db 13, 10, " for using my program.$"


START:
MOV AX, @DATA
MOV DS, AX

Entrance:
MOV AH, 9
MOV DX, OFFSET MSG1
INT 21h

MOV AH, 9
MOV DX, OFFSET MSG2
INT 21h

MOV AH, 0
INT 16h

PUSH AX
MOV DL,AL
MOV AH,2
INT 21h
POP AX

MOV AH, 9
MOV DX, OFFSET MSG3
INT 21h

MOV AH, 9
MOV DX, OFFSET MSG4
INT 21h

MOV AX, 4C00h
INT 21h

END START


What I supposed to do now is:

1. Display the welcome message and ask for name:

Hi, how are you?
What is your name

2. Display user's input:

Thanks <<input name>> for using my program.


Can someone explain to me, how do i declare variables in assembly, and store input in that variable.

Thanks

Comments

  • AsmGuru62AsmGuru62 Posts: 6,519Member
    : Hi,
    :
    : I am trying to write a simple program to ask for user's name, and display it back onto the screen.
    :
    : But, I am having problem, since I can only get one input from the keyboard.
    :
    : Here's my code (tasm)
    :
    : [code]
    : DOSSEG
    : .MODEL TINY ; 64k segment
    : .STACK 200h
    : .DATA
    :
    : MSG1 db 13, 10, "Hi, how are you? $"
    : MSG2 db 13, 10, "What is your name? $"
    : MSG3 db 13, 10, "Thanks $"
    : MSG4 db 13, 10, " for using my program.$"
    [red][b]
    : INPUT1 db 16, 0 ; Max. chars = 16
    : INPUT2 db 16 DUP (0) ; Buffer (16 bytes)
    [/b][/red]
    :
    :
    : START:
    : MOV AX, @DATA
    : MOV DS, AX
    :
    : Entrance:
    : MOV AH, 9
    : MOV DX, OFFSET MSG1
    : INT 21h
    :
    : MOV AH, 9
    : MOV DX, OFFSET MSG2
    : INT 21h
    :
    [red][b]
    : MOV AH, 10
    : MOV DX, OFFSET INPUT1
    : INT 21h
    :
    : MOV AL, INPUT1+1 ; How many chars entered
    : CBW ; Make it into AX
    : MOV BX, OFFSET INPUT2
    : ADD BX, AX ; Now BX points AFTER input text
    : MOV AL, '$'
    : MOV [BX], AL ; Store '$' here, so we can use AH=9
    [/b][/red]
    :
    : MOV AH, 9
    : MOV DX, OFFSET MSG3
    : INT 21h
    :
    [red][b]
    : MOV AH, 9
    : MOV DX, OFFSET INPUT2
    : INT 21h
    [/b][/red]
    :
    : MOV AH, 9
    : MOV DX, OFFSET MSG4
    : INT 21h
    :
    : MOV AX, 4C00h
    : INT 21h
    :
    : END START
    : [/code]
    :
    :
    : What I supposed to do now is:
    :
    : 1. Display the welcome message and ask for name:
    :
    : Hi, how are you?
    : What is your name
    :
    : 2. Display user's input:
    :
    : Thanks <<input name>> for using my program.
    :
    :
    : Can someone explain to me, how do i declare variables in assembly, and store input in that variable.
    :
    : Thanks
    :

Sign In or Register to comment.