Knowledge Base

Multi-channel MultiTrack: Making I behave like J

The precode IasJ: in front of an instruction will force index register I to be applied to that instruction using “J-rules”. Now why in the world would you ever want to do that?

There are 3 principal reasons:

  1. J does not exist outside of a task running under MultiTrack. You may however need to access data that is normally (inside MultiTrack tasks) accessed with jndexed addressing. In particular, you may want to do semaphore addressing using bit offsets (J-rules) rather than base byte offsets (I-rules).
  2. You may need to write a task that can freely access all the elements of another task’s data arrays. A prime example of this is a setup menu that needs to be able to adjust 4 different temperature setpoints for 4 instances of a temperature control task.
  3. You may want to use indexed addressing on instructions that hitherto did not have indexed versions.
Example:

There are no indexed versions of the floating point recall and store instructions fRecallW and fStore. However, you can force indexing by using the IasJ: precode. The following nonsense program will continuously increment 5 floating point counters stored in RAM locations 20 and up. Run it in SPLat/PC and see how it works. You can display floating point registers and data in the floating point window (CTRL+P).

Loop
        LoadI           5
Inner
        DecI
        IasJ:fRecallW   20
        fInc
        IasJ:fStore     20
        ItoX
        GoIfZ           Loop
        GoTo            Inner