Date : Thu, 02 Aug 2007 01:27:30 +0100
From : jgh@... (Jonathan Graham Harston)
Subject: Coprocessor/ Tube Use
>Message-ID: <919322.84666.qm@...>
Peter Craven <cjl_craves@...> wrote:
> 1. a) Can a program in the Coprocessor (client/parasite) transfer
> data from the host to the parasite, or does the program have to
Yes, that is the usual method. The client is in control of
operations and the host does what it is told.
> reside in the host? The examples in the Acorn Support Group
Code either side of the Tube can transfer data across the Tube.
>From the client side it has to be a data transfer that results
from an API call, such as OSWORD, OSCLI, OSFILE, etc.
>From the host side the only actions that can be performed /are/
data transfers.
> b) How would the example program from the Acorn Support Group
> Application Notes be changed to reside in the parasite and
> transfer H-->P??
The easiest way is to use an existing API, such as OSWORD 5/6 -
read/write byte in I/O memory:
DIM ctrl% 31:X%=ctrl%:Y%=X%DIV256
DEFPROCMemRd(src%,num%,dst%)
A%=5:REPEAT:!X%=src%:CALL &FFF1:?dst%=X%?4
src%=src%+1:dst%=dst%+1:num%=num%-1
UNTIL num%<1:ENDPROC
:
DEFPROCMemWr(dst%,num%,src%)
A%=6:REPEAT:!X%=dst%:X%?4=?src%:CALL &FFF1
src%=src%+1:dst%=dst%+1:num%=num%-1
UNTIL num%<1:ENDPROC
PROCMemRd(&3000,&800,&6000) will copy &800 bytes from &3000 in the
I/O memory to &6000 in local memory, which will be the second
processor memory if executed on the second processor.
Using OSWORD 5/6 is fairly slow as an eight-byte OSWORD transfer
has to be done for every byte of data transfered. Most programs
use OSWORD 5 to copy some code into the host to provide, eg, an
extra OSWORD call to do bulk data transfer. For instance, the Z80
client ROM sets up code for OSWORD &FF.
> 2. These same documents I have read also mention that BPUT for
> large amounts of data transfer.....
"Fast Tube BPUT", not BPUT.
> "Moving large quantities of data: To move large quantities of
> data, for example a complete screen update, the fast Tube BPUT
> OSBYTE call is used. Prior to the call, some machine code is
...is reassigned, not is used.
> Could anyone please elaborate and possibly give small example
> program?
.osb
CMP #157:BNE oldosb ; If not OSBYTE 157, daisy chain
STX dst+0:sty dst+1 ; Save XY as destination address
LDA #0:STA dst+2:STA dst+3 ; Send high word to &0000
STA src+0:lds #&30:STA src+1 ; Set source addr to screen start
.TubeClaim
LDA #&C0+TubeID
JSR &406:BCC TubeClaim ; Claim Tube
.Send256Bytes
LDX #dst:LDY #0 ; Point to dst address
LDA #7:JSR &406 ; Initiate 256-byte transfer
JSR TubeDelay ; Delay before starting
LDY #0
.SendLoop
LDA (src),Y:STA &FEE5 ; Send a byte
NOP:NOP:NOP ; Deley between bytes
INY:BNE SendLoop ; Loop for 256 bytes
INC dst+1:INC src+1 ; Inc pointers
BPL Send256Bytes ; Loop until end of screen
LDA #&80+TubeID ; Release Tube
JSR &406
Not the method I would use, I'd install a data transfer OSWORD
such as OSWORD &FF.
Another method is to use the actual OSWORD control block as the
data to be transfered, but that requires it to be copied into and
out of the control block. Assume we have set up code in the host
to respond to OSWORD &E0 as follows:
X%?0=send block length
X%?1=receive block length
X%!2=I/O memory address
X%+6... data to be transfered
then...
DEFPROCMemWr(dst%,num%,src%)
FOR A%=0 TO num%:X%?(A%+6)=src%?A%:NEXT
X%?0=num%+6:X%?1=0:X%!2=dst%
A%=&E0:CALL &FFF1:ENDPROC
would transfer up to 122 bytes via the control block. It also is
slow, but due the data having to be copied into the control block.
100 bytes are transfer in a single 107-byte Tube transfer instead
of 800 bytes of transfer using OSWORD 5/6.
I've put the source and object code for OSWORD &FF on my site at
http://mdfs.net/Software/Tube It's a slightly modifed version that
can be *RUN on any system to give OSWORD &FF on any second processor.
--
J.G.Harston - jgh@... - mdfs.net/User/JGH
BBC IDE Hard Drive Interface - http://mdfs.net/Info/Comp/BBC/IDE