Inline Assembly

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Inline Assembly

3,143 Views
UDP
Contributor I
Hello
 
Can someone give me a link to a document that describe deeply how to use the Inline Assembly ?
I want to access to c array in assembler ,assembler array ...
 
 
Thanks
 
 
 
Labels (1)
0 Kudos
3 Replies

432 Views
UDP
Contributor I
I looked as this document it's similar to the help file.
I am looking how to use an arrays ,structures in Inline Assembly.
0 Kudos

432 Views
CrasyCat
Specialist III
Hello
 
  For structure fields just use the  standard ANSI C notation
 
struct  {
long int a;
} mystruct;
   move.l mystruct.a,D0
For arrays the ANSI C notation (tab[2]) is not working. Mainly because array access often cannot be mapped to one single assembly instruction.
 
Here it really depends what you want to do.
Suppose you have an array of int and want to access element number 3 in the array, you can write:
   move.l D0,tab+(3*sizeof(int));
Now if you have a table of structure and want to access one field within an element of the structure you can for instance load A0 with the address of the desired element in the structure and then access the appropriate field using the struct construct (See manual referred in my last email).
For instance to access field x in fourth array element use the following:
  lea tab, A0
  adda.l #(4*sizeof(StrType)),A0
  move.l D0,struct(StrType.x)(A0)
StrType being defined as follows:
typedef struct StrType
{
 int x;
}StrType;
Anyway encoding of array access depends on what you intend to do.
I hope this helps.
 
CrasyCat
0 Kudos

432 Views
CrasyCat
Specialist III

Hello

I assume you are using CodeWarrior for Coldfire V6.2. Am I right?

Did you look at the manual {Install}\Help\PDF\Targeting_ColdFire.pdf. Chapter 8 Inline Assembly describes the Inline assembly syntax and usage.

CrasyCat

0 Kudos