~/cheatsheets $ man 1 interrupts

INTERRUPTS(1)hachem.wtf manualINTERRUPTS(1)

name

interrupts - x86 interrupt calls, my slice of ralf brown's list

synopsis

interrupts [--int-21h-dos-api] [--int-10h-bios-video] [--int-16h-bios-keyboard] [--int-13h-bios-disk] [--linux-32-bit-int-0x80] [--linux-64-bit-syscall]

description

the x86 interrupt calls i actually reach for. the full firehose is ralf brown's list, and this is just my slice of it.

int 21h (dos api)

ah picks the function.

; print a string, then exit clean
mov ah, 09h
mov dx, msg          ; ds:dx -> "$"-terminated string
int 21h
mov ax, 4c00h        ; ah=4ch (exit), al=0 (code)
int 21h
msg db "hello$"

int 10h (bios video)

; teletype one char, real mode (bootloader-style)
mov ah, 0eh
mov al, 'x'
int 10h

int 16h (bios keyboard)

; block until a key; ascii lands in al
xor ah, ah           ; ah=00h
int 16h

int 13h (bios disk)

; load the sector after the mbr to 0000:7e00
xor bx, bx
mov es, bx           ; es=0
mov bx, 7e00h        ; es:bx = buffer
mov ah, 02h
mov al, 1            ; one sector
mov ch, 0            ; cylinder 0
mov cl, 2            ; sector 2 (1-based)
mov dh, 0            ; head 0
mov dl, 80h          ; first hard disk
int 13h

linux 32-bit (int 0x80)

eax is the number, and the args go in ebx, ecx, edx, esi, edi.

; write(1, msg, 3); exit(0)
mov eax, 4
mov ebx, 1           ; stdout
mov ecx, msg
mov edx, 3
int 0x80
mov eax, 1
xor ebx, ebx
int 0x80

linux 64-bit (syscall)

rax is the number, and the args go in rdi, rsi, rdx, r10, r8, r9.

; write(1, msg, 3); exit(0)
mov rax, 1
mov rdi, 1           ; stdout
lea rsi, [rel msg]
mov rdx, 3
syscall
mov rax, 60
xor rdi, rdi
syscall

see also

gdb-lldb(1), graphics(1), math(1), quantum(1), x86-64(1), cheatsheets(1), hachem(1)

author

hachem <im@hachem.wtf>

~/cheatsheets $