Hallo!
Die folgende Codezeile wird vom Compiler meiner Meinung nach falsch
übersetzt:
1 | textOnLcd((*(menDispMenus+(21*(*menDispTopMenu)))).name, 0x01);
|
menDispMenus ist ein Pointer auf ein Array von structs mit der Grösse 21
Bytes.
menDispTopMenu ist ein Pointer auf ein uint8_t.
Nach dem das Ergebnis nie stimmte, habe ich mir das Disassembly
angeschaut und gesehen, dass der Compiler anstelle des Faktors 21 den
Faktor 0x01B9 nimmt. (In Registern 28/29):
textOnLcd((*(menDispMenus+(21*(*menDispTopMenu)))).name, 0x01);
00001E54 LDS R30,0x255A Load direct from data space
00001E56 LDS R31,0x255B Load direct from data space
00001E58 LDD R24,Z+0 Load indirect with displacement
00001E59 LDI R25,0x00 Load immediate
00001E5A LDI R28,0xB9 Load immediate
00001E5B LDI R29,0x01 Load immediate
00001E5C MUL R24,R28 Multiply unsigned
00001E5D MOVW R18,R0 Copy register pair
00001E5E MUL R24,R29 Multiply unsigned
00001E5F ADD R19,R0 Add without carry
00001E60 MUL R25,R28 Multiply unsigned
00001E61 ADD R19,R0 Add without carry
00001E62 CLR R1 Clear Register
00001E63 LDS R24,0x2968 Load direct from data space
00001E65 LDS R25,0x2969 Load direct from data space
00001E67 ADD R24,R18 Add without carry
00001E68 ADC R25,R19 Add with carry
00001E69 LDI R22,0x01 Load immediate
00001E6A CALL 0x0000056A Call subroutine
Wahrscheinlich habe ich irgendeinen Fehler im C-Code, aber ich finde ihn
einfach nicht.
Viele Grüsse
Erdbewohner