Giomancer

ZMA600ISA

Aug 20th, 2026 (edited)
35
0
315 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 46.66 KB | None | 0 0
  1. ZENTEC MICRODEVICES
  2.  
  3. Zg/α600 Microprocessor Abstract (Prototype)
  4.  
  5. Jan Augustyn & Stanisław Nowak
  6.  
  7. 28.I.1971 — Draft: Δ00
  8.  
  9.  
  10. ================================================================================
  11. INTRODUCTION
  12. ================================================================================
  13.  
  14. ⟪Preface,Introductory Notes⟫
  15.  
  16.  
  17. ================================================================================
  18. ARCHITECTURE
  19. ================================================================================
  20.  
  21. --------------------------------------------------------------------------------
  22. Register Set
  23. --------------------------------------------------------------------------------
  24.  
  25. [A] : Accumulator 6-bit
  26. [X] : high address/page 6-bit
  27. [Y] : low address/index 6-bit
  28. [XY] : index register-pair 12-bit
  29. [PC] : program counter 12-bit
  30. [F] : processor status 6-bit
  31. [SC] : stack counter 3-bit
  32.  
  33. The register set of the Zg/α600 is intentionally minimal and consists entirely
  34. of special-purpose registers. This choice was driven by the need to provide the
  35. essential functions for embedded control at the smallest practical cost: an
  36. accumulator for arithmetic and logic, a pair of index registers for efficient
  37. memory access, a program counter, a status register, and a counter for the
  38. internal stack. The resulting architecture trades some programming flexibility
  39. for a compact instruction set well suited to the industrial and hobbyist
  40. applications targeted by the processor.
  41.  
  42.  
  43. **Accumulator
  44. The accumulator, A, is 6-bit and is the central working register of the
  45. Zg/α600 and the sole destination for every arithmetic and logical
  46. operation. All two-operand instructions use the A register as their
  47. implicit first operand, combining it with a second operand supplied by
  48. an immediate value, an absolute memory location, or an indirect memory
  49. location. Single-operand operations act on A exclusively; there is no
  50. equivalent form that operates on the index registers or on memory
  51. directly.
  52.  
  53. Every instruction that writes a new value into A generates the Zero and
  54. Negative flags from that value, and does so identically whether the
  55. value originated from an arithmetic operation or from memory. The Carry
  56. and Overflow flags apply only to arithmetic operations; see ⟪Status
  57. Flags⟫ for details.
  58.  
  59. The compare operation is a notable exception among instructions that
  60. reference A: it reads the accumulator and updates flags according to the
  61. comparison, but never modifies the contents of A itself.
  62.  
  63. The accumulator communicates with memory exclusively through load and
  64. store operations; there is no other path by which A exchanges data with
  65. the address space. On reset, A is cleared to zero; see ⟪Reset/Power-on⟫
  66. for details.
  67.  
  68. **Index Register-pair
  69. The index registers, X and Y, are each 6-bit and are hardwired to form
  70. the 12-bit index register-pair XY, with X always occupying the high half
  71. {11:6} and Y always occupying the low half {5:0}. This pairing is fixed
  72. and is not configurable; it exists specifically to supply the effective
  73. address used by the register-indirect addressing mode. The pair is
  74. formed by direct concatenation, with no offset or arithmetic applied
  75. between the two halves.
  76.  
  77. X and Y may be loaded, stored, and transferred into individually, or
  78. loaded together as the full 12-bit pair. None of these operations affect
  79. any processor status flag, regardless of whether they target a single
  80. half or the full pair.
  81.  
  82. Increment and decrement operate only on the pair as a whole; there is no
  83. provision for incrementing or decrementing X or Y independently.
  84. Increment and decrement treat XY as a single 12-bit value, with a carry
  85. or borrow propagating from Y's top bit into X as needed. Overflow and
  86. underflow of the 12-bit pair are not detected or flagged; the value
  87. silently wraps and no processor status flag is affected by this
  88. operation.
  89.  
  90. The index registers support no operation that reads their contents
  91. without modifying them; there is no compare or test form analogous to
  92. what is available for the accumulator. On reset, both X and Y are
  93. cleared to zero; see ⟪Reset/Power-on⟫ for details.
  94.  
  95. **Program Counter
  96. The program counter, PC, is 12-bit and holds the address of the next
  97. instruction. PC advances by a fixed amount after each fetch, determined
  98. by instruction class: one word for Class 0 and Class 3, two words for
  99. Class 1, and three words for Class 2.
  100.  
  101. On reset, PC is loaded with the fixed address @0000. Placing the reset
  102. address at the base of the address space allows a small boot ROM
  103. occupying the lowest addresses to run first and initialize peripherals
  104. before handing off to the remainder of the program. See ⟪Reset/Power-on⟫
  105. for details.
  106.  
  107. **Processor Status
  108. The processor status register, F, is 6-bit and holds five condition
  109. flags: Carry, Zero, Negative, Overflow, and Interrupt (mask), along with
  110. one reserved bit. F has no direct load, store, or transfer form; its
  111. contents are modified only as a side effect of flag-setting
  112. instructions, the explicit interrupt-mask instructions, and the stack
  113. save/restore that occurs on subroutine calls, interrupts, and return.
  114. Refer to ⟪Status Flags⟫ for bit-level positions and the detailed
  115. behavior of each flag, including the reserved bit.
  116.  
  117. On reset, the whole of F is cleared; see ⟪Reset/Power-on⟫ for details.
  118.  
  119. **Stack Counter
  120. The internal stack counter, SC, is 3-bit and holds the location of the
  121. next available 18-bit layer in the eight-entry hardware stack,
  122. incrementing after a push and decrementing before a pull. There is no
  123. direct load, store, or transfer form for SC; it is moved only
  124. implicitly, as a side effect of the push and pull operations performed
  125. during subroutine calls, interrupts, and return.
  126.  
  127. SC has no overflow or underflow detection. Should a push or pull wrap
  128. the counter past its bounds, no warning is raised and the condition is
  129. treated strictly as a programmer error. On reset, SC is cleared to zero;
  130. see ⟪Reset/Power-on⟫ for details.
  131.  
  132.  
  133. --------------------------------------------------------------------------------
  134. Status Flags
  135. --------------------------------------------------------------------------------
  136.  
  137. The processor status register is six bits wide, and contains the current status
  138. of five flags: Carry (F{0}), Zero (F{1}), Negative (F{2}), Overflow (F{3}), and
  139. Interrupt (F{5}). F{4} of the register is currently reserved for future use and
  140. its value is ignored. Each flag is affected by a variety of operations as noted
  141. in their individual subsections. Operations whose primary target is the index
  142. register-pair do not affect the status register.
  143.  
  144. Stack operations save and restore the entire F register as part of every
  145. hardware stack frame; the frame format is always [PCL|PCH|F] (upper twelve bits
  146. hold the saved program counter, lower six bits hold the status register).
  147. Consequently, the current value of each flag is automatically preserved across
  148. every JPS, BRK, and hardware interrupt entry and is restored by RET.
  149.  
  150.  
  151. **Interrupt Mask Flag
  152. The Interrupt mask flag (F{I} or 'I') serves as the master
  153. enable/disable control for the maskable hardware interrupt request /IRQ.
  154. When F{I} = 1, the processor ignores /IRQ. When F{I} = 0, an asserted
  155. /IRQ will trigger an interrupt entry sequence. The non-maskable
  156. interrupt /NMI, the software interrupt instruction BRK, and reset are
  157. never masked; they always take effect regardless of the state of the I
  158. flag.
  159.  
  160. The I flag is only modified by the following events; it is never
  161. affected by ALU operations, loads, stores, transfers, or any other
  162. instruction.
  163.  
  164. /RST signal
  165. On reset, the I flag is cleared along with the rest of the status
  166. register. See ⟪Reset/Power-on⟫ for details.
  167. /IRQ signal
  168. When /IRQ is recognized and I = 0, the program counter and status
  169. register are pushed onto the stack layer (S[PCL|PCH|F]) and the I
  170. flag is set (F{I} ← 1). The program counter is then forced to the
  171. fixed vector at @1774 (PC ← [@1775|@1774]). If halted, an /IRQ
  172. signal will wake the processor, even if masked; see ⟪Interrupt
  173. Handling⟫ for details.
  174. /NMI signal
  175. When /NMI is recognized, the program counter and status register are
  176. pushed onto the stack layer (S[PCL|PCH|F]) and the I flag is set
  177. (F{I} ← 1). The program counter is then forced to the fixed vector
  178. at @1776 (PC ← [@1777|@1776]). See ⟪Interrupt Handling⟫ for details.
  179. BRK instruction
  180. When BRK is executed, the program counter and status register are
  181. pushed onto the stack layer (S[PCL|PCH|F]) then the I flag is set
  182. (F{I} ← 1). BRK then forces PC to the fixed vector at @1772 (PC ←
  183. [@1773|@1772]). The prior value of the flag is therefore preserved
  184. in the stack frame for later restoration by RET. See ⟪Interrupt
  185. Handling⟫ and ⟪Detailed Descriptions⟫ for details.
  186. SEI instruction
  187. When SEI is executed, it explicitly sets the I flag (F{I} ← 1); no
  188. other flags are modified.
  189. CLI instruction
  190. When CLI is executed, it explicitly clears the I flag (F{I} ← 0); no
  191. other flags are modified.
  192. RET instruction
  193. When RET is executed, it pulls the top frame from the hardware
  194. stack, restoring both the program counter and processor status
  195. register; the I flag inherits the restored value.
  196.  
  197. **Reserved F{4}
  198. F{4} is reserved for future use. Software should neither assume a
  199. defined value when reading it nor rely on any effect from writing it.
  200. Like the rest of F, it is cleared on reset and is saved and restored as
  201. part of the stack frame.
  202.  
  203. **Overflow Flag
  204. The Overflow flag (F{V} or 'V') signals whether the result of a signed
  205. 6-bit two's-complement arithmetic operation overflowed the representable
  206. range (−32..+31). The V flag is generated by arithmetic operations (with
  207. one explicit exception, LSL) and computed as the exclusive-OR of the
  208. carry into bit 5 and the carry out of bit 5: F{V} ← (Cin{5}) ⊕
  209. (Cout{5})
  210.  
  211. The V flag is only modified by the following events; it is never
  212. affected by two-operand logic operations, loads, stores, transfers,
  213. index operations, or control-flow instructions that do not perform
  214. arithmetic.
  215.  
  216. ADC, SBC, CMP, INC/DEC A instructions
  217. When these instructions are executed, the V flag is set (F{V} ← 1)
  218. when the signed result cannot be represented in six bits. The same
  219. computation applies whether the second operand is supplied by an
  220. immediate value, an absolute memory location, or an indirect memory
  221. location.
  222. LSL instruction
  223. When LSL is executed, the V flag is set to the XOR of the original
  224. bits 5 and 4 of the accumulator (F{V} ← A{5} ⊕ A{4}); this gives a
  225. simple signed-overflow indication for a single-bit left shift.
  226.  
  227. **Negative Flag
  228. The Negative (sign) flag (F{N} or 'N') signals the sign of the
  229. accumulator value by directly reflecting bit 5 of the result produced by
  230. most arithmetic, logical, load, shift, and compare operations: F{N} ←
  231. result{5}
  232.  
  233. The N flag is updated in parallel with the Z flag for the same group of
  234. operations.
  235.  
  236. The N flag is only modified by the following events; it is never
  237. affected by stores, index operations, or control-flow instructions that
  238. do not perform arithmetic.
  239.  
  240. Accumulator operations
  241. When an ALU operation targeting the accumulator is executed, the N
  242. flag is set or cleared (F{N} ← result{5}) based upon the result of
  243. the operation performed.
  244. LD A instructions
  245. When a value is loaded into the accumulator, the N flag is set or
  246. cleared (F{N} ← val{5}) based upon the value being loaded.
  247.  
  248. **Zero Flag
  249. The Zero (equal) flag (F{Z} or 'Z') signals that the value within the
  250. accumulator is zero and is set (F{Z} ← 1) when the result of an
  251. operation is all zeros; otherwise it is cleared (F{Z} ← 0). The Z flag
  252. is updated in parallel with the Negative flag (N) for the majority of
  253. arithmetic, logical, load, shift, and compare operations.
  254.  
  255. The Z flag is only modified by the following events; it is never
  256. affected by stores, index operations, or control-flow instructions that
  257. do not perform arithmetic.
  258.  
  259. Accumulator operations
  260. When an ALU operation targeting the accumulator is executed, the Z
  261. flag is set or cleared (【result = 0】? ⸨F{Z} ← 1⸩ : ⸨F{Z} ← 0⸩) based
  262. upon the result.
  263. LD A instructions
  264. When a value is loaded into the accumulator, the Z flag is set or
  265. cleared (【val = 0】? ⸨F{Z} ← 1⸩ : ⸨F{Z} ← 0⸩) based upon the value
  266. being loaded.
  267.  
  268. **Carry Flag
  269. The Carry flag (F{C} or 'C') indicates unsigned overflow in addition,
  270. the absence of a borrow in subtraction and comparison, and the bit
  271. shifted out of the accumulator by a shift. It is used to chain
  272. multi-word arithmetic via ADC and SBC.
  273.  
  274. The C flag is only modified by the following events; it is never
  275. affected by two-operand logic operations, loads, stores, index
  276. operations, or control-flow instructions.
  277.  
  278. ADC, SBC, CMP instructions
  279. After these instructions are executed, the C flag is set (F{C} ← 1)
  280. on carry-out from bit 5 for addition, and when no borrow is
  281. generated for subtraction and compare.
  282. INC/DEC A instructions
  283. After these instructions are executed, the C flag reports the carry
  284. or borrow from bit 5 as it does for addition and subtraction: INC A
  285. sets the C flag (F{C} ← 1) only on overflow from @63 → @00 and
  286. clears it otherwise, while DEC A clears the C flag (F{C} ← 0) only
  287. on underflow from @00 → @63 and sets it otherwise.
  288. LSL, LSR instructions
  289. When these instructions are executed, the C flag takes on the value
  290. of the bit being shifted off (LSL: F{C} ← A{5}; LSR: F{C} ← A{0}).
  291. NOT instruction
  292. When NOT is executed, the C flag is forced to 1 (F{C} ← 1).
  293. CLC instruction
  294. When CLC is executed, it explicitly clears the C flag (F{C} ← 0); no
  295. other flags are modified.
  296.  
  297.  
  298. --------------------------------------------------------------------------------
  299. Reset/Power-On
  300. --------------------------------------------------------------------------------
  301.  
  302. Following a reset, the program counter holds @0000 and the accumulator, index
  303. register-pair, stack counter, and status register all hold zero. The processor
  304. treats every reset identically, whether it occurs at initial application of
  305. power or at any later point during operation; no distinction is made between the
  306. two. Execution resumes by fetching the instruction at @0000. To prevent
  307. undefined operation, refer to ⟪Memory Organization⟫ for the proper memory system
  308. design.
  309.  
  310. Reset takes precedence over everything else the processor may be doing. An
  311. instruction in progress does not complete, an interrupt awaiting service is
  312. discarded, and a halt ends. No instruction defers or prevents a reset.
  313.  
  314.  
  315. --------------------------------------------------------------------------------
  316. Hardware Stack
  317. --------------------------------------------------------------------------------
  318.  
  319. The Zg/α600 provides a dedicated hardware stack entirely separate from the
  320. addressable memory space, consisting of eight internal storage layers. It shares
  321. no addressing with main memory and occupies no portion of the address space.
  322.  
  323. Each layer holds a single 18-bit frame, composed of the saved program counter
  324. and the saved processor status register in the form [PCL|PCH|F]. A push and a
  325. pull always move a complete frame as a single unit; there is no provision for
  326. saving or restoring PC and F independently of one another. The layer written or
  327. read is the one identified by the stack counter; see ⟪Stack Counter⟫.
  328.  
  329. Subroutine calls and interrupt entries draw from the same eight layers rather
  330. than from partitioned sets, so the depth available at any moment is divided
  331. between the calls currently active and the interrupts currently being serviced.
  332. Neither exhaustion nor underflow is detected: a ninth consecutive push
  333. overwrites the oldest frame still held, and a pull without a corresponding push
  334. recovers whatever that layer last contained.
  335.  
  336. On interrupt entry, PC and F are pushed as they stood immediately beforehand,
  337. and only then is F{I} forced to 1. The saved F therefore reflects the masking
  338. state in effect before the interrupt rather than the state the handler runs
  339. under, and RET restores the former on return.
  340.  
  341. Reset clears the stack counter but leaves the layers themselves untouched,
  342. holding whatever frames were present beforehand. Those frames are overwritten by
  343. subsequent pushes rather than read back, unless a program pulls before it has
  344. pushed, in which case it recovers a frame left over from before the reset.
  345.  
  346.  
  347. --------------------------------------------------------------------------------
  348. Memory Organization
  349. --------------------------------------------------------------------------------
  350.  
  351. The Zg/α600 uses the von Neumann memory model: program code, data, and
  352. peripherals all share a single, flat address space, with no architectural
  353. distinction between instruction fetches and data accesses beyond the operation
  354. being performed. The address space is twelve bits wide and organized into 6-bit
  355. words, giving 4096 (4 KiW) addressable locations. Each address names exactly one
  356. word; there is no finer granularity. The Zg/α600 defines no dedicated I/O
  357. space—peripherals, where present, occupy ordinary addresses at the system
  358. designer's discretion.
  359.  
  360. By convention, the lowest 1 KiW of the address space (@0000–@1777) is expected
  361. to be ROM-resident, containing boot code and anything the processor may need to
  362. reference before software has had the opportunity to run. The remaining 3 KiW
  363. (@2000–@7777) is left entirely to the system designer's discretion: RAM,
  364. additional ROM, peripherals, or any combination thereof.
  365.  
  366. This convention closes a specific hazard. Four addresses are referenced before
  367. any software has executed—the reset target at @0000 and the three interrupt
  368. vectors spanning @1772 through @1777—and each must hold a defined value from the
  369. moment power stabilizes. RAM contents are not guaranteed valid at cold power-on;
  370. only ROM, fixed at manufacture, offers that guarantee unconditionally. Because
  371. the reset target and the vectors alike fall within the ROM-resident region, they
  372. are valid from the first instruction a program executes, requiring no software
  373. initialization.
  374.  
  375. The convention is a recommendation, not a processor-enforced guarantee. The
  376. Zg/α600 has no means of knowing what physical memory is mapped to any given
  377. address and behaves identically regardless of what the system designer places
  378. there. A system that instead populates the low 1 KiW with RAM forgoes the
  379. guarantee and must ensure by external means that no interrupt source—an /NMI in
  380. particular—can reach the processor before boot firmware has established a valid
  381. state.
  382.  
  383.  
  384. ================================================================================
  385. INSTRUCTION SET
  386. ================================================================================
  387.  
  388. --------------------------------------------------------------------------------
  389. Addressing Modes
  390. --------------------------------------------------------------------------------
  391.  
  392. The Zg/α600 provides four modes of addressing the system: implied, immediate,
  393. direct, and register-indirect. Implied addressing uses single-word instructions
  394. in which both the source and destination are defined implicitly by the opcode
  395. itself; immediate addressing supplies a 6- or 12-bit constant or signed
  396. displacement in subsequent instruction words (depending upon class); direct
  397. addressing supplies a complete 12-bit memory address across two additional
  398. words; and register-indirect mode obtains the effective address from the index
  399. register-pair.
  400.  
  401.  
  402. **Implied Addressing
  403. Implied addressing mode is used when an instruction requires no address,
  404. immediate value, or register specifier in the instruction stream; the
  405. 6-bit opcode itself identifies the source and destination locations—no
  406. additional words are fetched. This mode covers simple register
  407. transfers, accumulator and index updates, basic logical operations on A,
  408. flag control, and processor-state instructions such as halt and software
  409. interrupt. The program counter is incremented by one after the
  410. instruction is read.
  411.  
  412. **Immediate Addressing
  413. Immediate addressing mode is used when an instruction requires a
  414. constant operand or relative branch displacement that follows the opcode
  415. in the instruction stream; after the 6-bit opcode word is read, the
  416. class of the instruction determines the number of additional 6-bit words
  417. to be fetched. This mode covers arithmetic, logical, and comparison
  418. operations that use a constant; the loading of registers A, X, and Y
  419. (including the XY pair) with immediate values; and conditional branches
  420. that use a 6-bit signed relative offset. Depending on the class of the
  421. instruction, the program counter is incremented by either two or three
  422. after the complete instruction is read.
  423.  
  424. **Direct Addressing
  425. Direct addressing mode is used when an instruction requires a full
  426. 12-bit memory address that follows the opcode in the instruction stream;
  427. after the 6-bit opcode word is read, the two additional 6-bit words
  428. containing the high and low halves of the absolute address are fetched
  429. ([PC+2|PC+1]). This mode covers jumps, subroutine calls, loads and
  430. stores, and arithmetic, logical, and comparison operations that access
  431. memory using a complete 12-bit address. PC is incremented by three after
  432. the complete instruction is read.
  433.  
  434. **Register-Indirect Addressing
  435. Register-Indirect addressing mode is used when an instruction requires a
  436. memory address that is supplied by the index register-pair. As with
  437. implied mode, the 6-bit opcode identifies the operation, and no
  438. additional words are fetched. This mode covers loads, stores,
  439. arithmetic, logical, and comparison operations, as well as jumps and
  440. subroutine calls, that use the current value of XY as the effective
  441. address. The program counter is incremented by one after the instruction
  442. is read.
  443.  
  444.  
  445. --------------------------------------------------------------------------------
  446. Encoding
  447. --------------------------------------------------------------------------------
  448.  
  449. Every Zg/α600 instruction consists of one, two, or three words and begins with a
  450. 6-bit operation code (opcode) that defines the instruction and if it requires
  451. any additional data. Utilizing variable-length instructions in this manner
  452. trades increased decoding complexity for code density when compared to that of
  453. fixed-length encoding.
  454.  
  455. Instructions are grouped into four classes identified by the two most
  456. significant bits {5:4} of their opcode. Every opcode within a class shares its
  457. one-, two-, or three-word instruction length. Each class is typically associated
  458. with one of the four addressing modes described previously, e.g., Implied at one
  459. word, Immediate at two, Direct at three, but class membership is defined by
  460. length, not by strict adherence to any mode's operand-forming behavior. The sole
  461. exception is the Register-Indirect mode, which claims a class for itself to
  462. expedite address formation from the index registers.
  463.  
  464. The remaining four bits of each opcode {3:0} select the specific instruction
  465. within its class; with four classes of sixteen opcodes each, the full 6-bit
  466. opcode space is exactly and evenly divided (4 × 16 = 64 = 2^6) with no reserved
  467. or wasted encoding space at the class level, though some individual opcodes
  468. remain reserved within classes.
  469.  
  470.  
  471. **Class 0 // [%00]
  472. Class 0 comprises opcodes with {5:4} = %00. Every instruction in this
  473. class is a single word: the opcode itself, with no further words
  474. fetched.
  475.  
  476. Membership in this class is defined by self-sufficiency: every operation
  477. it contains requires no additional data beyond the opcode itself to
  478. complete. This includes register transfers, software interrupt control,
  479. and simple accumulator and logical operations.
  480.  
  481. **Class 1 // [%01]
  482. Class 1 comprises opcodes with {5:4} = %01. Every instruction in this
  483. class is two words: the opcode, followed by a second word at [PC+1].
  484.  
  485. Membership in this class is defined by needing exactly one additional
  486. word of data to complete, regardless of how that word is used. This
  487. currently includes operations that take a small constant operand or
  488. conditional branches that use a signed relative offset.
  489.  
  490. **Class 2 // [%10]
  491. Class 2 comprises opcodes with {5:4} = %10. Every instruction in this
  492. class is three words: the opcode, followed by a second word at [PC+1]
  493. and a third at [PC+2].
  494.  
  495. Membership in this class is defined by needing exactly two additional
  496. words of data to complete, regardless of how those words are used. This
  497. currently includes operations that take a large constant operand or a
  498. complete 12-bit absolute address.
  499.  
  500. **Class 3 // [%11]
  501. Class 3 comprises opcodes with {5:4} = %11. Every instruction in this
  502. class is a single word: the opcode itself, with no further words
  503. fetched.
  504.  
  505. Membership in this class is defined by behavior rather than length:
  506. every operation it contains forms its effective address from the index
  507. register-pair, using register-indirect addressing exclusively.
  508.  
  509.  
  510. --------------------------------------------------------------------------------
  511. Instruction List
  512. --------------------------------------------------------------------------------
  513.  
  514. Class 0 Class 1 Class 2 Class 3
  515.  
  516. NOP LD A,#imm LD A,abs LD A,IXY
  517. HLT LD X,#imm ST A,abs ST A,IXY
  518. BRK LD Y,#imm LD X,abs LD X,IXY
  519. RET ADC #imm ST X,abs ST X,IXY
  520. SEI SBC #imm LD Y,abs LD Y,IXY
  521. CLI CMP #imm ST Y,abs ST Y,IXY
  522. CLC AND #imm LD XY,#imm ADC IXY
  523. INC A OR #imm ADC abs SBC IXY
  524. DEC A XOR #imm SBC abs CMP IXY
  525. INC XY BR ZS,rel CMP abs AND IXY
  526. DEC XY BR ZC,rel AND abs OR IXY
  527. LSL BR CS,rel OR abs XOR IXY
  528. LSR BR CC,rel XOR abs JP IXY
  529. TAX BR NS,rel JP abs JPS IXY
  530. TAY BR NC,rel JPS abs
  531. NOT JPV abs
  532.  
  533.  
  534. --------------------------------------------------------------------------------
  535. Detailed Descriptions
  536. --------------------------------------------------------------------------------
  537.  
  538. CLASS 0
  539. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  540.  
  541. NOP || No Operation
  542. Operation: None
  543. Mode: Implied
  544. Length: 1 word
  545. Flags affected: None
  546.  
  547. HLT || Halt
  548. Operation: suspends execution until interrupt or reset is
  549. recognized
  550. Mode: Implied
  551. Length: 1 word
  552. Flags affected: None
  553. Notes: An /IRQ asserted while F{I} = 1 ends the halt without
  554. triggering an entry sequence; execution continues at PC
  555. with no frame pushed and no vector taken.
  556.  
  557. BRK || Software Break
  558. Operation: S[PCL|PCH|F] ← PC|F;
  559. SC ← SC+1; F{I} ← 1;
  560. PC ← [@1773|@1772]
  561. Mode: Implied
  562. Length: 1 word
  563. Flags affected: I flag set unconditionally
  564.  
  565. RET || Return
  566. Operation: SC ← SC−1;
  567. PC|F ← S[PCL|PCH|F]
  568. Mode: Implied
  569. Length: 1 word
  570. Flags affected: None generated; the whole of F is replaced by the
  571. restored frame.
  572. Notes: RET serves as the sole return path for JPS, BRK, and
  573. both hardware interrupt sources alike.
  574.  
  575. SEI || Set Interrupt Mask
  576. Operation: F{I} ← 1
  577. Mode: Implied
  578. Length: 1 word
  579. Flags affected: I flag set unconditionally
  580.  
  581. CLI || Clear Interrupt Mask
  582. Operation: F{I} ← 0
  583. Mode: Implied
  584. Length: 1 word
  585. Flags affected: I flag cleared unconditionally
  586.  
  587. CLC || Clear Carry
  588. Operation: F{C} ← 0
  589. Mode: Implied
  590. Length: 1 word
  591. Flags affected: C flag cleared unconditionally
  592.  
  593. INC A || Increment Accumulator
  594. Operation: A ← A+1
  595. Mode: Implied
  596. Length: 1 word
  597. Flags affected: F{C} ← carry-out of bit 5;
  598. F{V} ← Cin{5} ⊕ Cout{5};
  599. F{Z} ← 1 if result = 0, else 0;
  600. F{N} ← result{5}
  601.  
  602. DEC A || Decrement Accumulator
  603. Operation: A ← A−1
  604. Mode: Implied
  605. Length: 1 word
  606. Flags affected: F{C} ← 1 if no borrow generated, else 0;
  607. F{V} ← Cin{5} ⊕ Cout{5};
  608. F{Z} ← 1 if result = 0, else 0;
  609. F{N} ← result{5}
  610.  
  611. INC XY || Increment Index Register-Pair
  612. Operation: XY ← XY+1
  613. Mode: Implied
  614. Length: 1 word
  615. Flags affected: None
  616.  
  617. DEC XY || Decrement Index Register-Pair
  618. Operation: XY ← XY−1
  619. Mode: Implied
  620. Length: 1 word
  621. Flags affected: None
  622.  
  623. LSL || Logical Shift Left
  624. Operation: A ← A≪1
  625. Mode: Implied
  626. Length: 1 word
  627. Flags affected: F{C} ← A{5};
  628. F{V} ← A{5} ⊕ A{4};
  629. F{Z} ← 1 if result = 0, else 0;
  630. F{N} ← result{5}
  631. Notes: C and V flags generated from pre-shift A.
  632.  
  633. LSR || Logical Shift Right
  634. Operation: A ← A≫1
  635. Mode: Implied
  636. Length: 1 word
  637. Flags affected: F{C} ← A{0};
  638. F{Z} ← 1 if result = 0, else 0;
  639. F{N} ← result{5}
  640. Notes: C flag generated from pre-shift A.
  641.  
  642. TAX || Transfer Accumulator to X
  643. Operation: A → X
  644. Mode: Implied
  645. Length: 1 word
  646. Flags affected: None
  647.  
  648. TAY || Transfer Accumulator to Y
  649. Operation: A → Y
  650. Mode: Implied
  651. Length: 1 word
  652. Flags affected: None
  653.  
  654. NOT || Bitwise Complement
  655. Operation: A ← ¬A
  656. Mode: Implied
  657. Length: 1 word
  658. Flags affected: F{C} ← 1;
  659. F{Z} ← 1 if result = 0, else 0;
  660. F{N} ← result{5}
  661. Notes: The forced carry provides the machine's only means of
  662. seeding F{C} ← 1; the pair `NOT; NOT` leaves A unchanged
  663. and sets carry ahead of a chained SBC sequence, serving
  664. in place of a dedicated set-carry instruction.
  665.  
  666. CLASS 1
  667. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  668.  
  669. LD A,#imm || Load Accumulator with Immediate
  670. Operation: A ← imm
  671. Mode: Immediate
  672. Length: 2 words
  673. Flags affected: F{Z} ← 1 if imm = 0, else 0;
  674. F{N} ← imm{5}
  675.  
  676. LD X,#imm || Load X with Immediate
  677. Operation: X ← imm
  678. Mode: Immediate
  679. Length: 2 words
  680. Flags affected: None
  681.  
  682. LD Y,#imm || Load Y with Immediate
  683. Operation: Y ← imm
  684. Mode: Immediate
  685. Length: 2 words
  686. Flags affected: None
  687.  
  688. ADC #imm || Add Immediate to Accumulator with Carry
  689. Operation: A ← A + imm + F{C}
  690. Mode: Immediate
  691. Length: 2 words
  692. Flags affected: F{C} ← carry-out of bit 5;
  693. F{V} ← Cin{5} ⊕ Cout{5};
  694. F{Z} ← 1 if result = 0, else 0;
  695. F{N} ← result{5}
  696.  
  697. SBC #imm || Subtract Immediate from Accumulator with Carry
  698. Operation: A ← A − imm − ¬F{C}
  699. Mode: Immediate
  700. Length: 2 words
  701. Flags affected: F{C} ← 1 if no borrow generated, else 0;
  702. F{V} ← Cin{5} ⊕ Cout{5};
  703. F{Z} ← 1 if result = 0, else 0;
  704. F{N} ← result{5}
  705.  
  706. CMP #imm || Compare Accumulator with Immediate
  707. Operation: A − imm
  708. Mode: Immediate
  709. Length: 2 words
  710. Flags affected: F{C} ← 1 if no borrow generated, else 0;
  711. F{V} ← Cin{5} ⊕ Cout{5};
  712. F{Z} ← 1 if result = 0, else 0;
  713. F{N} ← result{5}
  714. Notes: Accumulator remains unchanged by result.
  715.  
  716. AND #imm || Bitwise AND Immediate with Accumulator
  717. Operation: A ← A & imm
  718. Mode: Immediate
  719. Length: 2 words
  720. Flags affected: F{Z} ← 1 if result = 0, else 0;
  721. F{N} ← result{5}
  722.  
  723. OR #imm || Bitwise OR Immediate with Accumulator
  724. Operation: A ← A ∥ imm
  725. Mode: Immediate
  726. Length: 2 words
  727. Flags affected: F{Z} ← 1 if result = 0, else 0;
  728. F{N} ← result{5}
  729.  
  730. XOR #imm || Bitwise Exclusive-OR Immediate with Accumulator
  731. Operation: A ← A ⊕ imm
  732. Mode: Immediate
  733. Length: 2 words
  734. Flags affected: F{Z} ← 1 if result = 0, else 0;
  735. F{N} ← result{5}
  736.  
  737. BR ZS,rel || Branch if Zero Set
  738. Operation: 【F{Z} = 1】? PC ← PC+disp : —
  739. Mode: Immediate
  740. Length: 2 words
  741. Flags affected: None; branch operations only test flag state, never
  742. modify it.
  743.  
  744. BR ZC,rel || Branch if Zero Clear
  745. Operation: 【F{Z} = 0】? PC ← PC+disp : —
  746. Mode: Immediate
  747. Length: 2 words
  748. Flags affected: None; branch operations only test flag state, never
  749. modify it.
  750.  
  751. BR CS,rel || Branch if Carry Set
  752. Operation: 【F{C} = 1】? PC ← PC+disp : —
  753. Mode: Immediate
  754. Length: 2 words
  755. Flags affected: None; branch operations only test flag state, never
  756. modify it.
  757.  
  758. BR CC,rel || Branch if Carry Clear
  759. Operation: 【F{C} = 0】? PC ← PC+disp : —
  760. Mode: Immediate
  761. Length: 2 words
  762. Flags affected: None; branch operations only test flag state, never
  763. modify it.
  764.  
  765. BR NS,rel || Branch if Negative Set
  766. Operation: 【F{N} = 1】? PC ← PC+disp : —
  767. Mode: Immediate
  768. Length: 2 words
  769. Flags affected: None; branch operations only test flag state, never
  770. modify it.
  771.  
  772. BR NC,rel || Branch if Negative Clear
  773. Operation: 【F{N} = 0】? PC ← PC+disp : —
  774. Mode: Immediate
  775. Length: 2 words
  776. Flags affected: None; branch operations only test flag state, never
  777. modify it.
  778.  
  779. CLASS 2
  780. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  781.  
  782. LD A,abs || Load Accumulator from Absolute
  783. Operation: A ← M[abs]
  784. Mode: Direct
  785. Length: 3 words
  786. Flags affected: F{Z} ← 1 if M[abs] = 0, else 0;
  787. F{N} ← M[abs]{5}
  788.  
  789. ST A,abs || Store Accumulator into Absolute
  790. Operation: M[abs] ← A
  791. Mode: Direct
  792. Length: 3 words
  793. Flags affected: None
  794.  
  795. LD X,abs || Load X from Absolute
  796. Operation: X ← M[abs]
  797. Mode: Direct
  798. Length: 3 words
  799. Flags affected: None
  800.  
  801. ST X,abs || Store X to Absolute
  802. Operation: M[abs] ← X
  803. Mode: Direct
  804. Length: 3 words
  805. Flags affected: None
  806.  
  807. LD Y,abs || Load Y from Absolute
  808. Operation: Y ← M[abs]
  809. Mode: Direct
  810. Length: 3 words
  811. Flags affected: None
  812.  
  813. ST Y,abs || Store Y to Absolute
  814. Operation: M[abs] ← Y
  815. Mode: Direct
  816. Length: 3 words
  817. Flags affected: None
  818.  
  819. LD XY,#imm || Load Index Register-Pair with Immediate
  820. Operation: XY ← imm
  821. Mode: Immediate
  822. Length: 3 words
  823. Flags affected: None
  824.  
  825. ADC abs || Add Absolute to Accumulator with Carry
  826. Operation: A ← A + M[abs] + F{C}
  827. Mode: Direct
  828. Length: 3 words
  829. Flags affected: F{C} ← carry-out of bit 5;
  830. F{V} ← Cin{5} ⊕ Cout{5};
  831. F{Z} ← 1 if result = 0, else 0;
  832. F{N} ← result{5}
  833.  
  834. SBC abs || Subtract Absolute from Accumulator with Carry
  835. Operation: A ← A − M[abs] − ¬F{C}
  836. Mode: Direct
  837. Length: 3 words
  838. Flags affected: F{C} ← 1 if no borrow generated, else 0;
  839. F{V} ← Cin{5} ⊕ Cout{5};
  840. F{Z} ← 1 if result = 0, else 0;
  841. F{N} ← result{5}
  842.  
  843. CMP abs || Compare Accumulator with Absolute
  844. Operation: A − M[abs]
  845. Mode: Direct
  846. Length: 3 words
  847. Flags affected: F{C} ← 1 if no borrow generated, else 0;
  848. F{V} ← Cin{5} ⊕ Cout{5};
  849. F{Z} ← 1 if result = 0, else 0;
  850. F{N} ← result{5}
  851. Notes: Accumulator remains unchanged by result.
  852.  
  853. AND abs || Bitwise AND Accumulator with Absolute
  854. Operation: A ← A & M[abs]
  855. Mode: Direct
  856. Length: 3 words
  857. Flags affected: F{Z} ← 1 if result = 0, else 0;
  858. F{N} ← result{5}
  859.  
  860. OR abs || Bitwise OR Accumulator with Absolute
  861. Operation: A ← A ∥ M[abs]
  862. Mode: Direct
  863. Length: 3 words
  864. Flags affected: F{Z} ← 1 if result = 0, else 0;
  865. F{N} ← result{5}
  866.  
  867. XOR abs || Bitwise Exclusive-OR Accumulator with Absolute
  868. Operation: A ← A ⊕ M[abs]
  869. Mode: Direct
  870. Length: 3 words
  871. Flags affected: F{Z} ← 1 if result = 0, else 0;
  872. F{N} ← result{5}
  873.  
  874. JP abs || Unconditional Jump to Absolute Address
  875. Operation: PC ← abs
  876. Mode: Direct
  877. Length: 3 words
  878. Flags affected: None
  879.  
  880. JPS abs || Subroutine Jump to Absolute Address
  881. Operation: S[PCL|PCH|F] ← PC|F;
  882. SC ← SC+1; PC ← abs
  883. Mode: Direct
  884. Length: 3 words
  885. Flags affected: None; JPS itself does not modify any flags.
  886.  
  887. JPV abs || Jump to Absolute Address if Overflow Set
  888. Operation: 【F{V} = 1】? PC ← abs : —
  889. Mode: Direct
  890. Length: 3 words
  891. Flags affected: None
  892.  
  893. CLASS 3
  894. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  895.  
  896. LD A,IXY || Load Accumulator via Register-Indirect
  897. Operation: A ← M[XY]
  898. Mode: Register-Indirect
  899. Length: 1 word
  900. Flags affected: F{Z} ← 1 if M[XY] = 0, else 0;
  901. F{N} ← M[XY]{5}
  902.  
  903. ST A,IXY || Store Accumulator via Register-Indirect
  904. Operation: M[XY] ← A
  905. Mode: Register-Indirect
  906. Length: 1 word
  907. Flags affected: None
  908.  
  909. LD X,IXY || Load X via Register-Indirect
  910. Operation: X ← M[XY]
  911. Mode: Register-Indirect
  912. Length: 1 word
  913. Flags affected: None
  914.  
  915. ST X,IXY || Store X via Register-Indirect
  916. Operation: M[XY] ← X
  917. Mode: Register-Indirect
  918. Length: 1 word
  919. Flags affected: None
  920.  
  921. LD Y,IXY || Load Y via Register-Indirect
  922. Operation: Y ← M[XY]
  923. Mode: Register-Indirect
  924. Length: 1 word
  925. Flags affected: None
  926.  
  927. ST Y,IXY || Store Y via Register-Indirect
  928. Operation: M[XY] ← Y
  929. Mode: Register-Indirect
  930. Length: 1 word
  931. Flags affected: None
  932.  
  933. ADC IXY || Add Register-Indirect to Accumulator with Carry
  934. Operation: A ← A + M[XY] + F{C}
  935. Mode: Register-Indirect
  936. Length: 1 word
  937. Flags affected: F{C} ← carry-out of bit 5;
  938. F{V} ← Cin{5} ⊕ Cout{5};
  939. F{Z} ← 1 if result = 0, else 0;
  940. F{N} ← result{5}
  941.  
  942. SBC IXY || Subtract Register-Indirect from Accumulator with Carry
  943. Operation: A ← A − M[XY] − ¬F{C}
  944. Mode: Register-Indirect
  945. Length: 1 word
  946. Flags affected: F{C} ← 1 if no borrow generated, else 0;
  947. F{V} ← Cin{5} ⊕ Cout{5};
  948. F{Z} ← 1 if result = 0, else 0;
  949. F{N} ← result{5}
  950.  
  951. CMP IXY || Compare Accumulator with Register-Indirect
  952. Operation: A − M[XY]
  953. Mode: Register-Indirect
  954. Length: 1 word
  955. Flags affected: F{C} ← 1 if no borrow generated, else 0;
  956. F{V} ← Cin{5} ⊕ Cout{5};
  957. F{Z} ← 1 if result = 0, else 0;
  958. F{N} ← result{5}
  959. Notes: Accumulator remains unchanged by result.
  960.  
  961. AND IXY || Bitwise AND Accumulator with Register-Indirect
  962. Operation: A ← A & M[XY]
  963. Mode: Register-Indirect
  964. Length: 1 word
  965. Flags affected: F{Z} ← 1 if result = 0, else 0;
  966. F{N} ← result{5}
  967.  
  968. OR IXY || Bitwise OR Accumulator with Register-Indirect
  969. Operation: A ← A ∥ M[XY]
  970. Mode: Register-Indirect
  971. Length: 1 word
  972. Flags affected: F{Z} ← 1 if result = 0, else 0;
  973. F{N} ← result{5}
  974.  
  975. XOR IXY || Bitwise Exclusive-OR Accumulator with Register-Indirect
  976. Operation: A ← A ⊕ M[XY]
  977. Mode: Register-Indirect
  978. Length: 1 word
  979. Flags affected: F{Z} ← 1 if result = 0, else 0;
  980. F{N} ← result{5}
  981.  
  982. JP IXY || Jump to Register-Indirect
  983. Operation: PC ← XY
  984. Mode: Register-Indirect
  985. Length: 1 word
  986. Flags affected: None
  987.  
  988. JPS IXY || Jump to Subroutine via Register-Indirect
  989. Operation: S[PCL|PCH|F] ← PC|F;
  990. SC ← SC+1; PC ← XY
  991. Mode: Register-Indirect
  992. Length: 1 word
  993. Flags affected: None; JPS itself does not modify any flags.
  994.  
  995.  
  996. --------------------------------------------------------------------------------
  997. Opcode Map
  998. --------------------------------------------------------------------------------
  999.  
  1000. columns select class ({5:4}), rows select opcode-within-class ({3:0})
  1001.  
  1002.  
  1003. Class 0 Class 1 Class 2 Class 3
  1004. %00 %01 %10 %11
  1005.  
  1006. %0000 NOP LD A,#i LD A,ab LD A,IX
  1007. %0001 HLT LD X,#i ST A,ab ST A,IX
  1008. %0010 BRK LD Y,#i LD X,ab LD X,IX
  1009. %0011 RET ADC #i ST X,ab ST X,IX
  1010. %0100 SEI SBC #i LD Y,ab LD Y,IX
  1011. %0101 CLI CMP #i ST Y,ab ST Y,IX
  1012. %0110 CLC AND #i LD XY,#i ADC IX
  1013. %0111 INC A OR #i ADC ab SBC IX
  1014. %1000 DEC A XOR #i SBC ab CMP IX
  1015. %1001 INC XY BR ZS,rel CMP ab AND IX
  1016. %1010 DEC XY BR ZC,rel AND ab OR IX
  1017. %1011 LSL BR CS,rel OR ab XOR IX
  1018. %1100 LSR BR CC,rel XOR ab JP IX
  1019. %1101 TAX BR NS,rel JP ab JPS IX
  1020. %1110 TAY BR NC,rel JPS ab R
  1021. %1111 NOT R JPV ab R
  1022.  
Advertisement
Add Comment
Please, Sign In to add comment