Could some one please tell me how to get the lenght out of a register. I might have a buffer declared at 128 but it might only have 3 letters in it and may not be 0 terminated so from buffer to buffer there is no problem but when i try to do it with regsters i get the whole 128 lenght when i write it to file. You can tell all of the blank spaces the the text file show by moving the cursor to the end of the line....Anyway the example below will explan what i am trying to do.

::::: This is what i want to avoid doings. The string might be less than 128 sometimes

mov esi, eax
mov edi, offset Buffer1
mov ecx, 128
rep movsb

::::: Posted on 2002-03-13 19:05:50 by cmax
mov ecx, lengthof Buffer1
Posted on 2002-03-13 21:43:10 by The Svin
LENGTHOF & SIZEOF are MASM specific assembler functions which only evaluate at assemble-time. There is no way for the assembler (MASM) to know what a register will have in it at run-time. The assembler is basically very dumb about the whole purpose of your program - only in very rare circustances does it ever look beyond the current line it is parsing. MASM has many features that you won't find in FASM/NASM (yet). But don't get fooled into thinking the assembler knows anything more about your code than what you've told it explicitly.

When you do:

MyData dd 123 dup(0)

You tell the assembler that MyData is 492 bytes, and those bytes are meant to be accessed four at a time (DWORDS).

When you do:

mov eax, OFFSET MyData

The assembler doesn't keep track of what EAX holds. You can tell it to ASSUME what EAX is, but that is something you have to explicitly do. And unless you tell the assembler to ASSUME EAX:NOTHING these assumptions will cause you problems.

(LENGTHOF eax) means nothing to the assembler, and there isn't a way to extract that information out of EAX - the assembler doesn't keep track of it. It's that simple.

Hope this is a little clearer.
Posted on 2002-03-13 21:46:00 by bitRAKE
Now i know that i got to make other operations that i tried work this time instead of going giving up and going back to try to make something work that Never Had a Chance.

I wasted Many, Many,Many Moons trying to do this off and on for the pass 6 or 10 months.

Svin, i think you mis-understood my question but im going to try it out anyway just in case you did'nt ...

Thanks again
Posted on 2002-03-13 22:49:32 by cmax