Move the system to low memory and tweak readln.
This commit is contained in:
parent
6e5019dcb7
commit
522905d77c
1
make.sh
1
make.sh
|
@ -6,4 +6,3 @@ nasm system.asm -f bin -O0 -o ../system.bin
|
|||
|
||||
cd ..
|
||||
cat boot.bin system.bin > EttinOS.img
|
||||
rm boot.bin system.bin
|
||||
|
|
|
@ -24,31 +24,37 @@ db "FAT12 " ;File system type
|
|||
|
||||
start:
|
||||
|
||||
;Initialise ds
|
||||
;Set up the data segment
|
||||
mov ax, 0x0
|
||||
mov ds, ax
|
||||
|
||||
;Set up the stack
|
||||
cli
|
||||
mov ax, 0x0
|
||||
mov ss, ax
|
||||
mov sp, 0x7c00
|
||||
sti
|
||||
|
||||
;Load the system
|
||||
;Set the source
|
||||
mov dl, 0x0
|
||||
mov dh, 0x0
|
||||
mov ch, 0x0
|
||||
mov cl, 0x2
|
||||
;Set the destination
|
||||
mov ax, 0x1000
|
||||
mov ax, 0x0
|
||||
mov es, ax
|
||||
mov bx, 0x200
|
||||
mov bx, 0x7e00
|
||||
;Set the size
|
||||
mov al, 0x20
|
||||
mov al, 0x5
|
||||
;Load
|
||||
mov ah, 0x2
|
||||
int 0x13
|
||||
|
||||
;Boot the system
|
||||
jmp 0x1000:0x200
|
||||
jmp 0x0:0x7e00
|
||||
|
||||
;Padding
|
||||
times 0x1fe-($-$$) db 0
|
||||
times 0x1fe-($-$$) db 0x0
|
||||
|
||||
;Boot signature
|
||||
dw 0xaa55
|
||||
|
|
|
@ -2,14 +2,17 @@
|
|||
|
||||
readln:
|
||||
|
||||
;Store the length
|
||||
mov [.length], al
|
||||
;Store the input length in the stack
|
||||
mov ah, 0
|
||||
push ax
|
||||
|
||||
;Initialise the destination with spaces
|
||||
mov cx, [.length]
|
||||
mov cx, ax
|
||||
mov al, 0x20
|
||||
rep stosb
|
||||
sub di, [.length]
|
||||
pop ax
|
||||
push ax
|
||||
sub di, ax
|
||||
|
||||
;Initialise the cursor pointer
|
||||
mov bl, 0x1
|
||||
|
@ -34,7 +37,9 @@ cmp al, 0x8
|
|||
je .backspace
|
||||
|
||||
;Check for input end
|
||||
cmp bl, [.length]
|
||||
pop dx
|
||||
push dx
|
||||
cmp bl, dl
|
||||
je .loop
|
||||
|
||||
;Check for space
|
||||
|
@ -59,16 +64,7 @@ mov ah, 0xe
|
|||
int 0x10
|
||||
;Move the cursor pointer
|
||||
inc bl
|
||||
|
||||
.checkln:
|
||||
;Get the cursor position
|
||||
mov ah, 0x3
|
||||
int 0x10
|
||||
;Check if the current line is the last one of the input
|
||||
cmp dh, [.lastln]
|
||||
jle .loop
|
||||
;If it is mark it as so
|
||||
mov byte [.lastln], dh
|
||||
call .checkln
|
||||
jmp .loop
|
||||
|
||||
.erase:
|
||||
|
@ -77,55 +73,14 @@ mov al, 0x20
|
|||
jmp .char
|
||||
|
||||
.space:
|
||||
;Get the cursor position
|
||||
mov ah, 0x3
|
||||
int 0x10
|
||||
;Move from the end of a line to the beginning of the next one
|
||||
cmp dl, [cpl]
|
||||
je .nextln
|
||||
;Move forward within a line
|
||||
inc dl
|
||||
mov ah, 0x2
|
||||
int 0x10
|
||||
inc di
|
||||
inc bl
|
||||
call .nextchar
|
||||
jmp .loop
|
||||
|
||||
.nextln:
|
||||
mov ah, 0x2
|
||||
inc dh
|
||||
mov dl, 0x1
|
||||
int 0x10
|
||||
inc di
|
||||
inc bl
|
||||
;Go to the last input line check
|
||||
jmp .checkln
|
||||
|
||||
.backspace:
|
||||
;Check for the input beginning
|
||||
cmp bl, 0x1
|
||||
je .loop
|
||||
;Get the cursor position
|
||||
mov ah, 0x3
|
||||
int 0x10
|
||||
;Move from the beginning of a line to the end of the previous one
|
||||
cmp dl, 0x1
|
||||
je .prevln
|
||||
;Move backward within a line
|
||||
dec dl
|
||||
mov ah, 0x2
|
||||
int 0x10
|
||||
dec di
|
||||
dec bl
|
||||
jmp .loop
|
||||
|
||||
.prevln:
|
||||
mov ah, 0x2
|
||||
dec dh
|
||||
mov dl, [cpl]
|
||||
int 0x10
|
||||
dec di
|
||||
dec bl
|
||||
call .prevchar
|
||||
jmp .loop
|
||||
|
||||
.return:
|
||||
|
@ -133,7 +88,8 @@ jmp .loop
|
|||
;Go to the end of the input
|
||||
mov bh, 0x0
|
||||
sub di, bx
|
||||
add di, [.length]
|
||||
pop ax
|
||||
add di, ax
|
||||
|
||||
.findtrailing:
|
||||
;Check for a trailing space
|
||||
|
@ -158,11 +114,69 @@ call newline
|
|||
|
||||
ret
|
||||
|
||||
.length:
|
||||
db 0x0
|
||||
|
||||
.cursor:
|
||||
db 0x0
|
||||
|
||||
.lastln:
|
||||
db 0x0
|
||||
|
||||
.nextchar:
|
||||
;Get the cursor position
|
||||
mov ah, 0x3
|
||||
int 0x10
|
||||
;Move from the end of a line to the beginning of the next one
|
||||
cmp dl, [cpl]
|
||||
je .nextln
|
||||
;Move forward within a line
|
||||
inc dl
|
||||
mov ah, 0x2
|
||||
int 0x10
|
||||
inc di
|
||||
inc bl
|
||||
ret
|
||||
|
||||
.nextln:
|
||||
mov ah, 0x2
|
||||
inc dh
|
||||
mov dl, 0x1
|
||||
int 0x10
|
||||
inc di
|
||||
inc bl
|
||||
;Go to the last input line check
|
||||
call .checkln
|
||||
ret
|
||||
|
||||
.prevchar:
|
||||
;Get the cursor position
|
||||
mov ah, 0x3
|
||||
int 0x10
|
||||
;Move from the beginning of a line to the end of the previous one
|
||||
cmp dl, 0x1
|
||||
je .prevln
|
||||
;Move backward within a line
|
||||
dec dl
|
||||
mov ah, 0x2
|
||||
int 0x10
|
||||
dec di
|
||||
dec bl
|
||||
ret
|
||||
|
||||
.prevln:
|
||||
mov ah, 0x2
|
||||
dec dh
|
||||
mov dl, [cpl]
|
||||
int 0x10
|
||||
dec di
|
||||
dec bl
|
||||
ret
|
||||
|
||||
.checkln:
|
||||
;Get the cursor position
|
||||
mov ah, 0x3
|
||||
int 0x10
|
||||
;Check if the current line is the last one of the input
|
||||
cmp dh, [.lastln]
|
||||
jg .markln
|
||||
ret
|
||||
|
||||
.markln:
|
||||
;Mark the current line as the last one of the input
|
||||
mov byte [.lastln], dh
|
||||
ret
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[ORG 0x200]
|
||||
[ORG 0x7e00]
|
||||
jmp start
|
||||
|
||||
;Calls
|
||||
|
@ -17,17 +17,6 @@ jmp start
|
|||
|
||||
start:
|
||||
|
||||
;Initialise ds
|
||||
mov ax, 0x1000
|
||||
mov ds, ax
|
||||
|
||||
;Set up the stack
|
||||
cli
|
||||
mov ax, 0x1000
|
||||
mov ss, ax
|
||||
mov sp, 0x200
|
||||
sti
|
||||
|
||||
;Get the terminal width
|
||||
mov ah, 0xf
|
||||
int 0x10
|
||||
|
|
Loading…
Reference in New Issue