Page 1 of 1

Writing to Second Processor Memory from Sideways ROM

Posted: Sat Dec 17, 2016 5:52 pm
by BeebMaster
How do I store a byte in a location in the second processor RAM from a sideways ROM?

In my ROM image code, basically I have an "STA location" instruction. With the Tube off, it writes it in the I/O processor RAM, which is correct as I want it storing in the currently-in-use processor. But with the Tube on, it still writes it in the I/O processor instead of the second processor.

Re: Writing to Second Processor Memory from Sideways ROM

Posted: Sat Dec 17, 2016 6:22 pm
by jgharston
See the New Advanced User Guide p327 onwards or Acorn Application Note 4.

Claim the Tube
.TubeClaim
LDA #&C0+MyID ; recommend you use &3F for MyID
JSR &406:BCC TubeClaim

Initiate a data transfer
!block=CoProAddress
LDX #block AND 255 ; point XY to the block holding the 32-bit address in the second processor
LDY #block DIV 256
LDA #transfer ; 0=CoPro to Host, 1=Host to CoPro
JSR &406

Do the transfer
JSR TubeDelay ; Initial delay
JSR TubeDelay

For Host to CoPro transfers:
.TubeLoopSend
JSR TubeDelay
LDA source data ; data to send to CoPro
STA &FEE5 ; Send to CoPro
HaveIFinishedYet?
BNE TubeLoopSend

For CoProToHost transfers
.TubeLoopRecieve
JSR TubeDelay
LDA &FEE5 ; Get from CoPro
STA dest data ; Do something with the data
HaveIFinishedYet?
BNE TubeLoopRecieve

Release Tube:
LDA #&80+MyID ; same ID as when claiming
JSR &406

Subroutine for transfer delays:
.TubeDelay
JSR TubeDelay2
.TubeDelay2
RTS

Re: Writing to Second Processor Memory from Sideways ROM

Posted: Sat Dec 17, 2016 10:30 pm
by BeebMaster
Thanks very muchly for that, I've got it doing what it needs to be doing now - quite a faff to say I only wanted to transfer 6 bytes!!!

Re: Writing to Second Processor Memory from Sideways ROM

Posted: Sat Dec 17, 2016 11:20 pm
by jgharston
Normally the language processor is always in charge, so data is returned to the language processor in response to the language processor asking for it via the standard API.