Skip to content

Commit decf0af

Browse files
authored
Add files via upload
1 parent 66727a4 commit decf0af

File tree

1 file changed

+92
-0
lines changed

1 file changed

+92
-0
lines changed

hexdump.asm

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

0 commit comments

Comments
 (0)