Assembler to C code

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

Assembler to C code

Jump to solution
846 Views
PabloA
Contributor II

Hi there, please could somebody help me with this code in Assembler? I have to translate it to C code. It works fine in CodeWarrior for 8 bits microcontrollers, but with ColdFire it don't acept this asm instructions.

The idea is to control an LCD display with just 4 bits of data. To do this I have to Swap Display 8 bits data and write the higher nible first.

 

char Display_Data;

char PTAD_Data;

 

  asm

  {

    LDA   PTAD

    AND   #0b11110000     // Mask Non Display Data

    STA   PTAD_Data

    LDA   Display_Data    // Load Display Data

    NSA                        // Set Most Significant Nible First

    AND   #0b00001111     // Clear "Shift_Comp_Data" Bits

    ORA   PTAD_Data

    STA   PTAD            // Set Display Data

  }

 

 

 

Thanks!

 

Pablo

 

Labels (1)
0 Kudos
1 Solution
496 Views
kef
Specialist I

HI

   PTAD_Data = PTAD & 0xF0;

   PTAD = ((Display_Data >> 4) & 0x0F) | PTAD_Data;

View solution in original post

0 Kudos
2 Replies
497 Views
kef
Specialist I

HI

   PTAD_Data = PTAD & 0xF0;

   PTAD = ((Display_Data >> 4) & 0x0F) | PTAD_Data;

0 Kudos
496 Views
PabloA
Contributor II

Edward, Thank you for your time. I will use it!

Best regards!

Pablo

0 Kudos