diff options
author | Kartik Agaram <vc@akkartik.com> | 2020-12-22 16:55:19 -0800 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2020-12-23 00:04:20 -0800 |
commit | 6216a79974d2742bc454f722a28a3ed934f269c6 (patch) | |
tree | 1cce8f13b8f941ed617e900a2c1eb4cb97358e9f /apps | |
parent | 6cd12b1822308d770fab47388f4c713df2542c20 (diff) | |
download | mu-6216a79974d2742bc454f722a28a3ed934f269c6.tar.gz |
7375
A little more robustness after reading https://stackoverflow.com/questions/43786251/int-13h-42h-doesnt-load-anything-in-bochs/43787939#43787939
Diffstat (limited to 'apps')
-rw-r--r-- | apps/boot.hex | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/apps/boot.hex b/apps/boot.hex index d772af16..ec32103c 100644 --- a/apps/boot.hex +++ b/apps/boot.hex @@ -30,12 +30,24 @@ # loads the first sector (512 bytes) # from some bootable image (see the boot sector marker at the end of this file) # to the address range [0x7c00, 0x7e00) -# -# We don't read or write the stack before we get to 32-bit mode. No function -# calls. # 00: -# load_disk: + fa # cli # TODO: don't forget to reenable interrupts in a real program + + # initialize segment registers + # this isn't always needed, but is considered safe not to assume + b8 00 00 # ax <- 0 + 8e d8 # ds <- ax + 8e d0 # ss <- ax + 8e c0 # es <- ax + 8e e0 # fs <- ax + 8e e8 # gs <- ax + + # We don't read or write the stack before we get to 32-bit mode. No function + # calls, so we don't need to initialize the stack. + +# 0d: + # load more sectors from disk b4 02 # ah <- 2 # read sectors from disk b2 80 # dl <- 80 # hdd 0 b5 00 # ch <- 0 # cylinder 0 @@ -49,8 +61,8 @@ cd 13 # int 13h, BIOS disk service 0f 82 76 00 # jump-if-carry disk-error -# 1a: - fa # cli # TODO: don't forget to reenable interrupts in a real program +# 28: + # switch to 32-bit mode 0f 01 16 # lgdt 00/mod/indirect 010/subop 110/rm32/TODO 80 7c # *gdt_descriptor # 20: @@ -60,9 +72,8 @@ ea c0 7c 08 00 # far jump to initialize_32bit_mode after setting cs to the record at offset 8 in the gdt (gdt_code) # padding -# 2f: - 00 -00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +# 3c: + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |