Advertisement
NovaYoshi

64 instruction thing

Dec 10th, 2016
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 KB | None | 0 0
  1. -------- REGISTERS --------
  2. A - accumulator, 8-bit
  3. X - index, 8-bit
  4. Y - index, 8-bit
  5. SP - stack pointer
  6. PC - program counter
  7. F - flags: carry, negative, zero
  8.  
  9. -------- OPCODE FORMAT --------
  10. ffffff00 - zero
  11. ffffff01 nnnnnnnn - zeropage (or immediate)
  12. ffffff10 nnnnnnnn nnnnnnnn - absolute
  13. ffffff11 nnnnnnnn nnnnnnnn - absolute,x
  14.  
  15. Before an opcode is excuted, the bottom two bits are looked at to determine how many bytes to read,
  16. and this is put into a buffer. This buffer may be interpreted by the instruction as a constant value or a memory address.
  17. Branch opcodes interpret 8-bit values as relative, and 16-bit values as absolute.
  18. The "zero" addressing mode gives easy access to the first byte of memory.
  19.  
  20. f = function, from list below:
  21.  
  22. -------- FUNCTION TABLE --------
  23. Load/Store/Transfer
  24. 00 LDA constant
  25. 01 LDA memory
  26. 02 LDX constant
  27. 03 LDX memory
  28. 04 STA memory
  29. 05 STX memory
  30. 06 TAX
  31. 07 TXA
  32.  
  33. Add/Subtract
  34. 08 SUB constant
  35. 09 SUB memory
  36. 0A ADD constant
  37. 0B ADD memory
  38. 0C SBC constant
  39. 0D SBC memory
  40. 0E ADC constant
  41. 0F ADC memory
  42.  
  43. Bit math
  44. 10 NOR constant
  45. 11 NOR memory
  46. 12 XOR constant
  47. 13 XOR memory
  48.  
  49. Comparisons
  50. 14 CMP constant
  51. 15 CMP memory
  52. 16 CPX constant
  53. 17 CPX memory
  54.  
  55. Bit shifts
  56. 18 ASL
  57. 19 LSR
  58. 1A ROL memory
  59. 1B ROR memory
  60.  
  61. Y register
  62. 1C LDY constant
  63. 1D LDY memory
  64. 1E CPY constant
  65. 1F STY memory
  66. 20 INY
  67. 21 DEY
  68. 22 PHY
  69. 23 PLY
  70. 24 LDA memory+y \ absolute
  71. 25 STA memory+y /
  72. 24 LDA (memory)+y \ zeropage, indirect
  73. 25 STA (memory)+y /
  74.  
  75. 26 Unassigned
  76. 27 Unassigned
  77.  
  78. Miscellaneous
  79. 28 PHP
  80. 29 PLP
  81. 2A SWAP (A and X)
  82. 2B RTS
  83. 2C SEC
  84. 2D CLC
  85.  
  86. Increment/decrement
  87. 2E INC memory
  88. 2F DEC memory
  89. 30 INC
  90. 31 DEC
  91. 32 INX
  92. 33 DEX
  93.  
  94. Push/pull
  95. 34 PHA
  96. 35 PHX
  97. 36 PLA
  98. 37 PLX
  99.  
  100. Branches
  101. 38 BRA \ zeropage
  102. 39 BSR |
  103. 3A BPL |
  104. 3B BMI |
  105. 3C BNE |
  106. 3D BEQ |
  107. 3E BCC |
  108. 3F BCS /
  109.  
  110. Jumps
  111. 38 JMP \ absolute
  112. 39 JSR |
  113. 3A JPL |
  114. 3B JMI |
  115. 3C JNE |
  116. 3D JEQ |
  117. 3E JCC |
  118. 3F JCS /
  119.  
  120. -------- ALIASES/NOTES --------
  121.  
  122. NOT = NOR
  123. ORA = NOR whatever, NOT
  124. BIC = NOT, NOR #whatever
  125. AND = NOT, NOR #255^whatever
  126. NEG = NOT, INC
  127.  
  128. TAY = PHA, PLY
  129. TYA = PHY, PLA
  130. TXY = PHX, PLY
  131. TYX = PHY, PLX
  132.  
  133. ---
  134.  
  135. could replace CLC/SEC with ADD/SUB but it would mess up zero flag and sign flag
  136. A can be reset to zero in just one opcode with LDA
  137.  
  138. do we really need a nop?
  139.  
  140. you can do "LDA A,X,Y" if you're a weirdo
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement