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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;; Miguel's FoolOS Helper Functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;print_string
;print_hex
;disk_load
;
;
;
;
[bits 16]
;/*
;;global data
;STR_HEX_OUT:
; db "0x0000",0
;
;;print_string routine ([bx])
;;this routine will print a null terminated string at [bx] to the screen.
;print_string:
;
; pusha ;push all registers
; mov ah,0x0e
;
; print_string_loop:
;
; ;check if value at [bx] is "\0" (end of string)
; mov cl,[bx]
; cmp cl,0
; je print_string_finish
;
; ;otherwise instruct BIOS to print the current char
; mov al,cl
; int 0x10
;
; ;proceed with next char
; inc bx
; jmp print_string_loop
;
; print_string_finish:
;
; popa ;pop all registers
; ret ;return to caller
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;;print_hex routine (dx)
;;will print the value of the bx register as hex to the screen
;print_hex:
;
; pusha
;
; ;begin with last hex val (hex_out[5])
; mov bx,STR_HEX_OUT+5
;
; ;lets loop throuth all 4 'digits'
; print_hex_loop:
;
; ;get least significan hex digit to cx
; mov cx,dx
; and cx,0x000F
;
; ;check range (0-9 vs a-f)
; cmp cx,10
; jl print_hex_setnum
;
; ;set hex a-f
; mov al,'A'-10
; add al,cl
; jmp print_hex_al
;
; ;set hex 0-9
; print_hex_setnum:
; mov al,'0'
; add al,cl
;
; ; set hex_out[bx] to al
; print_hex_al:
; mov [bx],al
;
; ;proceed with the next significant hex 'digit'
; dec bx
; shr dx,4
;
; ;check if finished (otherwise loop)
; cmp bx,STR_HEX_OUT+1
; jne print_hex_loop
;
; ;output complete hex string and return to caller
; mov bx,STR_HEX_OUT
; call print_string
; popa
; ret
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;*/
;disk_load routune (load dh sectors from drive dl to es:bx)
disk_load:
pusha
mov ah,0x02 ;BIOS read sector func
mov al,dh ;read dh sectors (amount)
mov ch,0x00 ;cyl 0
mov dh,0x00 ;head 0
mov cl,0x02 ;start at sector 2
int 0x13 ;bios interrupt
popa
ret
|