Is it possible to check a string that is stored in a dword for spaces?
Sincerely yours;
jdm
You would need to check the nybbles for the value of the space char...20h for example.
If you put each byte of the double word in a register, it would be easier to detect.
I know how to put a dword in a registry, but how would I go back doing what you suggested?
Thanks for the help.
I'm working on a program that is to fetch a username from the user and store it in a variable. I want to be able to test that variable to make sure that it is only alpha letters, no tab or spaces included. If so then prompt the user again. I'm able to get the username from the user and store it in a value, but I'm having trouble with the rest. Any help would be appreciated a lot.
Thanks in advance for the help.
Sincerely yours;
jdm
hGreet PROC ;beginning of the hGreet proc
mov eax, lightgreen + (black * 16) ;light green text on black background
call SetTextColor ;set foreground and background color
mov edx, OFFSET myMessage ;moves a greeting message into edx
call writeString ;display message to the screen.
mov eax, lightred + (black * 16) ;light red text on black background
call SetTextColor ;set foreground and background color
mov edx, OFFSET myMessage7 ;moves instruction on username into edx
call writestring ;display message to screen
call crlf ;return line
mov eax, lightgreen + (black * 16) ;light green text on black background
call SetTextColor ;set foreground and backgorund color
mov edx, OFFSET myMessage2 ;moves a message into edx that prompts the user for a username
call writeString ;display to the screen
mov eax, white + (black * 16) ;white text on black background
call SetTextColor ;set foreground and background color
mov edx, OFFSET buffer ;points to the buffer
mov ecx, SIZEOF buffer ;specify max characters
call readString ;reads the input from the keyboard until the enter key is hit
mov byteCount, eax ;number of characters
mov eax, white + (black * 16) ;white text on black background
call SetTextColor ;set foreground and background color
mov uName, edx ;stores the username in uName
mov edx, OFFSET myMessage3 ;moves a message into edx
call writeString ;display message on the screen
mov edx,uName ;moves the username to edx
call writestring ;display username on screen
call crlf ;return line
hGreet ENDP ;end of the hGreet proc
This is what I'm using to get and store the username. BTW uName is a DWORD
mov edx, OFFSET buffer ;points to the buffer
mov ecx, SIZEOF buffer ;specify max characters
call readString ;reads the input from the keyboard until the enter key is hit
mov byteCount, eax ;number of characters
mov uName, edx ;stores the username in uName
I understand and have experimented with bit manipulation to detect the 20h in a portion of a word or double word. I don't have a satisfactory result yet.
For a personal project, I would force a byte comparison.
hang on...
I would also consider grabbing the word at the offset and comparing it like this:
;397489
mov di, buffer
mov bx, word ptr[di]; ; BX Now contains the space and the lower-case t
; at this point, I can compare bh or bl to 20h
int 20h
buffer:
db 't his is neat$'
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.