Files
stevia/include/util/error_func.nasm
Elaina Claus 586f3f0106 converted error handler to a 16bit far jump
optimized the early error printer a bit to save some bytes
removed DEBUG_HCF macro
2024-10-08 08:53:30 -04:00

50 lines
1.9 KiB
NASM

; Copyright (c) 2024 Elaina Claus
;
; Permission is hereby granted, free of charge, to any person obtaining a copy
; of this software and associated documentation files (the "Software"), to deal
; in the Software without restriction, including without limitation the rights
; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
; copies of the Software, and to permit persons to whom the Software is
; furnished to do so, subject to the following conditions:
;
; The above copyright notice and this permission notice shall be included in all
; copies or substantial portions of the Software.
;
; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
; SOFTWARE.
%ifndef __INC_ERROR_FUNC
%macro ERROR 1
mov al, %1 ; al = 1 byte error code mapped to ascii values
db 0xEA ; jmp far imm16:imm16
dw error ; error_far_seg
dw 0x0000 ; error_far_ptr
%endmacro
; pass error as ascii character in al, errors a-zA-Z or 0-9
ALIGN 4, db 0x90
error:
; fs = 0xb800 => fs:0x0000 = 0xb8000
mov dx, 0xB800
mov fs, dx ; F segment to 0xB800 = video memory
cmp al, STEVIA_DEBUG_OK
jge short .debug ; the 'letter >= W' (W, X, Y, Z) are used as special debug codes
mov ah, 0x4F ; color 0x4F is white text/red background
jmp short .print
.debug:
mov ah, 0x5F ; debug case is white text/purple background
.print:
mov word [fs:0x0000], ax
.halt:
hlt
jmp short .halt
%endif
%define __INC_ERROR_FUNC