All,
I'm interfacing to a very fast bus (compare to the speed of Arduino).
I have converted the C code to assembly and got 20% faster code.
When I look in the elf listing I see a big difference. Can any body explain the difference and how to correct:
Sketch (importent parts):
#include "SXAccessoire.h"
#define SX1_T0 3 // SXbus clock signal (Int1)
#define SX1_T1 5 // SXbus receive data signal
#define SX1_D 6 // SXbus send data signal
#define SX2_T0 3 // SXbus clock signal (Int1)
#define SX2_T1 7 // SXbus receive data signal
#define SX2_D 4 // SXbus send data signal
SXAccessoire SXbus[2];
// Interrupt service routine. (Int1, Rising edge)
void sxisr(void) {
SXbus[0].isr();
SXbus[1].isr();
}
void setup() {
// put your setup code here, to run once:
SXbus[0] = SXAccessoire(SX1_T0, SX1_T1, SX1_D); // 3 line interface
SXbus[1] = SXAccessoire(SX2_T0, SX2_T1, SX2_D); // 3 line interface
if ((SXbus[0].init() == 1) && (SXbus[1].init() == 1)) {
// Rising edges on INT1 triggers the interrupt routine sxisr (see above)
attachInterrupt(1, sxisr, RISING);
Serial.println("SXbus geinitialiseerd");
}
}
After a checkbuild the isr is converted differently:
If the isr in the library object is in assembly:
// Interrupt service routine. (Int1, Rising edge)
void sxisr(void) {
SXbus[0].isr();
74c: 0e 94 8c 00 call 0x118 ; 0x118 <_ZN12SXAccessoire3isrEv.constprop.25>
SXbus[1].isr();
750: 0c 94 8c 00 jmp 0x118 ; 0x118 <_ZN12SXAccessoire3isrEv.constprop.25>
If the isr in the library object is in cpp:
// Interrupt service routine. (Int1, Rising edge)
void sxisr(void) {
SXbus[0].isr();
830: 83 e3 ldi r24, 0x33 ; 51
832: 92 e0 ldi r25, 0x02 ; 2
834: 0e 94 70 02 call 0x4e0 ; 0x4e0 <_ZN12SXAccessoire3isrEv>
SXbus[1].isr();
838: 8a e2 ldi r24, 0x2A ; 42
83a: 93 e0 ldi r25, 0x03 ; 3
83c: 0c 94 70 02 jmp 0x4e0 ; 0x4e0 <_ZN12SXAccessoire3isrEv>
In the assembly version I also needs the data in r25:r24, since it is the base of the data in the library object.
How can I let the assembly version also generate the two ldi instructions?
Groet,
Gerard van der Sel.