| Electronic Components Datasheet Search |
|
AN669 Datasheet(PDF) 2 Page - Microchip Technology |
|
|
|||||||||||||||||||||||||||||
AN669 Datasheet(HTML) 2 Page - Microchip Technology |
|
2 / 7 page ![]() © 1997 Microchip Technology Inc. DS00669A-page 2 AN669 To illustrate, lets force fpm32() to cross the page boundary. A pragma directive is required to locate a routine (Example 2). EXAMPLE 2: FORCING FPM32 TO CROSS THE PAGE BOUNDARY #pragma memory ROM [MAXROM-0x7F0] @ 0x7F0; #include "fpm32.inc" The listing file generated is shown in Example 3. Notice the statement GOTO MTUN32 at address 0x7FC. How- ever, the routine MTUN32 is located at address 0x801. Remember, with the PIC16C74A the GOTO instruction only has an eleven bit address range. With the GOTO MTUN32 example, one more bit of address is needed to branch to 0x801 from 0x7FC. The extra bit of address is located in the PCLATH register. That means assem- bly code would have to be inserted into the floating point routines to initialize PCLATH before each GOTO. Since this solution is not desirable, the best approach is to locate the floating point subroutine in a single page. For example, change the pragma directive in Example 2 to locate the routine at 0x800. It is important to note that when fpm32() is called as a C function, the page bit in PCLATH is updated by MPLAB-C. In other words MPLAB-C adds the neces- sary assembly language code needed to call fpm32() or any other C function. The C function is called cor- rectly, but once within the C function, the raw embed- ded assembly language might have GOTOs or CALLs that cross over the page boundary and cause problems. EXAMPLE 3: FPM32 FORCED TO ADDRESS 0x7F0 TO SHOW CROSSING FROM PAGE 0 TO PAGE 1 void fpm32 (void) { #asm . . some code here . 07F0 0838 FPM32 MOVF AEXP,W ;test for zero arguments 07F1 1D03 BTFSS _Z 07F2 0839 MOVF BEXP,W 07F3 1903 BTFSC _Z 07F4 284E GOTO RES032M 07F5 0826 M32BNE0 MOVF AARGB0,W 07F6 0633 XORWF BARGB0,W 07F7 00AE MOVWF SIGN ;save sign in SIGN 07F8 0839 MOVF BEXP,W 07F9 07B8 ADDWF EXP, F 07FA 307E MOVLW EXPBIAS-1 07FB 1C03 BTFSS _C 07FC 2801 GOTO MTUN32 ;****** WON’T WORK ! 07FD 02B8 SUBWF EXP,F 07FE 1803 BTFSC _C 07FF 2843 GOTO SETFOV32M ;set multiply overflow flag 0800 2804 GOTO MOK32 0801 02B8 MTUN32 SUBWF EXP,F ;****** IN PAGE 1 ! 0802 1C03 BTFSS _C 0803 2854 GOTO SETFUN32M . . some more code here . #endasm } |
|
|
Link URL |
| Does ALLDATASHEET help your business so far? [ DONATE ] |
About Alldatasheet | Advertisement | Contact us | Privacy Policy | Link to Datasheet | Link Exchange | Manufacturer List All Rights Reserved©Alldatasheet.com |
| Russian : Alldatasheetru.com | Korean : Alldatasheet.co.kr | Spanish : Alldatasheet.es | French : Alldatasheet.fr | Italian : Alldatasheetit.com Portuguese : Alldatasheetpt.com | Polish : Alldatasheet.pl | Vietnamese : Alldatasheet.vn Indian : Alldatasheet.in | Mexican : Alldatasheet.com.mx | British : Alldatasheet.co.uk | New Zealand : Alldatasheet.co.nz |
|
Family Site : ic2ic.com |
icmetro.com |