-
Notifications
You must be signed in to change notification settings - Fork 0
/
hdgeometry.asm
78 lines (71 loc) · 920 Bytes
/
hdgeometry.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
CPU 8086
BITS 16
ORG 7C00h
_start:
xor ax, ax
mov di, di ; Patch point
cld
cli
mov ss, ax
mov sp, 7B00h
sti
mov ds, ax
mov es, ax
mov di, ax
mov ah, 08h
int 13h
jc .no
mov al, cl
and al, 63
mov ah, 0
call numberout
mov si, s_sects
call stringout
mov al, dh
mov ah, 0
inc ax
call numberout
mov si, s_heads
call stringout
mov ax, cx
and al, 0C0h
rol al, 1
rol al, 1
xchg ah, al
inc ax
call numberout
mov si, s_cyls
call stringout
jmp .hlt
.no mov si, no
call stringout
.hlt hlt
jmp .hlt
numberout:
push cx
push dx
mov cx, 10
mov si, 7BFFh
mov [si], byte 0
.loop xor dx, dx
div cx
add dl, '0'
dec si
mov [si], dl
or ax, ax
jnz .loop
pop dx
pop cx
stringout:
mov bx, 7
lodsb
.loop mov ah, 0Eh
int 10h
lodsb
or al, al
jnz .loop
.out ret
s_heads db ' heads', 13, 10, 0
s_sects db ' sectors', 13, 10, 0
s_cyls db ' cylinders', 13, 10, 0
no db 'Error!', 13, 10, 0