datasheetbank_Logo
전자부품 반도체 검색엔진( 무료 PDF 다운로드 ) - 데이터시트뱅크

AN669 데이터 시트보기 (PDF) - Microchip Technology

부품명
상세내역
일치하는 목록
AN669 Datasheet PDF : 7 Pages
1 2 3 4 5 6 7
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
07F0 0838
07F1 1D03
07F2 0839
07F3 1903
07F4 284E
.
. some code here
.
FPM32
MOVF
BTFSS
MOVF
BTFSC
GOTO
AEXP,W
_Z
BEXP,W
_Z
RES032M
;test for zero arguments
07F5 0826
07F6 0633
07F7 00AE
07F8 0839
07F9 07B8
M32BNE0
MOVF
XORWF
MOVWF
MOVF
ADDWF
AARGB0,W
BARGB0,W
SIGN
BEXP,W
EXP, F
;save sign in SIGN
07FA 307E
07FB 1C03
07FC 2801
MOVLW
BTFSS
GOTO
EXPBIAS-1
_C
MTUN32
;****** WON’T WORK !
07FD 02B8
07FE 1803
07FF 2843
0800 2804
SUBWF
BTFSC
GOTO
GOTO
EXP,F
_C
SETFOV32M
MOK32
;set multiply overflow flag
0801 02B8
0802 1C03
0803 2854
#endasm
}
MTUN32
.
. some more code here
.
SUBWF
BTFSS
GOTO
EXP,F
_C
SETFUN32M
;****** IN PAGE 1 !
© 1997 Microchip Technology Inc.
DS00669A-page 2

Share Link: 

datasheetbank.com [ Privacy Policy ] [ Request Datasheet ] [ Contact Us ]