Skip to content
Snippets Groups Projects
Commit 23771ca8 authored by Recolic Keghart's avatar Recolic Keghart
Browse files

init

parent ac38f229
No related branches found
No related tags found
No related merge requests found
build:
nasm -f bin boot.asm -o boot.img
run: build
qemu-system-x86_64 boot.img
[bits 16]
[org 0x7c00]
jmp _enter_prot_mode
jmp _init_prot_mode
gdt_begin:
......@@ -36,7 +36,7 @@ gdt_desc:
CODE_SEG_OFFSET equ gdt_entry_1 - gdt_begin
DATA_SEG_OFFSET equ gdt_entry_2 - gdt_begin
_enter_prot_mode:
_init_prot_mode:
cli
lgdt [gdt_desc]
mov eax, cr0
......@@ -46,6 +46,7 @@ _enter_prot_mode:
jmp CODE_SEG_OFFSET:_prot_begin
[bits 32]
%include "./str.32.inc"
_prot_begin:
mov ax, DATA_SEG_OFFSET
mov ds, ax
......@@ -56,8 +57,20 @@ _prot_begin:
mov ebp, 0x90000 ; 600KB free space here, until 0x7c00 + 0x200 byte (MBR sector 0)
mov esp, ebp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 32BIT PROTECTED MODE BEGIN ;;;;;;;;;;;;;;;;;;;;;;;;;;
_dead_loop:
mov ebx, _motd_32
call println_vga
mov ebx, _motd_32p
call println_vga
jmp _dead_loop
_motd_32:
db '----- CPU is in INTEL x86 protected mode now -----', 0x0
_motd_32p:
db '+++++ CPU is in INTEL x86 protected mode now +++++', 0x0
%include "./mbr_end.inc"
times 510-($-$$) db 0
dw 0xaa55
println_bios:
; Arg0: addr in register bx
; while true:
; if [bx] != NULL:
; print [bx]; ++bx
mov ah, 0x0e
_loop_begin:
mov al, [bx]
cmp al, 0x0
je _loop_exit
int 0x10
inc bx
jmp _loop_begin
_loop_exit:
ret
VGA_BEGIN_ADDR equ 0xb8000
println_vga:
; Arg0: addr in register ebx
pusha
mov edx, VGA_BEGIN_ADDR
mov ah, 0x0f
_loop_begin_1:
mov al, [ebx]
cmp al, 0x0
je _loop_exit_1
mov [edx], ax
inc ebx
add edx, 2
jmp _loop_begin_1
_loop_exit_1:
popa
ret
......@@ -3,8 +3,9 @@
;
[org 0x7c00]
mov bx, str
call println_bios
mov ebx, str
call println_vga
jmp $
println_bios:
; Arg0: addr in register bx
......@@ -22,13 +23,29 @@ _loop_begin:
_loop_exit:
ret
; [bits 32]
VGA_BEGIN_ADDR equ 0xb8000
println_vga:
; Arg0: addr in register eax
; Arg0: addr in register ebx
pusha
mov edx, VGA_BEGIN_ADDR
mov ah, 0x0f
_loop_begin_1:
mov al, [ebx]
cmp al, 0x0
je _loop_exit_1
mov [edx], ax
inc ebx
add edx, 2
jmp _loop_begin_1
_loop_exit_1:
popa
ret
str:
db 'This is Recolic!', 0x0
jmp $
times 510-($-$$) db 0
dw 0xaa55
......
asm ("jmp 0x14");
//void print_char(char to_print) {
// asm inline (
// "mov $0x0e, %%ah\n\t"
// "mov %0, %%al\n\t"
// "int $0x10"
// :
// : "Ir" (to_print)
// : "ax"
// );
//}
//
//void println(char *s) {
// while(*s != 0) {
// print_char(*s);
// }
//}
void main() {
_start_p:
asm (
"mov $0x0e, %ah\n\t"
"mov $0x55, %al\n\t"
"int $0x10"
);
//print_char('X');
//println("Hello world!");
//println("Recolic Booting OS HERE...");
}
asm (
"jmp 0x-2\n\t"
);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment