58 lines
1.2 KiB
Plaintext
58 lines
1.2 KiB
Plaintext
|
# Fill a region of memory with zeroes.
|
||
|
|
||
|
== code
|
||
|
|
||
|
copy-bytes: # src: (addr byte), dest: (addr byte), size: int
|
||
|
# pseudocode:
|
||
|
# curr-src/esi = src
|
||
|
# curr-dest/edi = dest
|
||
|
# i/ecx = 0
|
||
|
# while true
|
||
|
# if (i >= size) break
|
||
|
# *curr-dest = *curr-src
|
||
|
# ++curr-src
|
||
|
# ++curr-dest
|
||
|
# ++i
|
||
|
#
|
||
|
# . prologue
|
||
|
55/push-ebp
|
||
|
89/<- %ebp 4/r32/esp
|
||
|
# . save registers
|
||
|
50/push-eax
|
||
|
51/push-ecx
|
||
|
52/push-edx
|
||
|
56/push-esi
|
||
|
57/push-edi
|
||
|
# curr-src/esi = src
|
||
|
8b/-> *(ebp+8) 6/r32/esi
|
||
|
# curr-dest/edi = dest
|
||
|
8b/-> *(ebp+0xc) 7/r32/edi
|
||
|
# var i/ecx: int = 0
|
||
|
b9/copy-to-ecx 0/imm32
|
||
|
# edx = size
|
||
|
8b/-> *(ebp+0x10) 2/r32/edx
|
||
|
{
|
||
|
# if (i >= size) break
|
||
|
39/compare %ecx 2/r32/edx
|
||
|
7d/jump-if->= break/disp8
|
||
|
# *curr-dest = *curr-src
|
||
|
8a/byte-> *esi 0/r32/AL
|
||
|
88/byte<- *edi 0/r32/AL
|
||
|
# update
|
||
|
46/increment-esi
|
||
|
47/increment-edi
|
||
|
41/increment-ecx
|
||
|
eb/jump loop/disp8
|
||
|
}
|
||
|
$copy-bytes:end:
|
||
|
# . restore registers
|
||
|
5f/pop-to-edi
|
||
|
5e/pop-to-esi
|
||
|
5a/pop-to-edx
|
||
|
59/pop-to-ecx
|
||
|
58/pop-to-eax
|
||
|
# . epilogue
|
||
|
89/<- %esp 5/r32/ebp
|
||
|
5d/pop-to-ebp
|
||
|
c3/return
|