logs archiveIRC Archive / Undernet / #asm / 2006 / May / 18 / 1
nnp
anyone know why for a 30 char long string (not including the null) this code returns 30. Shouldnt it return 31?
http://pastebin.com/723659
EwIck
why would it return 31?
that wouldn't make sense
nnp
k, i must be misunderstanding something. Is ecx decremented everytime repne scasb checks a byte?
edcba
yes
EwIck
yeah
nnp
so, 0x00 is the 31st byte which is checked by it....so wouldnt ecx also be decremented (for the 31st time)
EwIck
no because there is termination of the loop (ZF=1)
nnp
ah...so the decrement is conditional and occurs after the rep if ZF=0?
EwIck
well, I'm looking
nah, according to the manual, it is decremented before the check for ZF
         

tiocsti
i know libraries do a not and a dec to do string length usually
EwIck
yeah
tiocsti
with the rest being quite similar, though
set ecx to -1 then do the repnz scasb then not ecx and dec it
and you get string length
nnp
eh? so if its decremented before the check......wouldnt it decrement also for the null?
tiocsti: yea, i think i've seen that method somewhere before
tiocsti
it took me a while to figure out what it was
like i got the looking for 0 part, but the not had me confused when i first saw it
then i was like...damn those trixy hobbitses
nnp
ha
EwIck
I think it saves you one sub for a not
or something
tiocsti
yeah saves you the mov and the sub
however, i think it serializes you too
performance wise, im not sure, it might be a wash
serializing on the ecx accesses
EwIck
well, in his code, I don't understand how it could return the true string length
tiocsti
either do i
EwIck
it should indeed return +1
tiocsti
it should include the \0
from what i can tell
unless his string is 0x40 bytes + a null
EwIck
64 is the buffer size
64 - 63 for a string of length 0
sub 64, 63 = 1
eh.
non sense
nnp
the string is 30(decimal) bytes + null
tiocsti
im almost interested enuff to look into that
but eh, not quite
nnp
k, i must be fu*king up elsewhere. I copied that code into a test file and it works
time for sleep i reckong
vml
Pu pu pu.
When are we getting a new manager?
tiocsti
we dont need no stinkin manager
vml
We couldn't thange the topic, and it would be catastrophic.
change
http://www.sacred-texts.com/dna/hgp011k.htm the nature is a good coder.
Our body is RISC :_p
edcba
it is just the encoding
         

MalibuVI
i use windows xp i use windows xp and im writing a function in assembler similar to malloc.c but how do i write the assembler code to set aside 2048 bytes for allocating memory
hello?
hello rembrandt
i use windows xp i use windows xp and im writing a function in assembler similar to malloc.c but how do i write the assembler code to set aside 2048 bytes for allocating memory
Ingersol
winapi call?
VirtualAlloc?
MalibuVI
yes virtual allocation
Ingersol
it is receipt.
use virtual alloc call.
"virtualAlloc" kernel32.dll
« prev next »