eq32.asm 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. __EQ32: ; Test if 32bit value HLDE equals top of the stack
  2. ; Returns result in A: 0 = False, FF = True
  3. lda z80_c ;- exx
  4. ldx z80_cp
  5. stx z80_c
  6. sta z80_cp
  7. lda z80_b
  8. ldx z80_bp
  9. stx z80_b
  10. sta z80_bp
  11. lda z80_e
  12. ldx z80_ep
  13. stx z80_e
  14. sta z80_ep
  15. lda z80_d
  16. ldx z80_dp
  17. stx z80_d
  18. sta z80_dp
  19. lda z80_l
  20. ldx z80_lp
  21. stx z80_l
  22. sta z80_lp
  23. lda z80_h
  24. ldx z80_hp
  25. stx z80_h
  26. sta z80_hp
  27. pla ;- pop bc ; Return address
  28. sta z80_b
  29. pla
  30. sta z80_c
  31. lda z80_c ;- exx
  32. ldx z80_cp
  33. stx z80_c
  34. sta z80_cp
  35. lda z80_b
  36. ldx z80_bp
  37. stx z80_b
  38. sta z80_bp
  39. lda z80_e
  40. ldx z80_ep
  41. stx z80_e
  42. sta z80_ep
  43. lda z80_d
  44. ldx z80_dp
  45. stx z80_d
  46. sta z80_dp
  47. lda z80_l
  48. ldx z80_lp
  49. stx z80_l
  50. sta z80_lp
  51. lda z80_h
  52. ldx z80_hp
  53. stx z80_h
  54. sta z80_hp
  55. ora z80_a ;- or a ; Reset carry flag
  56. pla ;- pop bc
  57. sta z80_b
  58. pla
  59. sta z80_c
  60. lda z80_l ;- sbc hl,bc ; Low part
  61. sbc z80_c
  62. sta z80_l
  63. lda z80_h
  64. sbc z80_b
  65. sta z80_h
  66. lda z80_e ;- ex_de_hl
  67. ldx z80_l
  68. stx z80_e
  69. sta z80_l
  70. lda z80_d
  71. ldx z80_h
  72. stx z80_d
  73. sta z80_h
  74. pla ;- pop bc
  75. sta z80_b
  76. pla
  77. sta z80_c
  78. lda z80_l ;- sbc hl,bc ; Hight part
  79. sbc z80_c
  80. sta z80_l
  81. lda z80_h
  82. sbc z80_b
  83. sta z80_h
  84. lda z80_c ;- exx
  85. ldx z80_cp
  86. stx z80_c
  87. sta z80_cp
  88. lda z80_b
  89. ldx z80_bp
  90. stx z80_b
  91. sta z80_bp
  92. lda z80_e
  93. ldx z80_ep
  94. stx z80_e
  95. sta z80_ep
  96. lda z80_d
  97. ldx z80_dp
  98. stx z80_d
  99. sta z80_dp
  100. lda z80_l
  101. ldx z80_lp
  102. stx z80_l
  103. sta z80_lp
  104. lda z80_h
  105. ldx z80_hp
  106. stx z80_h
  107. sta z80_hp
  108. lda z80_c ;- push bc ; CALLEE
  109. pha
  110. lda z80_b
  111. pha
  112. lda z80_c ;- exx
  113. ldx z80_cp
  114. stx z80_c
  115. sta z80_cp
  116. lda z80_b
  117. ldx z80_bp
  118. stx z80_b
  119. sta z80_bp
  120. lda z80_e
  121. ldx z80_ep
  122. stx z80_e
  123. sta z80_ep
  124. lda z80_d
  125. ldx z80_dp
  126. stx z80_d
  127. sta z80_dp
  128. lda z80_l
  129. ldx z80_lp
  130. stx z80_l
  131. sta z80_lp
  132. lda z80_h
  133. ldx z80_hp
  134. stx z80_h
  135. sta z80_hp
  136. lda z80_h ;- ld a,h
  137. sta z80_a
  138. ora z80_l ;- or l
  139. ora z80_d ;- or d
  140. ora z80_e ;- or e ; a = 0 only if HLDE = 0
  141. sec ;- sub 1 ; sets carry flag only if a = 0
  142. sbc #1
  143. sec ;- sbc a,a
  144. sbc z80_a
  145. rts ;- ret