Coding Questions and other Quandaries
I'm not sure what exactly you are doing with your code, but anyway....

Because the lefthand (MEM1) byte values that you've listed don't increase in perfect order, you can place those in a lookup table and use the righthand (MEM2) byte values as a loading offset in reference to the able

Adjust source so you can add the other things your code is suppose to do ofc

Code:
#Set EVA Upper
lis r11, 0x8000

#EVA Notes
#800003D0 = Byte for MEM1
#800003D1 = Byte for MEM2

#Load MEM2 char integer byte value
#Increment, check if its beyond max (0x11)
lbz r12, 0x3D1 (r11)
addi r12, r12, 1
cmplwi r12, 0x11
ble+ create_table

#Reset MEM1 and MEM2 bytes to Mario, then Store and end C0
li r10, 0
li r12, 0
b store_bytes

#Create the Table, but first backup C0 LR
create_table:
mflr r5

bl table
.byte 0x00 #Mario #Still needed in table for spacing so all other offset values will work in the lbzx instruction
.byte 0x01 #Luigi
.byte 0x02 #Peach
.byte 0x03 #Daisy
.byte 0x05 #Wario
.byte 0x06 #Waluigi
.byte 0x04 #Yoshi
.byte 0x0B #Koopa
.byte 0x07 #Donkey kong
.byte 0x09 #Diddy
.byte 0x0C #Boo
.byte 0x0A #Shy Guy
.byte 0x08 #Bowser
.byte 0x0D #BowserJr
.byte 0x0E #Fly Guy
.byte 0x0F #Para
.byte 0x10 #Wiggler
.byte 0x11 #Piranha
.align 2
table:
mflr r9

#Now based on newly incremented MEM2 value, load up byte value for MEM1
lbzx r10, r9, r12

#Restore LR
mtlr r5

#Store MEM1 and MEM2 bytes to EVA
store_bytes:
stb r10, 0x3D0 (r11)
stb r12, 0x3D1 (r11)

#End C0
blr

For compiled length comparisons here is my vs your source
C0000000 0000000B
3D608000 898B03D1
398C0001 280C0011
40A10010 39400000
39800000 4800002C
7CA802A6 48000019
00010203 0506040B
07090C0A 080D0E0F
10110000 7D2802A6
7D4960AE 7CA803A6
994B03D0 998B03D1
4E800020 00000000

C0000000 0000000F
3D608000 A18B03D0
2C0C0004 38AC0001
41820058 2C0C0005
38AC0001 4182004C
2C0C0006 38ACFFFE
41820040 2C0C0007
38AC0004 41820034
2C0C0008 38ACFFFF
41820028 2C0C000A
38AC0002 4182001C
2C0C000B 38ACFFFF
41820010 2C0C000C
38ACFFFC 40820008
7CAC2B78 918B03D4
4E800020 00000000
Reply


Messages In This Thread
RE: Coding Questions and other Quandaries - by Vega - 05-09-2023, 05:25 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)