#74184 - MrAdults - Fri Mar 03, 2006 8:26 am
I was using devkitPro r14, and I'm modifying my project to work with r17. I have one particular function that is showing very different results. It may not be completely clear out of context, but here is the function:
So, there are a few things you could see possibly going wrong here, such as the incoming string being 6 characters and the stack array not being zero'd out, or whatever. That is not happening - byte for byte, all 8 bytes from the name8 memory address and from the lump_p->name memory address match up. Additionally, both addresses are 4-byte-aligned.
The problem is that whatever code is generated by those *(int *)lump_p->name statements is not doing what it was doing in r14, so the ints are actually different values despite being cast from 2 identical and aligned 8-byte memory chunks. I could write some inline assembly to ldr and compare manually, but I would really prefer not to. Does anyone know why this would be different all of a sudden?
-Rich
Code: |
int W_CheckNumForName(char *name)
{ char name8[9]; int v1, v2; lumpinfo_t *lump_p; // Make the name into two integers for easy compares strncpy(name8, name, 8); name8[8] = 0; // in case the name was a full 8 chars strupr(name8); // case insensitive v1 = *(int *)name8; v2 = *(int *)&name8[4]; // Scan backwards so patch lump files take precedence lump_p = lumpinfo+numlumps; while(lump_p-- != lumpinfo) { if(*(int *)lump_p->name == v1 && *(int *)&lump_p->name[4] == v2) { return lump_p-lumpinfo; } } return -1; } |
So, there are a few things you could see possibly going wrong here, such as the incoming string being 6 characters and the stack array not being zero'd out, or whatever. That is not happening - byte for byte, all 8 bytes from the name8 memory address and from the lump_p->name memory address match up. Additionally, both addresses are 4-byte-aligned.
The problem is that whatever code is generated by those *(int *)lump_p->name statements is not doing what it was doing in r14, so the ints are actually different values despite being cast from 2 identical and aligned 8-byte memory chunks. I could write some inline assembly to ldr and compare manually, but I would really prefer not to. Does anyone know why this would be different all of a sudden?
-Rich