#90 Some additional peepholes for the mcs51 port

closed
nobody
None
5
2004-11-19
2004-11-17
Anonymous
No

I added following peepholes:

replace {
clr a
mov %1,a
mov %2,a
clr a
} by {
clr a
mov %1,a
mov %2,a
; Peephole 3.d removed redundant clr
}

replace {
clr a
mov %1,a
mov %2,a
mov %3,a
clr a
} by {
clr a
mov %1,a
mov %2,a
mov %3,a
; Peephole 3.e removed redundant clr
}

replace {
clr a
mov %1,a
mov %2,a
mov %3,a
mov %4,a
clr a
} by {
clr a
mov %1,a
mov %2,a
mov %3,a
mov %4,a
; Peephole 3.f removed redundant clr
}

replace {
clr a
mov %1,a
mov %2,a
mov %3,a
mov %4,a
mov %5,a
clr a
} by {
clr a
mov %1,a
mov %2,a
mov %3,a
mov %4,a
mov %5,a
; Peephole 3.g removed redundant clr
}

by doing so, the following sequence is optimized (sorry
for the german comments):

void External1 (void) interrupt IE1_VECTOR
{
// ein preemptive sicheres rücksetzen ist notwendig,
// da das Setzen der Zählwerte per HW-INT erfolgt

sollzeit = 0;
tmrhigh = 0;
}

673 ;F:/PCAD/PROJEKTE/SPEEDCTL/CONTROL/CONTROL.C
:134: void External1 (void) interrupt IE1_VECTOR
674 ; ---------------------------
--------------
675 ; function External1
676 ; ---------------------------
--------------
0108 677 _External1:
0002 678 ar2 = 0x02
0003 679 ar3 = 0x03
0004 680 ar4 = 0x04
0005 681 ar5 = 0x05
0006 682 ar6 = 0x06
0007 683 ar7 = 0x07
0000 684 ar0 = 0x00
0001 685 ar1 = 0x01
0108 C0 E0 686 push acc

687 ;F:/PCAD/PROJEKTE/SPEEDCTL/CONTROL/CONTROL.C
:139: sollzeit = 0;
688 ; genAssign

689 ;F:/PCAD/PROJEKTE/SPEEDCTL/CONTROL/CONTROL.C
:140: tmrhigh = 0;
690 ; genAssign
010A E4 691 clr a
010B F5 13 692 mov (_sollzeit +
3),a
010D F5 12 693 mov (_sollzeit +
2),a
010F F5 11 694 mov (_sollzeit +
1),a
0111 F5 10 695 mov _sollzeit,a
696 ; Peephole 3.f removed
redundant clr
0113 F5 15 697 mov
(_tmrhigh + 1),a
0115 F5 14 698 mov
_tmrhigh,a
0117 699 00101$:
0117 D0 E0 700 pop acc
0119 32 701 reti
702 ; eliminated unneeded
push/pop psw
703 ; eliminated unneeded
push/pop dpl
704 ; eliminated unneeded
push/pop dph
705 ; eliminated unneeded
push/pop b

And there are two more peepholes:

replace {
mov %1,%2
mov a,%1
} by {
; peephole 177.g optimized mov
mov a,%2
mov %1,a
} if notVolatile %1

replace {
mov %1,%2
mov a,%2
} by {
; peephole 177.h optimized mov
mov a,%2
mov %1,a
} if notVolatile %2

by doing so, the following sequence is optimized :

void Timer0 (void) interrupt TF0_VECTOR
{
TR0 = 0;
MOTOR ^= 1;
if (MOTOR)
TH0 = ~(pulslow = pulshigh);
else
TH0 = pulslow;
TL0 = 0;
TR0 = 1;
}

710 ;F:/PCAD/PROJEKTE/SPEEDCTL/CONTROL/CONTROL.C
:147: void Timer0 (void) interrupt TF0_VECTOR
711 ; ---------------------------
--------------
712 ; function Timer0
713 ; ---------------------------
--------------
011A 714 _Timer0:
011A C0 E0 715 push acc

716 ;F:/PCAD/PROJEKTE/SPEEDCTL/CONTROL/CONTROL.C
:149: TR0 = 0;
717 ; genAssign
011C C2 8C 718 clr _TR0

719 ;F:/PCAD/PROJEKTE/SPEEDCTL/CONTROL/CONTROL.C
:150: MOTOR ^= 1;
720 ; genXor
011E B2 B7 721 cpl _P3_7

722 ;F:/PCAD/PROJEKTE/SPEEDCTL/CONTROL/CONTROL.C
:151: if (MOTOR)
723 ; genIfx
724 ; genIfxJump
725 ; Peephole 111 removed
ljmp by inverse jump logic
0120 30 B7 09 726 jnb
_P3_7,00102$
0123 727 00107$:

728 ;F:/PCAD/PROJEKTE/SPEEDCTL/CONTROL/CONTROL.C
:152: TH0 = ~(pulslow = pulshigh);
729 ; genAssign
730 ; genCpl
731 ; peephole 177.h optimized
mov
0123 E5 17 732 mov a,_pulshigh
0125 F5 20 733 mov _pulslow,a
0127 F4 734 cpl a
0128 F5 8C 735 mov _TH0,a
736 ; Peephole 112.b changed
ljmp to sjmp
012A 80 03 737 sjmp 00103$
012C 738 00102$:

739 ;F:/PCAD/PROJEKTE/SPEEDCTL/CONTROL/CONTROL.C
:154: TH0 = pulslow;
740 ; genAssign
012C 85 20 8C 741 mov
_TH0,_pulslow
012F 742 00103$:

743 ;F:/PCAD/PROJEKTE/SPEEDCTL/CONTROL/CONTROL.C
:155: TL0 = 0;
744 ; genAssign
012F 75 8A 00 745 mov
_TL0,#0x00

746 ;F:/PCAD/PROJEKTE/SPEEDCTL/CONTROL/CONTROL.C
:156: TR0 = 1;
747 ; genAssign
0132 D2 8C 748 setb _TR0
0134 749 00104$:
0134 D0 E0 750 pop acc
0136 32 751 reti
752 ; eliminated unneeded
push/pop psw
753 ; eliminated unneeded
push/pop dpl
754 ; eliminated unneeded
push/pop dph
755 ; eliminated unneeded
push/pop b

I posted the complete peeph.def file to the lists already

Discussion

  • Frieder Ferlemann

    • status: open --> closed
     
  • Frieder Ferlemann

    Logged In: YES
    user_id=589052

    Added your peepholes 3.d-g and 177.g,h, thanks!

    If you move TL0 = 0; to the beginning of the IRQ
    you maybe don't need to clr/set TR0?

    void Timer0 (void) interrupt TF0_VECTOR
    {
    TL0 = 0;
    MOTOR ^= 1;
    if (MOTOR)
    TH0 = ~(pulslow = pulshigh);
    else
    TH0 = pulslow;
    }

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks