ChipDocs - Datasheet Source for Semiconductor and Electronic Circuit Components
More than
480 566 
registered clients
Partname:AN669
Description:Embedding Assembly Routines into C Language Using a Floating Point Routine as an Example
Manufacturer:Microchip Technology, Inc.
Datasheet:PDF (132K).
Click here to download *)

There are two 2K word pages of program memory in the PIC16C74A. Program memory 000h to 7FFh is page 0, 800h to FFFh is page 1. By making fpm32() a C function, MPLAB-C initializes the appropriate page bit in the PCLATH register before the subroutine call is made. (See data sheet for more on PCLATH). A potential problem could arise, however, if the new C function, fpm32(), crosses the page boundary (7FFh,800h). MPLAB-C does not insert code into the assembly code to initialize the page bits (remember MPLAB-C does take care of paging for function calls). That means it is up to the programmer to either; 1) add assembly language to initialize PCLATH appropriately, or 2) move the entire #asm function within a single page. Option 1 involves more work. The programmer must first compile the C code, then analyze the listing file to see if the assembly function crossed a page boundary. Finally, add the appropriate assembly language to initialize PCLATH then re-compile. This solution is not desirable since every time new C code is added to or deleted from the program, the routine, fpm32() can potentially move across the page boundary. Option 2 is the simplest solution - to locate the C function in a single page.

Click here to download AN669 Datasheet
Click here to download AN669 Datasheet
*)
*)Datasheets downloading from ChipDocs is only for our members (paid service). REGISTER NOW for your membership.
Free Electronics Engineering Subscription
Win Win Circuit - PCB,PCBA,Touch Screen,LED Lighting
Win Win Circuit LTD. PCB, PCBA, LCD Module
www.wwteq.com
COPYRIGHT 1997-2024 ChipDocs  ALL RIGHT RESERVED