Assembly how to check empty string?

Click For Summary
SUMMARY

The discussion focuses on checking for an empty string input in Assembly language, specifically when a user hits the Enter key without entering a value. The code snippet provided demonstrates the use of the EAX register and the comparison of the AL register to zero to determine if the input is empty. If the input is empty, the program exits using the ExitProcess function. Additionally, it highlights the importance of using the correct input function based on the operating system, such as using INT 21h for MSDOS to read a line of input.

PREREQUISITES
  • Understanding of Assembly language syntax and structure
  • Familiarity with the EAX and AL registers in x86 architecture
  • Knowledge of system calls and interrupts, particularly INT 21h for MSDOS
  • Basic concepts of program flow control in Assembly, including conditional jumps
NEXT STEPS
  • Research the use of INT 21h for reading user input in MSDOS Assembly
  • Learn about the ExitProcess function and its implementation in Assembly
  • Explore conditional jumps in Assembly language for flow control
  • Investigate different input methods for various operating systems in Assembly
USEFUL FOR

Assembly language programmers, systems programmers, and anyone developing low-level applications that require user input handling in a DOS environment.

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 ·
Replies
7
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 4 ·
Replies
4
Views
5K
  • · Replies 9 ·
Replies
9
Views
4K
  • · Replies 7 ·
Replies
7
Views
7K
  • · Replies 22 ·
Replies
22
Views
6K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 4 ·
Replies
4
Views
21K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 12 ·
Replies
12
Views
3K