Advertisement
Zeda

DE_Times_A (avg=237.671875cc)

Jun 10th, 2016
507
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. DE_Times_A:
  2. ;Input: DE,A
  3. ;Output: A:HL is the product, C=0, B,DE unaffected, z flag set if result is zero, c flag set if A is input as 1, else nc.
  4. ;A:128~255 219+6{0,10}+{0,19}    avg=258.5   *1/2
  5. ;A:64~127  203+5{0,10}+{0,19}    avg=237.5   *1/4
  6. ;A:32~63   187+4{0,10}+{0,19}    avg=216.5   *1/8
  7. ;A:16~31   171+3{0,10}+{0,19}    avg=195.5   *1/16
  8. ;A:8~15    155+2{0,10}+{0,19}    avg=174.5   *1/32
  9. ;A:4~7     139+{0,10}+{0,19}     avg=153.5   *1/64
  10. ;A:2~3     123+{0,19}            avg=132.5   *1/128
  11. ;A:1       107cc                 avg=107     *1/256
  12. ;A:0       119cc                 avg=119     *1/256
  13. ;overall avg: 237.671875cc
  14.     ld c,0
  15.     ld h,d
  16.     ld l,e
  17.     rla \ jr c,mul_07
  18.     rla \ jr c,mul_06
  19.     rla \ jr c,mul_05
  20.     rla \ jr c,mul_04
  21.     rla \ jr c,mul_03
  22.     rla \ jr c,mul_02
  23.     rla \ jr c,mul_01
  24.     rla
  25.     ret c
  26.     ld h,a
  27.     ld l,a
  28.     ret
  29. mul_07:
  30.     add hl,hl \ rla \ jr nc,$+4 \ add hl,de \ adc a,c
  31. mul_06:
  32.     add hl,hl \ rla \ jr nc,$+4 \ add hl,de \ adc a,c
  33. mul_05:
  34.     add hl,hl \ rla \ jr nc,$+4 \ add hl,de \ adc a,c
  35. mul_04:
  36.     add hl,hl \ rla \ jr nc,$+4 \ add hl,de \ adc a,c
  37. mul_03:
  38.     add hl,hl \ rla \ jr nc,$+4 \ add hl,de \ adc a,c
  39. mul_02:
  40.     add hl,hl \ rla \ jr nc,$+4 \ add hl,de \ adc a,c
  41. mul_01:
  42.     add hl,hl \ rla \ ret nc \ add hl,de \ adc a,c
  43.     ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement