Re: Learning to use PICS
From: Sergio Masci (sergio_at_NO.SPAM.xcprod.com)
Date: 12/04/04
- Next message: Bob Masta: "Re: oscilloscope recommendations"
- Previous message: Roger Johansson: "Re: oscilloscope recommendations"
- In reply to: Spehro Pefhany: "Re: Learning to use PICS"
- Next in thread: Bill Bowden: "Re: Learning to use PICS"
- Messages sorted by: [ date ] [ thread ]
Date: Sat, 4 Dec 2004 14:07:38 -0000
Spehro Pefhany <speffSNIP@interlogDOTyou.knowwhat> wrote in message
news:q7i2r0tfniq7smkrvlai7djkad2gc9pia6@4ax.com...
> On Sat, 4 Dec 2004 00:53:57 -0000, the renowned "Sergio Masci"
> <sergio@NO.SPAM.xcprod.com> wrote:
>
> >
> >
> >I would be interested to see the generated code and to know which
compiler
> >you are using.
>
> I think I have misspoken on the size- the assy file was hiding some of
> the instructions for some reason. Here's the code from the program
> memory (some manual transcription, so it may not be 100% correct).
> It's HitechC for 16F. 27 program words including two bank select
> instructions.
>
>
> 0007E5 MOVLW 0x8
> 0007E6 BCF 0x3, 0x5
> 0007E7 BCF 0x3, 0x6
> 0007E8 MOVWF 0x2E
> 0007E9 MOVF 0x2b,W
> 0007EA MOVWF 0x2d
> 0007EB BCF 0x3, 0
> 0007EC RLF 0x2a, F
> 0007ED RLF 0x2b, F
> 0007EE MOVF 0x2c, W
> 0007EF XORWF 0x2d, W
> 0007F0 MOVWF 0x40
> 0007F1 BTFSS 0x40, 0x7
> 0007F2 GOTO 0x7f7
> 0007F3 MOVLW CRC_LOW
> 0007F4 XORWF 0x2a, F
> 0007F5 MOVLW CRC_HIGH
> 0007F6 XORWF 0x2b, F
> 0007F7 BCF 0x3, 0
> 0007F8 RLF 0x2c,F
> 0007F9 DECFSZ 0x2e,F
> 0007FA GOTO 0x7e9
> 0007FB MOVF 0x2b, W
> 0007FC MOVWF 0x41
> 0007FD MOVF 0x2a, W
> 0007FE MOVWF 0x40
> 0007FF RETURN
>
>
> Best regards,
> Spehro Pefhany
Thank you for that.
It seems that the Hitech C compiler has noticed an optimisation in the "for
loop" that the XCSB compiler missed, essentially converting:
;----------
k = 8
loop_start
if k <= 0 then goto loop_end
...
k = k - 1
goto loop_start
loop_end
;----------
into
;----------
k = 8
loop_start
...
if (k = k - 1) != 0 then goto loop_start
;----------
Even so, it is still reassuring to see how close the output of both
compilers is. 26 machine code instructions for the Hitech C compiler and 31
for the XCSB compiler. If you look back at a previous post in this thread
you will see that I mentioned that the function epilog can actually reduce
the length of the overall code by 4 instructions (depending on optimisation)
So the code generated by the XCSB compiler would be only 27 machine code
instructions.
I will have to put this "for loop" optimisation on my todo list :-)
Regards
Sergio Masci
http://www.xcprod.com/titan/XCSB - optimising PIC compiler
FREE for personal non-commercial use.
- Next message: Bob Masta: "Re: oscilloscope recommendations"
- Previous message: Roger Johansson: "Re: oscilloscope recommendations"
- In reply to: Spehro Pefhany: "Re: Learning to use PICS"
- Next in thread: Bill Bowden: "Re: Learning to use PICS"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|