Assembly code porting from GCC

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Assembly code porting from GCC

ソリューションへジャンプ
1,005件の閲覧回数
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 解決策
792件の閲覧回数
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 返答(返信)
793件の閲覧回数
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 件の賞賛
返信
792件の閲覧回数
embitel
Contributor I

Thanks Kef... It works...

0 件の賞賛
返信
792件の閲覧回数
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 件の賞賛
返信
792件の閲覧回数
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 件の賞賛
返信
792件の閲覧回数
embitel
Contributor I

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

0 件の賞賛
返信