converted error handler to a 16bit far jump

optimized the early error printer a bit to save some bytes
removed DEBUG_HCF macro
This commit is contained in:
2024-10-08 08:53:30 -04:00
parent 8e05e071e8
commit 09d33086a0

View File

@@ -21,16 +21,10 @@
%ifndef __INC_ERROR_FUNC %ifndef __INC_ERROR_FUNC
%macro ERROR 1 %macro ERROR 1
xor ax, ax mov al, %1 ; al = 1 byte error code mapped to ascii values
mov al, %1 db 0xEA ; jmp far imm16:imm16
jmp error dw error ; error_far_seg
%endmacro dw 0x0000 ; error_far_ptr
%macro DEBUG_HCF 0
DEBUG_LOOP:
cli
hlt
jmp short DEBUG_LOOP
%endmacro %endmacro
; pass error as ascii character in al, errors a-zA-Z or 0-9 ; pass error as ascii character in al, errors a-zA-Z or 0-9
@@ -38,26 +32,19 @@ ALIGN 4, db 0x90
error: error:
; fs = 0xb800 => fs:0x0000 = 0xb8000 ; fs = 0xb800 => fs:0x0000 = 0xb8000
mov dx, 0xB800 mov dx, 0xB800
mov fs, dx mov fs, dx ; F segment to 0xB800 = video memory
mov dx, STEVIA_DEBUG_OK cmp al, STEVIA_DEBUG_OK
cmp ax, dx jge short .debug ; the 'letter >= W' (W, X, Y, Z) are used as special debug codes
jge error.debug_err mov ah, 0x4F ; color 0x4F is white text/red background
mov dh, 0x4F ; color 0x4F is white text/red background jmp short .print
jmp error.print .debug:
.debug_err: mov ah, 0x5F ; debug case is white text/purple background
mov dh, 0x5F ; debug case is white text/purple background
; the characters are two bytes in the order of 0xb8000: byte c, byte attribute
; since x86 is le, we store the attribute in the MSB of dx
.print: .print:
mov dl, al mov word [fs:0x0000], ax
mov word [fs:0x0000], dx .halt:
jmp error.stop
.stop:
hlt hlt
jmp short error.stop jmp short .halt
%endif %endif
%define __INC_ERROR_FUNC %define __INC_ERROR_FUNC