Compare commits

...

3 Commits

Author SHA1 Message Date
Virgil Dupras
ab6a2688fe recipes/trs80: self-hosting 2020-05-06 12:38:33 -04:00
Virgil Dupras
58ece9f9a1 editor: implement I command
Also, made LIST properly handle full 64-chars lines not ending with
a null or CR. Previously, such a line would be accompanied by its
following line, duplicating that line's output.
2020-05-06 12:19:36 -04:00
Virgil Dupras
f54b1dc504 Add 2>R and 2R>
This allows us to make DO..LOOP more compact.
2020-05-06 09:55:05 -04:00
11 changed files with 75 additions and 39 deletions

View File

@ -1,7 +1,9 @@
Return Stack
>R n -- R:n Pops PS and push to RS
2>R x y -- R:x y Equivalent to SWAP >R >R
R> R:n -- n Pops RS and push to PS
2R> R:x y -- x y Equivalent to R> R> SWAP
I -- n Copy RS TOS to PS
I' -- n Copy RS second item to PS
J -- n Copy RS third item to PS

View File

@ -2,7 +2,7 @@ T ( n -- ): select line n for editing.
P xxx: put typed line on selected line.
U xxx: insert typed line on selected line.
F xxx: find typed string in block.
I xxx: insert typed string at cursor

View File

@ -1,5 +1,5 @@
50 LOAD+ ( B152, extras )
1 5 LOADR+
1 6 LOADR+
: BROWSE
0 ACC ! L

View File

@ -1,5 +1,5 @@
: _type ( buf -- )
C< DUP 0xd = IF DROP EXIT THEN OVER DUP _zbuf ( c a )
C< DUP 0xd = IF 2DROP EXIT THEN OVER DUP _zbuf ( c a )
BEGIN ( c a )
C!+ C< SWAP
OVER 0x0d = UNTIL ( c a ) C! ;

15
blk/108 Normal file
View File

@ -0,0 +1,15 @@
: _ilen ( length of str in IBUF )
IBUF BEGIN C@+ EOL? UNTIL IBUF - 1- ;
: I
IBUF _type EDPOS @ 64 /MOD ( cno lno )
1+ 64 * _cpos ( cno next-line-ptr )
SWAP 63 -^ _ilen ( nlp nb-of-chars-to-move ilen )
2DUP > IF
SWAP OVER - 1+ ( nlp ilen nbc ) 0 DO ( a ilen )
SWAP 1- 2DUP -^ ( ilen a-1 a-ilen-1 ) C@ OVER C!
SWAP ( a ilen )
LOOP
ELSE DROP ( ilen becomes nbc )
THEN
SWAP DROP IBUF EDPOS @ _cpos ROT MOVE
;

18
blk/326
View File

@ -1,13 +1,17 @@
CODE >R
HL POPqq,
chkPS,
( 17 == pushRS )
17 BCALL,
HL POPqq, chkPS,
17 BCALL, ( 17 == pushRS )
;CODE
CODE 2>R
DE POPqq, HL POPqq, chkPS,
17 BCALL, ( 17 == pushRS ) EXDEHL, 17 BCALL,
;CODE
CODE R>
( 20 == popRS )
20 BCALL,
20 BCALL, ( 20 == popRS )
HL PUSHqq,
;CODE
CODE 2R>
20 BCALL, ( 20 == popRS ) EXDEHL, 20 BCALL,
HL PUSHqq, DE PUSHqq,
;CODE

View File

@ -3,11 +3,8 @@
: / /MOD SWAP DROP ;
: MOD /MOD DROP ;
( In addition to pushing H@ this compiles 2 >R so that loop
( In addition to pushing H@ this compiles 2>R so that loop
variables are sent to PS at runtime )
: DO
COMPILE SWAP COMPILE >R COMPILE >R
H@
; IMMEDIATE
: DO COMPILE 2>R H@ ; IMMEDIATE

View File

@ -12,5 +12,5 @@
: LOOP
COMPILE _ COMPILE (?br)
H@ - ,
COMPILE R> COMPILE DROP COMPILE R> COMPILE DROP
COMPILE 2R> COMPILE 2DROP
; IMMEDIATE

View File

@ -1,10 +1,12 @@
: .2 DUP 10 < IF SPC THEN . ;
: EOL? ( c -- f ) DUP 0xd = SWAP NOT OR ;
: LIST
BLK@
16 0 DO
I 1+ .2 SPC
64 I * BLK( + (print)
64 I * BLK( + DUP 64 + SWAP DO
I C@ DUP EOL? IF DROP LEAVE ELSE EMIT THEN
LOOP
NL
LOOP
;

Binary file not shown.

View File

@ -276,31 +276,47 @@ you're already supposed to know that one). Then, run `BYE` to return to TRSDOS
just halting). Then, you can dump memory to floppy as you already did for
`RECV`.
## Configuration
## Sending blkfs to floppy
In addition to the generic basic shell, this build of Collapse OS has support
for floppy drive `:1` as a block device (mapped to device `0`). Block device
commands work as expected.
As it is, your system fully supports reading and writing to floppy drive 1. It
also had `*CL<` to read a char from `*cl` and `*CL>` to emit a char to `*cl`.
In addition to this, there is a `flush` command to ensure that dirty buffers are
synced to disk. Make sure you run this after a write operation or before
swapping disks.
That's all you need to have a full Collapse OS with access to disk blocks.
On top of that, there's CFS support builtin. To enable a FS, type `fson` while
the active block device is properly placed (you can initialize a new FS by
writing `CFS\0\0\0\0` to the disk). If it doesn't error out, commands like
`fls` and `fnew` will work. Don't forget to flush when you're finished :)
First, make sure your floppies are formatted. Collapse OS is currently
hardcoded to single side and single density, which means there's a limit of 100
blocks per disk.
There is also a custom `recv` command that does the same "ping pong" as in
`recv.asm`, but once. It puts the result in `A`. This can be useful to send down
a raw CFS: you just need a while loop that repeatedly call `recv:putb a`.
You'll need to send those blocks through RS-232. Begin by taking over the
prompt:
## Assembling programs
' *CL> 0x53 RAM+ !
' *CL< 0x55 RAM+ !
Running `make` will yield a `floppy.cfs` file that you can dump on a disk. This
CFS contains a properly configured `zasm` as well as a test `hello.asm` file.
See B80 for details about those RAM offsets. Your serial link now has the
prompt. Now, you can use `/tools/blkup` to send a disk's contents. First,
extract the first 100 blocks from blkfs:
dd if=emul/blkfs bs=1024 count=100 > d1
Now, insert your formatted disk in drive 1 and push your blocks:
tools/blkup /dev/ttyUSB0 0 d1
It takes a while, but you will end up having your first 100 blocks on floppy!
Go ahead, `LIST` around. Then, repeat for other disks.
## Floppy organisation
Making blkfs span multiple disk is a bit problematic with regards to absolute
block references in the code. You'll need to work a bit to design your very
own Collapse OS floppy set. See Usage guide (B3) for details.
## Self-hosting
As it is, your installment of Collapse OS is self-hosting using instructions
very similar to `recipes/rc2014/selhost`. The difference is that instead of
writing the binary you have in memory to EEPROM, you'll quit to TRSDOS with
`BYE` and use TRSDOS' `DUMP` utility to save to disk like you already did
before.
By mounting this CFS (running `fson` with the active device properly placed),
you can assemble and run a binary from `hello.asm` in the same way that you
would in any CFS-enabled shell. You'll then see those sweet "Assembled from a
TRS-80" words!