From 13ddb358d18dd9cc7fdb244ead2ff127d0ece753 Mon Sep 17 00:00:00 2001 From: Quinten Kock Date: Mon, 17 Jul 2023 09:44:58 +0200 Subject: [PATCH] second commit --- sectcl.nasm | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/sectcl.nasm b/sectcl.nasm index a947e7b..bb1fea5 100644 --- a/sectcl.nasm +++ b/sectcl.nasm @@ -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