All pastes #593106 Raw Edit

Someone

public text v1 · immutable
#593106 ·published 2007-06-28 04:04 UTC
rendered paste body
FiveOf400:
    ; {80, 160, 240, 320, 400} to {1, 3, 7, 15, 31}

    ; divide by two    
    lsr zh ; carries over to...
    ror zl
    
    ;     0   1    2    3    4
    ;   {0, 40, 80, 120, 160, 200}

    ; add byte size / timing info to these
    
    ; jump if < 120
    cpi zl, 120     
    brlo under120   ; < 120

    ; jif < 160 (>=120)
    cpi zl, 160     
    brlo under160   

    ; 160 >= x > 200
    ldi xl, 31      ; 5 leds on

under160:
    ; 120 >= x > 160
    ldi xl, 15      ; 4 leds on
    ret

under120:
    ; jif < 80
    cpi zl, 80      
    brlo under80

    ; 80 >= x > 120
    ldi xl, 7       ; 3 leds on
    ret

under80:
    ; jif < 40
    cpi zl, 40      
    brlo under40    ; < 40

    ; 40 >= x > 80
    ldi xl, 3       ; 2 leds on
    ret

under40:
    ; 0 >= x > 40
    ldi xl, 1       ; 1 led on
    ret