Assembly code porting from GCC

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

Assembly code porting from GCC

跳至解决方案
968 次查看
embitel
Contributor I

Please let me know how to port the below GCC code to CodeWarrior (HCS12).

 

__asm__  __volatile__ ("tsta\n"
                              "bne ccnp_skip\n"); 

 

Thank you

Deepak

标签 (1)
0 项奖励
回复
1 解答
755 次查看
kef
Specialist I

__asm__  __volatile__ ("tsta\n"                               "bne ccnp_skip\n");

 

    You need to determine what was in A register in GCC code just above ^^ this line. Certainly A had to be loaded with some variable or maybe higher order byte of 16 or 32 bits variable. It could be also top most byte of some floating point variable and this asm line could be used to perform quick check for positive floating number is not to small or smth like that. Provided A was loaded with 8 bit variable var, code may look like this

 

a) in case ccnp_skip label is below __asm__ line

 

    if( var == 0 )

    {

        // code between __asm__ and ccnp_skip label

    }

ccnp_skip:

 

b) in case ccnp_skip label is above __asm__

 

   do{

        // code between __asm__ and ccnp_skip label

   } while (var != 0);

 

在原帖中查看解决方案

0 项奖励
回复
5 回复数
756 次查看
kef
Specialist I

__asm__  __volatile__ ("tsta\n"                               "bne ccnp_skip\n");

 

    You need to determine what was in A register in GCC code just above ^^ this line. Certainly A had to be loaded with some variable or maybe higher order byte of 16 or 32 bits variable. It could be also top most byte of some floating point variable and this asm line could be used to perform quick check for positive floating number is not to small or smth like that. Provided A was loaded with 8 bit variable var, code may look like this

 

a) in case ccnp_skip label is below __asm__ line

 

    if( var == 0 )

    {

        // code between __asm__ and ccnp_skip label

    }

ccnp_skip:

 

b) in case ccnp_skip label is above __asm__

 

   do{

        // code between __asm__ and ccnp_skip label

   } while (var != 0);

 

0 项奖励
回复
755 次查看
embitel
Contributor I

Thanks Kef... It works...

0 项奖励
回复
755 次查看
CrasyCat
Specialist III

Hello

 

  Which compiler are you using here?

  CodeWarrior? Anything else?

 

  Also I assume you intend to embed assembly code inside of an ANSI C function. Am I right?

 

CrasyCat

0 项奖励
回复
755 次查看
embitel
Contributor I

Yes, you are right. I am using Codewarrior compiler and this code I want to embed in a C function.

 

Regards,

Deepak

0 项奖励
回复
755 次查看
embitel
Contributor I

Yes, you are right. I am using Codewarrior compiler and this code I want to embed in a C function.

0 项奖励
回复