rename boot.hex to boot.subx
This commit is contained in:
parent
da438fa9f5
commit
98feca922e
|
@ -1,5 +1,5 @@
|
||||||
# Configuration for the Bochs x86 CPU emulator to run baremetal Mu programs
|
# 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:
|
# Installing Bochs:
|
||||||
# On Mac OS:
|
# On Mac OS:
|
||||||
|
|
|
@ -6,18 +6,13 @@
|
||||||
# - set up a handler for keyboard events
|
# - set up a handler for keyboard events
|
||||||
# - jump to start of program
|
# - jump to start of program
|
||||||
#
|
#
|
||||||
# To convert to a disk image, first prepare a realistically sized disk image:
|
# When translating, put this file first, followed by any other SubX files:
|
||||||
# dd if=/dev/zero of=disk.img count=20160 # 512-byte sectors, so 10MB
|
# ./translate_subx boot.subx ...
|
||||||
# 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
|
|
||||||
# To run:
|
# To run:
|
||||||
# qemu-system-i386 disk.img
|
# qemu-system-i386 disk.img
|
||||||
# Or:
|
# 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
|
# Since we start out in 16-bit mode, we need instructions SubX doesn't
|
||||||
# support.
|
# support.
|
||||||
|
@ -69,7 +64,7 @@
|
||||||
# stack grows down from 0x00070000
|
# stack grows down from 0x00070000
|
||||||
# see below
|
# see below
|
||||||
# heap: [0x01000000, 0x02000000)
|
# heap: [0x01000000, 0x02000000)
|
||||||
# see baremetal/120allocate.subx
|
# see 120allocate.subx
|
||||||
# Consult https://wiki.osdev.org/Memory_Map_(x86) before modifying any of this.
|
# Consult https://wiki.osdev.org/Memory_Map_(x86) before modifying any of this.
|
||||||
|
|
||||||
## 16-bit entry point
|
## 16-bit entry point
|
|
@ -11,12 +11,12 @@
|
||||||
# To convert to a disk image, first prepare a realistically sized disk image:
|
# 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
|
# dd if=/dev/zero of=disk.img count=20160 # 512-byte sectors, so 10MB
|
||||||
# Now fill in sectors:
|
# 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
|
# dd if=boot.bin of=disk.img conv=notrunc
|
||||||
# To run:
|
# To run:
|
||||||
# qemu-system-i386 disk.img
|
# qemu-system-i386 disk.img
|
||||||
# Or:
|
# 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
|
# Since we start out in 16-bit mode, we need instructions SubX doesn't
|
||||||
# support.
|
# support.
|
||||||
|
|
19
ex1.hex
19
ex1.hex
|
@ -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
|
|
2
ex1.subx
2
ex1.subx
|
@ -4,7 +4,7 @@
|
||||||
# graphics mode.
|
# graphics mode.
|
||||||
#
|
#
|
||||||
# To build a disk image:
|
# 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:
|
# To run:
|
||||||
# qemu-system-i386 disk.img
|
# qemu-system-i386 disk.img
|
||||||
# Or:
|
# Or:
|
||||||
|
|
39
ex2.hex
39
ex2.hex
|
@ -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
|
|
2
ex2.subx
2
ex2.subx
|
@ -1,7 +1,7 @@
|
||||||
# Test out the video mode by filling in the screen with pixels.
|
# Test out the video mode by filling in the screen with pixels.
|
||||||
#
|
#
|
||||||
# To build a disk image:
|
# 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:
|
# To run:
|
||||||
# qemu-system-i386 disk.img
|
# qemu-system-i386 disk.img
|
||||||
# Or:
|
# Or:
|
||||||
|
|
58
ex3.hex
58
ex3.hex
|
@ -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
|
|
|
@ -5,4 +5,4 @@ set -e
|
||||||
|
|
||||||
cat $* [0-9]*.mu |linux/mu > a.subx
|
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
|
||||||
|
|
|
@ -9,4 +9,4 @@ set -v
|
||||||
|
|
||||||
cat $* [0-9]*.mu |linux/bootstrap/bootstrap run linux/mu > a.subx
|
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
|
||||||
|
|
|
@ -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=/dev/zero of=disk.img count=20160 # 512-byte sectors, so 10MB
|
||||||
dd if=a.bin of=disk.img conv=notrunc
|
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
|
then
|
||||||
echo "a.bin won't all be loaded on boot"
|
echo "a.bin won't all be loaded on boot"
|
||||||
exit 1
|
exit 1
|
||||||
|
|
|
@ -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=/dev/zero of=disk.img count=20160 # 512-byte sectors, so 10MB
|
||||||
dd if=a.bin of=disk.img conv=notrunc
|
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
|
then
|
||||||
echo "a.bin won't all be loaded on boot"
|
echo "a.bin won't all be loaded on boot"
|
||||||
exit 1
|
exit 1
|
||||||
|
|
Loading…
Reference in New Issue