Inline Assembly

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Inline Assembly

3,498 次查看
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
 
 
 
标签 (1)
0 项奖励
回复
3 回复数

787 次查看
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 项奖励
回复

787 次查看
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 项奖励
回复

787 次查看
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 项奖励
回复