英锐恩单片机论坛,Microchip单片机,模拟器件,接口电路,麦肯单片机,单片机应用交流
标题:
CCSC中怎样才能使汇编后的GOTO变为CALL?
[打印本页]
作者:
winnie
时间:
2009-4-25 15:21
标题:
CCSC中怎样才能使汇编后的GOTO变为CALL?
CCSC中应怎样才能使在汇编时的GOTO变为CALL,以压缩空间。相关程式如下:CCSC程式:
while(1)
{
sub1() ; //1
sub2() ; //2
sub3() ; //3
sub4() ; //4
sub5() ; //5
sub2() ; //6
sub7() ; //7
//sub8() ; //8
subprogram8_9_flag =0 ; // 0 is subprogram8
sub8_9() ; //8 在汇编时生成GOTO,为何不是CALL
//sub9() ; //9
subprogram8_9_flag =1 ; // 1 is subprogram9
sub8_9() ; //9 在汇编时生成GOTO,为何不是CALL
sub3() ; //10
sub11() ; //11
sub5() ; //12
sub2() ; //13
//sub7() ; //14
}
汇编后的程式:
.................... subprogram8_9_flag =0 ; // 0 is subprogram8
*
0132: CLRF 0A
.................... sub8_9() ; //8 在汇编时生成GOTO,为何不是CALL
.................... //sub9() ; //9
.................... subprogram8_9_flag =1 ; // 1 is subprogram9
*
0150: MOVLW 01
0151: MOVWF 0A
.................... sub8_9() ; //9 在汇编时生成GOTO,为何不是CALL
.................... sub3() ; //10
.................... sub11() ; //11
.................... sub5() ; //12
.................... sub2() ; //13
作者:
winnie
时间:
2009-4-25 15:21
当main()中只调了一次
sub1(i) ;
sub2(j) ;
时候,生成goto语句。
两次及其以上,
生成call语句。
作者:
winnie
时间:
2009-4-25 15:21
#if defined(__PCM__)
#include <16F877.h>
#fuses HS,NOWDT,PROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=1200, xmit=PIN_C6, rcv=PIN_C7)
#elif defined(__PCH__)
#include <18F452.h>
#fuses HS,NOWDT,PROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=1200, xmit=PIN_C6, rcv=PIN_C7)
#endif
void sub1(int8 i)
{
i++;
}
void sub2(int8 j)
{
j++;
}
void main(void)
{
int8 i,j;
i=0;
j=0;
while(1)
{
sub1(i) ; file://1
sub2(j) ; file://2
sub1(i) ; file://1
sub2(j) ; file://2
sub1(i) ; file://1
sub2(j) ; file://2
}
}
——————————————————————————————
CCS PCH C Compiler, Version 3.187, 16465
Filename: C:\Documents and Settings\lanyong\My Documents\1.LST
ROM used: 104 (0%)
Largest free fragment is 32664
RAM used: 7 (0%) at main() level
8 (1%) worst case
Stack: 1 locations
*
0000: GOTO main
.................... #if defined(__PCM__)
.................... #include <16F877.h>
.................... #fuses HS,NOWDT,PROTECT,NOLVP
.................... #use delay(clock=20000000)
.................... #use rs232(baud=1200, xmit=PIN_C6, rcv=PIN_C7)
....................
.................... #elif defined(__PCH__)
.................... #include <18F452.h>
.................... //////// Standard Header file for the PIC18F452 device ////////////////
.................... #device PIC18F452
.................... #list
....................
.................... #fuses HS,NOWDT,PROTECT,NOLVP
.................... #use delay(clock=20000000)
.................... #use rs232(baud=1200, xmit=PIN_C6, rcv=PIN_C7)
.................... #endif
....................
.................... void sub1(int8 i)
.................... {
0004: NOP(FFFF)
.................... i++;
0006: INCF i,F
.................... }
0008: RETLW 00
000A: NOP(FFFF)
....................
.................... void sub2(int8 j)
.................... {
000C: NOP(FFFF)
.................... j++;
000E: INCF j,F
.................... }
0010: RETLW 00
0012: NOP(FFFF)
....................
.................... void main(void)
.................... {
0014: NOP(FFFF)
0016: CLRF TBLPTRU
0018: BCF RCON.7
001A: CLRF FSR0H
001C: CLRF FSR0L
001E: MOVLW 06
0020: MOVWF ADCON1
0022: MOVLW FF
0024: MOVWF SPBRG
0026: MOVLW 22
0028: MOVWF TXSTA
002A: MOVLW 90
002C: MOVWF RCSTA
.................... int8 i,j;
.................... i=0;
002E: CLRF i
.................... j=0;
0030: CLRF j
....................
.................... while(1)
.................... {
.................... sub1(i) ; file://1
0032: MOVFF i,i
0036: CALL sub1
.................... sub2(j) ; file://2
003A: MOVFF j,j
003E: CALL sub2
....................
.................... sub1(i) ; file://1
0042: MOVFF i,i
0046: CALL sub1
.................... sub2(j) ; file://2
004A: MOVFF j,j
004E: CALL sub2
....................
.................... sub1(i) ; file://1
0052: MOVFF i,i
0056: CALL sub1
.................... sub2(j) ; file://2
005A: MOVFF j,j
005E: CALL sub2
.................... }
0062: GOTO 0032
....................
.................... }
....................
0066: SLEEP
Configuration Fuses:
Word 1: 2200 HS NOOSCSEN
Word 2: 0E0F BROWNOUT WDT128 NOWDT BORV20 NOPUT
Word 3: 0100 CCP2C1
Word 4: 0081 STVREN NODEBUG NOLVP
Word 5: C000 PROTECT NOCPD NOCPB
Word 6: E00F NOWRT NOWRTD NOWRTB NOWRTC
Word 7: 400F NOEBTR NOEBTRB
欢迎光临 英锐恩单片机论坛,Microchip单片机,模拟器件,接口电路,麦肯单片机,单片机应用交流 (http://enroobbs.com/)
Powered by Discuz! X3.2