pon., 15 cze 2020 o 11:05 Maarten Brock <sourceforge.br...@dse.nl>
napisał(a):

> This sounds like an excellent job for the peephole optimizer.
> Are there restrictions on the operand that should be checked?
>
> Maarten
>

I have created following peephole rule for my if statement:

replace {
    mov a, __pa
    and a, #0x10
    cneqsn a, #0x00
    goto %1
} by {
    ; peephole PA4 check optimization.
    t1sn __pa, #4
    goto %1
}

I didn't use a pattern variable as __pa because i want to have more
control, at least for now. The problem for me is that in C bit position is
specified as bitmash ( byte & 0x10) while tXsn takes bit number (#4) and I
don't know how to create a rule that converts bit number as bitmask to bit
number. I could create 8 rules foreach tXsn with different bit numbers :/

pon., 15 cze 2020 o 17:24 Philipp Klaus Krause <p...@spth.de> napisał(a):

> But I had thought about having __near as a subspace of __data, for the
> lower half of  the __data address space.
>
> Philipp
>

 I didn't know about that, lower half. So checking variables thru tXsn
might fail ? If i use following rules can they make problems ?

// if( !(byte & 0x80) ) PULLSDA(); //Pull SDA low if MSB is 0
replace {
    mov a, _SendByte_PARM_1+0
    and a, #0x80
    ceqsn a, #0x00
    goto %1
} by {
    t0sn _SendByte_PARM_1+0, #7
    goto %1
}

// if( (byte & 0x80) ) RELEASESDA(); //Release SDA if MSB is 1
replace {
    mov a, _SendByte_PARM_1+0
    and a, #0x80
    cneqsn a, #0x00
    goto %1
} by {
    t1sn _SendByte_PARM_1+0, #7
    goto %1
}

Slawek

PS. Another rule that i'm using
// I2CData = (I2CData << 1) | (SDA);
replace {
    mov a, _I2CData+0
    mov p, a
    sl p
    mov a, __pa
    and a, #0x01
    or a, p
    mov _I2CData+0, a
} by {
    ; peephole SDA pulling optimization
    set0 __flag, #1  //Clear carry flag, nedeed ?
    t0sn    __pa, #0
    set1 __flag, #1
    slc _I2CData+0
}
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to