diff options
Diffstat (limited to 'bootloader')
| -rw-r--r-- | bootloader/Makefile | 3 | ||||
| -rw-r--r-- | bootloader/bootloader.asm | 28 | ||||
| -rw-r--r-- | bootloader/clearScreenIntBios.asm | 30 | ||||
| -rw-r--r-- | bootloader/printIntBios.asm | 27 | ||||
| -rw-r--r-- | bootloader/resetCursorPosIntBios.asm | 21 |
5 files changed, 106 insertions, 3 deletions
diff --git a/bootloader/Makefile b/bootloader/Makefile index 9cb2ec5..7fb8173 100644 --- a/bootloader/Makefile +++ b/bootloader/Makefile @@ -1,8 +1,7 @@ - bootloader.bin: bootloader.asm - nasm -f bin -o $@ $^ + nasm -f bin -o $@ $< clean: rm bootloader.bin diff --git a/bootloader/bootloader.asm b/bootloader/bootloader.asm index 25b9a46..f1bb48a 100644 --- a/bootloader/bootloader.asm +++ b/bootloader/bootloader.asm @@ -4,10 +4,36 @@ ;Save the first adress with a label to complete the MBR at the end. start: +;Include bios routines and jump to skip including code +jmp skipInc +%include "clearScreenIntBios.asm" +%include "printIntBios.asm" +skipInc: + ;Init CPU registers -mov ax, 0x0C70 ;Put bootloader adress in ax register +mov ax, 0x07C0 ;Put bootloader adress in ax register mov ds, ax ;Init data segment +;Init stack from 0x80000 to 0x8f000 +mov ax, 0x8000 +mov ss, ax ;Set stack segment +mov ax, 0x0f00 +mov sp, ax ;Set stack offset + +;Clear the screen +call clearScreenIntBios + +;Print msg +mov si, helloBootloader ;load msg in si register +call printIntBios ;print the msg + +;Pause here ! +infiniteLoop: + jmp infiniteLoop + +;Define data +helloBootloader db "PiegOS bootloader successfully running !", 0 + ;Complete the MBR with nothing times 510 - ($ - start) db 0x0 diff --git a/bootloader/clearScreenIntBios.asm b/bootloader/clearScreenIntBios.asm new file mode 100644 index 0000000..4739430 --- /dev/null +++ b/bootloader/clearScreenIntBios.asm @@ -0,0 +1,30 @@ +clearScreenIntBios: + + ;Save registers + push ax + push bx + push cx + push dx + + mov ax, 0x0600 ;Clear + mov bx, 0x0F00 ;Color black behind white foreground + + mov cx, 0x0000 ;Top left corner + mov dx, 0x5050 ;Bottom right corner 80x80 + + int 0x10 ;Clear the screen + + ;Restore registers + pop dx + pop cx + pop bx + pop ax + + ;Reset Cursor Position + call resetCursorPosIntBios + + ;Back to previous task + ret + +;Include resetCursorPosIntBios +%include "resetCursorPosIntBios.asm" diff --git a/bootloader/printIntBios.asm b/bootloader/printIntBios.asm new file mode 100644 index 0000000..2a6c735 --- /dev/null +++ b/bootloader/printIntBios.asm @@ -0,0 +1,27 @@ +printIntBios: + + ;Save registers + push ax + push bx + + ;Print loop + .loop: + + mov ah, 0x0E ;Use 0xE bios service for teletype print + lodsb ;Load char in al and inc SI register + cmp al, 0x0 ;Check if we print all the chain + je .end ;If yes go to end + + mov bl, 0x0F ;Else set color register + + int 0x10 ;And print the character + + jmp .loop ;Go to the next character + .end: + + ;Restore registers + pop bx + pop ax + + ;Back to previous task + ret diff --git a/bootloader/resetCursorPosIntBios.asm b/bootloader/resetCursorPosIntBios.asm new file mode 100644 index 0000000..18cb0d2 --- /dev/null +++ b/bootloader/resetCursorPosIntBios.asm @@ -0,0 +1,21 @@ +resetCursorPosIntBios: + + ;Save registers + push ax + push bx + push dx + + mov ax, 0x0200 ;Move cursor interrupt + mov bx, 0x0000 ; X position + mov dx, 0x0000 ; Y Position + + ;Call 0x10 interrupt service + int 0x10 + + ;Restore registers + pop dx + pop bx + pop ax + + ;Back to previous task + ret |
