520e3c2542
The ol' 8-byte-register-names issue strikes again. There's no way to access the lower 8 bits of ESI. There's still a bug in baremetal/ex2.mu; it's printing transposed somehow.
47 lines
1.2 KiB
Plaintext
47 lines
1.2 KiB
Plaintext
# Primitives for screen control.
|
|
|
|
pixel: # screen: (addr screen), x: int, y: int, color: int
|
|
# . prologue
|
|
55/push-ebp
|
|
89/<- %ebp 4/r32/esp
|
|
# . save registers
|
|
50/push-eax
|
|
51/push-ecx
|
|
# ecx = screen
|
|
8b/-> *(ebp+8) 1/r32/ecx
|
|
81 7/subop/compare %ecx 0/imm32
|
|
{
|
|
75/jump-if-!= break/disp8
|
|
# bounds checks
|
|
8b/-> *(ebp+0xc) 0/r32/eax
|
|
3d/compare-eax-and 0/imm32
|
|
7c/jump-if-< $pixel:end/disp8
|
|
3d/compare-eax-and 0x400/imm32/1024
|
|
7d/jump-if->= $pixel:end/disp8
|
|
8b/-> *(ebp+0x10) 0/r32/eax
|
|
3d/compare-eax-and 0/imm32
|
|
7c/jump-if-< $pixel:end/disp8
|
|
3d/compare-eax-and 0x300/imm32/768
|
|
7d/jump-if->= $pixel:end/disp8
|
|
# eax = y*1024 + x
|
|
8b/-> *(ebp+0x10) 0/r32/eax
|
|
c1/shift 4/subop/left %eax 0xa/imm8
|
|
03/add-> *(ebp+0xc) 0/r32/eax
|
|
# eax += location of frame buffer
|
|
03/add-> *0x7f28 0/r32/eax
|
|
# *eax = color
|
|
8b/-> *(ebp+0x14) 1/r32/ecx
|
|
88/byte<- *eax 1/r32/CL
|
|
# return
|
|
eb $pixel:end/disp8
|
|
}
|
|
# TODO: fake screen
|
|
$pixel:end:
|
|
# . restore registers
|
|
59/pop-to-ecx
|
|
58/pop-to-eax
|
|
# . epilogue
|
|
89/<- %esp 5/r32/ebp
|
|
5d/pop-to-ebp
|
|
c3/return
|