Advertisement
PikalaxALT

Using GBZ80 to do mod 24 using Chinese Remainder Theorem

Oct 1st, 2015
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. a_mod_3:
  2. .loop
  3.     sub 3
  4.     jr c, .loop
  5.     add 3
  6.     ret
  7.  
  8. dehl_mod_3:
  9.     push bc
  10.     ld b, 0
  11.     ld a, d
  12.     call a_mod_3
  13.     ld b, a
  14.     ld a, e
  15.     call a_mod_3
  16.     add b
  17.     ld b, a
  18.     ld a, h
  19.     call a_mod_3
  20.     add b
  21.     ld b, a
  22.     ld a, l
  23.     call a_mod_3
  24.     add b
  25.     pop bc
  26.     cp 3
  27.     ret c
  28.     call a_mod_3
  29.     ret
  30.  
  31. dehl_mod_24:
  32.     push bc
  33.     ld a, l
  34.     and 7
  35.     ld b, a
  36.     srl
  37.     srl
  38.     srl
  39.     add b
  40.     ld b, a
  41.     call dehl_mod_3
  42.     srl
  43.     srl
  44.     srl
  45.     cpl
  46.     add b
  47.     pop bc
  48.     ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement