No. There's "rep movsX" (where X is b/w/d) for moving data but that one
requires ecx to be initialized to the number of items to copy and
doesn't care much about what it's copying. A "lodsd" and "stosd"
followed by the test routine someone posted here earlier and a
conditional jump seems like the best solution to me (provided that the
gain of copying dwords make up for the time the test routine takes to
execute compared to a "lodsb","stosb","or al,al", "jnz lop" version).
[some time later]
Copying dwords certainly seem to make up for the overhead time of the
test routine. Even when implementing it with a .com file under dos (16
bit seg and _lots_ of penalties when operating on 32 bit data) it's a
few cycles faster per byte copied than the latter version (copying byte
by byte). In a proper implementation, with 32 bit segment, the
difference should be quite a bit bigger.
I don't guarantee that my implementation is bug-free (nothing is). Feel
free to check it out if you like, I've attached it to this mail. No,
it's not optimized.
-- Mikael;------------- start of test1.asm .model tiny .386 .code org 100h _main:
db 0fh,31h mov time1,eax
mov cx,10000 mainlop: ;----------------------------------------------------------- ;----------------------------------------------------------- ;-----------------------------------------------------------
lea si,s1 lea di,s2
lop: lodsb stosb or al,al jnz lop
;----------------------------------------------------------- ;----------------------------------------------------------- ;-----------------------------------------------------------
loop mainlop
db 0fh,31h
sub eax,time1 call _putd
ret
_putd: push eax shr eax,16 call _putw pop eax _putw: push eax mov al,ah call _putb pop eax _putb: push eax shr al,4 call _putn pop eax _putn: push eax and al,0fh add al,90h daa adc al,40h daa int 29h pop eax ret
time1 dd ?
s1 db 'Testing mem copy routines...',0 ; 28 chars s2 db 256 dup(?)
end _main
;------------- end of test1.asm
in the second version I replaced the inner loop with
;----------------------------------------------------------- ;----------------------------------------------------------- ;----------------------------------------------------------- lea si,s1 lea di,s2
lop: lodsd stosd
mov ebx,eax sub eax,01010101h not ebx and eax,ebx and eax,80808080h
jz lop ;----------------------------------------------------------- ;----------------------------------------------------------- ;-----------------------------------------------------------
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu