33 lines
587 B
NASM
33 lines
587 B
NASM
; x86-16 BIOS bootloader
|
|
[BITS 16]
|
|
[ORG 0x7C00]
|
|
; jmp 0x7C00:start
|
|
start:
|
|
|
|
call GetChar
|
|
jmp start
|
|
|
|
; REGISTERS
|
|
; SP: 'top of memory'
|
|
; BP: points to variable map
|
|
; others: general purpose
|
|
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:
|
|
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
|