I gave up on XC8 long ago but recently needed to quickly create some code for a 12LF1840. The original source was created long ago on an Arduino and I needed to port it over. Rather than work with MPLABx and the deliberately crippled XC8 Complier I decided to give Great Cow Basic a try. I was not expecting much, the documentation for GCB is disjointed and hard to find and Basic is not very structured to start with. Well I was pleasantly surprised. Faced with confusing documentation and not much time I scanned a couple of code examples to get a feel for the language structure, then dove in and used register and bit references direct from the data sheet, standard assignments and the minimum of Basic as I remembered it. To my surprise it took care of all of the config stuff, compiled first time and generated amazingly compact code in Assembler. The cherry on top, as a test I wondered what it would do with a PIC18F. I changed one line, the device name, and it recompiled and ran on an 18f14k22 first time. I have subsequently been playing with it and it even works as a fine assembler, ignoring Basic totally. Here is a short test program from the PICKit 3 starter guide: [code] #chip 18f14k22 #config MCLR =3D ON '__________________________________________________________________________= _____ ; -------------------LATC----------------- ; Bit#: -7---6---5---4---3---2---1---0--- ; LED: ---------------|DS4|DS3|DS2|DS1|- ; ----------------------------------------- Start: clrf TRISC ; make all of PORTC an output movlw b'00001000' ; start the rotation by setting DS4 ON movwf LATC ; write contents of the working register to the latch MainLoop: delayLoop: wait 500 ms ' Replaces Microchip macros Rotate: rrcf LATC,f ; rotate the LEDs (through carry) and turn on the next LED to the right btfss STATUS,C ; did the bit rotate into the carry (i.e. was DS1 just lit?) bra MainLoop ; nope, repeat this program forever bsf LATC, 3 ; yes, it did and now start the sequence over again by turning on DS4 bcf STATUS, C ; clear the carry bra MainLoop ; repeat this program forever end ; end code section [/code] and in GCB form [code] #chip 18f14k22 #config MCLR =3D ON '__________________________________________________________________________= _____ ; -------------------LATC----------------- ; Bit#: -7---6---5---4---3---2---1---0--- ; LED: ---------------|DS4|DS3|DS2|DS1|- ; ----------------------------------------- TRISC =3D 0 ' all pins are outputs LATC =3D 0b0001000 ' start with DS4 lit by setting bit 3 HIGH in LATC Do wait 500 ms ' delay 500ms Rotate LATC Right ' shift to the right by 1 if STATUS.C then LATC3 =3D 1 ' when the last LED is lit, restart th= e pattern Loop End [/code] take a look, it beats XC8 and is free Cheers Chris On Sun, Aug 30, 2015 at 12:57 PM, Isaac Marino Bavaresco < isaacbavaresco@yahoo.com.br> wrote: > Em 30/08/2015 00:29, Josh Koffman escreveu: > > On Fri, Aug 28, 2015 at 11:01 AM, Isaac Marino Bavaresco > > wrote: > >> I just found that my BAM() routine took more cycles than the time of t= he > >> LSB, so it messed things up. > >> > >> I was using 'memcpy', that took alone 390 tcy and a loop that took 182 > >> cycles. > >> After some code changes, the routine works OK. > >> > >> There was another mistake that made the delay of the previous bit bein= g > >> used, instead of the current bit. > >> > >> Expecting a PIC16F work OK for this application may be wishing too muc= h. > > Hi Isaac, > > > > Thanks for sharing your code! I will need a bit more time to study it, > > I think we code rather differently. That said, what do you consider > > "A_DECENT_COMPILER"? > > > > Thanks! > > > > Josh > > > Hi Josh, > > A decent compiler is a compiler that produces code that is hard for me > to improve it much in assembly. > > Years ago, I used to program in assembly, like many do still today. As > the compilers got better, I felt less need to program in asembly, to the > point that to improve the code just a little took too long time. > > That is not the case of this XC8 crap. It is a longtime since I last > designed something with an 8-bit PIC and got a surprise when I saw the > results of this "experiment". > I hope that for a PIC18 or an enhanced PIC16F the compiler can generate > code that is close to the optimum. > > Cheers, > > Isaac > > > > -- > http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > --=20 http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .