Add boot.asm
This commit is contained in:
commit
7c3cfdceb7
|
@ -0,0 +1,35 @@
|
|||
; boot.asm - A simple bootloader example
|
||||
[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 "Hello, World!"
|
||||
mov si, hello_message ; Load address of the 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
|
||||
hello_message db 'Hello, World!', 0 ; Null-terminated string
|
||||
|
||||
; 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