Page 1 of 1

68k and z80 linking source

Posted: Thu Oct 23, 2014 11:06 pm
by Count SymphoniC
I figured it's been long enough for me to ask another question.

How is this accomplished? I'm going to go ahead and learn z80 so I can start work on the DAC portion of my tracker, and I have plenty of documentation *cough* for z80 that I found from google *SNEEZEr57*. But I can't seem to find anything on linking these two assembly types, into one program. Is it even called linking? :)

Yes, that was a playful joke by the way, let's not take it too seriously.
Also I will disappear for a reasonable amount of time again once this question has been answered.

Posted: Fri Oct 24, 2014 12:34 am
by Mask of Destiny
Generally you create a raw binary of some sort of your Z80 program and include it in your 68K program as you would any other binary file. The only complication is if your Z80 program needs to refer to data at a particular address in your 68K binary (loading DAC samples through the banked area for instance). I'm not aware of a great solution to that problem.

EDIT: Actually invoking the Z80 portion is the responsibility of your 68K code. Basically involves bus requesting the Z80, copying the data and releasing the bus request (and maybe resetting the Z80 too for good measure).

Posted: Fri Oct 24, 2014 12:53 am
by Count SymphoniC
Mask of Destiny wrote:Generally you create a raw binary of some sort of your Z80 program and include it in your 68K program as you would any other binary file. The only complication is if your Z80 program needs to refer to data at a particular address in your 68K binary (loading DAC samples through the banked area for instance). I'm not aware of a great solution to that problem.

EDIT: Actually invoking the Z80 portion is the responsibility of your 68K code. Basically involves bus requesting the Z80, copying the data and releasing the bus request (and maybe resetting the Z80 too for good measure).
Alright thanks. Good thing I already have bus requests and resets figured out. I'll have to find some source code that does what you describe and understand how it's done from there. That should suffice I think. If I'm unable to figure it out (I don't see why that would be the case) I'll return here. Thanks again.

Posted: Fri Oct 24, 2014 8:49 am
by Stef
Count SymphoniC wrote: Alright thanks. Good thing I already have bus requests and resets figured out. I'll have to find some source code that does what you describe and understand how it's done from there. That should suffice I think. If I'm unable to figure it out (I don't see why that would be the case) I'll return here. Thanks again.
Again you can find all that in SGDK sources ;)

Posted: Fri Oct 24, 2014 6:05 pm
by Chilly Willy
A little summary... suppose you need to play a PCM effect via the Z80. The Z80 may need to know the start of the PCM samples, the length, and the rate to play at. Rather than try to have the Z80 read that info from lists in the rom, you instead define set locations in the Z80 sram and have the 68000 fill in those locations with the proper info. It's simple to have the 68000 read the lists in rom since the linker works on the 68000, so have it retrieve the data for the Z80. Doing things that way make it simple to coordinate the Z80 and 68000.