You are here

Using inline assembly in a C program | Cypress Semiconductor

Using inline assembly in a C program

Last Updated:

December 05, 2010

Assembly instructions can be used in a C program by using inline assembly using the "asm" keyword. 

Below is a sample code that uses inline assembly to print two strings on an LCD.  The code shows two different methods to use the inline assembly.

#include  "m8c.h"       // part specific constants and macros
#include "PSoCAPI.h"    // PSoC API definitions for all User Modules

char string1[]="PSoC3";
char string2[]="PSoC5";

void main()


      // Option-1 Using separate "asm" instructions
      asm("mov A,>_string1");
      asm("mov X,<_string1");
      asm("call LCD_PrString");

      // Option-2 Using a single "asm" instruction and \n character
      asm("mov A,>_string2\n"     
          "mov X,<_string2\n"   
          "call LCD_PrString");