Skip to content

Instantly share code, notes, and snippets.

@Raffy27
Created May 19, 2022 13:50
Show Gist options
  • Save Raffy27/38f5411e22aa5a825c15235e915152f8 to your computer and use it in GitHub Desktop.
Save Raffy27/38f5411e22aa5a825c15235e915152f8 to your computer and use it in GitHub Desktop.
Code to dump the IVT in DOS
MyData segment para public 'Data'
Msg1 db 'IVT Dump', 10, '$'
Msg2 db 'IV[cs:ip] =', 9, 9, 9, '[', '$'
MsgX db ':', '$'
Msg3 db ']', 10, '$'
Msg4 db 'IVT Dump End', 10, '$'
HexTable db '0123456789ABCDEF'
MyData ends
MyCode segment para public 'Code'
Print macro msg
push ax
push dx
lea dx, msg
mov ah, 09h
int 21h
pop dx
pop ax
endm
Main proc far
Assume cs:MyCode, ds:MyData
; Boilerplate code for data segment access
push ds
xor ax, ax
push ax
mov ax, MyData
mov ds, ax
Print Msg1
xor ax, ax
mov es, ax
xor bx, bx
mov cx, 256
next_vector:
Print Msg2
mov ax, es:[bx]
push ax
inc bx
inc bx
mov ax, es:[bx]
call PrintHex
Print MsgX
pop ax
call PrintHex
Print Msg3
inc bx
inc bx
loop next_vector
Print Msg4
ret
Main endp
PrintHex proc near
push ax
push bx
push dx
xor dx, dx
lea bx, HexTable
push ax ; Save the number to the stack
shr ax, 12
xlat
mov dl, al ; Save the result to dl for printing
mov ah, 02h
int 21h
pop ax ; Get the number for the next character
push ax ; Save again
shl ax, 4 ; Get rid of the leftmost 2 bits
shr ax, 12
xlat
mov dl, al
mov ah, 02h
int 21h
pop ax
push ax
xor ah, ah
shr ax, 4
xlat
mov dl, al
mov ah, 02h
int 21h
pop ax
and ax, 000Fh
xlat
mov dl, al
mov ah, 02h
int 21h
pop dx
pop bx
pop ax
ret
PrintHex endp
MyCode ends
end Main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment