You are on page 1of 2

linux code Assembler OS: sudo apt-get install build-essential qemu nasm code asm: mov mov cmp

jge ... label: mov ax, 10 mylabel: db 'Message here', 0 foo: db 0 mov byte al, [foo] bx, 1000h ax, [bx] ax, 50 label

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

mov ax, 07C0h mov ds, ax mov si, text_string call print_string jmp $

; Set data segment to where we're loaded

; Put string position into SI ; Call our string-printing routine ; Jump here - infinite loop!

text_string db 'This is my cool new OS!', 0 print_string: mov ah, 0Eh .repeat: lodsb cmp al, 0 je .done int 10h jmp .repeat .done: ret ; Routine: output string in SI to screen ; int 10h 'print char' function ; Get character from string ; If char is zero, end of string ; Otherwise, print it

times 510-($-$$) db 0 dw 0xAA55

; Pad remainder of boot sector with 0s ; The standard PC boot signature

Buils OS: nasm -f bin -o myfirst.bin myfirst.asm Disk images: dd status=noxfer conv=notrunc if=myfirst.bin of=myfirst.flp Emulator: qemu -fda myfirst.flp cdiso: mkisofs -o myfirst.iso -b myfirst.flp cdiso/

You might also like