Hello all again! Many thanks for your contributions so far, I have read with great interest the discussion. At this point, I am posting the code I have written together with the .asm generated. Please don't ciritise the code too much here as this is not the point here - it's a WIP. The point is that SDCC seems to be producing code that is extremely bloated. There's really not too much going on in this code but yet the .asm seems to be be very large for what it is.
Is this normal for SDCC? Is there something I am doing wrong here during compilation? E.g. Linking in a library that I shouldn't be? Is there a way I can reduce the code. As I said in an earlier posting, using PCW a friend has managed to produce a .hex file of 175 bytes as opposed to the 820 generated by SDCC. Many thanks in advance, Richard _________________________________________________________________Be the first to hear what's new at MSN - sign up to our free newsletters! http://www.msn.co.uk/newsletters
#include <pic16f628.h> #define STATE_PERIOD (80) #define STRIKE_THRESHOLD (3) #define STRIKE_OFF (0) #define STRIKE_ON (8) #define LEDS_ALL_ON (0xFF) #define LEDS_ALL_OFF (0x00) typedef unsigned char UBYTE; typedef unsigned int UWORD; static UBYTE gRolloverFlag=0; /* Rollover counter */ /*----------------------------------------------------------------------------** FUNCTIONS *
*----------------------------------------------------------------------------* */ /*----------------------------------------------------------------------------** Funct: TimerISR (int repeat) * * * * Desc: *
* This function is the the interrupt service routine used to handle ** Timer interrupt rollover. * * * * Parameters: *
*----------------------------------------------------------------------------* */ void TimerISR (void) interrupt 0 { T0IF=0; TMR0=62; gRolloverFlag=1; } /*----------------------------------------------------------------------------** Funct: void main (void) * * * * Desc: *
* This is the main entry point into this program. ** * * Parameters: *
*----------------------------------------------------------------------------* */ void main (void) { static UBYTE Strike=STRIKE_OFF; /* current bite state */ static UBYTE StrikeCntr; /* counts the number of strikes */ static UBYTE LedOutput; /* Current LED state */ static UBYTE FlashRate; static UBYTE StateCntr; static UBYTE PollCntr; static UBYTE StateCntr; static UBYTE FlashCntr; static UBYTE SampWindowCntr; /* initialise PIC */ CMCON=0x7; /* disable comparator */ OPTION_REG=0xD7; /* setup the option register */ INTCON=0x00; /* initialise to zero */ TRISA=0x0F; /* enable port a for input */ TRISB=0xC0; /* enable Port b for output */ PS0=1; /* prescalar reg 0 */ PS1=1; /* prescalar reg 1 */ PS2=1; /* prescalar reg 2. sets up the prescaler to 1:256 */ PSA=0; /* enables the prescaler */ T0CS=0; /* set the clock source for internal oscillator */ T0IF=0; /* clear the interrupt flag */ T0IE=1; /* enable tmr0 interrupt */ GIE=1; /* enable Global interrupts */ while (1) { if (gRolloverFlag==1) { /* increment our state counters *./ gRolloverFlag=0; PollCntr++; SampWindowCntr++; StateCntr++; FlashCntr++; } if (PollCntr==2) { /* poll switch every 100MS */ if (PORTA==0x01) StrikeCntr++; if (StrikeCntr==1) SampWindowCntr=0; PollCntr=0; } /* if sample period > 3 seconds reset window */ if (SampWindowCntr==60 ) StrikeCntr=0; if (StrikeCntr==STRIKE_THRESHOLD) { /* we have a strike */ Strike=STRIKE_ON; FlashRate=0; } if (Strike>0 && StateCntr==STATE_PERIOD) { /* enter new state period */ Strike--; FlashRate+=3; StateCntr=0; FlashCntr=0; } if (FlashRate==0) { /* handle led output status */ LedOutput=LEDS_ALL_ON; } else if (FlashRate==FlashCntr) { /* Toggle LED Status */ LedOutput=~LedOutput; FlashCntr=0; } if (Strike==0) LedOutput=LEDS_ALL_OFF; PORTB=LedOutput; } }
code.asm
Description: Binary data
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user