The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: john113 on April 21, 2008, 02:51:51 AM

Title: Working with text
Post by: john113 on April 21, 2008, 02:51:51 AM
If I have a text buffer, and want to replace characters, how can I load letters one by one into a register to manipulate?

Please help...
Title: Re: Working with text
Post by: donkey on April 21, 2008, 03:20:23 AM
Normally you would use a register to hold the pointer to the text buffer then mov the bytes in one at a time...

// Assuming MASM syntax here
// Use EDI as the pointer to your buffer
mov edi, offset TextBuffer
@@:
mov al, [edi]

// test to see if you're at the end of the buffer (for NULL terminated strings)
test al, al
jz @F
// The character is in AL, do what you want to it
....

// Put the character back in the same position in the string
mov [edi], al

// Next character
inc edi
jmp @B
@@: