Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;bool bigint_frombytes(BIGINT dest, const void *restrict src, size_t len, bool big_endian);
- bigint_frombytes:
- call ti._frameset0
- ; (ix + 6) = dest
- ; (ix + 9) = src
- ; (ix + 12) = len
- ; (ix + 15) = big_endian
- ; ensure that src and dest don't overlap
- ld hl, (ix + 9)
- ld de, (ix + 6)
- xor a
- sbc hl, de
- jr z, .exit
- add hl, de
- push hl, de
- ; zero out dest
- xor a
- ld (de), a
- inc de
- ld hl, (ix + 9)
- ld bc, 31
- ldir
- ; restore src and dest, load num bytes to copy
- pop de,hl
- ld bc, (ix + 12)
- ld a, (ix + 15)
- or a
- jr nz, copy_bigendian
- add hl, bc
- dec hl
- .loop_littleendian:
- ldi
- jr po, .return_1
- dec hl
- dec hl
- jr loop_littleendian
- .copy_bigendian:
- ; add 32 - bc to de
- ldir
- .return_1:
- ld a, 1
- .exit:
- ld sp, ix
- pop ix
- ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement