diff options
Diffstat (limited to 'boot.subx')
-rw-r--r-- | boot.subx | 46 |
1 files changed, 11 insertions, 35 deletions
diff --git a/boot.subx b/boot.subx index 7e2290a8..541bfd59 100644 --- a/boot.subx +++ b/boot.subx @@ -5,38 +5,11 @@ # - switch to 32-bit mode (giving up access to BIOS primitives) # - set up a handler for keyboard events # - jump to start of program -# -# 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 boot.bochsrc # boot.bochsrc loads disk.img -# -# Since we start out in 16-bit mode, we need instructions SubX doesn't -# support. -# This file contains just lowercase hex bytes and comments. Programming it -# requires liberal use of: -# - comments documenting expected offsets -# - size checks on the emitted file (currently: 6144 bytes) -# - xxd to spot-check contents of specific offsets in the generated output -# -# Programs using this initialization: -# - can't use any syscalls -# - can't print text to video memory (past these boot sectors) -# - must only print raw pixels (256 colors) to video memory (resolution 1024x768) -# - must start executing immediately after this file (see outline below) -# -# Don't panic! This file doesn't contain any loops or function calls. 80% of -# it is data. One pass through less than 1KB of code (there's lots of -# padding), and then we jump into a better notation. The rest of the stack -# (really only in a couple of slightly higher-level places) needs to know just -# a few magic constants: -# Video memory: start is stored at 0x8128 -# Keyboard buffer: starts at 0x8028 -# -# No mouse support. _That_ would require panicking. + +# Code in this file needs to be more deliberate about the SubX facilities it +# uses: +# - sigils only support 32-bit general-purpose registers, so don't work with segment registers or 16-bit or 8-bit registers +# - metadata like rm32 and r32 can sometimes misleadingly refer to only the bottom 16 bits of the register; pay attention to the register name # Outline of this file with offsets and the addresses they map to at run-time: # -- 16-bit mode code @@ -67,17 +40,20 @@ # see 120allocate.subx # Consult https://wiki.osdev.org/Memory_Map_(x86) before modifying any of this. +== code + ## 16-bit entry point # Upon reset, the IBM PC: # - loads the first sector (512 bytes) -# from some bootable image (see the boot sector marker at the end of this file) +# from some bootable image (look for the boot sector marker further down this file) # to the address range [0x7c00, 0x7e00) # - starts executing code at address 0x7c00 -# offset 00 (address 0x7c00): # disable interrupts for this initialization - fa # cli + fa/clear-interrupts + +== data # initialize segment registers # this isn't always needed, but the recommendation is to not make assumptions |