-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstat.asm
More file actions
69 lines (54 loc) · 1.15 KB
/
Copy pathstat.asm
File metadata and controls
69 lines (54 loc) · 1.15 KB
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
; stat.asm - Display program statistics
; Shows program count and memory layout
bits 16
org 0xA000
SYSCALL_INT equ 0x80
SYS_PUTC equ 0x01
SYS_PUTS equ 0x02
start:
mov ax, cs
mov ds, ax
mov es, ax
mov si, msg_title
call sys_puts
; Get program table info
mov di, 0x0600
mov al, [di + 4]
mov [prog_count], al
mov si, msg_count ; print "Total programs: "
call sys_puts
mov al, [prog_count] ; print program count in hex
call print_hex8
mov si, msg_memory_layout
call sys_puts
ret
print_hex8:
push ax
shr al, 4
call print_hex_digit
pop ax
call print_hex_digit
ret
print_hex_digit:
and al, 0x0F
cmp al, 0x0A
jl .is_digit
add al, 'A' - 0x0A
jmp .print_it
.is_digit:
add al, '0'
.print_it:
mov ah, SYS_PUTC
int SYSCALL_INT
ret
sys_puts:
mov ah, SYS_PUTS
int SYSCALL_INT
ret
msg_title:
db "=== Program Statistics ===", 13, 10, 0
msg_count:
db "Total programs: ", 0
msg_memory_layout:
db 13, 10, "Memory: Kernel=0x7E00, Shell=0x9000, User=0xA000", 13, 10, 0
prog_count: db 0