Writing to Second Processor Memory from Sideways ROM

Discuss all aspects of programming here. From 8-bit through to modern architectures.
User avatar
BeebMaster
Posts: 2455
Joined: Sun Aug 02, 2009 4:59 pm
Location: Lost in the BeebVault!
Contact:

Writing to Second Processor Memory from Sideways ROM

Postby BeebMaster » Sat Dec 17, 2016 5:52 pm

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.
Image

User avatar
jgharston
Posts: 2661
Joined: Thu Sep 24, 2009 11:22 am
Location: Whitby/Sheffield

Re: Writing to Second Processor Memory from Sideways ROM

Postby jgharston » Sat Dec 17, 2016 6:22 pm

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

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.25
(C) Copyright J.G.Harston 1989,2005-2015
>_

User avatar
BeebMaster
Posts: 2455
Joined: Sun Aug 02, 2009 4:59 pm
Location: Lost in the BeebVault!
Contact:

Re: Writing to Second Processor Memory from Sideways ROM

Postby BeebMaster » Sat Dec 17, 2016 10:30 pm

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!!!
Image

User avatar
jgharston
Posts: 2661
Joined: Thu Sep 24, 2009 11:22 am
Location: Whitby/Sheffield

Re: Writing to Second Processor Memory from Sideways ROM

Postby jgharston » Sat Dec 17, 2016 11:20 pm

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.

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.25
(C) Copyright J.G.Harston 1989,2005-2015
>_


Return to “programming”

Who is online

Users browsing this forum: No registered users and 2 guests