Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- gcdD_C:
- ;gcd(D,C)->HL
- ;binary GCD algorithm
- ld a,d \ or a \ ret z
- ld a,c \ or a \ ret z
- cp d \ ret z
- ld b,1
- or d \ rra \ jr c,+_
- inc b \ rr d \ rr c
- ld a,d \ or c \ rra \ jr nc,$-8
- _:
- srl d \ jr nc,$-2
- rl d
- ld a,c
- _:
- rra \ jr nc,$-1
- rla
- sub d
- jr z,+_
- jr nc,-_ \ neg
- ld c,d
- ld d,a
- ld a,c
- jp -_
- _:
- ld a,d
- add a,a
- djnz $-1
- ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement