Let's get coding!

Moderator: a31chris

Post Reply
User avatar
Jaguar MOD
Posts: 894
Joined: Mon Apr 01, 2013 7:09 am


Post by a31chris » Mon Feb 24, 2014 7:27 pm

LinkoVitch wrote:
Rocky1138 wrote:I saw this in the T2K sources:

What is REGEQU? A Google search pulls up some Jaguar results but no definitions. How is it different from a regular EQU?
It's a register equate.. purely to make your code more readable.

Instead of refering soley to register values (which with 32 of them can be a bit of a mind melter, especially a few 1000 lines in and re-reading your code a month later) you can use more friendly names.

in the example you gave.. without the REGEQU you might have

moveq #4,r5

which will set register 5 to be the value 4

using the REGEQU however, you could rewrite that to

moveq #4,L_INC

The result is exactly the same, except now when you read the code you don't need to remember that register 5 is L_INC. The assembler would simply transpose it to moveq #4,r5 internally and assemble it.

Also should you decide you want it to be a different register (you know for your own OCD reasons or whatever ) you just change that one EQUREG and bingo, they all change.

an EQU on the other hand is a way of setting a constant for use in your code, so you could say have


now in your code you could have



and the value 3 would end up in the LIVES (r10) register. Should you at some point decide you want to change this default value, you change the EQU and your code changes. Very useful if you make use of a single value throughout your code. Saves trawling through code looking for every instance of a value.. Also can make code more readible too, as you don't have to remember why your are putting a particular random looking number into a register.. you can see that at this point you are putting a named constant into a register which will probably make more sense.

What came after the Jaguar was the PS1 which for all it's greatness, ushered in corporate development and with it the bleached, repetitive, bland titles which for the most part we're still playing today. - David Wightman

Post Reply