2020-12-30 03:14:26 +00:00
|
|
|
# Test out the video mode by filling in the screen with pixels.
|
|
|
|
#
|
|
|
|
# To build a disk image:
|
2021-03-15 04:41:47 +00:00
|
|
|
# ./translate_subx boot.subx ex2.subx # emits disk.img
|
2020-12-30 03:14:26 +00:00
|
|
|
# To run:
|
|
|
|
# qemu-system-i386 disk.img
|
|
|
|
# Or:
|
2021-03-15 04:27:39 +00:00
|
|
|
# bochs -f baremetal/boot.bochsrc # boot.bochsrc loads disk.img
|
2020-12-30 03:14:26 +00:00
|
|
|
|
2021-01-14 05:41:45 +00:00
|
|
|
== code
|
|
|
|
|
2021-01-09 21:45:41 +00:00
|
|
|
main:
|
2021-01-09 21:43:39 +00:00
|
|
|
# ecx <- start of video memory
|
2021-01-28 05:16:36 +00:00
|
|
|
8b/-> *0x8128 1/r32/ecx
|
2020-12-30 03:14:26 +00:00
|
|
|
|
2021-01-09 21:43:39 +00:00
|
|
|
# eax <- final pixel of video memory
|
|
|
|
8d/copy-address *(ecx + 0x0bffff) 0/r32/eax # 0xbffff = 1024*768 - 1
|
2020-12-30 03:14:26 +00:00
|
|
|
|
2021-01-09 21:43:39 +00:00
|
|
|
# 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
|
|
|
|
}
|
2020-12-30 03:14:26 +00:00
|
|
|
|
2021-01-09 21:43:39 +00:00
|
|
|
# hang indefinitely
|
|
|
|
{
|
|
|
|
eb/jump loop/disp8
|
|
|
|
}
|