7462 - SubX version of baremetal/ex2.subx

This commit is contained in:
Kartik Agaram 2020-12-29 19:14:26 -08:00
parent 796f3b70f2
commit c5dfa89bb3
3 changed files with 36 additions and 1 deletions

Binary file not shown.

View File

@ -1143,7 +1143,7 @@ $emit-output:emit-disp8:
# emit-hex(out, *address - address-of-next-instruction, 1)
# . . push args
68/push 1/imm32
8b/copy 1/mod/*+disp8 6/rm32/esi . . . 0/r32/eax 8/disp8 . # copy *(esi+8) to eax
8b/copy 0/mod/indirect 6/rm32/esi . . . 0/r32/eax . . # copy *esi to eax
29/subtract 3/mod/direct 0/rm32/eax . . . 3/r32/ebx . . # subtract ebx from eax
50/push-eax
ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 0xc/disp8 . # push *(ebp+12)

35
baremetal/ex2.subx Normal file
View File

@ -0,0 +1,35 @@
# Test out the video mode by filling in the screen with pixels.
#
# To build a disk image:
# ./translate_subx_baremetal baremetal/ex2.subx # emits disk.img
# To run:
# qemu-system-i386 disk.img
# Or:
# bochs -f baremetal/boot.bochsrc # boot.bochsrc loads disk.img
# main: (address 0x8800)
== code
# ecx <- start of video memory
8b/-> 0/mod/indirect 5/rm32/use-disp32 0x7f28/disp32/video-memory 1/r32/ecx
# eax <- final pixel of video memory
8d/copy-address *(ecx + 0x0bffff) 0/r32/eax # 0xbffff = 1024*768 - 1
# for each pixel in video memory
{
39/compare %eax 1/r32/ecx
7c/jump-if-< break/disp8
# write its column number to it
88/byte<- *eax 0/r32/AL
48/decrement-eax
eb/jump loop/disp8
}
# hang indefinitely
{
eb/jump loop/disp8
}
# vim:ft=subx