summaryrefslogtreecommitdiff
path: root/boot0
diff options
context:
space:
mode:
Diffstat (limited to 'boot0')
-rw-r--r--boot0/Makefile16
-rw-r--r--boot0/mbr.asm4
-rw-r--r--boot0/print_string_16.asm115
3 files changed, 133 insertions, 2 deletions
diff --git a/boot0/Makefile b/boot0/Makefile
new file mode 100644
index 0000000..e930498
--- /dev/null
+++ b/boot0/Makefile
@@ -0,0 +1,16 @@
+#master boot record
+
+include ../Makefile.common
+
+MBR=mbr.bin
+
+ASM_SOURCES=$(wildcard *.asm)
+
+$(MBR): $(ASM_SOURCES)
+
+clean:
+ -rm $(MBR)
+
+
+
+
diff --git a/boot0/mbr.asm b/boot0/mbr.asm
index 1673c0c..c0a555d 100644
--- a/boot0/mbr.asm
+++ b/boot0/mbr.asm
@@ -40,8 +40,8 @@ STR_BOOT: db "Boot drive: ",0
BOOT_DRIVE: db 0xff
; include print and disk load routines
-%include "boot/print_string_16.asm"
-%include "boot0/disk_load_16.asm"
+%include "print_string_16.asm"
+%include "disk_load_16.asm"
; Here we start!
stage1:
diff --git a/boot0/print_string_16.asm b/boot0/print_string_16.asm
new file mode 100644
index 0000000..9f81a87
--- /dev/null
+++ b/boot0/print_string_16.asm
@@ -0,0 +1,115 @@
+[bits 16]
+
+BLANK:
+ db 0x12
+
+SPACE:
+ db " ",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_clear:
+
+pusha
+ mov ah,0x6 ;func
+ mov al,0 ;scroll one line
+ mov bh,[BLANK] ;blank char
+
+ mov ch,0 ;upper left corner
+ mov cl,0
+ mov dh,20 ;lower right corner
+ mov dl,40
+ int 0x10
+
+ mov ah,0x2
+ mov bh,0
+ mov dl,0
+ mov dh,20
+ int 0x10
+popa
+
+print_nextline:
+
+ pusha
+
+ mov ah,0x6 ;func
+ mov al,1 ;scroll one line
+ mov bh,[BLANK] ;blank char
+
+ mov ch,0 ;upper left corner
+ mov cl,0
+ mov dh,20 ;lower right corner
+ mov dl,40
+ int 0x10
+
+
+ mov ah,0x3
+ mov bh,0
+ int 0x10
+
+
+ mov ah,0x2
+ mov dl,0
+ int 0x10
+
+ mov bx,SPACE
+ call print_string
+
+ popa
+ ret
+
+
+;print byte from al to screen
+ print_hex_byte:
+
+ pusha
+
+ mov [.temp],al
+ shr al,4
+ cmp al,10
+ sbb al,69h
+ das
+
+ mov ah,0Eh
+ int 10h
+
+ mov al,[.temp]
+ ror al,4
+ shr al,4
+ cmp al,10
+ sbb al,69h
+ das
+
+ mov ah,0Eh
+ int 10h
+
+popa
+
+ ret
+
+ .temp db 0