The OS you can just emulate it in qemu, because virtualbox, .. looking on the size of the file. qemu ignore it and it's emualte this.
Bootloader:
[BITS 16] ; The OS is running in the Realmode
[ORG 0x7C00] ; The start address from the Bootloader
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;; Bootloader ;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
boot:
cli ; disable interrupts
mov ax, 0x9000 ; AX get the worth 0x9000
mov ss, ax ; ss get ax worth
xor sp, sp ; sp get the worth 0
sti ; enable interrupts
mov ah, 0 ; SET
mov al, 12h ; THE
int 10h ; Graphic Mode(VGA)
mov si, bootmsg ; Bootmessage
call print_yellow ; printing in yellow
mov [bootdrive], dl ; string bootdrive get the worth dl
call load_kernel ; we must load the kernel
mov ax, 0x1000 ; this is the kernel address
mov es, ax ; es get the worth of ax
mov ds, ax ; ds get the wort of ax
push ax ; 1
mov ax, 0 ; 2
push ax ;3
retf ; 4
; 1 - 4 : ax get the worth 0
bootdrive db 0 ; the bootdrive is the first floppy drive
bootmsg db 'Bootloader Message : Loading Kernel of ', 230, 'OS Version 0.1.0...', 0x0D, 0x0A, 0
; bootmessage, the 230 is the ascii code for ยต
load_kernel:
xor ax, ax ; 1
mov dl, [bootdrive] ;2
int 0x13 ;3
; 1 - 3 : we must initialize the first f
loppy drive
jc cannot_reset_diskett ; if thats didn't go, please print a error message and stopp the computer
mov si, can_resset ; but if its go, please print a message, that we have initialize the first floppy
;drive
call print_white ; please print in white color
jmp load_kernel_part_two ; were jumping in the second part
load_kernel_part_two:
mov ax, 0x1000 ; ax is get the wort 0x1000(kernel address)
mov es, ax ; es is get ax worth
xor bx, bx ; bx is get the whort 0
mov ah, 2 ;the function to search for the kernel, begins
mov al, 5 ;we search 5 sectors
mov cx, 2 ; we search in 2 cylinder
mov dh, 0 ; page num
ber : 9
int 13h ; interrupt nummer
jc cannot_load_kernel ; if it didn't go, please print a error message
mov si, kernel_loaded ; but if its go, pelase print, that the kernel was loading
call print_white ; in white, please
retn
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;; No Error Messages ;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
can_resset db 'Bootloader could initialize the first Floppy Drive', 0x0D, 0x0A, 0
kernel_loaded db 'Bootloader could load the kernel of', 230, 'OS', 0x0D, 0x0A, 0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;; Graphic Functions ;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
print_white:
mov ah, 0Bh ; you know, we're in the video mode
mov bh, 0 ; because of this, we need a textcolor
mov bl, 15 ; if you didn't get a textcolor, so its didn't printing somewhat
lodsb ; give the character out
or al, al ; if al = o
jz .done_white ; ignore it
mov ah, 0Eh ; printing
int 10h ; a character
jmp print_white ; because there a lots of character, you must repeat the function
.done_white:
ret ; going to the main kernel
;heres the same like in the function printing_white, but just...
print_yellow:
mov ah, 0Bh
mov bh, 0
mov bl, 14 ;... the textcolor number changes
lodsb
or al, al
jz .done_yellow
mov ah, 0Eh
int 10h
jmp print_yellow
.done_yellow
ret
print_red:
mov ah, 0Bh
mov bh, 0
mov bl, 12
lodsb
or al, al
jz .done_red
mov ah, 0Eh
int 10h
jmp print_red
.done_red
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;; Fail Messages ;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
cannot_reset_diskett:
mov si, cannot_reset
call print_red
cannot_reset db 'Error : Bootloader could not initialize the first Floppy Drive', 0x0D, 0x0A, 0
hlt ; stopp the computer
cannot_load_kernel:
mov si, cannot_kernel
call print_red
cannot_kernel db 'Error : Bootloader could not find the kernel of', 230, 'OS Version 0.1.0', 0x0D, 0x0A, 0
hlt
times 512 - ($ - $$) - 2 db 0 ; the bootloader is a sector worth
dw 0AA55h ; the magicnumber
Kernel:
mov ax, 0x1000 ;1
mov ds, ax ; 2
mov es, ax ; 3
; 1-3 : This need the Kernel, that the bootloader can find him
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;; Kernel ;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
main; ; main function
mov si, reboot_pc_key
call print_blue
jmp reboot_pc ; jump to reboot function
reboot_pc_key db 'Please press any key, to reboot the computer...', 0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;; Functions ;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
reboot_pc:
xor ah, ah ; pres a key
int 16h ;interrupt number
jmp 0xFFFF:0x0000 ;reboot the computer
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;; Graphics ;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
print_blue: ; so like print_white, just the textcolor number changes
mov ah, 0Bh
mov bh, 0
mov bl, 9
lodsb
or al, al
jz .done_blue
mov ah, 0Eh
int 10h
jmp print_blue
.done_blue:
ret
times 512 - ($ - $$) hlt ; he kernel is a sector worth
I have emulate this in qemu
makefile.sh:
nasm -f bin -o bootloader.bin bootloader.asm
nasm -f bin -o kernel.bin kernel.asm
cat bootloader.bin kernel.bin > first_test.iso
qemu -fda first_test.iso

so, heres the picture, where i emulate the first test os
I have made this code myself!!!
Download: http://www.file-upload.net/download-3230475/first_os_test.zip.html
No comments:
Post a Comment