Assembly how to check empty string?

AI Thread Summary
To check for an empty string in Assembly, the user should compare the AL register after input. If the AL register is zero, indicating no input, the program should exit using the ExitProcess function. The method of reading input may vary based on the operating system, with MSDOS using specific interrupts to capture user input. It's essential to define the input method clearly, whether reading a full string or character by character. Proper handling of user input is crucial for program flow and error management.
naja
Messages
3
Reaction score
0
I am asking user to enter a number if user hits enter key instead of entering a value then i need to exit the program. see code below

Code:
 ; i put the value into eax
 cmp AL,0 ;i compare is al reg is empty
 je exitProgram
 ; some instructions
 exitProgram:
 Invoke ExitProcess,0
 Public _start
 END
 
Physics news on Phys.org
You need to show what function you are reading a string of characters or if reading one character at at time. The function may depend on what operating system you are running on. For example for MSDOS, to get a line of input from the user, you could use

mov ah,00ah
mov dx,offset buffer
int 021h
...
 
Last edited:

Similar threads

Replies
7
Views
3K
Replies
3
Views
2K
Replies
4
Views
5K
Replies
9
Views
4K
Replies
7
Views
7K
Replies
12
Views
2K
Replies
4
Views
21K
Replies
7
Views
2K
Back
Top