PICmicro & dsPIC >> PIC W.I.P. (Work In Progress)

Pages: 1
Fil



Reged: May 24 2005
Posts: 1
Optimisations in PICC compiler
      #78302 - Fri Oct 10 2008 08:05 AM

I like to research disasm lstings...
I'm testing PICC 9.60 PL3

1.
Disasm code 1:
Code:
 
21: b = a > 1 ? 1 : 0;
01E 3002 MOVLW 0x2
01F 0220 SUBWF 0x20, W
020 3000 MOVLW 0
021 1803 BTFSC 0x3, 0
022 3001 MOVLW 0x1
023 00A1 MOVWF 0x21


I think it's good optimization.

Disasm code 2:
Code:
 
21: b = a > 1 ? 4 : 0;
01E 3002 MOVLW 0x2
01F 0220 SUBWF 0x20, W
020 1803 BTFSC 0x3, 0
021 2824 GOTO 0x24
022 3000 MOVLW 0
023 2825 GOTO 0x25
024 3004 MOVLW 0x4
025 00A1 MOVWF 0x21


But it's no good. Why? If I compare 0 and 1 - it's good, but for another constants it not so.

2.
Code:
 
20 013 2814 GOTO 0x14
21 014 1283 BCF STATUS, 0x5
22 015 1303 BCF STATUS, 0x6


goto on next address
It's goto from end of startup.as to main. Optimiser must remove it.

3.
Begin of interrupt handler:
Code:
 
6 005 0803 MOVF STATUS, W
7 006 0183 CLRF STATUS <- Status cleared
8 007 00A4 MOVWF 0x24
9 008 190B isr BTFSC INTCON, 0x2
10 009 110B BCF INTCON, 0x2
11 00A 3010 MOVLW 0x10
12 00B 1283 BCF STATUS, 0x5 <-and two bits of Status cleared again (no need)
13 00C 1303 BCF STATUS, 0x6



4. IRP tracking
Code:

unsigned char *iter;
unsigned char arr[10];
iter = arr;
*iter = 5;
++iter;
*iter = 7;


and disasm:
Code:

39 026 3025 MOVLW 0x25
40 027 00A4 MOVWF iter
41 028 0084 MOVWF FSR
42 029 1383 BCF STATUS, 0x7 <- clear IRP
43 02A 3005 MOVLW 0x5
44 02B 0080 MOVWF INDF
45 02C 0AA4 INCF iter, F
46 02D 0824 MOVF iter, W
47 02E 0084 MOVWF FSR
48 02F 1383 BCF STATUS, 0x7 <- clear IRP again (no need)
49 030 3007 MOVLW 0x7
50 031 0080 MOVWF INDF


If program use only banks 0 and 1 (OCG may ckeck it) IRP may be cleared only 1 time on startup.


Post Extras: Print Post   Remind Me!   Notify Moderator  
Pages: 1



Extra information
0 registered and 3 anonymous users are browsing this forum.

Moderator:  lucky, Andrew L, dave g, meisty, josh stevo 

Print Topic

Forum Permissions
      You cannot start new topics
      You cannot reply to topics
      HTML is enabled
      UBBCode is enabled

Rating:
Topic views: 436

Rate this topic

Jump to

Contact Us | Privacy statement HI-TECH Software

Powered by UBB.threads™ 6.5.5