Assembly code porting from GCC to CodeWarrior

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

Assembly code porting from GCC to CodeWarrior

1,057 次查看
embitel
Contributor I

Please let me know how to port the below code from GCC to CodeWarrior. This whole code is embedded in C code.

 

 __asm__ __volatile__ (
            "ldd   #512\n"
            "tthclr:\n"
            "movw   #0, 2,y+\n"
            "dbne   d, tthclr\n"
            :
            : "y"(ram_data)
            : "d");

 

The problem is with the last three lines of code.

 

            :
            : "y"(ram_data)
            : "d");

 

 

Thank you,

Deepak

标签 (1)
0 项奖励
回复
4 回复数

813 次查看
MJW
NXP Employee
NXP Employee

Hello Deepak,

 

from looking at the code I don't see a real reason to write this in assembly language; I would just re-write this loop in C.

 

But if you are looking for an easy way to have the exact same code in Codewarrior, this should do:

 

asm {        ldy  #ram_data        ldd  #512tthclr:        movw #0,2,y+        dbne d,tthclr}

 

HTH,

MJW

0 项奖励
回复

813 次查看
embitel
Contributor I

Hello MJW,

 

Thanks for the solution. I have one doubt. What is the meaning of  "d" in the last line of code.

            :
            : "y"(ram_data)
            : "d"

 

Regards,

Deepak

0 项奖励
回复

813 次查看
MJW
NXP Employee
NXP Employee

Hello Deepak,

 

If I remember correctly, the last line tells gcc that the register "d" was changed ("clobbered") in the inline assembly portion.

 

HTH,

MJW

 

0 项奖励
回复

813 次查看
embitel
Contributor I

Hello MJW,

 

How can we replicate that same behaviour of "d" in CodeWarrior? As I am just porting, I would like to have all the code.

 

Regards,

Deepak

0 项奖励
回复