Programming Forums
User Name Password Register
 

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

Reply
 
Thread Tools Display Modes
Old Jun 30th, 2012, 7:09 AM   #1
minsu44
Newbie
 
Join Date: Jun 2011
Posts: 6
Rep Power: 0 minsu44 is on a distinguished road
Error Handling For Null Input[Question]

Well this is not so much of a need, but i really want to learn how to do error handling **embly language[TASM]
Basically if the user just types or presses enter the code will go back to the same question with probably a message box or writing stating that they must put at least one letter.

Example:
Enter string: (user just presses enter)
(message box or ill just print error message)[cuz im not sure if there is message box in ASM or not haha]
Enter string: A [this is still considered string so its accepted]
you entered: A

         TITLE error handling
         DOSSEG
         .model SMALL
         .stack 100h
         .data

PINPUT   db "Enter String: $"
SINPUT   db 14 dup("$")
CRLF     db 13,10,"$"
PENTER   db "You Entered: $"
UERROR   db "Error must enter something! $"
         .code

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

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

		 
names:	  mov dx, OFFSET PINPUT		; Print Enter String: 
          mov ah, 09h	 ; DOS screen output function call
          int 21h		; universal DOS function call
		  
		
          mov byte ptr SINPUT, 11
          mov dx, OFFSET SINPUT			; scan Input	
          mov ah, 0Ah 					
		  int 21h


		  cmp SINPUT, 21h  ;because 21h starts characters
		  jl Erroring  ; jump if something below 21h is entered
		  
		  jmp Prnt	 ; skip error and print user entered value
		  
Erroring: 
		  mov dx, OFFSET UERROR 	  ; print error message
          mov ah, 09h
          int 21h
		  
		  mov dx, OFFSET CRLF 		; print \n
          mov ah, 09h
          int 21h
		  
		  jmp names
		  
Prnt:     
		  mov dx, OFFSET CRLF 		; print \n
          mov ah, 09h
          int 21h
		  
		  mov dx, OFFSET PENTER		; print You entered:
          mov ah, 09h
          int 21h		 		  
		 
		  
		  mov SI, 0002
          lea DX, SINPUT[SI]  	; Print string entered
          mov ah, 09h
		  int 21h
		  
		
          mov ah, 4ch
          int 21h
          end BEGIN
minsu44 is offline   Reply With Quote
Old Jul 2nd, 2012, 1:09 AM   #2
sixstringartist
Programming Guru

 
Join Date: Jun 2005
Posts: 1,333
Rep Power: 14 sixstringartist will become famous soon enough
Re: Error Handling For Null Input[Question]

the control flow of your program looks correct, so at a glance I dont see an issue. What is it doing that you dont expect?
sixstringartist is offline   Reply With Quote
Old Jul 10th, 2012, 4:37 PM   #3
GetSet
Hobbyist Programmer
 
Join Date: Feb 2012
Posts: 143
Rep Power: 6 GetSet is on a distinguished road
Re: Error Handling For Null Input[Question]

if you want to test for an empty string, question is the string null terminated? if so, test for null (0) at the base index of the character array for the string.
GetSet 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




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

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