This commit is contained in:
parent
5c1186a77b
commit
ee81002eb0
20
boot.subx
20
boot.subx
|
@ -164,10 +164,8 @@
|
|||
66 83 c8 01 # eax <- or 0x1
|
||||
== code
|
||||
0f 22/cr<- 3/mod/direct 0/rm32/cr0 0/r32/eax
|
||||
== data
|
||||
# . far jump that sets cs to offset 8 in the gdt in the process
|
||||
ea 00 7d 08 00 # far jump to initialize_32bit_mode after setting cs to the record at offset 8 in the gdt (gdt_code) [label]
|
||||
== code
|
||||
ea/jump-far-absolute 0x00087d00/disp32 # address 0x7d00 in offset 8 of the gdt
|
||||
|
||||
== data
|
||||
|
||||
|
@ -197,11 +195,10 @@ disk_error:
|
|||
## GDT: 3 records of 8 bytes each
|
||||
== data
|
||||
|
||||
# e0:
|
||||
# gdt_start:
|
||||
# gdt_null: mandatory null descriptor
|
||||
gdt_start:
|
||||
# offset 0: gdt_null: mandatory null descriptor
|
||||
00 00 00 00 00 00 00 00
|
||||
# gdt_code: (offset 8 from gdt_start)
|
||||
# offset 8: gdt_code
|
||||
ff ff # limit[0:16]
|
||||
00 00 00 # base[0:24]
|
||||
9a # 1/present 00/privilege 1/descriptor type = 1001b
|
||||
|
@ -209,7 +206,7 @@ disk_error:
|
|||
cf # 1/granularity 1/32-bit 0/64-bit-segment 0/AVL = 1100b
|
||||
# limit[16:20] = 1111b
|
||||
00 # base[24:32]
|
||||
# gdt_data: (offset 16 from gdt_start)
|
||||
# offset 16: gdt_data
|
||||
ff ff # limit[0:16]
|
||||
00 00 00 # base[0:24]
|
||||
92 # 1/present 00/privilege 1/descriptor type = 1001b
|
||||
|
@ -218,10 +215,9 @@ disk_error:
|
|||
00 # base[24:32]
|
||||
# gdt_end:
|
||||
|
||||
# f8:
|
||||
# gdt_descriptor:
|
||||
17 00 # final index of gdt = gdt_end - gdt_start - 1
|
||||
e0 7c 00 00 # start = gdt_start [label]
|
||||
gdt_descriptor:
|
||||
0x17/imm16 # final index of gdt = size of gdt - 1
|
||||
gdt_start/imm32/start
|
||||
|
||||
# padding
|
||||
# fe:
|
||||
|
|
BIN
linux/pack
BIN
linux/pack
Binary file not shown.
|
@ -915,7 +915,8 @@ convert-data: # line: (addr stream byte), out: (addr buffered-file)
|
|||
# return
|
||||
# if has-metadata?(word-slice, "imm32")
|
||||
# emit(out, word-slice, 4)
|
||||
# # disp32 is not permitted in data segments, and anything else is only a byte long
|
||||
# else if has-metadata?(word-slice, "imm16")
|
||||
# emit(out, word-slice, 2)
|
||||
# else
|
||||
# emit(out, word-slice, 1)
|
||||
# write-buffered(out, "\n")
|
||||
|
@ -1059,7 +1060,7 @@ $convert-data:label:
|
|||
# . . discard args
|
||||
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
|
||||
# return
|
||||
75/jump-if-!= $convert-data:end/disp8
|
||||
0f 85/jump-if-!= $convert-data:end/disp32
|
||||
$convert-data:check-for-imm32:
|
||||
# if (has-metadata?(word-slice, "imm32"))
|
||||
# . eax = has-metadata?(ecx, "imm32")
|
||||
|
@ -1072,7 +1073,7 @@ $convert-data:check-for-imm32:
|
|||
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
|
||||
# . if (eax == false) process as a single byte
|
||||
3d/compare-eax-and 0/imm32/false
|
||||
74/jump-if-= $convert-data:single-byte/disp8
|
||||
74/jump-if-= $convert-data:check-for-imm16/disp8
|
||||
$convert-data:imm32:
|
||||
# emit(out, word-slice, 4)
|
||||
# . . push args
|
||||
|
@ -1084,6 +1085,30 @@ $convert-data:imm32:
|
|||
# . . discard args
|
||||
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32 # add to esp
|
||||
e9/jump $convert-data:loop/disp32
|
||||
$convert-data:check-for-imm16:
|
||||
# if (has-metadata?(word-slice, "imm16"))
|
||||
# . eax = has-metadata?(ecx, "imm16")
|
||||
# . . push args
|
||||
68/push "imm16"/imm32
|
||||
51/push-ecx
|
||||
# . . call
|
||||
e8/call has-metadata?/disp32
|
||||
# . . discard args
|
||||
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
|
||||
# . if (eax == false) process as a single byte
|
||||
3d/compare-eax-and 0/imm32/false
|
||||
74/jump-if-= $convert-data:single-byte/disp8
|
||||
$convert-data:imm16:
|
||||
# emit(out, word-slice, 2)
|
||||
# . . push args
|
||||
68/push 2/imm32
|
||||
51/push-ecx
|
||||
ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 0xc/disp8 . # push *(ebp+12)
|
||||
# . . call
|
||||
e8/call emit/disp32
|
||||
# . . discard args
|
||||
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32 # add to esp
|
||||
e9/jump $convert-data:loop/disp32
|
||||
$convert-data:single-byte:
|
||||
# emit(out, word-slice, 1)
|
||||
# . . push args
|
||||
|
|
Binary file not shown.
|
@ -1601,20 +1601,6 @@ $emit-output:end:
|
|||
5d/pop-to-ebp
|
||||
c3/return
|
||||
|
||||
$emit-output:global-variable-abort:
|
||||
# . _write(2/stderr, error)
|
||||
# . . push args
|
||||
68/push "emit-output: must refer to global variables with /disp32 or /imm32"/imm32
|
||||
68/push 2/imm32/stderr
|
||||
# . . call
|
||||
e8/call _write/disp32
|
||||
# . . discard args
|
||||
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
|
||||
# . syscall(exit, 1)
|
||||
bb/copy-to-ebx 1/imm32
|
||||
e8/call syscall_exit/disp32
|
||||
# never gets here
|
||||
|
||||
$emit-output:imm8-abort:
|
||||
# . _write(2/stderr, error)
|
||||
# . . push args
|
||||
|
|
BIN
linux/survey_elf
BIN
linux/survey_elf
Binary file not shown.
|
@ -2327,20 +2327,6 @@ $emit-segments:end:
|
|||
5d/pop-to-ebp
|
||||
c3/return
|
||||
|
||||
$emit-segments:global-variable-abort:
|
||||
# . _write(2/stderr, error)
|
||||
# . . push args
|
||||
68/push "emit-segments: must refer to global variables with /disp32 or /imm32"/imm32
|
||||
68/push 2/imm32/stderr
|
||||
# . . call
|
||||
e8/call _write/disp32
|
||||
# . . discard args
|
||||
81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp
|
||||
# . syscall(exit, 1)
|
||||
bb/copy-to-ebx 1/imm32
|
||||
e8/call syscall_exit/disp32
|
||||
# never gets here
|
||||
|
||||
$emit-segments:imm8-abort:
|
||||
# . _write(2/stderr, error)
|
||||
# . . push args
|
||||
|
|
Loading…
Reference in New Issue