Files
8086-Programs/interrupts/asm/common.inc
T
asmhatreandClaude Sonnet 5.5 09af523f8c Add interrupts module: INT 3 (CC breakpoint) vs INT 21h (DOS services)
NASM sources, DOSBox/FreeDOS Debug/Unicorn harness, captured output and 31
assertions backing the ankurm.com article "INT 3 vs INT 21h in 8086 Assembly".

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KqJyCidz3ZgRyHABv2GVJh
2026-09-30 19:10:56 +00:00

65 lines
924 B
PHP

; common.inc -- tiny output helpers shared by the demo programs (DOS .COM, NASM syntax)
; print the '$'-terminated string at DS:DX (INT 21h, AH=09h)
puts:
mov ah, 09h
int 21h
ret
; print CRLF
crlf:
mov dx, s_crlf
jmp puts
s_crlf db 0Dh, 0Ah, '$'
; print AX as four hex digits using INT 21h AH=02h
puthex16:
push ax
mov al, ah
call puthex8
pop ax
puthex8:
push ax
shr al, 1
shr al, 1
shr al, 1
shr al, 1
call nib
pop ax
and al, 0Fh
nib:
add al, '0'
cmp al, '9'
jbe .ok
add al, 7
.ok:
mov dl, al
mov ah, 02h
int 21h
ret
; print AX as unsigned decimal
putdec:
push bx
push cx
push dx
xor cx, cx
mov bx, 10
.d1:
xor dx, dx
div bx
push dx
inc cx
test ax, ax
jnz .d1
.d2:
pop dx
add dl, '0'
mov ah, 02h
int 21h
loop .d2
pop dx
pop cx
pop bx
ret