Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- _get_degree:
- ; input: hl = ptr to binary polynomial (little endian-encoded)
- ; degree in a
- ; destroys: bc, flags
- ld bc, 29
- add hl, bc
- ld c, 30
- .byte_loop:
- ld a, (hl)
- or a ; if byte is 0
- jr nz, .found_byte
- ld a, d
- sub a, 8
- ld d, a
- dec hl
- dec c
- jr nz .byte_loop
- ; exit
- ld a, -1
- ret
- .found_byte:
- ; process bits
- ld b, 8
- .bit_loop:
- rla
- jr c, .found_bit
- dec d
- djnz .bit_loop
- .found_bit:
- ld a, c
- dec a
- dec b
- add a, a
- add a, a
- add a, a
- or a, b
- ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement