Archive / / / / / boot.asm
2002-09-23 22:36:19 UTC
previous next
; http://my.execpc.com/~geezer/temp/qna.txt section boot.text progbits alloc exec nowrite align=16 MB_PAGE_ALIGN equ 1<<0 MB_MEM_FIELDS equ 1<<1 %macro multiboot_header 1 align 4 dd 0x1BADB002 dd %1 dd -(0x1BADB002 + (%1)) %endmacro multiboot_header MB_PAGE_ALIGN | MB_MEM_FIELDS %macro hang 0 %%infinite_loop: jmp %%infinite_loop %endmacro ; ---------------------- DISPLAY FUNCTIONS -------------------- ; name: print_string ; arguments: color, string ; name: print_newline ; arguments: none ; name: clear_screen ; arguments: none ; ; Define variables section boot.data progbits alloc noexec write align=4 current_line dd 0 current_pos dd 0 section boot.text %macro print_string 2+ [section boot.data] %%str: db %2, 0 __SECT__ push ebx push eax mov esi, %%str mov bl, %1 call print_string_function pop eax pop ebx %endmacro print_string_function: mov edi, 0xb8000 add edi, [current_pos] add edi, [current_line] .loop: lodsb cmp al, 0 je .end stosb mov al, bl stosb add [current_pos], dword 2 jmp .loop .end: ret %macro print_newline 0 mov [current_pos], dword 0 add [current_line], dword 160 %endmacro %macro clear_screen 0 push ecx push eax mov ecx, 1000 mov eax, 0 mov edi, 0xb8000 rep stosd pop eax pop ecx %endmacro global entry entry: mov ecx, 0x4FFFFF mov esp, ecx push ebx push eax clear_screen print_string 0x0F, 'Starting kryptOS 0.01.01...' print_newline print_newline print_string 0x07, 'Getting boot information from boot loader...' pop eax cmp eax, 0x2BADB002 jne no_multiboot pop eax mov ebx, [eax] ; Get flags bt ebx, 2 jnc no_command_line parse_cmdline: mov ecx, [eax+16] .trim: cmp [ecx], byte ' ' jne .trimmed add ecx, 1 jmp .trim .trimmed: section boot.data cmd_mem_str db 'mem',0 cmd_lower_mem_str db 'lower_mem',0 cmd_init_str db 'init',0 section boot.text mov edx, cmd_mem_str call check .check: ; Origional in ecx, Argument in edx push ecx .checkloop: cmp [edx], byte 0 je .equal mov esi, [ecx] cmp [edx], esi jne .not_equal add ecx, 1 add edx, 1 jmp .checkloop .not_equal: pop ecx mov edx, 0 ret .equal cmp [ecx], byte ' ' je .equal2 cmp [ecx], byte '=' je .equal2 cmp [ecx], byte ',' je .equal2 jmp .not_equal .equal2 ; print_newline ; print_newline ; mov esi, ecx ; mov bl, 0x07 ; call print_string_function hang no_command_line: print_newline print_string 0x07, 'No command line' hang no_multiboot: print_string 0x0C, 'Failed' print_newline print_newline print_string 0x07, 'Please install a multiboot compatible boot loader' hang section .text global main main: push eax ; Useless drivil mov eax, ebx nop nop nop nop mov ebx, eax pop eax ret section .data a_useless_string db 'I have no point!!! Look at me!! I', 39, 'm pointless!',0 section .bss big_number resb (1024*1024*3)