piclist 1996\04\14\005636a >
Thread: Compiler Efficiency
www.piclist.com/techref/index.htm?key=compiler+efficiency
flavicon
face BY : Clyde Smith-Stubbs email (remove spam text)



myke predko <EraseMEmykeSTOPspamspamPASSPORT.CA> wrote:

> I would have expected any decent compiler to create the following code from
> this source:
>
> again:
>   incf b1, reg                  ;  b1 = b1 + 1
>   movlw 1                       ;  toggle 0
>   xorwf portx, reg
>   goto again

That's precisely what a decent compiler does produce; herewith a C file:

#include        <pic.h>

main()
{
       unsigned char   c;

       for(;;) {
               c = c+1;
               PORTA ^= 1;
       }
}

and here's the unretouched generated assembler code:

       psect   text
_main:
;       _c assigned to ?a_main+0
l2:
;x.c: 5: unsigned char c;
;x.c: 7: for(;;) {
;x.c: 8: c = c+1;
       incf    ?a_main
;x.c: 9: PORTA ^= 1;
       movlw   1
       xorwf   5
;x.c: 10: }
       goto    l2

The optimizer has not shifted the movlw outside the loop - that's a
useful touch that can be added.

Clyde

--
Clyde Smith-Stubbs       | HI-TECH Software,       | Voice: +61 7 3300 5011
.....clydespamBeGonespam@spam@hitech.com.au      | P.O. Box 103, Alderley, | Fax:   +61 7 3300 5246
http://www.hitech.com.au | QLD, 4051, AUSTRALIA.   | BBS:   +61 7 3300 5235
----------------------------------------------------------------------------
For info on the World's best C cross compilers for embedded systems, point
your WWW browser at http://www.hitech.com.au, or email spamBeGoneinfo.....spamKILLspamhitech.com.au

seeking: microchip devices pic
<9604140456.AA15685@MIT.EDU>

In reply to: <9604131953.AA08197@trojan.hitech.com.au> from "myke predko" at Apr 13, 96 03:57:00 pm
See also: www.piclist.com/techref/index.htm?key=compiler+efficiency
Reply You must be a member of the piclist mailing list (not only a www.piclist.com member) to post to the piclist. This form requires JavaScript and a browser/email client that can handle form mailto: posts.
Subject (change) Compiler Efficiency

month overview.

new search...