Forums

56800e Inline assembler and inline functions

Started by jack...@motec.com.au March 8, 2006
Hi,
  I have a couple of questions about inline assembler and inline functions in
the 56800E compiler under CW5.6
 
Question 1:
Is there anyway to use members of a C struct in the assembler code?
I can use local or static variables in assembler functions eg.
         int32 myVar;
         asm {
         move.l myVar,A
          }
 
but is there a way to use a pointer to a struct to access struct elements in
inline assembler, without having to hard code the offsets of elements? I don't
want to have to change the assembler every time the struct is changed.
 
Question 2:
The following example function works correctly, loading a return value into Y0
and returning.
ctUINT16 MyFunc (ctUINT32 myInt32) { 
   asm{   
     LSRR.L #2,A   
     MOVE.W A1,Y0  //Load return value into Y0  
   }
}
 
ctUINT16 MyFunc2(void) { 
 return MyFunc(1234); 
} 
 
This compiles to:
  subroutine "FMyFunc"
  lsrr.l      #<2,A
  move.w      A1,Y0
  rts         
 
  subroutine "FMyFunc2"
  move.l      #1234,A
  jsr         >FMyFunc
  rts         
 
Unfortunately this does NOT work when I make MyFunc an inline function:
ctUINT16 MyFunc (ctUINT32 myInt32) { 
   asm{   
     LSRR.L #2,A   
     MOVE.W A1,Y0  //Load return value into Y0  
   }
}
 
ctUINT16 MyFunc2(void) { 
 return MyFunc(1234); 
} 
 
This compiles to:
  subroutine "FMyFunc2"
  lsrr.l      #<2,A
  move.w      A1,Y0
  move.w      B1,Y0
  rts
	which is totally wrong. Is there a way to inline a function containing inline
assambler?