How to convert that code which for cosmic compiler to CW 11.1

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

How to convert that code which for cosmic compiler to CW 11.1

671 次查看
Gildarai
Contributor II

Hello all.

I'm working convert the source code for CW 11.1 from cosmic compiler. 

Some code is written by assembly, So I'm not sure how to convert to code for CW 11.1.

 

Could you give me some help?

 

1. leadingBits = (uint16_t)(int16_t)_asm("clb d2, d2\n");

I tried change the code as follow. I'm not sure it is correct.

#define findLeadingBit16(val, num) {asm LD D6, val; asm CLB D6, D0; asm LD D1, #14; asm SUB D1, D0; asm ST D1, num;}

findLeadingBit16(input, leadingSignBits);

 

2. tempValue = rbits(x) + rbits(y);

   result = bitsr(tempValue);

标记 (4)
0 项奖励
回复
2 回复数

635 次查看
lama
NXP TechSupport
NXP TechSupport

I do not absolutely understand what you want to do especily explicit conversions and variables types but parameters passing and used registers are described in the compiler.pdf manual capters 18.4.1 Argument Passing, 18.4.2 Return Values. The document is in the help file of your instalation dir.

I suggest you to do some investigation with test project to see how it works because the parameters are usually past via stack plus based on inlining pragma the code can be inlined o rif it is ust #define set of commands then i tis inlined by you using definition at given place.

 

Assembler code you can include like

asm

 {

    Your assembler code

};

 

Or

asm … ;

asm …. ;

asm ….

 

So, better is to know exact task.

 

You can write also your code in C (some temp project) and then “right mouse button” -> disassemble and you will se how it is done.

0 项奖励
回复

645 次查看
jiri_kral
NXP Employee
NXP Employee

Hi, 

I'm not familiar with S12z and CW, but I suggest use normal function instead of define.  You can try this implementation: 

void findLeadingBit16(int val, int num) {

asm {

             LD D6, val;

            CLB D6, D0; 

            LD D1, #14

            SUB D1, D0; 

           ST D1, num;

}

}

0 项奖励
回复