Originally posted by TheRebornSometimes, I saw some patches in asar that have "if... then".
Wait, what? Isn't that NOT ASM?
You're right - those are not ASM, they're commands for Asar. (Like a preprocessor, if you will.) They're not inserted into the ROM (just like "header", "org", defines and labels aren't) - Asar checks them to find out what code to insert.
Originally posted by TheRebornAnd the second question is about the STA $XXXX|!addr, x...
I think I need some help!
The | operator is also a command for Asar. The same goes for +, - * and others: you can use them in your code to do calculations, and Asar will calculate the result and generate ASM code from it. For example, if you said
LDA $0DBF+$6000
, the actual code inserted into the ROM would be
LDA $6DBF
. (Of course, this only works with constant values.)
The | operator does a bitwise OR operation on the two numbers - in this case, you can think of it as "add the numbers if the second is less than the first". !addr is most likely defined in the .asm file to be something like $6000.
In total, the line
STA $XXXX|!addr
means "
STA $XXXX
, but add !addr to $XXXX if necessary". This is useful for SA-1 ROMs, because they need different adresses in their patches.