Skip to content

Instantly share code, notes, and snippets.

@jackrusher
Created December 7, 2021 11:13
Show Gist options
  • Save jackrusher/0b087a2c29db2a0d69d0c2e381d1048b to your computer and use it in GitHub Desktop.
Save jackrusher/0b087a2c29db2a0d69d0c2e381d1048b to your computer and use it in GitHub Desktop.
;; Boot to PRINT10
;;
;; Use nasm to assemble the code to a binary:
;;
;; $ nasm -f bin -o boot.bin boot.nasm
;;
;; Use dd to make an empty floppy disk image:
;;
;; $ dd if=/dev/zero of=boot.flp ibs=1k count=1440
;;
;; Fill the header of the disk image with the boot binary:
;;
;; $ dd if=boot.bin of=boot.flp conv=notrunc
;;
;; ... and then you can boot qemu from the floppy image:
;;
;; $ qemu-system-i386 boot.flp
;;
;; Both 'nasm' and 'qemu' can be installed with 'brew' under OS X, and
;; 'dd' is included by default.
;;; entry point for bootloader
start:
mov ax, 0x07C0 ; this offset is where our code is loaded
mov ds, ax ; these segment registers need to know it
mov es, ax ; to handle address lookups correctly
mov ax, 0001h ; 40x25 color screen mode
int 10h ; ...
loop:
mov dx, 10 ; delay for that C64 vibe
mov ah, 86h ; ...
int 15h ; ...
rdtsc ; get current cycle count
and ax,1 ; low bit set?
jz right ; jump to write a right slash
mov al, '\' ; left slash
mov ah, 0eh ; write the character
int 10h ; ...
jmp loop
right:
mov al, '/' ; right slash
mov ah, 0eh ; write the character
int 10h ; ...
jmp loop
times 510-($-$$) db 0 ; Zero fill the rest of the boot sector
dw 0xAA55 ; BIOS boot signature magic number
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment