tari

dec_iX0.s

Jun 8th, 2010
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.92 KB | None | 0 0
  1. | Assembly Source File
  2. | Created 8/16/09; 23:26:32
  3.  
  4. |Handlers for x=0
  5.  
  6. _hX0:
  7. move.b d7, d0
  8. and.b #7, d0
  9. goLUT _X0ZLUT
  10.  
  11. _hX0Z0:
  12. btst.b #5, d7
  13. beq _hX0Z0JRCC |set bit 5 here is always conditional relative jump
  14. |otherwise use the LUT
  15. move.b d7, d0
  16. lsr.b #3, d0
  17. andi.b #3, d0
  18. goLUT _X0Z0LUT
  19.  
  20. |00000000 - NOP
  21. |No operation
  22. _hX0Z0NOP:
  23. move.b #4, d7
  24. rts
  25. |00001000 - EX AF, AF'
  26. |Exchange AF with its shadow
  27. |No flags affected
  28. _hX0Z0EXAF:
  29. lea reg_AF(a6), a0
  30. lea reg_SHADOW_AF(a6), a1
  31. move.w (a0), d0
  32. move.w (a1), (a0)
  33. move.w (a1), d0
  34. move.b #4, d7
  35. rts
  36. |00010000:nnnnnnnn - DJNZ ofs8
  37. |Decrement B and jump to ofs8 if B does not become zero
  38. |No flags affected
  39. _hX0Z0DJNZ:
  40. subq.b #1, reg_B(a6)
  41. beq _hX0Z0DJNZ_nj
  42. |should loop back
  43. move.b (a5), d0
  44. subq.l #1, a5 |return to opcode
  45. ext.w d0 |sign-extend the offset so we can add it
  46. adda.w d0, a5
  47. move.b #13, d7
  48. rts
  49. _hX0Z0DJNZ_nj:
  50. addq #1, a5
  51. move.b #8, d7
  52. rts
  53. |00011000:nnnnnnnn - JR ofs8
  54. |Jump to ofs8
  55. _hX0Z0JR:
  56. move.b (a5), d0
  57. subq #1, a5
  58. ext.w d0
  59. adda.w d0, a5
  60. move.b #12, d7
  61. rts
  62. |001cc000:nnnnnnnn - JR cc, ofs8
  63. |Jump to ofs8 if cc is true
  64. _hX0Z0JRCC:
  65. lsr #4, d7
  66. and.b #3, d7
  67. jsr checkCondition
  68. bne _hX0Z0JR |just like a plain jr if condition is true
  69. move.b #7, d7
  70. rts
  71.  
  72. |16-bit load/add
  73. _hX0Z1:
  74. btst.b #3, d7
  75. beq _hX0Z1LDimm16
  76. |00rr1001 - ADD HL, r16
  77. |Add r16 to HL
  78. |C affected as defined, H set if carry from bit 11, N reset
  79. |TODO: implement H and N flags
  80. _hX0Z1ADDHL:
  81. lsr.b #3, d7
  82. bclr #0, d7 |Register to grab
  83. move.w (a6, d7.b), d0
  84. add.w d0, reg_HL(a6)
  85. move.b #11, d7
  86. |TODO: copy carry from 68k to z80
  87. rts
  88. |00rr0001:nnnnnnnn:nnnnnnnn - LD r16, imm16
  89. |Set r16 to imm16
  90. _hX0Z1LDimm16:
  91. lsr.b #3, d7
  92. adda.w d7, a0 |Safe not to mask, since only other possible set bit is 0
  93. move.b 1(a5), (a6, d7.b) |MSB
  94. move.b (a5), 1(a6, d7.b) |LSB
  95. addq.l #2, a5 |Next instruction
  96. move.b #10, d7
  97. rts
  98.  
  99. |00nnn010[:nnnnnnnn:nnnnnnnn] - various 16-bit indirect loads
  100. _hX0Z2:
  101. clr.l d0
  102. move.b 1(a5), d0
  103. lsl.w #8, d0
  104. move.b (a5), d0
  105. movea.l addrSpace(a6), a1
  106. adda.l d0, a1 |a1 points to (imm16) if needed
  107. move.b d7, d0
  108. lsr.b #3, d0
  109. and.b #7, d0 |bits 3-5 for index
  110. goLUT _hX0Z2LUT
  111. _hX0Z2bc2a:
  112. _hX0Z2de2a: |save a bit of code space with these
  113. _hX0Z2a2bc:
  114. _hX0Z2a2de:
  115. lsr.b #1, d0 |this could break (horribly) if goLUT ever changes
  116. and.b #2, d0 |offset from a6 to read
  117. clr.l d1
  118. move.b 1(a6, d0.b), d1
  119. lsl.w #8, d1
  120. move.b (a6, d0.b), d1 |emulated address to read
  121. movea.l addrSpace(a6), a0
  122. adda.l d1, a0 |effective address to read
  123. |jump according to bit 3 now
  124. btst.b #3, d7
  125. bne _hX0Z2a2r16
  126. _hX0Z2r162a:
  127. move.b (a0), reg_A(a6)
  128. move.b #7, d7
  129. rts
  130. _hX0Z2a2r16:
  131. move.b reg_A(a6), (a0)
  132. move.b #7, d7
  133. rts
  134.  
  135. _hX0Z2LUT:
  136. .word _hX0Z2bc2a
  137. .word _hX0Z2de2a
  138. .word _hX0Z2i2hl
  139. .word _hX0Z2i2a
  140. .word _hX0Z2a2bc
  141. .word _hX0Z2a2de
  142. .word _hX0Z2hl2i
  143. .word _hX0Z2a2i
Add Comment
Please, Sign In to add comment