Skip to content
Snippets Groups Projects
Commit 1b42e951 authored by Stephen D's avatar Stephen D
Browse files

Enabled disk writes, SEDIT buffer saves

parent dede5d05
No related branches found
No related tags found
No related merge requests found
......@@ -28,7 +28,7 @@
call print
;; testing
;//mov ax, 0xDE94
;///mov ax, 0x300
;//call print_hex
;; Load sectors 2 and 3(more OS)
......@@ -36,15 +36,14 @@
mov dh, 0 ;head
mov al, 2 ;Num sectors
mov bx, 0x7E00 ;RAM
call load_sector
call read_sector
mov al, '>' ;cmd line
call print_char
mov al, ' '
call print_char
loop:
loop:
mov ah, 0
int 0x16 ;Reads a character to al
cmp al, 0x8 ;Backspace
......@@ -66,7 +65,6 @@ loop:
jmp loop
%include "string.asm"
;//%include "textedit.asm"
%include "print.asm"
%include "disk.asm"
......
......@@ -3,26 +3,39 @@
;; ch - cylinder number
;; dh - head number
;; es:bx - RAM location
load_sector:
read_sector:
push ax
mov ah, 0x02
call do_sector
pop ax
ret
write_sector:
push ax
mov ah, 0x03
call do_sector
pop ax
ret
do_sector:
pusha ;preserve registers
mov [disk_errors], byte 0 ;Reset error count
mov ah, 0x02
mov dl, 0x00 ;Floppy
load_sector_int:
do_sector_int:
pusha ;registers get changed by int
;; crash here
;; eip register garbage
int 0x13
jc load_sector_err ;CF set
jc do_sector_err ;CF set
popa
popa
ret
load_sector_err:
do_sector_err:
;; should count # of times errored
popa
add [disk_errors], byte 1 ;Increment err count
cmp [disk_errors], byte 5
jle load_sector_int
jle do_sector_int
;; Handle error
shr ax, 8 ;right binary shift
mov ah, 0
......@@ -32,4 +45,3 @@ load_sector_err:
ret
disk_errors: db 0
db 'X'
......@@ -2,6 +2,8 @@
sedit_init:
pusha
mov [SEDIT_CURSOR_POSITION], byte 0
mov bx, SEDIT_INIT_MSG ;Init msg
call print
......@@ -49,8 +51,7 @@ sedit_enter:
mov al, 0xD
call print_char
mov al, 0xA
call print_char ;Print out the enter
call print_char ;Print out the enter
jmp sedit_loop
......@@ -58,9 +59,18 @@ sedit_backspace:
sub [SEDIT_CURSOR_POSITION], byte 2
;; Backspace the teletype
jmp sedit_loop
sedit_exit:
;; save buffer
mov dh, 0
mov cx, 14 ;sect & cyl
mov al, 2
mov bx, SEDIT_EDITOR_BUFFER
call write_sector
;; print & exit
mov bx, SEDIT_EXIT_MSG
call print
popa
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment