Arduino assembly in library objects

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.

It looks like the isr() is a class method without an object reference. Check your declaration and assembly code.

EDIT: class method is Delphi, in C++ it's a static method.

Hello DrDiettrich,

The isr is indeed a normal class method like qall others. The only difference is it's content, only assembly code. How do I set an object reference?
The declaration in the .h file is:

class SXAccessoire {
public
    ......
	void isr(void);                                       // Interrupt service routine, runs in the background
    ......

And the function itself:

void SXAccessoire::isr(void) {
ISRInit:
  asm goto (
  "   movw  r30, r24             ; Get classdata pointer in Z         \n\t"  
     ......
  "   ret                                                             \n\t"
  :
  :
  :
  :
  );
}

What change do I apply to the declaration?

Groet,

Gerard van der Sel.

Wild guess: use the this pointer in the method, somehow.

The object this is the sketch. The object searched for are SXbus[0] and SXbus[1].
But since I am leaving this and going to one of the two other variables like CPP there must be a context switch. In CPP it is given by the compiler/linker. What is wrong with my code.

Groet,

Gerard van der Sel.

Your code does not use any object and thus the compiler makes it a static method (ordinary function), not a method.