forked from crazyettin/EttinOS
Finish writing fileify, remove printch and readch since those have not proven useful, merge the code in byte2hex to keycode, and rename printnl back to newline because it was easy to confuse with println.
This commit is contained in:
parent
a62a87970a
commit
45a11e601f
|
@ -1,49 +0,0 @@
|
|||
;Converts a byte in AL to a hex string at DI.
|
||||
|
||||
byte2hex:
|
||||
|
||||
;Store the initial registers in the stack
|
||||
push si
|
||||
push ax
|
||||
push bx
|
||||
push cx
|
||||
|
||||
;Move the byte to AH
|
||||
mov ah, al
|
||||
|
||||
;Set a key for the hex digits
|
||||
mov si, .key
|
||||
|
||||
;Set a counter for the two hex digits
|
||||
mov cx, 0x2
|
||||
|
||||
.loop:
|
||||
|
||||
;Read a nibble
|
||||
rol ax, 0x1
|
||||
rol ax, 0x1
|
||||
rol ax, 0x1
|
||||
rol ax, 0x1
|
||||
mov bx, ax
|
||||
|
||||
;Convert the nibble to a hex digit
|
||||
and bx, 0xf
|
||||
mov bl, [si + bx]
|
||||
|
||||
;Store the hex digit
|
||||
mov [di], bl
|
||||
|
||||
;Repeat
|
||||
inc di
|
||||
dec cx
|
||||
jnz .loop
|
||||
|
||||
;Load the initial registers from the stack
|
||||
pop cx
|
||||
pop bx
|
||||
pop ax
|
||||
pop si
|
||||
|
||||
ret
|
||||
|
||||
.key db "0123456789abcdef"
|
|
@ -1,7 +1,5 @@
|
|||
;Reads a string, checks if it is a valid 8.3 file name, converts it into FAT formatting, and prints it.
|
||||
|
||||
;To do: change the .test call to work with flags instead of direct jumps.
|
||||
|
||||
fileify:
|
||||
|
||||
;Read a string
|
||||
|
@ -23,39 +21,42 @@ sub di, 0xb
|
|||
mov bl, 0x8
|
||||
|
||||
.nameloop:
|
||||
|
||||
;Load a character
|
||||
lodsb
|
||||
|
||||
;Check for a period
|
||||
cmp al, 0x2e
|
||||
je .initext
|
||||
|
||||
call .test
|
||||
;Check for everything else and convert to upper case
|
||||
call .checkconv
|
||||
jmp .nameloop
|
||||
|
||||
.initext:
|
||||
;Set DI and initialise the counter for the extension
|
||||
;Set DI and initialise the length counter for the extension
|
||||
mov bl, 0x3
|
||||
mov di, .file+0x8
|
||||
|
||||
.extloop:
|
||||
call .test
|
||||
;Load a character
|
||||
lodsb
|
||||
;Check for a period
|
||||
push ax
|
||||
cmp al, 0x2e
|
||||
je .error
|
||||
pop ax
|
||||
;Check for everything else and convert to upper case
|
||||
call .checkconv
|
||||
jmp .extloop
|
||||
|
||||
.error:
|
||||
pop ax
|
||||
mov si, .errormsg
|
||||
call println
|
||||
jmp .done
|
||||
|
||||
.print:
|
||||
mov si, .name
|
||||
call printstr
|
||||
mov si, .extension
|
||||
call printstr
|
||||
mov al, 0x7c
|
||||
call printch
|
||||
call printnl
|
||||
pop ax
|
||||
mov si, .file
|
||||
call println
|
||||
|
||||
.done:
|
||||
ret
|
||||
|
@ -64,7 +65,7 @@ ret
|
|||
|
||||
.errormsg db "Invalid file name", 0x0
|
||||
|
||||
.test:
|
||||
.checkconv:
|
||||
|
||||
;Check for the string end
|
||||
cmp al, 0x0
|
||||
|
@ -103,13 +104,13 @@ je .error
|
|||
;Find and convert lower case letters to upper case
|
||||
;Check for lower case
|
||||
cmp al, 0x61
|
||||
jl .conttest
|
||||
jl .storech
|
||||
cmp al, 0x7a
|
||||
jg .conttest
|
||||
jg .storech
|
||||
;Convert lower to upper case
|
||||
sub al, 0x20
|
||||
|
||||
.conttest:
|
||||
.storech:
|
||||
|
||||
;Store the character
|
||||
stosb
|
||||
|
|
|
@ -17,13 +17,13 @@ call printstr
|
|||
;Convert the scancode to a hex string
|
||||
mov al, [.scan]
|
||||
mov di, .keycode
|
||||
call byte2hex
|
||||
call .byte2hex
|
||||
|
||||
;Convert the ascii value to a hex string
|
||||
mov al, [.ascii]
|
||||
mov di, .keycode
|
||||
add di, 0x2
|
||||
call byte2hex
|
||||
call .byte2hex
|
||||
|
||||
;Print the keycode
|
||||
mov si, .keycode
|
||||
|
@ -37,3 +37,51 @@ ret
|
|||
.ascii db 0x0
|
||||
|
||||
.keycode times 0x5 db 0x0
|
||||
|
||||
.byte2hex:
|
||||
|
||||
;Store the initial registers in the stack
|
||||
push si
|
||||
push ax
|
||||
push bx
|
||||
push cx
|
||||
|
||||
;Move the byte to AH
|
||||
mov ah, al
|
||||
|
||||
;Set a key for the hex digits
|
||||
mov si, .key
|
||||
|
||||
;Set a counter for the two hex digits
|
||||
mov cx, 0x2
|
||||
|
||||
.loop:
|
||||
|
||||
;Read a nibble
|
||||
rol ax, 0x1
|
||||
rol ax, 0x1
|
||||
rol ax, 0x1
|
||||
rol ax, 0x1
|
||||
mov bx, ax
|
||||
|
||||
;Convert the nibble to a hex digit
|
||||
and bx, 0xf
|
||||
mov bl, [si + bx]
|
||||
|
||||
;Store the hex digit
|
||||
mov [di], bl
|
||||
|
||||
;Repeat
|
||||
inc di
|
||||
dec cx
|
||||
jnz .loop
|
||||
|
||||
;Load the initial registers from the stack
|
||||
pop cx
|
||||
pop bx
|
||||
pop ax
|
||||
pop si
|
||||
|
||||
ret
|
||||
|
||||
.key db "0123456789abcdef"
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
;Prints a newline
|
||||
|
||||
printnl:
|
||||
newline:
|
||||
|
||||
;Store the initial registers in the stack
|
||||
push si
|
||||
|
||||
;Print the newline
|
||||
mov si, .nl
|
||||
mov si, .newline
|
||||
call printstr
|
||||
|
||||
;Load the initial registers from the stack
|
||||
|
@ -14,4 +14,4 @@ pop si
|
|||
|
||||
ret
|
||||
|
||||
.nl db 0xd, 0xa, 0x0
|
||||
.newline db 0xd, 0xa, 0x0
|
|
@ -1,8 +0,0 @@
|
|||
;Prints a character from AL
|
||||
|
||||
printch:
|
||||
|
||||
mov ah, 0xe
|
||||
int 0x10
|
||||
|
||||
ret
|
|
@ -6,6 +6,6 @@ println:
|
|||
call printstr
|
||||
|
||||
;Print a newline
|
||||
call printnl
|
||||
call newline
|
||||
|
||||
ret
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
;Reads a character to AL
|
||||
|
||||
readch:
|
||||
|
||||
;Store the initial registers
|
||||
push bx
|
||||
push ax
|
||||
|
||||
;Read a keypress
|
||||
mov ah, 0x0
|
||||
int 0x16
|
||||
|
||||
;Check for non-printing characters
|
||||
cmp al, 0x1f
|
||||
jle readch
|
||||
cmp al, 0x7f
|
||||
je readch
|
||||
|
||||
;Print the character
|
||||
mov ah, 0xe
|
||||
int 0x10
|
||||
|
||||
;Load the initial registers
|
||||
pop bx
|
||||
mov ah, bh
|
||||
pop bx
|
||||
|
||||
ret
|
|
@ -6,6 +6,6 @@ readln:
|
|||
call readstr
|
||||
|
||||
;Print a newline
|
||||
call printnl
|
||||
call newline
|
||||
|
||||
ret
|
||||
|
|
|
@ -4,19 +4,16 @@ ORG 0x500
|
|||
jmp start
|
||||
|
||||
;Calls
|
||||
%include "BYTE2HEX.INC"
|
||||
%include "CMPSTR.INC"
|
||||
%include "PRINTNL.INC"
|
||||
%include "PRINTCH.INC"
|
||||
%include "PRINTSTR.INC"
|
||||
%include "PRINTLN.INC"
|
||||
%include "READCH.INC"
|
||||
%include "READSTR.INC"
|
||||
%include "NEWLINE.INC"
|
||||
%include "PRINTLN.INC"
|
||||
%include "READLN.INC"
|
||||
|
||||
;Commands
|
||||
%include "ECHO.INC"
|
||||
;%include "FILEIFY.INC"
|
||||
%include "FILEIFY.INC"
|
||||
%include "HELLO.INC"
|
||||
%include "HELP.INC"
|
||||
%include "KEYCODE.INC"
|
||||
|
@ -59,20 +56,20 @@ je loop
|
|||
mov si, buffer
|
||||
mov di, cmd.echo
|
||||
call cmpstr
|
||||
;jnc .fileify
|
||||
jnc .hello
|
||||
jnc .fileify
|
||||
;jnc .hello
|
||||
;Execute
|
||||
call echo
|
||||
jmp loop
|
||||
;.fileify:
|
||||
;;Check
|
||||
;mov si, buffer
|
||||
;mov di, cmd.fileify
|
||||
;call cmpstr
|
||||
;jnc .hello
|
||||
;;Execute
|
||||
;call fileify
|
||||
;jmp loop
|
||||
.fileify:
|
||||
;Check
|
||||
mov si, buffer
|
||||
mov di, cmd.fileify
|
||||
call cmpstr
|
||||
jnc .hello
|
||||
;Execute
|
||||
call fileify
|
||||
jmp loop
|
||||
.hello:
|
||||
;Check
|
||||
mov si, buffer
|
||||
|
|
Loading…
Reference in New Issue