I'm writing a program in .asm which prompts the user to enter a sentence. I have no problems with this but one requirement of the program is to change the format of the sentence by replacing all the spaces (" ") with underscore characters ("_"). How do I go about singling out the spaces and the changing them?
patrickgormally
0
Newbie Poster
Recommended Answers
Jump to PostYou would have to load the first byte from your string and check to see if it is a space. If it is, then replace that byte with '_'. Otherwise, just check the next byte. You'd repeat this in a loop until you find the end-of-string character.
Which assembly syntax …
Jump to PostThat's nice code, but I think it'll replace the character after the space with an underscore; you increment BX before you store the underscore. Also, you're comparing words (
cmp AX, [bx]
), not bytes, so your code will never find any spaces.To simplify your code, you might want to …
All 5 Replies
Assembly Guy
72
Posting Whiz
patrickgormally
0
Newbie Poster
Assembly Guy
72
Posting Whiz
patrickgormally
0
Newbie Poster
Assembly Guy
72
Posting Whiz
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.