Wednesday 15 May 2013

assembly - Is there any reason to use MOVS/CMPS/STOS/SCAS without a repeat prefix? -



assembly - Is there any reason to use MOVS/CMPS/STOS/SCAS without a repeat prefix? -

the x86 architecture allows string instructions used or without repeat prefix. don't seem interesting without repeat prefix. movs without rep, example, can replaced simple mov.

is there reason utilize movs (and stos, scas, cmps) without rep? or useless idiosyncrasy of x86 instruction set?

yes. not on purpose, yet can utilize them sort of optimization.

it is, example, faster (provided rsi, rsi point right location) utilize movs than

mov rax,[whatever1] mov [whatever2],rax

for rest, i'm not sure @ moment, execution times looked guess. incrementing/decrementing rsi, rdi side effect here actually.

also, printing c style string in low level mode (no formatting or special chars; direct video memory access) like:

; ... _load_char: lodsb or al,al jz _end_of_string stosw jmp _load_char _end_of_string: ; ...

here need examine each single character load , determine if end of string reached or not cannot utilize rep. though 1 might think of repz movsb won't work here, since 1 of 2 consecutive bytes in video mem attribute byte particular character. in case intended feature.

assembly x86

No comments:

Post a Comment