Created
June 18, 2011 00:32
-
-
Save Themaister/1032658 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| org 7c00h | |
| jmp 0:start | |
| start: | |
| xor ax, ax | |
| mov ds, ax | |
| mov eax, 80000000h | |
| cpuid | |
| cmp eax, 80000000h | |
| jb no32 | |
| mov eax, 80000001h | |
| cpuid | |
| bt edx, 29 | |
| jnc no64 | |
| mov bx, success_str | |
| call puts | |
| in al, 092h | |
| or al, 2 | |
| out 092h, al | |
| xor ax, ax | |
| mov es, ax | |
| mov bx, kernel_init | |
| mov ah, 02h | |
| mov al, 01h | |
| mov ch, 0 | |
| mov cl, 2 | |
| mov dh, 0 | |
| mov dl, 0 | |
| int 13h | |
| jc fail | |
| jmp 0:kernel_init | |
| puts: | |
| mov si, 0 | |
| mov ah, 0eh | |
| puts_loop: | |
| mov al, [bx + si] | |
| cmp al, 0 | |
| je puts_end | |
| int 10h | |
| inc si | |
| jmp puts_loop | |
| puts_end: | |
| ret | |
| no32: | |
| mov bx, no32_str | |
| call puts | |
| jmp $ | |
| no64: | |
| mov bx, no64_str | |
| call puts | |
| jmp $ | |
| fail: | |
| mov bx, fail_str | |
| call puts | |
| jmp $ | |
| no32_str: db "No 32-bit! :(", 0ah, 0dh, 00h | |
| no64_str: db "No 64-bit! :(", 0ah, 0dh, 00h | |
| success_str: db "Yay! :D", 0ah, 0dh, 00h | |
| fail_str: db "Failed to load :(", 0ah, 0dh, 00h | |
| # Pad | |
| times 510 - ($-$$) db 0 | |
| db 55h | |
| db 0aah | |
| # Sector 2 | |
| kernel_init: | |
| mov bx, kernel_init_str | |
| call puts | |
| jmp $ | |
| kernel_init_str: db "Kernel init!", 0ah, 0dh, 00h | |
| times 1024 - ($-$$) db 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment