.global init
.global blink
.global float_test

float_test:
  ldi r25, 0b00111110
  ldi r24, 0b00100000
  ldi r23, 0b01000000
  ldi r22, 0b00000000
  clr r1
  ret

blink:
  ldi   r20, 250
  call  delay_n_ms
  ldi   r20, 250
  call  delay_n_ms
  
  sbi   PORTD, LED_PORT ; high
  ldi   r20, 250
  call  delay_n_ms
  cbi   PORTD, LED_PORT ; low
  
  ret

delay_n_ms:
  ; delay for ~r20 * 1ms. r20, r30, and r31 are modified.
  ; 1 ms ~ 16000 cycles at 16MHz.
  ; The basic loop takes about 5 cycles, so we need about 3000 loops.
  ldi   r31, 3000 >> 8  ; high byte of the 3000
  ldi   r30, 3000 & 255 ; low byte of the 3000
delaylp:
  sbiw    r30, 1 ; sub word r30 1
  brne    delaylp ; jne delaylp
  subi    r20, 1
  brne    delay_n_ms
  ret