Add boot.asm
This commit is contained in:
parent
b5072c853e
commit
17e6ac0b84
|
@ -0,0 +1,44 @@
|
|||
[bits 16] ; Set to 16-bit mode
|
||||
[org 0x7C00] ; BIOS loads the bootloader at this address
|
||||
|
||||
start:
|
||||
; Clear screen
|
||||
mov ax, 0x0003 ; Set video mode to 3 (80x25 color text)
|
||||
int 0x10 ; BIOS interrupt to set video mode
|
||||
|
||||
; Print first message
|
||||
mov si, hello_message ; Load address of the first message into SI
|
||||
call print_string ; Call function to print the string
|
||||
|
||||
; Print second message
|
||||
mov si, second_message ; Load address of the second message into SI
|
||||
call print_string ; Call function to print the string
|
||||
|
||||
; Print third message
|
||||
mov si, third_message ; Load address of the third message into SI
|
||||
call print_string ; Call function to print the string
|
||||
|
||||
; Hang the system (infinite loop)
|
||||
hang:
|
||||
jmp hang ; Jump to hang indefinitely
|
||||
|
||||
; Function to print a string
|
||||
print_string:
|
||||
mov ah, 0x0E ; BIOS teletype output function
|
||||
.next_char:
|
||||
lodsb ; Load byte at DS:SI into AL and increment SI
|
||||
cmp al, 0 ; Check for null terminator
|
||||
je .done ; If null, we are done
|
||||
int 0x10 ; Call BIOS to print character in AL
|
||||
jmp .next_char ; Repeat for next character
|
||||
.done:
|
||||
ret ; Return from function
|
||||
|
||||
; Data section for messages
|
||||
hello_message db 'Hello, World!', 0 ; Null-terminated string
|
||||
second_message db 'CPU: HeckerSoft Generic CPU', 0 ; Second message
|
||||
third_message db 'Enjoy exploring!', 0 ; Third message
|
||||
|
||||
; Bootloader signature (must be present)
|
||||
times 510 - ($ - $$) db 0 ; Fill the rest of the sector with zeros
|
||||
dw 0xAA55 ; Boot signature
|
Loading…
Reference in New Issue