Advertisement
AnthonyCagliano

Untitled

Dec 7th, 2022
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. ;bool bigint_frombytes(BIGINT dest, const void *restrict src, size_t len, bool big_endian);
  2. bigint_frombytes:
  3. call ti._frameset0
  4. ; (ix + 6) = dest
  5. ; (ix + 9) = src
  6. ; (ix + 12) = len
  7. ; (ix + 15) = big_endian
  8.  
  9. ; ensure that src and dest don't overlap
  10. ld hl, (ix + 9)
  11. ld de, (ix + 6)
  12. xor a
  13. sbc hl, de
  14. jr z, .exit
  15. add hl, de
  16. push hl, de
  17.  
  18. ; zero out dest
  19. xor a
  20. ld (de), a
  21. inc de
  22. ld hl, (ix + 9)
  23. ld bc, 31
  24. ldir
  25.  
  26. ; restore src and dest, load num bytes to copy
  27. pop de,hl
  28. ld bc, (ix + 12)
  29. ld a, (ix + 15)
  30. or a
  31. jr nz, copy_bigendian
  32. add hl, bc
  33. dec hl
  34. .loop_littleendian:
  35. ldi
  36. jr po, .return_1
  37. dec hl
  38. dec hl
  39. jr loop_littleendian
  40. .copy_bigendian:
  41. ; add 32 - bc to de
  42. ldir
  43. .return_1:
  44. ld a, 1
  45. .exit:
  46. ld sp, ix
  47. pop ix
  48. ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement