2020-12-30 05:08:05 +00:00
|
|
|
# Test out the video mode by filling in the screen with pixels.
|
|
|
|
#
|
|
|
|
# To build a disk image:
|
2020-12-31 03:25:32 +00:00
|
|
|
# ./translate_mu_baremetal baremetal/ex2.mu # emits disk.img
|
2020-12-30 05:08:05 +00:00
|
|
|
# To run:
|
|
|
|
# qemu-system-i386 disk.img
|
|
|
|
# Or:
|
2020-12-31 03:25:32 +00:00
|
|
|
# bochs -f baremetal/boot.bochsrc # boot.bochsrc loads disk.img
|
2020-12-30 05:08:05 +00:00
|
|
|
#
|
|
|
|
# Expected output:
|
|
|
|
# html/baremetal.png
|
|
|
|
|
|
|
|
fn main {
|
|
|
|
var y/eax: int <- copy 0
|
|
|
|
{
|
2021-01-17 18:49:23 +00:00
|
|
|
compare y, 0x300 # screen-height = 768
|
2020-12-30 05:08:05 +00:00
|
|
|
break-if->=
|
|
|
|
var x/edx: int <- copy 0
|
|
|
|
{
|
2021-01-17 18:49:23 +00:00
|
|
|
compare x, 0x400 # screen-width = 1024
|
2020-12-30 05:08:05 +00:00
|
|
|
break-if->=
|
2020-12-30 05:19:41 +00:00
|
|
|
var color/ecx: int <- copy x
|
|
|
|
color <- and 0xff
|
2021-01-16 04:30:07 +00:00
|
|
|
pixel-on-real-screen x, y, color
|
2020-12-30 05:08:05 +00:00
|
|
|
x <- increment
|
|
|
|
loop
|
|
|
|
}
|
|
|
|
y <- increment
|
|
|
|
loop
|
|
|
|
}
|
|
|
|
}
|