Is there an opcode that zeroes a range of memory?
If not, I wonder how ZeroMemory does?:confused:
If not, I wonder how ZeroMemory does?:confused:
A similar question has been asked here.
It does it by using a number of instructions, of course.
Is there an opcode that runs a 3r337 3D engine? If not, I wonder
how quake3 and the rest does it...
Is there an opcode that runs a 3r337 3D engine? If not, I wonder
how quake3 and the rest does it...
why dont you try this
cleanbuff proc
mov eax, offset logfont
xor ebx,ebx
mov BYTE PTR ,0
@@:
inc ebx
mov BYTE PTR ,0
cmp ebx,SIZEOF LOGFONT
jne @B
ret
cleanbuff endp
cleanbuff proc
mov eax, offset logfont
xor ebx,ebx
mov BYTE PTR ,0
@@:
inc ebx
mov BYTE PTR ,0
cmp ebx,SIZEOF LOGFONT
jne @B
ret
cleanbuff endp
ZeroMemory macro memory, n
local _Byte
local _MoveByByte
local _MoveByQword
local _Done
mov ebx, memory
mov eax, n
xor edx, edx
mov ecx, eax
and eax, 0FFFFFFF0h
je _Byte
add ebx, eax
pxor mm0, mm0
neg eax
_MoveByQword:
movq qword ptr [ebx+eax], mm0
add eax, 16
jne _MoveByQword
_Byte:
and ecx, 0Fh
je _Done
add ebx, ecx
neg ecx
_MoveByByte:
mov byte ptr [ebx+ecx], dl
inc ecx
jne _MoveByByte
_Done:
endm
It does it by using a number of instructions, of course.
Is there an opcode that runs a 3r337 3D engine? If not, I wonder
how quake3 and the rest does it...
Originally posted by f0dder It does it by using a number of instructions, of course.
Is there an opcode that runs a 3r337 3D engine? If not, I wonder
how quake3 and the rest does it...
Is there an opcode that runs a 3r337 3D engine? If not, I wonder
how quake3 and the rest does it...
LOL
mov eax, 031337h
pushad
cli
runquake3 eax
sti
popad
ret
Thanks to all (except fOdder!!!! you were fooling me!!! :o I was asking about the opcodes (of course, not "opcode") that are likely to be the implementation of RtlZeroMemory!).
jademtech, the thread you told me helped me out.
jademtech, the thread you told me helped me out.
bomb01, you are supposed to joke
back:"I tried runquake3 and it did
not work".
back:"I tried runquake3 and it did
not work".
Hi bdjames,
May be...
May be...
ZeroMemory macro memory, n
local _Byte
local _MoveByByte
local _MoveByQword
local _Done
mov ebx, memory
mov eax, n
;xor edx, edx
mov ecx, eax
;and eax, 0FFFFFFF0h
and eax, -8
je _Byte
;add ebx, eax
mov edx, eax
pxor mm0, mm0
;neg eax
_MoveByQword:
movq qword ptr [ebx+eax-8], mm0
;add eax,16
sub eax, 8
jnz _MoveByQword
add ebx, edx
_Byte:
;and ecx,0Fh
and ecx, 7
je _Done
;add ebx, ecx
;neg ecx
_MoveByByte:
;mov byte ptr [ebx+ecx-1], dl
mov byte ptr [ebx+ecx-1], 0
dec ecx
jnz _MoveByByte
_Done:
endm
:)Oops...
Yes a byte is eight not four bits...
But is
mov byte ptr , 0
faster than:
mov byte ptr , dl
I will check it tomorrow.
Yes a byte is eight not four bits...
But is
mov byte ptr , 0
faster than:
mov byte ptr , dl
I will check it tomorrow.
ZeroMemory macro memory, n
local _Byte
local _MoveByByte
local _MoveByQword
local _Done
mov ebx, memory
mov eax, n
mov ecx, eax
and eax, -8
je _Byte
pxor mm0, mm0
mov edx, eax
_MoveByQword: movq qword ptr [ebx+eax-8], mm0
sub eax, 8
jne _MoveByQword
add ebx, edx
_Byte: and ecx, 7
je _Done
_MoveByByte: mov byte ptr [ebx+ecx-1], 0
dec ecx
jne _MoveByByte
_Done:
endm
I hate those who keep joking when others are with trouble...at least, not in this thread. :o
My joke came at a time when your question was already answered. Your "trouble" was no longer, and I didn't expect to be outright hated for posting innocent little lighthearted humor.
bdjames, I appreciate your idea with quadword, but would
be faster than the jmps in your code?
xor eax, eax
lea edi, Buffer
mov ecx, dwBufferLength
mov edx, ecx
shr ecx, 2
shl ecx, 2
sub edx, ecx
shr ecx, 2
rep stosd
mov ecx, edx
rep stosb
be faster than the jmps in your code?
My joke came at a time when your question was already answered. Your "trouble" was no longer, and I didn't expect to be outright hated for posting innocent little lighthearted humor.
iblis, sorry for my offense.
I'd haul off.
lol mine works fine to zero out memory
Should depend on size of buffer...
~ 1cycle per dword
ZeroMemory macro buffer, n
local _Byte
local _MoveByQword
mov edi, buffer
mov ecx, n
xor eax, eax
mov ebx, ecx
pxor mm0, mm0
and ecx, 7
and ebx, -8
je _Byte
add edi, ebx
neg ebx
_MoveByQword: movq qword ptr [edi+ebx],mm0
add ebx, 8
jne _MoveByQword
_Byte: rep stosb
endm
~ 1cycle per dword
bdjames, what's the syntax to enable MMX support?
I know that .mmx enables the support for instruction set, but the assembler doesn't recognize mmx registers even if .mmx is specified.:confused:
I know that .mmx enables the support for instruction set, but the assembler doesn't recognize mmx registers even if .mmx is specified.:confused:
if you're using the case sensitive option, use MM0 instead of mm0.
there was another thread about uppercasing MMX registers, but i forgot where that went.
edit: nm. found it:
click here
there was another thread about uppercasing MMX registers, but i forgot where that went.
edit: nm. found it:
click here
Qages
.data?
buffer01 byte 260 ?
if buffer01 had 259 character in it and i have already used it and wanted to clear this once (.data?) buffer..... will your code do it?
Or will a simple
mov buffer01 [0], 0
do the same thing.
Posted on 2002-05-13 01:47:35 by cmax
.data?
buffer01 byte 260 ?
if buffer01 had 259 character in it and i have already used it and wanted to clear this once (.data?) buffer..... will your code do it?
Or will a simple
mov buffer01 [0], 0
do the same thing.
Posted on 2002-05-13 01:47:35 by cmax
cmax, clearing the first byte will of course not clear the whole buffer -
but if you use the buffer for zero-terminated strings, it has the effect
of readying the buffer for a new string (setting the string length
to zero)
but if you use the buffer for zero-terminated strings, it has the effect
of readying the buffer for a new string (setting the string length
to zero)