Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jun 28th, 2012, 8:43 AM   #1
minsu44
Newbie
 
Join Date: Jun 2011
Posts: 6
Rep Power: 0 minsu44 is on a distinguished road
Problem How to get user input an print properly?[TASM]

Hello i am really just a begginner in assembly (TASM).
anyway, my program is quite simple it is tasked to just ask the user's name and ID number. after which i have to print "hello <name> your ID is <number>"

but I cant seem to print both of them at the same line. the second user input seems to over write the first user input for some odd reason.


the out put should be:
hello, <name> your ID is: <number>

but it keeps getting over written and usually its like
hello, <number> or <number> <part of name>

help please?
         TITLE simple proj
         DOSSEG
         .model SMALL
         .stack 100h
         .data
GREET    db "Hello, $"
PNAME    db "Name: $"
SNAME    db 24 dup("$")
CRLF     db 13,10,"$"
PID      db "ID# : $"
SID      db 12 dup("$")
URID	 db "! Your ID number is: $"

         .code

BEGIN:mov ax, @data
          mov ds, ax
          mov es, ax
		  

          mov al, 03h    		 	; clear screen
          mov ah, 00h
          int 10h

		 
		  
	 mov dx, OFFSET PNAME		; Print NAME: 
          mov ah, 09h				
          int 21h					
		  
		
          mov byte ptr SNAME, 21
          mov dx, OFFSET SNAME		; scanf Name		
          mov ah, 0Ah
	int 21h

	mov	dx, OFFSET CRLF 	; print \n
          mov ah, 09h
          int 21h
		  
          mov dx, OFFSET PID  		; Print ID:			
          mov ah, 09h
          int 21h


          mov byte ptr SID, 9
          mov dx, OFFSET SID 		; Scanf ID			
          mov ah, 0Ah
		  int 21h
		  
		  
	 mov	dx, OFFSET CRLF 	; print \n
          mov ah, 09h
          int 21h


	mov	dx, OFFSET GREET	; print Hello,
          mov ah, 09h
          int 21h


          mov SI, 0002
          lea DX, SNAME[SI]  		; Print Name Entered
          mov ah, 09h
		  int 21h
		 
		 
	mov dx, OFFSET GREET		; print URID
          mov ah, 09h
          int 21h
		  
		  
	mov SI, 0002
          lea DX, SID[SI]  		; Printf ID Entered
          mov ah, 09h
	int 21h
		  
		
          mov ah, 4ch
          int 21h
          end BEGIN
minsu44 is offline   Reply With Quote
Old Jun 28th, 2012, 10:44 AM   #2
sixstringartist
Programming Guru

 
Join Date: Jun 2005
Posts: 1,333
Rep Power: 14 sixstringartist will become famous soon enough
Re: Problem How to get user input an print properly?[TASM]

A few things:

Im not very familiar with TASM. Im assuming $ is a delimiter \0?

What is the purpose of your mov SI, 0002 instructions?

Also you're printing GREET twice at the end. I assume you want to print URID instead of the second GREET.

Any reason why you're using TASM? If I were you I would use an assembler that is still supported such as MASM.
sixstringartist is offline   Reply With Quote
Old Jun 28th, 2012, 10:52 AM   #3
minsu44
Newbie
 
Join Date: Jun 2011
Posts: 6
Rep Power: 0 minsu44 is on a distinguished road
Re: Problem How to get user input an print properly?[TASM]

yes $ is an indicator that this certain line for string has ended

the mov SI, 0002 is because when in tasm the
1st storage(0000) is max length,
and 2nd storage(0001) is actual length used/entered
so the 3rd storage(0002) is used where the input saving starts taking place.

oh my yes i didnt notice that. yes thank you for the correction.
it should be:
	mov dx, OFFSET URID		; print URID
          mov ah, 09h
          int 21h
nonetheless, my problem still remains the same
it is not able to properly print in ONE LINE: hello, <name>! your ID is: <number>

thank you so much for taking your precious time to correct and even look into my problem.
minsu44 is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
case esac: basics - not exits after input edcompsci Bash / Shell Scripting 9 Jan 4th, 2012 2:29 PM
How to use malloc, to input an array size form user treashunter C 5 May 15th, 2011 10:28 PM
If statement from user input smythml Bash / Shell Scripting 1 Apr 19th, 2010 9:46 PM
input data from user into array lilmul123 C++ 5 May 26th, 2006 9:29 AM
Python calculator problem Nebula Python 14 Feb 8th, 2006 12:24 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:28 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC