Skip to content

Commit

Permalink
Merge pull request #23 from fourstix/b_k430
Browse files Browse the repository at this point in the history
Merge updated from b_k430 branch for Kernel 4.3.0 into main branch since Kernel 4.3.0 is the official version now.
  • Loading branch information
fourstix authored Aug 2, 2023
2 parents e6cecae + c94ccd7 commit 5c54458
Show file tree
Hide file tree
Showing 12 changed files with 244 additions and 18 deletions.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,19 @@ Print the value of the Elf/OS stack pointer.
Elf/OS I/O Utility Commands
-------------------------------------

## about
**Usage:** about
Show information about the current drive. Write the contents of the file /cfg/about.nfo to the output
to show information about the disk in the current drive.

## clr
**Usage:** clr
Clear the screen. Clears both ANSI and non-ANSI displays. *Copy or rename to 'cls' to replace default Elf/OS command in the /bin directory.*

## drive
**Usage:** drive
Write the current drive number to the output.

## input
**Usage:** input
Input and display data read from Port 4
Expand Down Expand Up @@ -144,7 +153,7 @@ Library Files
The command files are grouped into three Elf/OS library files that can be unpacked with the Elf/OS lbr command using the e option to *extract* files.
* file_utils.lbr - Library file for Elf/OS file utilities containing the cmd, flags, header, scpy, xtrim and xsb commands. Extract these files with the Elf/OS command *lbr e file_utils*
* sys_utils.lbr - Library file for Elf/OS system utilities containing the int, malloc, mfree, req, seq and stack commands. Extract these files with the Elf/OS command *lbr e sys_utils*
* io_utils.lbr - Library file for Elf/OS I/O utilities containing the clr, input, nop, output, pause, pwd, say and up commands. Extract these files with the Elf/OS command *lbr e io_utils*
* io_utils.lbr - Library file for Elf/OS I/O utilities containing the about, clr, drive, input, nop, output, pause, pwd, say and up commands. Extract these files with the Elf/OS command *lbr e io_utils*
* pixie_utils.lbr - Library file for ELf/OS 1861 Pixie Video utilities contains the spaceship, dma_test, tvclock and voff commands. Extract these files with the Elf/OS command *lbr e pixie_utils*
* stg_utils.lbr - Library file for the STG EPROM utilities containing the stg and videostg commands. Extract these files with the Elf/OS command *lbr e stg_utils*

Expand Down Expand Up @@ -178,7 +187,9 @@ Repository Contents
* xtrim.asm - Trim an executable file to its runtime size.
* xsb.asm - XMODEM Send using the hardware UART
* **/src/io/** -- Source files for Elf/OS I/O utilities.
* about.asm - Show information about the current drive
* clr.asm - Clear the screen
* drive.asm - Print the current drive number
* input.asm - Input and display data read from Port 4
* nop.asm - No Operation - simple program that does nothing
* output.asm - Output hh - send the hex value 'hh' out to Port 4
Expand Down
Binary file modified bin/file/flags.bin
Binary file not shown.
Binary file modified bin/file/scpy.bin
Binary file not shown.
Binary file added bin/io/about.bin
Binary file not shown.
Binary file added bin/io/drive.bin
Binary file not shown.
Binary file modified hlp/utils.lbr
Binary file not shown.
Binary file modified lbr/file_utils.lbr
Binary file not shown.
Binary file modified lbr/io_utils.lbr
Binary file not shown.
21 changes: 13 additions & 8 deletions src/file/flags.asm
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ d_ideread: equ 0447h
br start

; Build date
date: db 80h+9, ; Month, 80h offset means extended info
db 20 ; Day
dw 2021 ; year
date: db 80h+1, ; Month, 80h offset means extended info
db 13 ; Day
dw 2023 ; year
; Current build number
build: dw 5 ; build
build: dw 7 ; build

; Must end with 0 (null)
db 'Copyright 2021 Gaston Williams',0
db 'Copyright 2023 Gaston Williams',0

start: lda ra ; move past any spaces
smi ' '
Expand All @@ -58,12 +58,17 @@ start1: COPY ra, rf ; copy argument address to rf
loop1: lda ra ; look for first less <= space
smi 33
lbdf loop1
dec ra ; backup to char
ldi 0 ; need proper termination
dec ra ; backup to previous char
dec ra ; back up to trailing character
lda ra ; check for trailing slash
smi '/' ; remove trailing slash for dir file name
lbnz end_ln ; any other character is okay
dec ra ; move back one character
end_ln: ldi 0 ; need proper termination
str ra
LOAD rd, fildes ; get file descriptor
LOAD r7, 0h ; no special flags
LOAD r7, 10h ; open a directory or a file
CALL o_open ; attempt to open file
lbnf opened ; jump if file opened

Expand Down
20 changes: 11 additions & 9 deletions src/file/scpy.asm
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
br start ; Jump past build information

; Build date
date: db 80H+9 ; Month, 80H offset means extended info
db 24 ; Day
dw 2021 ; Year
date: db 80H+1 ; Month, 80H offset means extended info
db 14 ; Day
dw 2023 ; Year

; Current build number
build: dw 5
build: dw 7
; Must end with 0 (null)
db 'Copyright 2021 Gaston Williams',0

Expand Down Expand Up @@ -111,7 +111,7 @@ good6: ldi 0 ; need terminator

CALL o_inmsg
db 'File not found',10,13,0
lbr o_wrmboot ; and return to os
lbr err_exit ; and return to os

opened: LOAD rf, flags ; check for directory
ldn rf ; get flag byte from fildes
Expand All @@ -122,7 +122,7 @@ opened: LOAD rf, flags ; check for directory
db 'Source cannot be a directory.',10,13,0

CALL o_close ; close source file and exit
lbr o_wrmboot ; and exit
lbr err_exit ; and exit
cont: COPY rd, r7 ; make copy of descriptor

Expand All @@ -132,7 +132,7 @@ cont: COPY rd, r7 ; make copy of descriptor
LOAD r7, 0h ; flags for open, don't create

CALL o_open ; attempt to open file
lbdf create ; DF = 1 -> no such file, reopen to create
lbdf reopen ; DF = 1 -> no such file, reopen to create

LOAD rf, dflags ; check destination flags
ldn rf ; get the destination flag byte
Expand All @@ -156,14 +156,16 @@ dupe: LOAD rf, noprompt ; get no prompt flag
LOAD rf, buffer ; check response
ldn rf ; Is first character 'y' or not?
smi 'Y' ; 'Y' is a positive response
bz reopen ; reopen file if positive respone
lbz reopen ; reopen file if positive response
smi 20h ; 'y' is 32 less than 'Y'
lbz reopen ; reopen if positive, otherwise quit

abend: CALL o_close ; close destination
POP rd ; recover source descriptor
CALL o_close ; close source
lbr o_wrmboot ; exit to Elf/OS
err_exit: ldi 0ffh ; set retval for error code
shl ; set df true for error
RETURN ; exit to Elf/OS (DF = 1, D = FE)

reopen: CALL o_close ; close and reopen file to overwrite

Expand Down
121 changes: 121 additions & 0 deletions src/io/about.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
; *******************************************************************
; *** This software is copyright 2004 by Michael H Riley ***
; *** You have permission to use, modify, copy, and distribute ***
; *** this software so long as this copyright notice is retained. ***
; *** This software may not be used in commercial applications ***
; *** without express written permission from the author. ***
; *******************************************************************

#include ops.inc
#include bios.inc
#include kernel.inc


; ************************************************************
; This block generates the Execution header
; It occurs 6 bytes before the program start.
; ************************************************************

org 02000h-6 ; Header starts at 01ffah
dw 2000h
dw endrom-2000h
dw 2000h
org 2000h ; Program code starts at 2000
br start

; Build date
date: db 80h+1, ; Month, 80h offset means extended info
db 13 ; Day
dw 2023 ; year

; Current build number
build: dw 7 ; build

db 'Copyright 2023 Gaston Williams',0

start: LOAD rf, about_fn ; information file about this config
LOAD rd, fildes ; get file descriptor
ldi 0 ; flags for open
plo r7
CALL o_open ; attempt to open file
lbnf main ; jump if file was opened
LOAD rf, errmsg ; get error message
CALL o_msg ; display it
ldi 0ch
RETURN ; and return to os
main: ldi 0 ; clear out skip character
phi r9
ldi 23 ; 23 lines before pausing
plo r9
mainlp: ldi 0 ; want to read 16 bytes
phi rc
ldi 16
plo rc
LOAD rf, buffer ; buffer to retrieve data
CALL o_read ; read the header
glo rc ; check for zero bytes read
lbz done ; jump if so
LOAD r8, buffer ; buffer to retrieve data
linelp: lda r8 ; get next byte
stxd ; save a copy
CALL o_type
irx ; recover character
ghi r9 ; get skip character
lbz cont ; continue on if no skip character
sm ; check if this is skip character
lbz skipped ; jump if skipped
cont: ldx ; get character to check for eol
smi 10 ; check for lf (0ah)
lbnz chk_cr ; if not lf check for cr
ldi 13 ; skip next char if cr (eol: lf,cr)
phi r9
lbr newline ; process new line
chk_cr: smi 3 ; check for cr (0dh - 0ah = 3)
lbnz linelp2 ; jump if not cr
ldi 10 ; skip next char if lf (eol: cr,lf)
phi r9
newline: dec r9 ; decrement line count
glo r9 ; see if full page
lbnz linelp2 ; jump if not
call o_inmsg ; display more message
db 10,'-MORE-',0
call o_readkey ; check keys
smi 3 ; check for <CTRL><C>
lbz done ; exit if <ESC> is pressed
call o_inmsg ; display cr/lf
db 10,13,0
ldi 23 ; reset line count
plo r9
skipped: ldi 0
phi r9
linelp2: dec rc ; decrement read count
glo rc ; see if done
lbnz linelp ; loop back if not
lbr mainlp ; and loop back til done

done: sep scall ; close the file
dw o_close
ldi 0
RETURN ; return to os




about_fn: db '/cfg/about.nfo',0
errmsg: db 'File not found',10,13,0
fildes: db 0,0,0,0
dw dta
db 0,0
db 0
db 0,0,0,0
dw 0,0
db 0,0,0,0

endrom: equ $

.suppress

buffer: ds 20
cbuffer: ds 80
dta: ds 512
87 changes: 87 additions & 0 deletions src/io/drive.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
; -------------------------------------------------------------------
; Print Current Drive
; Copyright 2023 by Gaston Williams
; -------------------------------------------------------------------
; Based on software written by Michael H Riley
; Thanks to the author for making this code available.
; Original author copyright notice:
; *******************************************************************
; *** This software is copyright 2004 by Michael H Riley ***
; *** You have permission to use, modify, copy, and distribute ***
; *** this software so long as this copyright notice is retained. ***
; *** This software may not be used in commercial applications ***
; *** without express written permission from the author. ***
; *******************************************************************

#include ops.inc
#include bios.inc
#include kernel.inc


; ************************************************************
; This block generates the Execution header
; It occurs 6 bytes before the program start.
; ************************************************************

org 02000h-6 ; Header starts at 01ffah
dw 2000h
dw endrom-2000h
dw 2000h
org 2000h ; Program code starts at 2000
br start ; Jump past build information

; Build date
date: db 80h+1 ; Month, 80h offset means extended info
db 28 ; Day
dw 2023 ; Year

; Current build number
build: dw 8 ; build
; Must end with 0 (null)
db 'Copyright 2023 Gaston Williams',0

start: LOAD rf, dta ; point to suitable buffer
ldi 0
str rf ; place terminator
CALL o_chdir ; get current directory
LOAD rf, dta ; point to retrieved path
lda rf ; get first character
smi '/' ; check for drive number string '//n'
lbnz error
lda rf ; get first character
smi '/' ; check for drive number string '//n'
lbnz error
LOAD rd, drv_num ; point to drive number in message
lda rf ; next character is the number character
str rd ; put character into message string
inc rd ; point to next possible char
ldn rf ; check for second char
smi '/' ; if this is a slash, we're done
lbz show ; show single digit drive number
ldn rf ; otherwise store second number in message
str rd ; put second digit in drive number
show: LOAD rf, out_msg ; point to completed mesage
CALL o_msg ; and display it
LOAD rf, crlf ; display a cr/lf
CALL o_msg ; display it
lbr done
error: LOAD rf,err_msg ; show error message
ldi 0FFh ; set error code
shl ; set DF flag for error
done: RETURN ; return to caller

; -- over-lapping strings
out_msg: db 'Current drive: '
drv_num: db 0,0,0
crlf: db 13,10,0
; -- error message
err_msg: db 'Error: unable to read drive number.',10,13,0

endrom: equ $

dta: ds 512

0 comments on commit 5c54458

Please sign in to comment.