News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Working with text

Started by john113, April 21, 2008, 02:51:51 AM

Previous topic - Next topic

john113

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...

donkey

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
@@:
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable