diff options
-rw-r--r-- | boot.subx | 20 | ||||
-rwxr-xr-x | linux/pack | bin | 59445 -> 59507 bytes | |||
-rw-r--r-- | linux/pack.subx | 31 | ||||
-rwxr-xr-x | linux/survey_baremetal | bin | 53229 -> 53128 bytes | |||
-rw-r--r-- | linux/survey_baremetal.subx | 14 | ||||
-rwxr-xr-x | linux/survey_elf | bin | 56434 -> 56331 bytes | |||
-rw-r--r-- | linux/survey_elf.subx | 14 |
7 files changed, 36 insertions, 43 deletions
diff --git a/boot.subx b/boot.subx index 0db21e32..dd01f409 100644 --- a/boot.subx +++ b/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: diff --git a/linux/pack b/linux/pack index c46ca06b..557b1c0c 100755 --- a/linux/pack +++ b/linux/pack Binary files differdiff --git a/linux/pack.subx b/linux/pack.subx index 85b86511..b619712a 100644 --- a/linux/pack.subx +++ b/linux/pack.subx @@ -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 diff --git a/linux/survey_baremetal b/linux/survey_baremetal index c5aaf0c2..74ff0852 100755 --- a/linux/survey_baremetal +++ b/linux/survey_baremetal Binary files differdiff --git a/linux/survey_baremetal.subx b/linux/survey_baremetal.subx index 7097701b..a8a44ec4 100644 --- a/linux/survey_baremetal.subx +++ b/linux/survey_baremetal.subx @@ -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 diff --git a/linux/survey_elf b/linux/survey_elf index 0b8f6969..87eba506 100755 --- a/linux/survey_elf +++ b/linux/survey_elf Binary files differdiff --git a/linux/survey_elf.subx b/linux/survey_elf.subx index 3df7a121..f1d1bc96 100644 --- a/linux/survey_elf.subx +++ b/linux/survey_elf.subx @@ -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 |