diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2021-03-14 21:41:47 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2021-03-14 21:41:47 -0700 |
commit | 98feca922e46c82d1efdb44b99021b771bdac44d (patch) | |
tree | 9b59a558e787693b5db14fd44ea8b7d240246b5c | |
parent | da438fa9f5e4297f37833daa4f1d76ddd6d10a42 (diff) | |
download | mu-98feca922e46c82d1efdb44b99021b771bdac44d.tar.gz |
rename boot.hex to boot.subx
-rw-r--r-- | boot.bochsrc | 2 | ||||
-rw-r--r-- | boot.subx (renamed from boot.hex) | 15 | ||||
-rw-r--r-- | boot0.hex | 4 | ||||
-rw-r--r-- | ex1.hex | 19 | ||||
-rw-r--r-- | ex1.subx | 2 | ||||
-rw-r--r-- | ex2.hex | 39 | ||||
-rw-r--r-- | ex2.subx | 2 | ||||
-rw-r--r-- | ex3.hex | 58 | ||||
-rwxr-xr-x | translate | 2 | ||||
-rwxr-xr-x | translate_emulated | 2 | ||||
-rwxr-xr-x | translate_subx | 2 | ||||
-rwxr-xr-x | translate_subx_emulated | 2 |
12 files changed, 14 insertions, 135 deletions
diff --git a/boot.bochsrc b/boot.bochsrc index 9a02d67c..a1c8a4bc 100644 --- a/boot.bochsrc +++ b/boot.bochsrc @@ -1,5 +1,5 @@ # Configuration for the Bochs x86 CPU emulator to run baremetal Mu programs -# See baremetal/boot.hex for more details. +# See boot.subx for more details. # # Installing Bochs: # On Mac OS: diff --git a/boot.hex b/boot.subx index f0fe88c7..7e2290a8 100644 --- a/boot.hex +++ b/boot.subx @@ -6,18 +6,13 @@ # - set up a handler for keyboard events # - jump to start of program # -# To convert to a disk image, first prepare a realistically sized disk image: -# dd if=/dev/zero of=disk.img count=20160 # 512-byte sectors, so 10MB -# Create initial sectors from this file: -# bootstrap/bootstrap run hex < baremetal/boot.hex > boot.bin -# Translate other sectors into a file called a.img -# Load all sectors into the disk image: -# cat boot.bin a.img > disk.bin -# dd if=disk.bin of=disk.img conv=notrunc +# When translating, put this file first, followed by any other SubX files: +# ./translate_subx boot.subx ... +# # To run: # qemu-system-i386 disk.img # Or: -# bochs -f baremetal/boot.bochsrc # boot.bochsrc loads disk.img +# bochs -f boot.bochsrc # boot.bochsrc loads disk.img # # Since we start out in 16-bit mode, we need instructions SubX doesn't # support. @@ -69,7 +64,7 @@ # stack grows down from 0x00070000 # see below # heap: [0x01000000, 0x02000000) -# see baremetal/120allocate.subx +# see 120allocate.subx # Consult https://wiki.osdev.org/Memory_Map_(x86) before modifying any of this. ## 16-bit entry point diff --git a/boot0.hex b/boot0.hex index 197be1e7..01cc9c56 100644 --- a/boot0.hex +++ b/boot0.hex @@ -11,12 +11,12 @@ # To convert to a disk image, first prepare a realistically sized disk image: # dd if=/dev/zero of=disk.img count=20160 # 512-byte sectors, so 10MB # Now fill in sectors: -# bootstrap/bootstrap run hex < baremetal/boot0.hex > boot.bin +# bootstrap/bootstrap run hex < boot0.hex > boot.bin # dd if=boot.bin of=disk.img conv=notrunc # To run: # qemu-system-i386 disk.img # Or: -# bochs -f baremetal/boot.bochsrc # boot.bochsrc loads disk.img +# bochs -f boot.bochsrc # boot.bochsrc loads disk.img # # Since we start out in 16-bit mode, we need instructions SubX doesn't # support. diff --git a/ex1.hex b/ex1.hex deleted file mode 100644 index cb5f7e25..00000000 --- a/ex1.hex +++ /dev/null @@ -1,19 +0,0 @@ -# The simplest possible program: just an infinite loop. -# All is well if your computer clears screen and hangs without restarting. -# On an emulator the window may get bigger to accomodate the higher-resolution -# graphics mode. -# -# To convert to a disk image, first prepare a realistically sized disk image: -# dd if=/dev/zero of=disk.img count=20160 # 512-byte sectors, so 10MB -# Load the program on the disk image: -# cat baremetal/boot.hex baremetal/ex1.hex |bootstrap/bootstrap run hex > a.bin -# dd if=a.bin of=disk.img conv=notrunc -# To run: -# qemu-system-i386 disk.img -# Or: -# bochs -f baremetal/boot.bochsrc # boot.bochsrc loads disk.img - -# main: (address 0x9400) -e9 fb ff ff ff # jump to main, hanging indefinitely - -# vim:ft=subx diff --git a/ex1.subx b/ex1.subx index 0cd024fe..9ff2113f 100644 --- a/ex1.subx +++ b/ex1.subx @@ -4,7 +4,7 @@ # graphics mode. # # To build a disk image: -# ./translate_subx boot.hex ex2.subx # emits disk.img +# ./translate_subx boot.subx ex2.subx # emits disk.img # To run: # qemu-system-i386 disk.img # Or: diff --git a/ex2.hex b/ex2.hex deleted file mode 100644 index 6447b462..00000000 --- a/ex2.hex +++ /dev/null @@ -1,39 +0,0 @@ -# Test out the video mode by filling in the screen with pixels. -# -# To run, first prepare a realistically sized disk image: -# dd if=/dev/zero of=disk.img count=20160 # 512-byte sectors, so 10MB -# Load the program on the disk image: -# cat baremetal/boot.hex baremetal/ex2.hex |bootstrap/bootstrap run hex > a.bin -# dd if=a.bin of=disk.img conv=notrunc -# To run: -# qemu-system-i386 disk.img -# Or: -# bochs -f baremetal/boot.bochsrc # boot.bochsrc loads disk.img - -# main: (address 0x9400) - -# ecx <- LFB -8b # copy *rm32 to r32 - 0d # 00/mod/indirect 001/r32/ecx 101/rm32/use-disp32 - 28 81 00 00 # disp32 [label] - -# eax <- LFB + 0xbffff (1024*768 - 1) -8d # copy-address rm32 to r32 - 81 # 10/mod/*+disp32 000/r32/eax 001/rm32/ecx - ff ff 0b 00 # disp32 - -# $loop: -# if (eax < ecx) break -39 # compare rm32 with r32 - c8 # 11/mod/direct 001/r32/ecx 000/rm32/eax -7c 05 # break if < [label] -# *eax <- al -88 # copy r8 to m8 at r32 - 00 # 00/mod/indirect 000/r8/AL 000/rm32/eax -48 # decrement eax -eb f7 # loop to -9 bytes [label] - -# $break: -e9 fb ff ff ff # hang indefinitely - -# vim:ft=subx diff --git a/ex2.subx b/ex2.subx index cb75211c..d7809d36 100644 --- a/ex2.subx +++ b/ex2.subx @@ -1,7 +1,7 @@ # Test out the video mode by filling in the screen with pixels. # # To build a disk image: -# ./translate_subx boot.hex ex2.subx # emits disk.img +# ./translate_subx boot.subx ex2.subx # emits disk.img # To run: # qemu-system-i386 disk.img # Or: diff --git a/ex3.hex b/ex3.hex deleted file mode 100644 index 58ccbffa..00000000 --- a/ex3.hex +++ /dev/null @@ -1,58 +0,0 @@ -# Draw pixels in response to keyboard events, starting from the top-left -# and in raster order. -# -# To run, first prepare a realistically sized disk image: -# dd if=/dev/zero of=disk.img count=20160 # 512-byte sectors, so 10MB -# Load the program on the disk image: -# cat baremetal/boot.hex baremetal/ex3.hex |bootstrap/bootstrap run hex > a.bin -# dd if=a.bin of=disk.img conv=notrunc -# To run: -# qemu-system-i386 disk.img -# Or: -# bochs -f baremetal/boot.bochsrc # boot.bochsrc loads disk.img - -# main: (address 0x9000) - -# eax <- LFB -8b # copy *rm32 to r32 - 05 # 00/mod/indirect 000/r32/eax 101/rm32/use-disp32 - 28 81 00 00 # disp32 [label] - -# var read index/ecx: byte = 0 -31 c9 # ecx <- xor ecx; 11/direct 001/r32/ecx 001/rm32/ecx - -# $loop: - # CL = *read index - 8a # copy m8 at r32 to r8 - 0d # 00/mod/indirect 001/r8/cl 101/rm32/use-disp32 - cc 7d 00 00 # disp32 [label] - # CL = *(keyboard buffer + ecx) - 8a # copy m8 at r32 to r8 - 89 # 10/mod/*+disp32 001/r8/cl 001/rm32/ecx - d0 7d 00 00 # disp32 [label] - # if (CL == 0) loop (spin loop) - 80 - f9 # 11/mod/direct 111/subop/compare 001/rm8/CL - 00 # imm8 - 74 ef # loop -17 [label] -# offset 0x19: - # otherwise increment read index - fe # increment byte - 05 # 00/mod/indirect 000/subop/increment 101/rm32/use-disp32 - cc 7d 00 00 # disp32 [label] - # clear top nibble of index (keyboard buffer is circular) - 80 # and byte - 25 # 00/mod/indirect 100/subop/and 101/rm32/use-disp32 - cc 7d 00 00 # disp32 [label] - 0f # imm8 - # print a pixel in fluorescent green - c6 # copy imm8 to m8 at rm32 - 00 # 00/mod/indirect 000/subop 000/rm32/eax - 31 # imm32 - 40 # increment eax - eb dc # loop -36 [label] - -# $break: -e9 fb ff ff ff # hang indefinitely - -# vim:ft=subx diff --git a/translate b/translate index 25a1b7f9..7cc1be12 100755 --- a/translate +++ b/translate @@ -5,4 +5,4 @@ set -e cat $* [0-9]*.mu |linux/mu > a.subx -./translate_subx boot.hex mu-init.subx [0-9]*.subx a.subx +./translate_subx boot.subx mu-init.subx [0-9]*.subx a.subx diff --git a/translate_emulated b/translate_emulated index 06786821..a9c1e05d 100755 --- a/translate_emulated +++ b/translate_emulated @@ -9,4 +9,4 @@ set -v cat $* [0-9]*.mu |linux/bootstrap/bootstrap run linux/mu > a.subx -./translate_subx_emulated boot.hex mu-init.subx [0-9]*.subx a.subx +./translate_subx_emulated boot.subx mu-init.subx [0-9]*.subx a.subx diff --git a/translate_subx b/translate_subx index 43323f6a..08519d9f 100755 --- a/translate_subx +++ b/translate_subx @@ -34,7 +34,7 @@ cat a.survey |linux/hex > a.bin dd if=/dev/zero of=disk.img count=20160 # 512-byte sectors, so 10MB dd if=a.bin of=disk.img conv=notrunc -if [ `stat --printf="%s" a.bin` -ge 193536 ] # 6 tracks * 63 sectors per track * 512 bytes per sector (keep this sync'd with boot.hex) +if [ `stat --printf="%s" a.bin` -ge 193536 ] # 6 tracks * 63 sectors per track * 512 bytes per sector (keep this sync'd with boot.subx) then echo "a.bin won't all be loaded on boot" exit 1 diff --git a/translate_subx_emulated b/translate_subx_emulated index 787be559..d5120f48 100755 --- a/translate_subx_emulated +++ b/translate_subx_emulated @@ -29,7 +29,7 @@ cat a.survey |linux/bootstrap/bootstrap run linux/hex > a.bi dd if=/dev/zero of=disk.img count=20160 # 512-byte sectors, so 10MB dd if=a.bin of=disk.img conv=notrunc -if [ `stat --printf="%s" a.bin` -ge 193536 ] # 6 tracks * 63 sectors per track * 512 bytes per sector (keep this sync'd with boot.hex) +if [ `stat --printf="%s" a.bin` -ge 193536 ] # 6 tracks * 63 sectors per track * 512 bytes per sector (keep this sync'd with boot.subx) then echo "a.bin won't all be loaded on boot" exit 1 |