Skip to content

Commit

Permalink
Fixed 0x10cAtlas#46, cat command is now implemented
Browse files Browse the repository at this point in the history
Removed old legacy code
  • Loading branch information
chessmaster42 committed May 5, 2012
1 parent bf86ca0 commit 3435df9
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 3,553 deletions.
76 changes: 72 additions & 4 deletions apps/AtlasShell.dasm16
Expand Up @@ -99,6 +99,13 @@
IFE C, 0
JSR command_cdf

; Check for the 'cat' command
SET A, command_cat
SET B, command_parameter_buffer
JSR [0x101A]
IFE C, 0
JSR command_catf

; Check if we're trying to run a file
IFN [ack_command], 1
JSR command_runfile
Expand Down Expand Up @@ -712,14 +719,74 @@
SET C, POP
SET B, POP
SET A, POP
;JSR [0x1002]
SET PC, POP

:command_catf
SET PUSH, A
SET PUSH, B
SET PUSH, C

; Capture the param
SET A, input_text_buffer
SET B, 1
JSR shell_getparameter
JSR [0x101F] ; newline
; Get the file from the filename
SET A, command_parameter_buffer
JSR [0x1029] ; filesystem_getfile
IFE C, 0
SET PC, command_catf_end

SET A, [C] ; Get the directory ID
IFN A, [present_working_directory] ; And make sure the file is in our directory
SET PC, command_catf_end

ADD C, 1
SET A, [C] ; Get the file flags
AND A, 0x0008 ; Check if the file is executable
IFN A, 0
SET PC, command_catf_end

ADD C, 17 ; skip over the filename to the file start pointer
SET A, [C] ; Store the file start in A
ADD C, 1 ; Move to the file end pointer
SET B, [C] ; Store the file end in B
SUB B, A ; Get the length into B

SET PUSH, B
SET PUSH, A
JSR [0x100F] ; page_alloc
SET C, A
SET A, POP
SET B, C
SET C, POP
AND C, 0x03FF ; For now we are limiting cat to just 1024 words of output
JSR [0x1013] ; mem_copy
SET A, B
:command_catf_sanitize
IFE [B], 0
SET [B], 32
ADD B, 1
SUB C, 1
IFN C, 0
SET PC, command_catf_sanitize
SET [B], 0

JSR [0x101E] ; text_out

:command_catf_end
SET [ack_command], 1

SET C, POP
SET B, POP
SET A, POP
SET PC, POP

:AtlasShell_die
SET A, input_buffer
JSR [0x1027]
JSR [0x101F]
JSR [0x1005]
JSR [0x1027] ; unregister_keyboard
JSR [0x101F] ; newline
JSR [0x1005] ; proc_kill_me

; ==BEGIN HELPER FUNCTIONS==
; Displays OS version using API call to get version numbers
Expand Down Expand Up @@ -862,6 +929,7 @@
:command_cd_help dat "Syntax : cd [directory|..|/]", 0xA0, 0x00
:command_cd_unknown dat " doesnt exist", 0xA0, 0
:command_runfile_notexe_text dat "File is not executable", 0xA0, 0x00
:command_cat dat "cat", 0

:proc_list_buffer
dat 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000
Expand Down
6 changes: 3 additions & 3 deletions include/kernel.inc
Expand Up @@ -212,9 +212,9 @@ dat 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000
dat keyboard_unregister ; 0x1027 Unregisters a specific memory location
dat keyboard_is_exclusive_active ; 0x1028 Unregisters a specific memory location

dat filesystem_getfile ; Returns the start of the matched filesystem entry in C, 0 otherwise
dat filesystem_getfile_table ; Returns the start of the filesystem file table. May be deprecated later
dat filesystem_getfile_bystart ; Returns the start of the matched filesystem entry in C, 0 otherwise
dat filesystem_getfile ; 0x1029 Returns the start of the matched filesystem entry in C, 0 otherwise
dat filesystem_getfile_table ; 0x102A Returns the start of the filesystem file table. May be deprecated later
dat filesystem_getfile_bystart ; 0x102B Returns the start of the matched filesystem entry in C, 0 otherwise
:api_end


Expand Down

0 comments on commit 3435df9

Please sign in to comment.