Well, first lets start with simple ARDS Codetypes:
Code:
Ram Write Codes:
Type 0: 32 bit write (str)
0XXXXXXX YYYYYYYY: writes word YYYYYYYY to [XXXXXXXX+offset]
Type 1: 16 bit write (strh)
1XXXXXXX 0000YYYY: writes half-word YYYY to [XXXXXXXX+offset]
Type 2: 8 bit write (strb)
2XXXXXXX 000000YY: writes byte YY to [XXXXXXXX+offset]
If Codes (32 bits):
(These rules apply for all conditionals [conditionals are codetypes 3-A])
If these conditions are not met, the code(s) following this are not executed
(i.e execution status is set to false) until a code type "D0" or "D2" is
encountered, or until the end of the code list is reached.
Type 3: 32 bit If Less Than (code value)>(data at address)(bhi, "unsigned higher")
3XXXXXXX YYYYYYYY: checks if YYYYYYYY>(word at [XXXXXXXX]).
Type 4: 32 bit If Greater Than (code value)<(data at address)(bcc, "unsigned lower")
4XXXXXXX YYYYYYYY: checks if YYYYYYYY<(word at [XXXXXXXX]).
Type 5: 32 bit If Equal to
5XXXXXXX YYYYYYYY: checks if YYYYYYYY ==(word at [XXXXXXXX]).
Type 6: 32 bit If Not Equal to
6XXXXXXX YYYYYYYY: checks if YYYYYYYY !=(word at [XXXXXXXX]).
Codetypes 7, 8, 9 and A are perfect for any "joker" code (to check
the pad status, try them on register 04000130). They should also be used for event flag check.
Type 7: 16 bit If Less Than (code value) > (mask & data at address)(unsigned)
7XXXXXXX ZZZZYYYY: checks if YYYY > (not ZZZZ) & half-word at [XXXX]).
Type 8: 16 bit If Greater Than (code value) < (mask & data at address)(unsigned)
8XXXXXXX ZZZZYYYY: checks if YYYY < (not ZZZZ) & half-word at [XXXX]).
Type 9: 16 bit If Equal to (code value) == (mask & data at address)(unsigned)
9XXXXXXX ZZZZYYYY: checks if YYYY == (not ZZZZ) & half-word at [XXXX]).
Type A: 16 bit If Not Equal to (code value) != (mask & data at address)(unsigned)
AXXXXXXX ZZZZYYYY: checks if YYYY != (not ZZZZ) & half-word at [XXXX]).
Offset Load Code:
Type B: Loads the 32bit value into the 'offset'.
BXXXXXXX 00000000: offset = word at [0XXXXXXX+offset].
Loop Start Code:
Type C: Defines the start of the loop code.
C0000000 YYYYYYYY: set the 'Dx repeat value' to YYYYYYYY, saves the 'Dx next code to be executed'
and the 'Dx execution status'. Repeat will be executed when a D1/D2 code is encountered.
When repeat is executed, the AR reloads the 'next code to be executed' and the 'execution status'
from the Dx registers.
Special Codes:
The D0-D2 codetypes are always executed (even if the 'execution status' is set off).
Type D0: End Iff
D0000000 00000000: Loads the previous execution status (if none exists, the execution status stays
at 'execution codes').
Type D1: Used to execute the loop set by the code type C (executes the code(s) after the type C code n times
(n being the 'Dx repeat value'), but does not clear the Dx registers upon finishing).
D1000000 00000000 : if the 'Dx repeat value', set by code type C, is different than 0, it is decremented and
then the AR loads the 'Dx next code to be executed' and the 'execution status' (=jumps back to the code following
the type C code). When the repeat value is 0, this code will load the saved code status value.
Type D2 : Used to apply the code type C setting (executes the code(s) after the type C code n times, n being the
Dx repeat value). Also acts as a 'Full terminator' (clears all temporary data, ie. execution status, offsets,
code C settings...).
D2000000 00000000 : if the 'Dx repeat value', set by code type C, is different than 0, it is decremented and then the
AR loads the 'Dx next code to be executed' and the 'execution status' (=jumps back to the code following the type C code).
When the repeat value is 0, this code will clear the code status, the offset value, and the Dx data value (which can be set
by codes DA, DB and DC).
Offset Set Code:
Type D3 : set the 'offset' to the value of the code.
D3000000 XXXXXXXX : set the offset value to XXXXXXXX.
Add a value to the Dx Data Register:
Type D4 : adds the value of the code to the data register used by D6~DB.
D4000000 XXXXXXXX : adds XXXXXXXX to the 'Dx data'.
More arithmetical/logical operations can be set using the 'NDS AR HACK #2'.
Set the value of the Dx Data Register:
Type D5 : sets the data register used by D6~D8 to the value of the code.
D5000000 XXXXXXXX : sets the 'Dx data' to XXXXXXXX.
Incrementive write of the Dx Data Register (32/16/8bits):
Type D6 : 32-bits incrementive write of the data register (str).
D6000000 XXXXXXXX : writes the 'Dx data' word to [XXXXXXXX+offset], and
increments the offset by 4.
Type D7 : 16-bits incrementive write of the data register (strh).
D7000000 XXXXXXXX : writes the 'Dx data' halfword to [XXXXXXXX+offset], and
increments the offset by 2.
Type D8 : 8-bits incrementive write of the data register (strb).
D8000000 XXXXXXXX : writes the 'Dx data' byte to [XXXXXXXX+offset], and
increments the offset by 1.
Dx Data Register (32/16/8bits) Load Codes:
Type D9 : 32-bits read to the data register (ldr).
D9000000 XXXXXXXX : loads the word at [XXXXXXXX+offset] and stores it in the
'Dx data'.
Type DA : 16-bits read to the data register (ldrh).
DA000000 XXXXXXXX : loads the halfword at [XXXXXXXX+offset] and stores it in
the 'Dx data'.
Type DB : 8-bits read to the data register (ldrb).
DB000000 XXXXXXXX : loads the byte at [XXXXXXXX+offset] and stores it in the
'Dx data'.
Add to Offset Code :
Type DC : adds the offset 'data' to the current offset (some kind of dual offset)
DC000000 XXXXXXXX : offset = (offset + XXXXXXXX).
Patch Code:
Type E: 'patch' code. Copies YYYYYYYY bytes from (curent code location + 8)
to [XXXXXXXX + offset].
EXXXXXXX YYYYYYYY
Example:
EXXXXXXX 00000010
AAAAAAAA BBBBBBBB
CCCCCCCC DDDDDDDD
writes AAAAAAAABBBBBBBBCCCCCCCCDDDDDDDD to XXXXXXXX
If the execution status if set off, the AR skips all the line of the patch code
(skips (YYYYYYYY+7)>>2 codes).
Memory Copy Code:
Type F : memory copy code. It seems you have to use the code type D3, DC or B
before, to set the offset (which is then an address). Then D2 should be needed
to clear the offset (else it will affect all the next codes).
D3000000 XXXXXXXX
FYYYYYYY ZZZZZZZZ
should copy ZZZZZZZZ bytes from offset (=XXXXXXXX in this case) to YYYYYYYY
(YYYYYYYY if fixed, ie. no offset are added to it).
* The E and F type work as follow :
If the number of data to write/copy if >3, it is done with a ldr/str, and then 4
is removed from the number of data to copy.
Else, if the number of data to copy if <3, it's done with a ldrb/strb and then 1
is removed from the number of data to copy and it loops until the number of data
to copy is eqal to zero. That means that the first address to write to must be aligned
in case of the number of bytes to copy is superior to 3 (else there will be a 'bug' if the
number of code to write is > 3 and not a multiple of 4), and that the number of
bytes to write doesn't not have to be a multiple of 4 (can be any number).
And before we go any further try reading this: http://siestacat.wordpress.com/
Edit: It also explains the simple 0, 1, and 2 Codetypes into depth.