Bon, ya une manière de faire de gcc que je ne comprends pas du tout...
J'ai une fonction C :
/** CompareStrings
*
* Check if the string RefString terminated by a char of SeparatorTable is contained in the string table StringTable
* Return #item in the table, or -1 if the string isn't in the table. First item is #0
* Put in *NextChar a ptr to the next char after RefString if NextChar != NULL
**/
short CompareStrings(const char **NextChar, const char *RefString, const char *StringTable, const char *SeparatorTable)
{
// TODO
// This function could be optimized a lot, comparing char by char the two strings,
// and checking SeparatorTable if they match and *StringTable == 0.
// Here the StringTable is read twice, which is not optimal, but it's easier to write.
const char *EndChar;
const char *Separator;
short Item = 0;
unsigned long length;
while (*StringTable)
{
length = strlen(StringTable);
if (!strncmp(RefString, StringTable, length))
{
EndChar = RefString + length;
Separator = SeparatorTable;
do
{
if (*Separator == *EndChar)
{
if (NextChar != NULL)
*NextChar = EndChar;
return Item;
}
} while (*Separator++);
}
StringTable += length + 1;
Item++;
}
return -1;
}
qui donne ça en assembleur :
[source=plain] movm.l #0x1e30,-(%sp)
move.l 28(%sp),%a3
move.l 32(%sp),%d5
move.l 36(%sp),%a2
move.l 40(%sp),%d6
clr.w %d4
jbra .L2
.L3:
move.l %a2,-(%sp)
jsr _ROM_CALL_27E:l
move.l %d0,%d3
move.l %d0,-(%sp)
move.l %a2,-(%sp)
move.l %d5,-(%sp)
jsr _ROM_CALL_272:l
lea (16,%sp),%sp
tst.w %d0
jbne .L4
move.l %d5,%a1
add.l %d3,%a1
move.b (%a1),%d1
move.l %d6,%a0
.L6:
move.b (%a0),%d0
cmp.b %d0,%d1
jbne .L7
cmp.w #0,%a3
jbeq .L15
move.l %a1,(%a3)
.L15:
move.w %d4,%d0
jbra .L11
.L7:
tst.b %d0
jbeq .L4
addq.l #1,%a0
jbra .L6
.L4:
lea 1(%a2,%d3.l),%a2
addq.w #1,%d4
.L2:
tst.b (%a2)
jbne .L3
moveq #-1,%d0
.L11:
movm.l (%sp)+,#0xc78
rts[/source]
Comme on peut voir, le
if (NextChar != NULL) est traduit en
cmp.w #0,%a3Pourquoi un cmp
.w ? Si l'adresse que je passe pointe vers $10000, ça fait quoi ? Alors qu'un
move.l %a3,%d0 eût été plus petit (-2 octets), et peut-être plus rapide

Là, j'avoue que je capte pas du tout... (tout le reste me semble bien compilé)