Memory declarations in merged programs

Software questions and issues with the FV-1

Moderator: frank

Post Reply
Aion
Posts: 33
Joined: Sat Mar 22, 2008 1:17 am

Memory declarations in merged programs

Post by Aion »

Hi Frank,

I have two groups of effects performed by one FV-1. The first group uses the left channel, the second the right channel of the FV-1. Each of the two group has 5 effects to select. Let's denote them by L1...L5 and R1...R5. Only one effect from the 5 of the each group can be selected, but two effects from the both groups can be used together. For example:

L group off - R1 on
L2 on - R group off
L3 on - R5 on
etc.

This gives 36 combinations or programs which are loaded to FV-1 by a microcontroller. Modification of any of the resulting 36 codes leads to time-consuming and troublesome modification of many programs.

Therefore I assembled 2 x 5 effects (5 x Ln and 5 x Rn) separately and I am merging both machine codes during loading to FV-1 (so 80 ticks are for Lx, and 48 for Rn). It works but there is a question:

How to declare memories in separately assembled programs, whose machine codes are merged during loading to FV-1?

I have simply done that by declaring

mem RAM1 4000 ;in programs from L group
mem RAM2 28000 ; in programs from R group

Is there a better method, especially in case I will need more memory segments in one of the programs?
frank
Posts: 1244
Joined: Wed Oct 19, 2005 12:26 pm
Contact:

Post by frank »

Yeah, building programs on the fly is always a pain but you did figure out 99% of the trick (split instructions on a fixed number and always loading from one set first). Splitting the memory on a fixed boundary is the right thing to do and you must make all programs respect that boundary and you can do this by knowing how SpinAsm allocates memory.

For example, a left program that requires 2 500 long blocks you would do things as normal and declare them as normal:

mem left_1 500;
mem left_2 500;

And that is OK, SpinAsm assigns addresses starting at 0 as it runs into each mem statement so these will be at the start of memory.

But a right program also needs to assign multiple blocks so the very first mem statement in a right program should be:

mem left_memory 4000;

But you do not use this block, it just there to force right memory blocks to start above left memory. Then do normal mem statements for right blocks after that left_memory declaration. So a right program might start with:

mem left_memory 4000;
mem right_1 1024;
mem right_2 713;

Also remember that when you ask for X memory spaces SpinAsm allocates X+1 because you always need 1 more than you ask for to write to, so the two 500 left blocks in the example above actually use 1002 memory locations from 0 - 1001 inclusive. I mention this so if you hear something odd check the memory allocation as each program assembles in SpinAsm to make sure that you are not accidentally overlapping the end of left memory with the start of right memory by only 1 or 2 locations.
Frank Thomson
Experimental Noize
Aion
Posts: 33
Joined: Sat Mar 22, 2008 1:17 am

Post by Aion »

Thank you very much!
Post Reply