second commit
This commit is contained in:
parent
ba898f2132
commit
13ddb358d1
22
sectcl.nasm
22
sectcl.nasm
|
|
@ -1,25 +1,33 @@
|
||||||
; x86-16 BIOS bootloader
|
; x86-16 BIOS bootloader
|
||||||
[BITS 16]
|
[BITS 16]
|
||||||
[ORG 0x7C00]
|
[ORG 0x7C00]
|
||||||
; jmp 0x7C00:start
|
MOV AX, 0x7E00>>4 ; segment address
|
||||||
start:
|
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
|
call GetChar
|
||||||
jmp start
|
jmp main
|
||||||
|
|
||||||
; REGISTERS
|
; REGISTERS
|
||||||
; SP: 'top of memory'
|
|
||||||
; BP: points to variable map
|
; BP: points to variable map
|
||||||
|
; stack: managed
|
||||||
; others: general purpose
|
; others: general purpose
|
||||||
|
|
||||||
|
; GetChar :: () -> (AL)
|
||||||
GetChar:
|
GetChar:
|
||||||
xor AX,AX ; clear AH
|
xor AX,AX ; clear AH
|
||||||
int 0x16 ; read key via BIOS
|
int 0x16 ; read key via BIOS
|
||||||
; read key is now in AL
|
; read key is now in AL
|
||||||
; fallthrough to PutChar to echo read key
|
; fallthrough to PutChar to echo read key
|
||||||
|
|
||||||
|
; PutChar :: (AL) -> (AL)
|
||||||
PutChar:
|
PutChar:
|
||||||
mov AH,0xe ; TTY mode
|
mov AH,0xe ; TTY mode
|
||||||
int 0x10 ; print character in AL
|
int 0x10 ; print character in AL
|
||||||
cmp AL, 13 ; if \r, print \r\n and return \n
|
cmp AL, 13 ; if \r, print \r\n and return \n
|
||||||
jne .ret
|
jne .ret
|
||||||
mov AL, 10
|
mov AL, 10
|
||||||
|
|
@ -27,6 +35,8 @@ call PutChar
|
||||||
.ret: ret
|
.ret: ret
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; fill up sector, add boot signature
|
; fill up sector, add boot signature
|
||||||
TIMES 510 - ($ - $$) db 0
|
TIMES 510 - ($ - $$) db 0
|
||||||
DW 0xAA55
|
DW 0xAA55
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue