4 ms·
Yes, the architecture on which you're most likely reading this (x86 or x64) also has semi-dedicated string handling instructions, akin to higher level string fu
by SCHiM 11y ago
Yes, the architecture on which you're most likely reading this (x86 or x64) also has semi-dedicated string handling instructions, akin to higher level string functions.
For example, a string copy 'instruction' that copies a 0 terminated string from one location to another looks like this:
lea esi, source_string
lea edi, dest_string
repnz movsb ; copies esi -> edi until *esi = 0
- rasz_pl 11y agoare you sure about that? http://docs.huihoo.com/help-pc/asm-repne.html http://docs.huihoo.com/help-pc/asm-repne.html http://faydoc.tripod.com/cpu/repnz.htm http://faydoc.tripod.com/cpu/repnz.htm repnz movsb is undocumented and undefined, MOVS doesnt modify flags, not sure how would that work
- SCHiM 11y agoWhoops, looks like I've indeed mixed up my assembler. While the rep/repe/repnz can be used in conjunction with movs(b/w) it will not terminate on the z flag in the eflags register (so it won't stop if *esi == 0) but rather when ecx = 0. So ecx needs to contain the size of the string you want to move, and rep movsb does not use the zero flag.