avr-rust / delay

arduino-like delay routines based on busy-wait loops
Apache License 2.0
15 stars 11 forks source link

Cycle accurate implementation #28

Closed bombela closed 2 years ago

bombela commented 2 years ago

Below is an example of the code produced. The name of the function is the number of cycles.

test_0:
    ret

test_1:
    nop
    ret

test_2:
.Ltmp0:
    rjmp    .Ltmp0
    ret

test_3:
.Ltmp1:
    rjmp    .Ltmp1
    nop
    ret

test_4:
.Ltmp2:
    rjmp    .Ltmp2
.Ltmp3:
    rjmp    .Ltmp3
    ret

test_5:
.Ltmp4:
    rjmp    .Ltmp4
.Ltmp5:
    rjmp    .Ltmp5
    nop
    ret

test_6:
    ldi r24, 2
.Ltmp6:
    dec r24
    brne    .Ltmp6
    ret

test_42:
    ldi r24, 14
.Ltmp0:
    dec r24
    brne    .Ltmp0
    ret

test_773:
    ldi r24, 193
    ldi r25, 0
.Ltmp25:
    sbiw    r24, 1
    brne    .Ltmp25
    ret

test_262_151:
    ldi r24, 205
    ldi r25, 204
    ldi r18, 0
.Ltmp41:
    sbiw    r24, 1
    sbci    r18, 0
    brne    .Ltmp41
.Ltmp42:
    rjmp    .Ltmp42
.Ltmp43:
    rjmp    .Ltmp43
    ret

test_83_886_087:
    ldi r24, 86
    ldi r25, 85
    ldi r18, 213
    ldi r19, 0
.Ltmp62:
    sbiw    r24, 1
    sbci    r18, 0
    sbci    r19, 0
    brne    .Ltmp62
    ret

test_25_769_803_784:
    ldi r24, 0
    ldi r25, 0
    ldi r18, 0
    ldi r19, 0
.Ltmp86:
    sbiw    r24, 1
    sbci    r18, 0
    sbci    r19, 0
    brne    .Ltmp86
.Ltmp87:
    rjmp    .Ltmp87
.Ltmp88:
    rjmp    .Ltmp88
    nop
    ret
stappersg commented 2 years ago

Commit https://github.com/bombela/avr-delay/commit/c7229a7e64d72b7fbd1924d27a223164d0f52843 should not be in this merge request.

bombela commented 2 years ago

Commit bombela@c7229a7 should not be in this merge request.

Where should it be then?

stappersg commented 2 years ago

Commit bombela@c7229a7 should not be in this merge request.

Where should it be then?

In a separate MR

bombela commented 2 years ago

Ok I moved the offending commit to its own PR #29.

stappersg commented 2 years ago

On Sun, Jun 12, 2022 at 05:11:15AM -0700, François-Xavier Bourlet wrote:

Commit @.*** should not be in this merge request.

Where should it be then?

In a separate MR

Groeten Geert Stappers -- Silence is hard to parse