swap32.asm 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. ; Exchanges current DE HL with the
  2. ; ones in the stack
  3. ;
  4. __SWAP32:
  5. pla ;- pop bc ; Return address
  6. sta z80_b
  7. pla
  8. sta z80_c
  9. lda z80_c ;- exx
  10. ldx z80_cp
  11. stx z80_c
  12. sta z80_cp
  13. lda z80_b
  14. ldx z80_bp
  15. stx z80_b
  16. sta z80_bp
  17. lda z80_e
  18. ldx z80_ep
  19. stx z80_e
  20. sta z80_ep
  21. lda z80_d
  22. ldx z80_dp
  23. stx z80_d
  24. sta z80_dp
  25. lda z80_l
  26. ldx z80_lp
  27. stx z80_l
  28. sta z80_lp
  29. lda z80_h
  30. ldx z80_hp
  31. stx z80_h
  32. sta z80_hp
  33. pla ;- pop hl ; exx'
  34. sta z80_h
  35. pla
  36. sta z80_l
  37. pla ;- pop de
  38. sta z80_d
  39. pla
  40. sta z80_e
  41. lda z80_c ;- exx
  42. ldx z80_cp
  43. stx z80_c
  44. sta z80_cp
  45. lda z80_b
  46. ldx z80_bp
  47. stx z80_b
  48. sta z80_bp
  49. lda z80_e
  50. ldx z80_ep
  51. stx z80_e
  52. sta z80_ep
  53. lda z80_d
  54. ldx z80_dp
  55. stx z80_d
  56. sta z80_dp
  57. lda z80_l
  58. ldx z80_lp
  59. stx z80_l
  60. sta z80_lp
  61. lda z80_h
  62. ldx z80_hp
  63. stx z80_h
  64. sta z80_hp
  65. lda z80_e ;- push de ; exx
  66. pha
  67. lda z80_d
  68. pha
  69. lda z80_l ;- push hl
  70. pha
  71. lda z80_h
  72. pha
  73. lda z80_c ;- exx
  74. ldx z80_cp
  75. stx z80_c
  76. sta z80_cp
  77. lda z80_b
  78. ldx z80_bp
  79. stx z80_b
  80. sta z80_bp
  81. lda z80_e
  82. ldx z80_ep
  83. stx z80_e
  84. sta z80_ep
  85. lda z80_d
  86. ldx z80_dp
  87. stx z80_d
  88. sta z80_dp
  89. lda z80_l
  90. ldx z80_lp
  91. stx z80_l
  92. sta z80_lp
  93. lda z80_h
  94. ldx z80_hp
  95. stx z80_h
  96. sta z80_hp
  97. lda z80_e ;- push de
  98. pha
  99. lda z80_d
  100. pha
  101. lda z80_l ;- push hl
  102. pha
  103. lda z80_h
  104. pha
  105. lda z80_c ;- exx
  106. ldx z80_cp
  107. stx z80_c
  108. sta z80_cp
  109. lda z80_b
  110. ldx z80_bp
  111. stx z80_b
  112. sta z80_bp
  113. lda z80_e
  114. ldx z80_ep
  115. stx z80_e
  116. sta z80_ep
  117. lda z80_d
  118. ldx z80_dp
  119. stx z80_d
  120. sta z80_dp
  121. lda z80_l
  122. ldx z80_lp
  123. stx z80_l
  124. sta z80_lp
  125. lda z80_h
  126. ldx z80_hp
  127. stx z80_h
  128. sta z80_hp
  129. pla ;- pop hl
  130. sta z80_h
  131. pla
  132. sta z80_l
  133. pla ;- pop de
  134. sta z80_d
  135. pla
  136. sta z80_e
  137. lda z80_c ;- push bc
  138. pha
  139. lda z80_b
  140. pha
  141. rts ;- ret