-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhexdump.asm
92 lines (80 loc) · 1.38 KB
/
hexdump.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
start:
jmp main
times 0x30 - ($-$$) db 2 ;useless data that can be modified by the bios
;on my machine, bytes 0x1C, 0x1D, 0x1E, 0x1F, and 0x24 are set to 0; i figured it out with this program
main:
;setup memory adresses
mov ax, 0x07c0
mov ds, ax
mov es, ax
mov ss, ax
mov sp, 0x7c00
; disable blinking
mov ax, 0x1003
mov bx, 0
int 10h
;start colored text mode
mov ax, 3
int 0x10
mov ax, 0x0500
int 0x10
mov si,start
xor bx,bx
mov ah, 0x0e
memdump_loop:
lodsb
call printhex
;put spaces between values
mov al,' '
int 0x10
test si, 0x00FF
je memdump_end
test si, 0x000F
jne memdump_loop
memdump_newline:
;next line
mov al,10
int 0x10
mov al,13
int 0x10
jmp memdump_loop
memdump_end:
mov ah, 0
int 0x16
cmp al, 'w'
jne noup
mov ax,si
sub ax,0x0200
mov si,ax
noup:
mov ah, 0x0e
jmp memdump_newline
printhex:;print al as hexadecimal
push ax
push bx
push cx
xor bx,bx
mov ah, 0x0e
mov cl,al
and al, 0xF0
shr al, 4
call dectoHex
int 0x10
mov al,cl
and al, 0x0F
call dectoHex
int 0x10
pop cx
pop bx
pop ax
ret
dectoHex:
cmp al,0x0a
jns dectoHex_ch
add al,0x30
ret
dectoHex_ch:
add al,0x37
ret
times 510 - ($-$$) db 0
db 0x55, 0xaa