From fba0a56add2202403ee7329751694687cbca6966 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sun, 14 Mar 2021 22:56:51 -0700 Subject: . --- boot.subx | 30 ++++++++++++++---------------- linux/survey_baremetal | Bin 53166 -> 53229 bytes linux/survey_baremetal.subx | 29 ++++++++++++++++++++++++++++- 3 files changed, 42 insertions(+), 17 deletions(-) diff --git a/boot.subx b/boot.subx index b8b34c4a..78680400 100644 --- a/boot.subx +++ b/boot.subx @@ -184,26 +184,24 @@ 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 -# cf: -# disk_error: +== code + +disk_error: # print 'D' to top-left of screen to indicate disk error # *0xb8000 <- 0x0f44 - # bx <- 0xb800 - bb 00 b8 - # ds <- bx - 8e db # 11b/mod 011b/reg/ds 011b/rm/bx - # al <- 'D' - b0 44 - # ah <- 0x0f # white on black - b4 0f - # bx <- 0 - bb 00 00 - # *ds:bx <- ax - 89 07 # 00b/mod/indirect 000b/reg/ax 111b/rm/bx - -e9 fd ff # loop forever + bb/copy-to-bx 0xb800/imm16 + 8e/seg-> 3/mod/direct 3/rm32/bx 3/r32/ds + b0/copy-to-al 0x44/imm8/D + b4/copy-to-ah 0x0f/imm8/white-on-black + bb/copy-to-bx 0/imm16 + 89/<- 0/mod/indirect 7/rm32/bx 0/r32/ax # *ds:bx <- ax + # loop forever + { + e9/jump loop/disp16 # TODO: make this disp8 + } ## GDT: 3 records of 8 bytes each +== data # e0: # gdt_start: diff --git a/linux/survey_baremetal b/linux/survey_baremetal index 0ae468ff..c5aaf0c2 100755 Binary files a/linux/survey_baremetal and b/linux/survey_baremetal differ diff --git a/linux/survey_baremetal.subx b/linux/survey_baremetal.subx index 53addef9..7097701b 100644 --- a/linux/survey_baremetal.subx +++ b/linux/survey_baremetal.subx @@ -1501,7 +1501,7 @@ $emit-output:check-disp8: 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp # . if (eax == false) goto next check 3d/compare-eax-and 0/imm32/false - 74/jump-if-= $emit-output:check-disp32/disp8 + 74/jump-if-= $emit-output:check-disp16/disp8 $emit-output:emit-disp8: # emit-hex(out, *address - address-of-next-instruction, 1) # . . push args @@ -1516,6 +1516,33 @@ $emit-output:emit-disp8: 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32 # add to esp # continue e9/jump $emit-output:word-loop/disp32 +$emit-output:check-disp16: + # if (!has-metadata?(word-slice, "disp16")) goto next check + # . eax = has-metadata?(edx, "disp16") + # . . push args + 68/push "disp16"/imm32 + 52/push-edx + # . . 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) goto next check + 3d/compare-eax-and 0/imm32/false + 74/jump-if-= $emit-output:check-disp32/disp8 +$emit-output:emit-disp16: + # emit-hex(out, *address - address-of-next-instruction, 2) + # . . push args + 68/push 2/imm32 + 8b/copy 0/mod/indirect 6/rm32/esi . . . 0/r32/eax . . # copy *esi to eax + 29/subtract 3/mod/direct 0/rm32/eax . . . 3/r32/ebx . . # subtract ebx from eax + 50/push-eax + ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 0xc/disp8 . # push *(ebp+12) + # . . call + e8/call emit-hex/disp32 + # . . discard args + 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32 # add to esp + # continue + e9/jump $emit-output:word-loop/disp32 $emit-output:check-disp32: # if (!has-metadata?(word-slice, "disp32")) abort # . eax = has-metadata?(edx, "disp32") -- cgit 1.4.1-2-gfad0