; x86-16 BIOS bootloader [BITS 16] [ORG 0x7C00] MOV AX, 0x7E00>>4 ; segment address MOV SS, AX ; set stack segment MOV SP, 0xFFFF ; put stack at top of segment MOV DS, AX ; set data segment XOR BP, BP jmp 0x0:main ; can probably be removed to save 5 bytes? main: call GetChar jmp main ; REGISTERS ; BP: points to variable map ; stack: managed ; others: general purpose ; GetChar :: () -> (AL) GetChar: xor AX,AX ; clear AH int 0x16 ; read key via BIOS ; read key is now in AL ; fallthrough to PutChar to echo read key ; PutChar :: (AL) -> (AL) PutChar: mov AH,0xe ; TTY mode int 0x10 ; print character in AL cmp AL, 13 ; if \r, print \r\n and return \n jne .ret mov AL, 10 call PutChar .ret: ret ; fill up sector, add boot signature TIMES 510 - ($ - $$) db 0 DW 0xAA55