This commit is contained in:
Kartik K. Agaram 2021-03-14 22:56:51 -07:00
parent dda5fd08d8
commit fba0a56add
3 changed files with 42 additions and 17 deletions

View File

@ -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:

Binary file not shown.

View File

@ -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")