boot.subx is now clean SubX
This commit is contained in:
parent
341f0c59be
commit
bc182ae559
16
boot.subx
16
boot.subx
|
@ -134,11 +134,7 @@
|
|||
0f 01/lgdt 2/subop/lgdt 0/mod/indirect 6/rm32/use-disp16 0x7cf8/disp16/gdt_descriptor
|
||||
# enable paging
|
||||
0f 20/<-cr 3/mod/direct 0/rm32/eax 0/r32/cr0
|
||||
== data
|
||||
# TODO: SubX doesn't understand 66 prefix
|
||||
#? 66 83/or 3/mod/direct 0/rm32/eax 1/r32/?? 1/imm8 # eax <- or 0x1
|
||||
66 83 c8 01 # eax <- or 0x1
|
||||
== code
|
||||
66 83/or 3/mod/direct 0/rm32/eax 1/r32/?? 1/imm8 # eax <- or 0x1
|
||||
0f 22/->cr 3/mod/direct 0/rm32/eax 0/r32/cr0
|
||||
# far jump to initialize_32bit_mode that sets cs to offset 8 in the gdt in the process
|
||||
# We can't refer to the label directly because SubX doesn't have syntax for
|
||||
|
@ -191,10 +187,7 @@ gdt_descriptor:
|
|||
|
||||
== code 0x7d00
|
||||
initialize_32bit_mode:
|
||||
== data
|
||||
# TODO: SubX doesn't understand 66 prefix
|
||||
66 b8 10 00 # ax <- offset 16 from gdt_start
|
||||
== code
|
||||
66 b8/copy-to-ax 0x10/imm16 # offset 16 from gdt_start
|
||||
8e/->seg 3/mod/direct 0/rm32/ax 3/r32/ds
|
||||
8e/->seg 3/mod/direct 0/rm32/ax 2/r32/ss
|
||||
8e/->seg 3/mod/direct 0/rm32/ax 0/r32/es
|
||||
|
@ -223,10 +216,7 @@ initialize_32bit_mode:
|
|||
e6/write-al-into-port 0x21/imm8
|
||||
|
||||
fb/enable-interrupts
|
||||
== data
|
||||
# TODO: SubX doesn't understand db prefix
|
||||
db e3/initialize-floating-point-coprocessor
|
||||
== code
|
||||
db/floating-point-coprocessor e3/initialize
|
||||
# eax <- cr4
|
||||
0f 20/<-cr 3/mod/direct 0/rm32/eax 4/r32/cr4
|
||||
# eax <- or bit 9
|
||||
|
|
BIN
linux/pack
BIN
linux/pack
Binary file not shown.
|
@ -1977,6 +1977,8 @@ emit-opcodes: # line: (addr stream byte), out: (addr buffered-file)
|
|||
# f3 xx
|
||||
# f2 0f xx
|
||||
# f3 0f xx
|
||||
# 66 xx (hacky support for boot.subx)
|
||||
# db xx (hacky support for boot.subx)
|
||||
#
|
||||
# pseudocode:
|
||||
# rewind-stream(line)
|
||||
|
@ -1985,7 +1987,7 @@ emit-opcodes: # line: (addr stream byte), out: (addr buffered-file)
|
|||
# if (slice-empty?(op1) || slice-starts-with?(op1, "#")) return
|
||||
# op1 = next-token-from-slice(op1->start, op1->end, "/")
|
||||
# write-slice-buffered(out, op1)
|
||||
# if !slice-equal?(op1, "0f") && !slice-equal?(op1, "f2") && !slice-equal?(op1, "f3")
|
||||
# if !slice-equal?(op1, "0f") && !slice-equal?(op1, "f2") && !slice-equal?(op1, "f3") && !slice-equal?(op1, "66") && !slice-equal?(op1, "db")
|
||||
# return
|
||||
#
|
||||
# var op2 = next-word(line)
|
||||
|
@ -2116,6 +2118,30 @@ $emit-opcodes:op1:
|
|||
# . if (eax != false) goto op2
|
||||
3d/compare-eax-and 0/imm32/false
|
||||
75/jump-if-!= $emit-opcodes:op2/disp8
|
||||
# if (slice-equal?(op1, "66")) goto op2
|
||||
# . eax = slice-equal?(op1, "66")
|
||||
# . . push args
|
||||
68/push "66"/imm32
|
||||
51/push-ecx
|
||||
# . . call
|
||||
e8/call slice-equal?/disp32
|
||||
# . . discard args
|
||||
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
|
||||
# . if (eax != false) goto op2
|
||||
3d/compare-eax-and 0/imm32/false
|
||||
75/jump-if-!= $emit-opcodes:op2/disp8
|
||||
# if (slice-equal?(op1, "db")) goto op2
|
||||
# . eax = slice-equal?(op1, "db")
|
||||
# . . push args
|
||||
68/push "db"/imm32
|
||||
51/push-ecx
|
||||
# . . call
|
||||
e8/call slice-equal?/disp32
|
||||
# . . discard args
|
||||
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
|
||||
# . if (eax != false) goto op2
|
||||
3d/compare-eax-and 0/imm32/false
|
||||
75/jump-if-!= $emit-opcodes:op2/disp8
|
||||
# otherwise return
|
||||
e9/jump $emit-opcodes:end/disp32
|
||||
$emit-opcodes:op2:
|
||||
|
|
Loading…
Reference in New Issue