2020-12-27 05:44:01 +00:00
|
|
|
# Test out the video mode by filling in the screen with pixels.
|
2020-12-27 03:13:23 +00:00
|
|
|
#
|
|
|
|
# To run, first prepare a realistically sized disk image:
|
|
|
|
# dd if=/dev/zero of=disk.img count=20160 # 512-byte sectors, so 10MB
|
2020-12-27 19:39:17 +00:00
|
|
|
# Load the program on the disk image:
|
2021-03-04 08:24:24 +00:00
|
|
|
# cat baremetal/boot.hex baremetal/ex2.hex |bootstrap/bootstrap run hex > a.bin
|
2020-12-27 03:13:23 +00:00
|
|
|
# dd if=a.bin of=disk.img conv=notrunc
|
|
|
|
# To run:
|
|
|
|
# qemu-system-i386 disk.img
|
2020-12-27 06:01:45 +00:00
|
|
|
# Or:
|
2020-12-30 02:56:21 +00:00
|
|
|
# bochs -f baremetal/boot.bochsrc # boot.bochsrc loads disk.img
|
2020-12-27 03:13:23 +00:00
|
|
|
|
2021-01-28 08:25:54 +00:00
|
|
|
# main: (address 0x9400)
|
2020-12-27 05:44:01 +00:00
|
|
|
|
|
|
|
# ecx <- LFB
|
|
|
|
8b # copy *rm32 to r32
|
|
|
|
0d # 00/mod/indirect 001/r32/ecx 101/rm32/use-disp32
|
2021-01-28 05:16:36 +00:00
|
|
|
28 81 00 00 # disp32 [label]
|
2020-12-27 05:44:01 +00:00
|
|
|
|
2020-12-27 16:33:22 +00:00
|
|
|
# eax <- LFB + 0xbffff (1024*768 - 1)
|
2020-12-27 05:44:01 +00:00
|
|
|
8d # copy-address rm32 to r32
|
|
|
|
81 # 10/mod/*+disp32 000/r32/eax 001/rm32/ecx
|
2020-12-27 16:33:22 +00:00
|
|
|
ff ff 0b 00 # disp32
|
2020-12-27 05:44:01 +00:00
|
|
|
|
2020-12-27 03:13:23 +00:00
|
|
|
# $loop:
|
2020-12-27 05:44:01 +00:00
|
|
|
# if (eax < ecx) break
|
|
|
|
39 # compare rm32 with r32
|
|
|
|
c8 # 11/mod/direct 001/r32/ecx 000/rm32/eax
|
2020-12-28 07:35:31 +00:00
|
|
|
7c 05 # break if < [label]
|
2020-12-27 18:51:09 +00:00
|
|
|
# *eax <- al
|
|
|
|
88 # copy r8 to m8 at r32
|
|
|
|
00 # 00/mod/indirect 000/r8/AL 000/rm32/eax
|
2020-12-27 03:13:23 +00:00
|
|
|
48 # decrement eax
|
2020-12-28 07:35:31 +00:00
|
|
|
eb f7 # loop to -9 bytes [label]
|
2020-12-27 03:13:23 +00:00
|
|
|
|
|
|
|
# $break:
|
|
|
|
e9 fb ff ff ff # hang indefinitely
|
|
|
|
|
|
|
|
# vim:ft=subx
|