anvol
4/14/2018 - 2:12 PM

avr_max.asm

__zero_reg__ = 1
find_max(long*, long):
  push r12
  push r13
  push r14
  push r15
  push r16
  push r17
  mov r12,r20
  mov r13,r21
  mov r14,r22
  mov r15,r23
  mov r30,r24
  mov r31,r25
  ld r16,Z
  ldd r17,Z+1
  ldd r18,Z+2
  ldd r19,Z+3
  cpi r20,lo8(2)
  cpc r21,__zero_reg__
  cpc r22,__zero_reg__
  cpc r23,__zero_reg__
  brlt .L2
  mov r30,r24
  mov r31,r25
  adiw r30,4
  ldi r24,lo8(1)
  ldi r25,hi8(1)
  ldi r26,hlo8(1)
  ldi r27,hhi8(1)
.L4:
  ld r20,Z+
  ld r21,Z+
  ld r22,Z+
  ld r23,Z+
  cp r16,r20
  cpc r17,r21
  cpc r18,r22
  cpc r19,r23
  brge .L3
  mov r16,r20
  mov r17,r21
  mov r18,r22
  mov r19,r23
.L3:
  adiw r24,1
  adc r26,__zero_reg__
  adc r27,__zero_reg__
  cp r24,r12
  cpc r25,r13
  cpc r26,r14
  cpc r27,r15
  brne .L4
.L2:
  mov r22,r16
  mov r23,r17
  mov r24,r18
  mov r25,r19
  pop r17
  pop r16
  pop r15
  pop r14
  pop r13
  pop r12
  ret