cpu 8086 org 0x0000 db 0x55, 0xAA db 0x00 jmp init nop times (0x18 - ($-$$)) db 0 dw 0 dw pnp pnp: db "$PnP" db 1 ; version 1 db 2 ; 2 * 16 length dw 0 ; offset of next header db 0 db 0 ; checksum (filled by fix-rom) dd 0 ; device identifier dw 0 ; manufacturer string dw name ; product name string db 0,0,0 ; device type string db 0x20 ; device indicator, bit for "read cacheable" set dw 0 ; boot connection vector dw 0 ; boot disconnect vector dw 0 ; bootstrap entry point dw 0 ; reserved dw 0 name: db "dprintf" init: push ds push ax xor ax, ax mov ds, ax mov word [1*4], int3entry mov word [1*4+2], cs mov word [3*4], int3entry mov word [3*4+2], cs pop ax pop ds retf crlf: xor bx, bx mov ax, 0x0e0a int 0x10 mov al, 0x0d int 0x10 ret printr: mov al, cl int 0x10 mov al, ch int 0x10 mov al, '=' int 0x10 call printd mov al, ' ' int 0x10 ret printd: mov cl, 4 ; this double-call is essentially a 4 times repeating loop call .c1 .c1: call .c2 .c2: ; grab highest nibble from dx mov al, dh ; remove highest nibble from dx shl dx, cl ; shift away second-highest nibble that we accidentally copied shr al, cl ; map 0-9 to ascii codes for '0' to '9' add al, 0x30 ; if result is larger than '9', ... cmp al, 0x3a jl .noadj ; ... add 7 so we continue at 'A' add al, 7 .noadj: int 0x10 ret int3entry: push bx push dx push cx push ax push bp mov bp, sp call crlf xor bx, bx mov ah, 0x0e mov cx, 'AX' mov dx, [bp+2] call printr mov cx, 'CX' mov dx, [bp+4] call printr mov cx, 'DX' mov dx, [bp+6] call printr mov cx, 'BX' mov dx, [bp+8] call printr mov cx, 'BP' mov dx, [bp] call printr mov cx, 'SP' lea dx, [bp+16] call printr mov cx, 'SI' mov dx, si call printr mov cx, 'DI' mov dx, di call printr call crlf mov cx, 'ES' mov dx, es call printr mov cx, 'CS' mov dx, [bp+12] call printr mov cx, 'SS' mov dx, ss call printr mov cx, 'DS' mov dx, ds call printr mov cx, 'IP' mov dx, [bp+10] call printr call crlf pop bp pop ax pop cx pop dx pop bx iret align 512