Assembly code porting from GCC

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Assembly code porting from GCC

Jump to solution
798 Views
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

Labels (1)
0 Kudos
1 Solution
585 Views
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);

 

View solution in original post

0 Kudos
5 Replies
586 Views
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 Kudos
585 Views
embitel
Contributor I

Thanks Kef... It works...

0 Kudos
585 Views
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 Kudos
585 Views
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 Kudos
585 Views
embitel
Contributor I

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

0 Kudos