second commit

This commit is contained in:
Quinten Kock 2023-07-17 09:44:58 +02:00
parent ba898f2132
commit 13ddb358d1
1 changed files with 16 additions and 6 deletions

View File

@ -1,25 +1,33 @@
; x86-16 BIOS bootloader
[BITS 16]
[ORG 0x7C00]
; jmp 0x7C00:start
start:
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 start
jmp main
; REGISTERS
; SP: 'top of memory'
; 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
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
@ -27,6 +35,8 @@ call PutChar
.ret: ret
; fill up sector, add boot signature
TIMES 510 - ($ - $$) db 0
DW 0xAA55