Notes

Bit Numbers

Use # in front of the number, so bit 0 is "#0"

Special Function Registers

You can use SFR's in the assembler directly instead of including via an input or output.  Doing this is faster as the compiler won't move the SFR via W0 and instead will access it directly.

Multiple Assembler Statements

Use "/n" to seperate multiple assemlber commands

Using Assembler


      asm ( "instruction" );


      asm volatile ("mov %0,w0"     
      :                                   //Outputs
      : "g" (pic_address.word.MSW)        //Inputs
      : "w0");                            //Clobbers
      asm volatile ( "mov w0,TBLPAG" );


      asm volatile ("mov %0, w2"
      :                                   //Outputs
      : "g" (data_l)                      //Inputs
      : "w2");                            //Clobbers

      asm volatile ("goto %0"
      :                                   //Outputs
      : "g" (FLASH_FIRMWARE_START_ADDRESS)      //Inputs
      );                                  //Clobbers

Wait for IRQ bit to be set while loop in assembler

	//while (!IFS0bits.T2IF)
	//	;
	//LATDbits.LATD0 = 0;
	//Assembler equivalent:
	__asm__ volatile ("loop1: btss IFS0,#7 \n goto loop1 \n bclr LATD,#0"
	:							//Outputs
	:							//Inputs
	: );						//Clobbers
Move register to port at specific moment

	__asm__ volatile ("mov %0,W0 \n setm LATD \n nop \n nop \n nop \n mov W0,LATD"
	:							//Outputs
	: "g"(data_out)				//Inputs
	: "w0");					//Clobbers

 

 

 

 

 

 

USEFUL?
We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.

Comments

Your email address will not be published. Required fields are marked *