Topic: rewriting Pasmo to SDCC equilivant

I've been playing around with the sound engines a bit and there are a number of them that I have not been able to convert to use with SDCC.

I am specifically working on Nanobeep, but I see this little line of code in many of the sound engines.

I have yet to find a way after much googling to find the SDCC equivalent of the command combo

oldSP equ $+1
ld sp,0

Which according to what I understand oldSP will read the value of sp prior to being changed back to 0.

The problems is that I am using SDCC assembly and me not knowing assembly very well I am having trouble converting this to some equivalent in SDCC.

Any help with this would be appreciated.

Thanks

Re: rewriting Pasmo to SDCC equilivant

I don't know what would be the equivalent in SDCC syntax, might be as simple as

oldSP = $+1

Generally, what this pseudo-op construct means is: "assign a label (oldSP) to the current address ($) + 1". So in this example, oldSP will point to the address immediately after the "ld sp,nnnn" instruction, which happens to be the "nnnn" part. There is some other part in the code (usually in the init part) that writes the value of SP at that point in time to the location of oldSP. The snippet "ld sp,old_value" is then usually called on exit, to restore SP to it's proper value, as many beeper engines mess with the stack a lot.

Anyway, the point is that if you don't have any form of "label equ $+x" available, you can also simply locate all points in the code that write to 'label' (in case of the SP backup there'll usually just be one such location). That write op will look something like

  ld (oldSP),sp

which you can change to

  ld (oldSP + 1),sp

and then change the "oldSP equ $+1" to simply "oldSP".

Re: rewriting Pasmo to SDCC equilivant

As far as I remember, SDCC assembler simply does not allow 'current address', because it gets calculated at linking time only. So the second approach should help, i.e. ld (var+1),sp.

website - 1bit music - other music - youtube - bandcamp - patreon - twitter (latest news there)

Re: rewriting Pasmo to SDCC equilivant

I got it to work perfectly! 

ld (oldSP + 1),sp
..
ld (mLoopVar + 1),de
..
ld (speed + 2),de

Works like a champ.

Since I am doing this all with Z88dk and SDCC as the compiler, the compiler can place the music engine anywhere if finds fit, so I stripped out the #ORG and of course change all # to $, make the proper changes with the ld (oldSP + 1),sp   etc and I just got it to compile and play perfectly.

Thank you so much.

Andy

Re: rewriting Pasmo to SDCC equilivant

I'm going to be doing a write up on some sound engines and their conversions working with z88dk with SDCC.  I'm also planning on talking to Alvin about including other sound engine to work naively with z88dk.

The Nanobeep code working with SDCC is at https://drive.google.com/open?id=1yzUqN … B10CQpM87G

With your suggestions, it should now be rather straightforward to convert any of the other engines.

Andy