Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; -----------------------------------------
- ; function usqrt
- ; -----------------------------------------
- _usqrt:
- sub sp, #25
- ; util.c: 43: uint32_t a = 0; /* accumulator */
- clrw x
- ldw (0x0b, sp), x
- ldw (0x09, sp), x
- ; util.c: 44: uint32_t r = 0; /* remainder */
- clrw x
- ldw (0x07, sp), x
- ldw (0x05, sp), x
- ; util.c: 49: for (i = 0; i < 16 + ADC_ARR_BITSIZE - ADC_SHIFT; i++) /* NOTE 1 */
- ld a, #0x16
- ld (0x15, sp), a
- 00106$:
- ; util.c: 51: r = (r << 2) + TOP2BITS(x);
- ldw y, (0x05, sp)
- ldw (0x11, sp), y
- ldw x, (0x07, sp)
- ld a, #0x02
- 00121$:
- sllw x
- rlc (0x12, sp)
- rlc (0x11, sp)
- dec a
- jrne 00121$
- ldw (0x13, sp), x
- ldw y, (0x1c, sp)
- ldw (0x16, sp), y
- ldw x, (0x1e, sp)
- ld a, #0x1e
- 00123$:
- srl (0x16, sp)
- rrc (0x17, sp)
- rrcw x
- dec a
- jrne 00123$
- ldw (0x18, sp), x
- ldw x, (0x13, sp)
- addw x, (0x18, sp)
- ldw (0x0f, sp), x
- ld a, (0x12, sp)
- adc a, (0x17, sp)
- ld (0x0e, sp), a
- ld a, (0x11, sp)
- adc a, (0x16, sp)
- ld (0x05, sp), a
- ldw y, (0x0f, sp)
- ldw (0x07, sp), y
- ld a, (0x0e, sp)
- ld (0x06, sp), a
- ; util.c: 52: x <<= 2; /* NOTE 2 */
- ldw y, (0x1e, sp)
- ldw x, (0x1c, sp)
- ld a, #0x02
- 00125$:
- sllw y
- rlcw x
- dec a
- jrne 00125$
- ldw (0x1e, sp), y
- ldw (0x1c, sp), x
- ; util.c: 53: a <<= 1;
- ldw y, (0x0b, sp)
- ldw x, (0x09, sp)
- sllw y
- rlcw x
- ldw (0x0b, sp), y
- ldw (0x09, sp), x
- ; util.c: 54: e = (a << 1) + 1;
- ldw y, (0x0b, sp)
- ldw x, (0x09, sp)
- sllw y
- rlcw x
- addw y, #0x0001
- ld a, xl
- adc a, #0x00
- rlwa x
- adc a, #0x00
- ld xh, a
- ldw (0x03, sp), y
- ldw (0x01, sp), x
- ; util.c: 55: if (r >= e)
- ldw x, (0x07, sp)
- cpw x, (0x03, sp)
- ld a, (0x06, sp)
- sbc a, (0x02, sp)
- ld a, (0x05, sp)
- sbc a, (0x01, sp)
- jrc 00102$
- ; util.c: 57: r -= e;
- ldw y, (0x07, sp)
- subw y, (0x03, sp)
- ld a, (0x06, sp)
- sbc a, (0x02, sp)
- ld xl, a
- ld a, (0x05, sp)
- sbc a, (0x01, sp)
- ld xh, a
- ldw (0x07, sp), y
- ldw (0x05, sp), x
- ; util.c: 58: a++;
- ldw y, (0x0b, sp)
- addw y, #0x0001
- ld a, (0x0a, sp)
- adc a, #0x00
- ld xl, a
- ld a, (0x09, sp)
- adc a, #0x00
- ld xh, a
- ldw (0x0b, sp), y
- ldw (0x09, sp), x
- 00102$:
- ld a, (0x15, sp)
- dec a
- ld (0x15, sp), a
- ; util.c: 49: for (i = 0; i < 16 + ADC_ARR_BITSIZE - ADC_SHIFT; i++) /* NOTE 1 */
- tnz a
- jreq 00128$
- jp 00106$
- 00128$:
- ; util.c: 61: return a;
- ldw x, (0x0b, sp)
- addw sp, #25
- ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement