Advertisement
AnthonyCagliano

Untitled

Dec 10th, 2022
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. _bigint_square:
  2. ; Destination needs space for 61 bytes during computation (But at the end, only the first 30 bytes contain valid data)
  3. ; Input: DE: Start of source, IY: Start of destination
  4. ; Output: A destroyed, B=C=0, DE: Start of destination + 10, HL: Start of destination + 9, IY: Start of destination + 31
  5. ld hl, -61
  6. call ti._frameset
  7. lea iy, ix - 61 ; using a temp buffer for dest
  8. ld hl, (ix + 9) ; iy = src
  9. ld c,30
  10. .byteLoop:
  11. ld a, (de)
  12. inc de
  13. ld b, 8
  14. .bitLoop:
  15. add hl, hl
  16. rla
  17. adc hl, hl
  18. djnz .bitLoop
  19. ld (iy), hl
  20. lea iy, iy + 2
  21. dec c
  22. jr nz, .byteLoop
  23.  
  24. ld b, 29
  25. .reduceLoop:
  26. dec iy
  27. ld hl, (iy - 2)
  28. ld a, h
  29. rra
  30. ld a, l
  31. rra
  32. xor a, (iy - 31)
  33. ld (iy - 31), a
  34. add hl, hl
  35. lea de, iy - 21
  36. ld a, (de)
  37. xor a, h
  38. ld (de), a
  39. djnz .reduceLoop
  40.  
  41. ld a, l
  42. rrca
  43. and a, 1
  44. ld (iy - 2), a
  45. rlca
  46. xor a, l
  47. lea hl, iy - 22
  48. xor a, (hl)
  49. ld (hl), a
  50.  
  51. ; copy tmp buffer to dest
  52. ld de, (ix + 6)
  53. lea hl, ix - 61
  54. ld bc, 30
  55. ldir
  56.  
  57. ld sp, ix
  58. pop ix
  59. ret
  60.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement