All pastes #593094 Raw Edit

Someone

public text v1 · immutable
#593094 ·published 2007-06-28 03:52 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}
    
    cpi zl, 120     ; compare with 120
    brlo under120   ; < 120

    cpi zl, 160     
    brlo under160   ; < 160

    ldi xl, 31      ; 5 leds on

under160:
    ldi xl, 15      ; 4 leds on
    ret

under120:
    cpi zl, 80      
    brlo under80    ; < 80

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

under80:
    cpi zl, 40      
    brlo under40    ; < 40

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

under40:
    ldi xl, 1       ; < 40    1 led on
    ret