; MBR Boot sector that prints Hello World
;
; To compile:
;     nasm -f bin boot.asm -o boot.bin
;
;     (Check `hexdump -C boot.bin` to view raw MBR contents)
;
; To run:
;     /usr/libexec/qemu-kvm ./boot.bin -monitor stdio -vnc :XX,password=on
;
;     (Replace XX with a two-digit number. This will start a VNC server at port
;      5900 + XX, so if I enter 22 then the server will run on port 5922.
;      Everyone needs to use a unique port.)
;
;     Once running, enter 'change vnc password' in the QEMU monitor.
;     Enter your desired password.
;     
;     After that, from your development machine:
;         ssh username@stargate.cs.usfca.edu -L 59XX:gojira:59XX
;     
;     Use a VNC client to connect to localhost:59XX on your development machine.
;     
;     macOS has one built in; in Finder press cmd+K to bring up the connect
;     dialog, then enter: vnc://localhost:59XX
;

mov ah, 0x0E ; Teletype output
mov al, 'H'  ; Character to print
int 0x10     ; Call BIOS interrupt 0x10
mov al, 'e'
int 0x10
mov al, 'l'
int 0x10
mov al, 'l'
int 0x10
mov al, 'o'
int 0x10
mov al, ' '
int 0x10
mov al, 'W'
int 0x10
mov al, 'o'
int 0x10
mov al, 'r'
int 0x10
mov al, 'l'
int 0x10
mov al, 'd'
int 0x10

cli ; Disable interrupts (Clear Interrupt Flag)
done:
    hlt      ; Halt the CPU until next interrupt fired
    jmp done ; If interrupted, halt again

times 510-($-$$) db 0 ; Pad the rest with 0
dw 0xAA55 ; Indicates that this is bootable
