diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2021-02-10 20:08:32 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2021-02-10 20:08:32 -0800 |
commit | 07852ae00f655ba74ee0f6916190192cf918dbc3 (patch) | |
tree | 351a15aebd3e4b6540243a5f39e84bb7290b3f06 /baremetal/310copy-bytes.subx | |
parent | 4a3414791f4e2a178c60e1a496dbe2698f2f70d9 (diff) | |
download | mu-07852ae00f655ba74ee0f6916190192cf918dbc3.tar.gz |
7710
Include a file for commit 7708.
Diffstat (limited to 'baremetal/310copy-bytes.subx')
-rw-r--r-- | baremetal/310copy-bytes.subx | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/baremetal/310copy-bytes.subx b/baremetal/310copy-bytes.subx new file mode 100644 index 00000000..26fc807e --- /dev/null +++ b/baremetal/310copy-bytes.subx @@ -0,0 +1,58 @@ +# Some helpers for copying non-overlapping regions of memory. +# Really only intended to be called from code generated by mu.subx. + +== 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 |