Simple Bootloader in Assembly
#1
How-To Make This:
Pt. 1

Pt. 2


Code:
Spoiler(Show)
Code:
BITS 16

start:
mov ax, 07C0h ; Set up 4K stack space after this bootloader
add ax, 288 ; (4096 + 512) / 16 bytes per paragraph
mov ss, ax
mov sp, 4096

mov ax, 07C0h ; Set data segment to where we're loaded
mov ds, ax


mov si, msg ; Put string position into SI
call print_string ; Call our string-printing routine

jmp $ ; Jump here - infinite loop!


msg db 'My OS :p', 0


print_string: ; Routine: output string in SI to screen
mov ah, 0Eh ; int 10h 'print char' function

.repeat:
lodsb ; Get character from string
cmp al, 0
je .done ; If char is zero, end of string
int 10h ; Otherwise, print it
jmp .repeat

.done:
ret


times 510-($-$$) db 0 ; Pad remainder of boot sector with 0s
dw 0xAA55 ; The standard PC boot signature
Reply
#2
>nasm
>mfw nasm

Enough of me being a code snob though, this is an ok example if you are getting started.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Assembly language | the stack Ahmed 5 22,294 10-22-2017, 02:46 AM
Last Post: indirection
  [udemy]Assembly Language Adventures: Complete Course Hatsune Miku 0 17,624 09-25-2015, 01:00 PM
Last Post: Hatsune Miku