OpenCores
URL https://opencores.org/ocsvn/m65c02/m65c02/trunk

Subversion Repositories m65c02

[/] [m65c02/] [trunk/] [Src/] [Microprogram-Sources/] [M65C02_uPgm_V3a.txt] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 MichaelA
header
2
Project: M65C02_uP_ROM
3
File Revision: 0020
4
Author(s): Michael A. Morris
5
Description: M65C02 Microprogram
6
endh
7
 
8
--------------------------------------------------------------------------------
9
--
10
--  Copyright 2011-2012 by Michael A. Morris, dba M. A. Morris & Associates
11
--
12
--  All rights reserved. The source code contained herein is publicly released
13
--  under the terms and conditions of the GNU Lesser Public License. No part of
14
--  this source code may be reproduced or transmitted in any form or by any
15
--  means, electronic or mechanical, including photocopying, recording, or any
16
--  information storage and retrieval system in violation of the license under
17
--  which the source code is released.
18
--
19
--  The source code contained herein is free; it may be redistributed and/or
20
--  modified in accordance with the terms of the GNU Lesser General Public
21
--  License as published by the Free Software Foundation; either version 2.1 of
22
--  the GNU Lesser General Public License, or any later version.
23
--
24
--  The source code contained herein is freely released WITHOUT ANY WARRANTY;
25
--  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
26
--  PARTICULAR PURPOSE. (Refer to the GNU Lesser General Public License for
27
--  more details.)
28
--
29
--  A copy of the GNU Lesser General Public License should have been received
30
--  along with the source code contained herein; if not, a copy can be obtained
31
--  by writing to:
32
--
33
--  Free Software Foundation, Inc.
34
--  51 Franklin Street, Fifth Floor
35
--  Boston, MA  02110-1301 USA
36
--
37
--  Further, no use of this source code is permitted in any form or means
38
--  without inclusion of this banner prominently in any derived works.
39
--
40
--  Michael A. Morris
41
--  Huntsville, AL
42
--
43
--------------------------------------------------------------------------------
44
 
45
--------------------------------------------------------------------------------
46
-- Revision History:
47
--------------------------------------------------------------------------------
48
--
49
--  0001    11D09   mam     Initial development.
50
--
51
--  0002    11D17   mam     Continued development.
52
--
53
--  0003    12A21   mam     Continued development, added En_PC field, removed
54
--                          Bus Interface Unit (BIU) and Program Control Unit
55
--                          (PCU) control fields and changed Memory Data Output
56
--                          field to Memory Data Output/Input Field. The BIU and
57
--                          PCU concepts deemed to complex for this implementa-
58
--                          tion. Implementation now relies on direct control of
59
--                          the bus cycles by the microprogram. Conditional exe-
60
--                          cution of most branches is now used to allow the uP
61
--                          execution to be controlled by the test signals. this
62
--                          allows tighter and faster uPgms, and facilitates the
63
--                          implementation of the uPgm.
64
--
65
--  0004    12A22   mam     Completed development of the MAM6502 microprogram.
66
--                          Added comments below regarding the implementation of
67
--                          the conditional branches discussed in note 0003. No
68
--                          attempt is made to minimize the number or length of
69
--                          the microroutines. Only five instructions are used,
70
--                          and no subroutines are used. Several direct address-
71
--                          microroutines are equivalent. Since several of these
72
--                          addressing modes yield the same effective address,
73
--                          they could be combined, but it is unlikely to save
74
--                          enough to allow the branch address field and MPC
75
--                          address register to be decreased from 8 to 7 bits.
76
--
77
--  0005    12B07   mam     Completed the restructing of the microprogram. the
78
--                          basic structure remains the same. However, issues
79
--                          related to the pipelining of the instruction decode
80
--                          (fixed microword) have been corrected by incorpora-
81
--                          ting a instruction decode ROM directly into the uP
82
--                          ROM itself. This corrects the primary issue which is
83
--                          that the first microword of each instruction se-
84
--                          quence needed to be specific for each instruction or
85
--                          addressing mode. With the previous architecture, too
86
--                          much special handling logic was needed to ensure
87
--                          proper execution of individual instructions. The
88
--                          special logic needed was proving to be difficult to
89
--                          implement, and thus violating the primary motivation
90
--                          for the development of the control unit as a micro-
91
--                          programmed state machine. With the new structure,
92
--                          the first microword on the control unit is deter-
93
--                          simultaneously with the look-up in the instruction
94
--                          decoder ROM of the fixed instruction microword. The
95
--                          format of the Instruction Decode ROM has been sim-
96
--                          plified, and the actual opcode embedded in the
97
--                          fixed microword in order to preserve a width of 32
98
--                          for this ROM and that of the variable microwords. If
99
--                          this field is left out, since its contents matches
100
--                          the input, then the total amount of microwords (var
101
--                          plus fixed) is 32 + 24 = 56 bits. The two level,
102
--                          i.e. fixed and variable microcode, will be main-
103
--                          tained because the 24 bits of the fixed microword is
104
--                          required until the control unit indicates that the
105
--                          instruction is ready to execute, i.e. enable ALU.
106
--                          The final major change was that the specific modifi-
107
--                          cations to many of the branching instructions of the
108
--                          MAM6502_MPC (based on the F9408A_MPC) have been un-
109
--                          done, and conditional execution applied, under con-
110
--                          trol of control field in the variable microword, to
111
--                          all instructions of the MPC. This allows the micro-
112
--                          programmed state machine, i.e. control unit, to be
113
--                          responsible for the synchronization and capture of
114
--                          external data. The automatic cycle wait delay that
115
--                          is now built in for all MPC instructions, can be
116
--                          automatically performed if the microprogram allows
117
--                          it explicitly, or it can simply use multiple states
118
--                          to implement the required timing and external bus
119
--                          synchronization. Finally, the external memory was
120
--                          defined as a LUT RAM. This means that data reads and
121
--                          data writes are single clock cycle operations. The
122
--                          Rdy cycle completion signal will stretch the control
123
--                          unit operations dependent on the external memory. If
124
--                          needed, additional logic can be added, and the con-
125
--                          trol unit should execute instructions as required.
126
--
127
--  0006    12B16   MAM     Completed checkout of the basic instructions and
128
--                          addressing modes: Jumps, Branches, push/pop, all
129
--                          alu operations with immediate operands, acc modes
130
--                          instructions, all flag set/clear instructions, and
131
--                          all other implied operand instructions except BRK.
132
--                          Optimized microroutines to eliminate state redundant
133
--                          with _Nxt (Fetch/Execute) state. This eliminates the
134
--                          second state of Push/Pop instructions, all immediate
135
--                          operand instructions, and all branches. Labels moved
136
--                          and grouped with the _Nxt label as a reminder that
137
--                          this optimization is included.
138
--
139
--  0007    12B19   MAM     Added missing instruction: STZ dp,X
140
--
141
--  0008    12B20   MAM     Reworked the _Int and _Brk microroutines. Added the
142
--                          ISR strobe to the third cycle, i.e. Push P state, to
143
--                          explicitly clear D and set I before start of inter-
144
--                          rupt/trap service routine.
145
--
146
--  0009    12B22   MAM     Added limited support for interrupt handling at spe-
147
--                          cific instruction boundaries. The Branch Multi-Way
148
--                          MPC instruction is used in the last state of each
149
--                          microroutine to sample the external Int signal. the
150
--                          configuration of the _Nxt and _Int microstates form
151
--                          a 2-way branch table. The last state in a micro-
152
--                          routine points to this 2-way table, and if the Int
153
--                          signal is asserted, then the _Int microroutine is
154
--                          executed, otherwise the normal instruction fetch
155
--                          and decode of the next instruction is performed by
156
--                          the BRV1 instruction at _Nxt.
157
--
158
--  0010    12B23   MAM     Completed conversion of the microcode for the other
159
--                          instruction groups, except the RMW groups, to sup-
160
--                          port interrupts. Due to the overlapped nature of the
161
--                          fetch and execute, the first microstate in _Int was
162
--                          set to signal Done. In this way while PCH is being
163
--                          pushed, the instruction is being executed. A problem
164
--                          still remains in how to deal with the extra cycle
165
--                          required to complete ADC/SBC in BCD mode. The BCD
166
--                          adder requires an extra cycle to complete adjustment
167
--                          of the two BCD digits following the initial binary
168
--                          sum.
169
--
170
--  0011    12B24   MAM     Changed microprogram for CLI/SEI so that they are
171
--                          interruptable. That is, if IRQ/NMI is asserted when
172
--                          these instructions enable/disable interrupts, then
173
--                          the trap will not be taken until the completion of
174
--                          instruction which follows. (BCD operations issue
175
--                          rectified in change made to M65C02_Core/M65C02_ALU
176
--                          modules.)
177
--
178
--  0012    12B25   MAM     Added WE_R to _Int microstate to allow instruction
179
--                          being interrupted to complete. All other elements
180
--                          needed to correctly interrupt an instruction made
181
--                          to module M65C02_Core. Added a second jump table for
182
--                          normal or interrupt processing of RMW instructions.
183
--                          _Nxt/_Int are not acceptable since they assert WE_R
184
--                          to allow instruction to complete while PCH is being
185
--                          pushed. RMW instructions have already written any
186
--                          registers, so a second WE_R could corrupt memory or
187
--                          the PSW. Thus, the BRV1 and BRV2 microstates in the
188
--                          RMW jump table do not assert WE_R.
189
--
190
--  0013    12C04   MAM     Made corrections to all RMW operations. Change makes
191
--                          the output of the ALU come out on the output data
192
--                          bus on the correct cycle. The ALU provides the out-
193
--                          put on the cycle following the read, so there's no
194
--                          need for a cycle to wait on ALU Valid before writing
195
--                          result back to memory.
196
--
197
--  0014    12D28   MAM     Corrected the _LDX_abs instruction. Improperly took
198
--                          branch to _RO_AbsX instead of _RO_Abs. (Notified of
199
--                          error by Windfall @forum.6502.org.)
200
--
201
--------------------------------------------------------------------------------
202
--------------------------------------------------------------------------------
203
--
204
--  Forked from M65C02_uPgm_V3.txt when M65C02_MPCv3 started being used in the
205
--  core, and the original MPC was retained for use with M65C02_Base, the origi-
206
--  nal source file for the M65C02 processor core.
207
--
208
--  0015    12K12   MAM     Modified the microcode to remove the Wait control
209
--                          signal, and replace it with a ZP control signal. ZP
210
--                          is asserted whenever an indexed zp address mode, or
211
--                          an indirect indexed zero page address mode is used.
212
--                          For indexed zero page addressing (zp,X; zp,Y), the
213
--                          target location must be in page zero, i.e. % 256.
214
--                          For indirect indexed addressing ((zp,X); (zp),Y)),
215
--                          both halves of the 16-bit pointer must be located on
216
--                          page zero. In (zp,X), the fetch operation of the
217
--                          high byte of the pointer must wrap on page 0.
218
--
219
--  0016    12K17   MAM     Corrected entry for $22 from BRV1 to BRV3. removed
220
--                          use of {SC, Done} field in preparation for reusing
221
--                          the field to control the M65C02_MPCv3 microcycle
222
--                          length, uLen[1:0], field from within the micro-
223
--                          program.
224
--
225
--  0017    12K20   MAM     Changed the MemTyp field of the first microword to
226
--                          ensure that the first instruction fetch cycle deter-
227
--                          mines whether a wait state, multi-cycle microcycle
228
--                          is needed.
229
--
230
--  0018    12L09   MAM     Added support for WAI, STP, and indirect jumps for
231
--                          NMI and IRQ/BRK. Also added indirect jump for RST,
232
--                          but without pushes to the stack required for other
233
--                          exceptions.
234
--
235
--  0019    12L15   MAM     Added Rockwell instructions. RMBx/SMBx instructions
236
--                          use to the _RMW_DP microroutine to execute. The BBRx
237
--                          and BBSx instructions use a new microroutine to exe-
238
--                          cute: _BByx_dp_rel.
239
--
240
--  0020    13B23   MAM     Removed IF from first microword. Performs memory
241
--                          read cycle not required to fetch vector value from
242
--                          the reset vector.
243
--
244
--------------------------------------------------------------------------------
245
--  Comments
246
--------------------------------------------------------------------------------
247
--
248
--  The microprogram controller being targeted is the F9408A MPC. That control-
249
--  ler provides for sequential execution (FTCH), microroutine subroutines (RTS,
250
--  BSR), multi0way branching (BMW), unconditional externally controlled branch-
251
--  ing (BRV0, BRV1, BRV2, BRV3), and conditional branching using external test
252
--  inputs (BTL0, BTH0, BTL1, BTH1, BTL2, BTH2, BTL3, BTH3). Past use of this
253
--  controller has been focused on using the FTCH, BRV0, BSR, RTS, and BTL0/BTH0
254
--  as the basis of control. An external multiplexer controlled by the microword
255
--  and tied to the T0 test pin has been used for most tests. BRV0 has been used
256
--  in a conventional manner, and as such, it has only been used as an uncondi-
257
--  tional branch to a microprogram address supplied in the microword. No extra-
258
--  ordinary use of these basic control structures has been attempted.
259
--
260
--  With the program and data memory of the target, the M65C02 synthesizable
261
--  microprocessor/microcomputer, external to the core, there is a need to
262
--  implement a memory interface. From an implementation perspective, the exter-
263
--  nal memory interface would need to supply a ready signal so that the M65C02
264
--  logic can capture any input data into the instruction register, IR, one of
265
--  the two internal temporary operand registers, OP1 and OP2, or one of the
266
--  programmer-visible registers of the processor core: A, X, Y, P, or S.
267
--
268
--  If the direct approach to using the F9408A MPC is maintained, a number of
269
--  additional clock cycles will be added to each operation. A discrete logic
270
--  FSM approach for the processor core controller would branch to any number of
271
--  multiple states as needed to minimize the total number of cycles needed to
272
--  implement any instruction of the processor core. A microprogrammed approach
273
--  for implementing the processor core is the objective because it provides a
274
--  more flexible approach to the implementation, and provides an easier path to
275
--  upgrading the instruction set with additional instructions from the Rockwell
276
--  and the Western Design Center versions of the basic processor core. With an
277
--  F9408A MPC, a simple straight forward approach can be taken to the develop-
278
--  ment of the microprogrammed state machine. Without using external logic to
279
--  augment the operation of the F9408A, the resulting micoprogram can be limit-
280
--  ed to simple, single variable tests, which will result in the additional of
281
--  clock cycles to most operations/algorithms. This is not a limitation of the
282
--  F9408A MPC itself, or microprogramming in general, but of the application in
283
--  which the F9408A is included.
284
--
285
--  Mult-way branching in standard FSMs is natural, but is also one of the most
286
--  difficult design aspects of FSMs. Depending on the type of FSM being develp-
287
--  ed, implementing (area and speed) efficient state transition equations for
288
--  FSMs with many branches in many states is difficult and can be very diffi-
289
--  cult to test and debug. The same statement applies to microprogrammed state
290
--  machines, and is one reason why most MPCs have only a limited number of
291
--  instructions which support multi-way branching. However, microprogrammed
292
--  state machines are not limited by the architectural limitation imposed by
293
--  standard MPCs.
294
--
295
--  The M65C02 supports the reset trap, a non-maskable interrupt (NMI), a mask-
296
--  able interrupt, and the break instruction trap. In most cases, the two
297
--  interrupts are evaluated at the completion of each instruction. However, the
298
--  first instruction after one of these traps/interrupts is always executed. To
299
--  allow for this behavior to be easily implemented, BRV1 is used to initiate
300
--  the execution of a instruction regardless of the state of the NMI and/or IRQ
301
--  signals. BMW is used to test up to three signals and select the appropriate
302
--  action. Thus, most instructions will initiate the fetch of the next instruc-
303
--  tion by terminating their execution with BMW. Using a 2-way table, the BMW
304
--  will either complete the execution of the current instruction and the fetch
305
--  of the next instruction's opcode, or it will branch into the interrupt/traps
306
--  handler microroutine. Single cycle instructions will use BRV3 for the same
307
--  purpose, but implemented in a different manner. The next state for BMW is
308
--  either BRV1 or BRV2. BRV1 is used to complete the execution of the current
309
--  instruction and fetch the next instruction's opcode. BRV2 is used to capture
310
--  the interrupt vector and complete the execution of the current instruction.
311
--  Both the IRQ/NMI trap handler and the BRK handler start with a BRV2 instruc-
312
--  tion, which completes the current instruction and captures the PC. The BRV3
313
--  MPC operation performs the same function as BRV1, but the next state is
314
--  either the first state of the next instruction or the IRQ/NMI trap micro-
315
--  routine, which capture's the current instruction PC with BRV2.
316
--
317
--  The microprogram behavior is based on two assumptions: (1) external memory
318
--  is of a type in which the read data available is related to the address pre-
319
--  sented during the cycle, i.e. asynchronous, no-wait state RAM; and (2) the
320
--  PC control field causes the modification of the PC for the next clock cycle.
321
--  With these two assumptions, the microprogram starts with an unconditional
322
--  jump to a 2-way jump table which initiates the fetch of an instruction op-
323
--  code from memory, or vectors to the microprogram's interrupt handler. The
324
--  BRV1 instruction is used to capture and decode using ROM/RAM the fetched op-
325
--  code. The opcode is used directly as it is being read from memory to provide
326
--  to address a 256-way branch table in the microprogram ROM, and simultaneous-
327
--  ly a second decode ROM/RAM that provides the fixed portion of each instruc-
328
--  tions operation. That is, the 256-way instruction decoder built into
329
--  the microprogram ROM is the decoder for the variable microprogram, and the
330
--  second ROM is the decoder for the fixed microword. The variable micropro-
331
--  gram implements the control sequences necessary for an instruction from the
332
--  perspective of the addressing mode of the instruction, and the fixed micro-
333
--  program word defines the ALU operation to be performed when all operands are
334
--  available. The fixed microword is applied to the ALU under control of the
335
--  microprogram. Altogether, the number of bits required is 32 for the variable
336
--  microwords, and 24 for the fixed microword, or 56 bits total. (An additional
337
--  8 bits are included in the fixed microword, but they are simply reserved for
338
--  future use should that be required.) For debugging purposes, the opcode is
339
--  also loaded into the Instruction Register (IR), but it's not required.
340
--
341
--  Following the initial word at address 0, there are 31 microwords reserved
342
--  for future use. The intended use of these 31 locations is as a microprogram
343
--  bootloader for the remainder of the microprogram microstore, and for the
344
--  fixed instruction decoder ROM. Thus, at some future date, it may be possible
345
--  to update the microprogram ROMs dynamically from external memory or a serial
346
--  port.
347
--
348
--  The 2-way jump table, which is the target of the first unconditional branch,
349
--  is has two locations which are expected to be accessed by a BMW instruction.
350
--  The first location is labeled as _Nxt to signify that it is the fetch cycle
351
--  for the next opcode. The second location is used to initiate the interrupt
352
--  handler in the event that the external INT signal is asserted. An external
353
--  interrupt handler is expected to determine if an NMI or unmasked IRQ inter-
354
--  rupt should be taken. If INT is asserted, then the BRV2 instruction in the
355
--  second location of the jump table will capture the interrupt vector and jump
356
--  to the microprogram's interrupt handler.
357
--
358
--  Following the jump table are microroutines for handling specific instruc-
359
--  tions, or for handling specific addressing modes. The most significant 256
360
--  locations in the microprogram ROM/RAM constitute the initial microstate for
361
--  each of the 256 possible instruction opcodes. In the present implementation
362
--  only 177/178 of these instructions represent valid instructions. The remain-
363
--  der are executed as NOPs, and are reserved for future use. (The Rockwell
364
--  extensions use an additonal 32 of the opcodes, leaving 46 opcodes undefined.
365
--  Western Design Center uses all 256 of the opcodes to implement the 16-bit
366
--  W65C816 processor, which also provides an emulation of the 8-bit W65C02.)
367
--
368
--  A second 2-way jump table is included specifically for the RMW instructions.
369
--  The purpose of the microword with the BRV1 instruction is to complete the
370
--  execution of the current instruction, and simultaneously to fetch and decode
371
--  the next instruction. For most instructions, the ALU operation is performed
372
--  during in a terminal microstate with a BRV1 instruction which has Done and
373
--  Reg_WE asserted. For RMW instructions, the ALU operation initiated by the
374
--  Reg_WE control field occurs before the write back to memory of the computed
375
--  result. To use a BMW instruction to jump to the same 2-way jump table used
376
--  for RO or WO multicycle instructions may result in the M65C02 registers,
377
--  including the PSW, being written twice during a cycle. To avoid this issue,
378
--  a second BRV1, BRV2 2-way jump accessed by a BMW instruction is used for the
379
--  RMW instructions. The BRV1 microstate in the RMW jump table does not assert
380
--  Reg_WE. This allows a RMW instruction to complete in the same manner as
381
--  other multicycle instructions, and prevents any of the registers from being
382
--  written more than once per instruction cycle.
383
--
384
--  In implementing the microroutines, no attempt was made to combine the micro-
385
--  routines for various addressing modes such as Pre-Indexed and Post-Indexed
386
--  Data Page or Absolute that yield the same result. Therefore, the bit in the
387
--  fixed microword which previously identified the index register used by a
388
--  specific opcode has been reused for other purposes. The result of this opti-
389
--  mization is that all of the indexed addressing modes require separate micro-
390
--  routines for correct implementation. All that being the case, the implemen-
391
--  tation of the M65C02 microprogram uses only 256 microwords for instruction
392
--  decode, and an additional 79 microwords to implement the complete micropro-
393
--  gram. Therefore, there remain 177 microwords with which to implement addi-
394
--  tional instructions or capabilities such as bootloading the microprogram
395
--  memory. The current implementation uses approximately 1.88 microwords per
396
--  instruction, and this includes the 78 unimplemented/unused opcodes which the
397
--  M65C02 implements as NOPs. If those opcodes are not included, then a total
398
--  of 257 states, 178 + 79, are used to implement the M65C02 microprogram, or
399
--  1.444 microwords per instruction. The number of microstates per instruction
400
--  are a good measure of the efficiency of the implementation. For virtually
401
--  all instructions, the M65C02, due to its pipelined implementation, saves at
402
--  least one cycle per instruction when compared to the W65C02, R65C02, or the
403
--  original MOS6502 implementations.
404
--
405
--  The test program used for diagnostics and proofing of the implementation is
406
--  averaging 1.88 clock cycles per instruction. This is an improvement of more
407
--  than 40% over a standard implementation of the 6502 instruction set.
408
--
409
--------------------------------------------------------------------------------
410
--------------------------------------------------------------------------------
411
--  Forked from M65C02_uPgm_V3
412
--------------------------------------------------------------------------------
413
--------------------------------------------------------------------------------
414
--
415
--  No changes were implemented to the structure of the microwords in the basic
416
--  microprogram to accomodated the new M65C02_MPCv3 microprogram controller.
417
--  Instead, external changes to the M65C02_Core module allowed several of the
418
--  original fields to be redefined. In redefining the fields, the widths were
419
--  not changed and neither were their location in the microword. The single bit
420
--  Wait field, bit 18, was redefined as the ZP field. The single bit SC and
421
--  Done fields, bit 17 and 16, respectively, were redefined as the uLen[1:0]
422
--  field. In the previous implementation, SC and Done were used as a two bit
423
--  field, so replacing them with the uLen field is direct drop-in replacement.
424
--
425
--  Version three of the MPC uses dynamic microcycle length control to stretch
426
--  the microcycle of the M65C02 core. Microcycle length extension is required
427
--  when a BCD mode ADC/SBC is performed. Microcycle length extension may also
428
--  be required to access various types of memory.
429
--
430
--  The new MemTyp[1:0] field is expected to be used to let external logic know
431
--  the type of memory cycle that is being performed: program memory fetch, zero
432
--  page access, stack page access, or data memory access. The intent is for the
433
--  microprogram to let a memory controller external to the core know what the
434
--  next memory cycle will so that the memory controller can select between LUT
435
--  RAM (zero page), block RAM (stack page and internal program/data memory), or
436
--  external memory. Alternatively, this field can be reconfigured to directly
437
--  control the length of the next microcycle.
438
--
439
--  In general, it is expected that the MemTyp[1:0] field will directly connect
440
--  to a memory controller external to the MPC. That memory controller will set
441
--  the uLen[1:0] input of the core to control the microcycle controller of the
442
--  MPC. The current architecture of the address generator in the core makes it
443
--  difficult to use AO to determine whether the memory is internal or external.
444
--  However, the microprogram does "know" what memory type is being addressed
445
--  next. Thus, the microprogram can inform an external memory controller
446
--  whether page 0, page 1, or program/data memory is to be accessed next. Since
447
--  this data is only available to the microprogram, the MemTyp field can be
448
--  used by an memory controller outside of the core to implement address detec-
449
--  tion in a later state of the memory access cycle to dynamically change from
450
--  1 cycle distributed RAM (page 0), to 2 cycle block RAM memory with 0 wait
451
--  states (page 1 and internal program/data memory), or 4 cycle memory with
452
--  external wait state insertion (external program/data memory).
453
--
454
--------------------------------------------------------------------------------
455
--------------------------------------------------------------------------------
456
--
457
--------------------------------------------------------------------------------
458
-- F9408A Instruction definitions
459
--------------------------------------------------------------------------------
460
 
461
RTS         .asm    0       -- Return from Subroutine
462
BSR         .asm    1       -- Branch to subroutine
463
FTCH        .asm    2       -- Fetch next instruction
464
BMW         .asm    3       -- Branch multi-way
465
BRV0        .asm    4       -- Branch via 0
466
BRV1        .asm    5       -- Branch via 1
467
BRV2        .asm    6       -- Branch via 2
468
BRV3        .asm    7       -- Branch via 3
469
BTH0        .asm    8       -- Branch if T0 is high
470
BTH1        .asm    9       -- Branch if T1 is high
471
BTH2        .asm    10      -- Branch if T2 is high
472
BTH3        .asm    11      -- Branch if T3 is high
473
BTL0        .asm    12      -- Branch if T0 is low
474
BTL1        .asm    13      -- Branch if T1 is low
475
BTL2        .asm    14      -- Branch if T2 is low
476
BTL3        .asm    15      -- Branch if T3 is low
477
 
478
--------------------------------------------------------------------------------
479
-- ROM ( output ) Field definitions
480
--------------------------------------------------------------------------------
481
 
482
Inst        .def    4       -- Instruction
483
BA          .def    9       -- Branch Address
484
ZP          .def    1       -- Force mod 256 Address Calculation
485
MemTyp      .def    2       -- Memory Access Type Control Field
486
NA_Cntl     .def    4       -- Next Address Control Field
487
PC_Cntl     .def    2       -- Program Counter Control Field
488
IO_Cntl     .def    2       -- I/O Cycle Control Field
489
DIO_Cntl    .def    2       -- Data Input/Output Demux/Mux Control Field
490
Stk_Cntl    .def    2       -- ALU Stack Pointer Control Field
491
RegWE_Cntl  .def    3       -- Register Write Enable (A, X, Y, S, P)
492
PSW_Cntl    .def    1       -- Asserted to Clear D and Set I in PSW
493
 
494
--------------------------------------------------------------------------------
495
-- Constant definitions
496
--------------------------------------------------------------------------------
497
 
498
--  Next Address Control Definitions
499
 
500
PC          .equ    0       -- NA <= PC (default)
501
Inc         .equ    1       -- NA <= PC  + 1
502
MAR         .equ    2       -- NA <= MAR + 0
503
Nxt         .equ    3       -- NA <= MAR + 1
504
Stk         .equ    4       -- NA <= SP  + 0
505
DPN         .equ    5       -- NA <= {  0, OP1} + 0
506
DPX         .equ    6       -- NA <= {  0, OP1} + {0, X}
507
DPY         .equ    7       -- NA <= {  0, OP1} + {0, Y}
508
LDA         .equ    8       -- NA <= {OP2, OP1} + 0
509
LDAX        .equ    14      -- NA <= {OP2, OP1} + {0, X}
510
LDAY        .equ    15      -- NA <= {OP2, OP1} + {0, Y}
511
 
512
--  Program Counter Control Field
513
 
514
Pls         .equ    1       -- PC <= PC + 1
515
Jmp         .equ    2       -- PC <= NA
516
Rel         .equ    3       -- PC <= PC + (CC ? {{8{DI[7]}}, DI} : 1)
517
 
518
--  Bus Interface Unit Definitions
519
 
520
WR          .equ    1       -- Bus Operand Write
521
RD          .equ    2       -- Bus Operand Read
522
IF          .equ    3       -- Bus Insruction Fetch
523
 
524
--  Memory Data Input Demultiplexer Definitions
525
 
526
ALU         .equ    0       -- M   <= DI
527
OP2         .equ    1       -- OP2 <= DI
528
OP1         .equ    2       -- OP1 <= DI
529
IR          .equ    3       -- IR  <= DI
530
 
531
--  Memory Data Output Multiplexer Definitions
532
 
533
--ALU         .equ    0       -- DO  <= Out
534
PCH         .equ    1       -- DO  <= PCH
535
PCL         .equ    2       -- DO  <= PCL
536
PSW         .equ    3       -- DO  <= PSW (P)
537
 
538
--  ALU Stack Operation Definitions
539
 
540
Psh         .equ    2       -- S <= S - 1
541
Pop         .equ    3       -- S <= S + 1
542
 
543
--  Register Write Enable Control Field Definitions
544
 
545
WE_A        .equ    1       -- Write Enable A
546
WE_X        .equ    2       -- Write Enable X
547
WE_Y        .equ    3       -- Write Enable Y
548
WE_R        .equ    4       -- Write Enable Register - write selected register
549
WE_S        .equ    5       -- Write Enable S
550
WE_P        .equ    6       -- Write Enable P
551
WE_M        .equ    7       -- Write Enable M(emory)
552
 
553
--  Miscellaneous Control Field Definitions
554
 
555
ISR         .equ    1       -- Assert ISR: Clear D, Set I
556
 
557
--------------------------------------------------------------------------------
558
--
559
--  Microprogram Controller Resources
560
--
561
--  T[0]    -   Valid - ALU Operation Complete/Done
562
--  T[1]    -   Unused
563
--  T[2]    -   Unused
564
--  T[3]    -   Unused
565
--
566
--  Via[0]  -   BA, but also waits for the completion of a memory or ALU cycle
567
--  Via[1]  -   Instruction Decoder, effectively functions as a 256 way branch
568
--  Via[2]  -   Samples Vector and loads it into {OP2, OP1}
569
--  Via[3]  -   Instruction Decoder with branch to Interrupt Handler, _Int
570
--
571
--  MW[2:0] -   MW[2] - uP_BA[2]; MW[1] - uP_BA[1]; MW[0] - Int;
572
--
573
--   xx0    -   Instruction Fetch
574
--   xx1    -   Interrupt Trap
575
--
576
--------------------------------------------------------------------------------
577
-- MAM6502 Microprogram Start
578
--------------------------------------------------------------------------------
579
 
580
--  I   BA, Wt, En, NA, PC, IO, DI, SP, Reg_WE, ISR
581
 
582
_Start: .org    0
583
    BRV2    _Rst,0,1                            -- Load {OP2, OP1} with Vector
584
_Rst:
585
    FTCH    $,0,1, LDA,, RD, OP1                -- Read Indirect Dst Ptr Lo
586
    FTCH    $,0,1, Nxt, Jmp, RD, OP2            -- Read Indirect Dst Ptr Hi
587
--
588
    BRV1    $,0,1,, Pls, IF, IR                 -- Instruction Fetch
589
 
590
--  this space reserved for future use - boot loader for the microprogram ROMs
591
 
592
--------------------------------------------------------------------------------
593
--------------------------------------------------------------------------------
594
-- 2-Way Jump Table: _Nxt and _Int
595
--------------------------------------------------------------------------------
596
--------------------------------------------------------------------------------
597
-- Instruction Fetch and Execute Microstate
598
--------------------------------------------------------------------------------
599
 
600
_Nxt:   .org    32
601
_Psh:
602
_Pop:
603
_Rel:
604
_Imm:
605
    BRV1    _Nxt,0,1,, Pls, IF, IR,, WE_R           -- Instruction Fetch/Execute
606
 
607
--------------------------------------------------------------------------------
608
--  Interrupt Entry - NMI, (unmasked) IRQ (falls through to second state of BRK)
609
--------------------------------------------------------------------------------
610
 
611
_Int:
612
    BRV2    _Brk,0,1, Stk,, WR, PCH, Psh, WE_R      -- Push PCH, capture Vector
613
 
614
--------------------------------------------------------------------------------
615
--  BRK Entry - BRK #imm (_Int falls through to _Brk, see comment above)
616
--------------------------------------------------------------------------------
617
 
618
_Brk:
619
    FTCH    $,0,1, Stk,, WR, PCL, Psh               -- Push PCL
620
    FTCH    $,0,1, Stk, Jmp, WR, PSW, Psh,, ISR     -- Push P; Clr D, Set I
621
--
622
    FTCH    $,0,1, LDA,, RD, OP1                    -- Read Indirect Dst Ptr Lo
623
    FTCH    $,0,1, Nxt, Jmp, RD, OP2                -- Read Indirect Dst Ptr Hi
624
--
625
    BRV1    $,0,1,, Pls, IF, IR                     -- Instruction Fetch
626
 
627
--------------------------------------------------------------------------------
628
--  Jump To Subroutine - JSR Abs                    (Not interruptable)
629
--------------------------------------------------------------------------------
630
 
631
_JSR:
632
    FTCH    $,0,1,,, IF, OP2                        -- Load Indirect Dst Ptr Hi
633
    FTCH    $,0,1, Stk,, WR, PCH, Psh               -- Push PC Hi
634
    BRV0    _Nxt,0,1, Stk, Jmp, WR, PCL, Psh        -- Push PC Lo
635
 
636
--------------------------------------------------------------------------------
637
--  Return from Interrupt - RTI                     (Not interruptable)
638
--------------------------------------------------------------------------------
639
 
640
_RTI:
641
    FTCH    $,0,1, Stk,, RD, OP1, Pop, WE_P         -- Pop PCL
642
    FTCH    $,0,1, Stk, Jmp, RD, OP2, Pop           -- Pop PCH
643
--
644
    BRV1    $,0,1,, Pls, IF, IR                     -- Next, no Reg_WE, P okay
645
 
646
--------------------------------------------------------------------------------
647
--  Return From Subroutine - RTS                    (Not interruptable)
648
--------------------------------------------------------------------------------
649
 
650
_RTS:
651
    BRV0    _Nxt,0,1, Stk, Jmp, RD, OP2, Pop        -- Pop PCH
652
 
653
--------------------------------------------------------------------------------
654
--  Jump Absolute - JMP  Abs                        (Not interruptable)
655
--------------------------------------------------------------------------------
656
 
657
_Jmp:
658
    BRV0    _Nxt,0,1,, Jmp, IF, OP2
659
 
660
--------------------------------------------------------------------------------
661
--  Jump Indirect - JMP (Abs)                       (Not interruptable)
662
--------------------------------------------------------------------------------
663
 
664
_JmpI:
665
    FTCH    $,0,1,, Pls, IF, OP2                    -- Load Indirect Dst Ptr Lo
666
    FTCH    $,0,1, LDA,, RD, OP1                    -- Read Indirect Dst Ptr Hi
667
    BRV0    _Nxt,0,1, Nxt, Jmp, RD, OP2             -- Goto Next
668
 
669
--------------------------------------------------------------------------------
670
--  Jump Pre-Indexed Indirect - JMP (Abs, X)       (Not interruptable)
671
--------------------------------------------------------------------------------
672
 
673
_JmpXI:
674
    FTCH    $,0,1,, Pls, IF, OP2                    -- Load Indirect Dst Ptr Lo
675
    FTCH    $,0,1, LDAX,, RD, OP1                   -- Read Indirect Dst Ptr Hi
676
    BRV0    _Nxt,0,1, Nxt, Jmp, RD, OP2             -- Goto Next
677
 
678
--------------------------------------------------------------------------------
679
--  Memory Read-Only Data Page Direct - xxx DP
680
--------------------------------------------------------------------------------
681
 
682
_RO_DP:
683
    BMW     _Nxt,1,1, DPN,, RD, OP1                     -- Read DP Mem
684
 
685
-----------------------------------------------------------------------------
686
--  Memory Read-Only Pre-Indexed Data Page Direct - xxx DP, X
687
--------------------------------------------------------------------------------
688
 
689
_RO_DPX:
690
    BMW     _Nxt,1,1, DPX,, RD, OP1                     -- Read DP Mem
691
 
692
--------------------------------------------------------------------------------
693
--  Memory Read-Only Post-Indexed Data Page Direct - xxx DP, Y
694
--------------------------------------------------------------------------------
695
 
696
_RO_DPY:
697
    BMW     _Nxt,1,1, DPY,, RD, OP1                     -- Read DP Mem
698
 
699
------------------------------------------------------------------------------
700
--  Memory Read-Only Data Page Indirect - xxx (DP)
701
--------------------------------------------------------------------------------
702
 
703
_RO_DPI:
704
    FTCH    $,1,1, DPN,, RD, OP1                        -- Read DP Mem Ptr Lo
705
    FTCH    $,1,1, Nxt,, RD, OP2                        -- Read DP Mem Ptr Hi
706
    BMW     _Nxt,0,1, LDA,, RD, OP1                     -- Read Operand
707
 
708
--------------------------------------------------------------------------------
709
--  Memory Read-Only Pre-Indexed Data Page Indirect - xxx (DP, X)
710
--------------------------------------------------------------------------------
711
 
712
_RO_DPXI:
713
    FTCH    $,1,1, DPX,, RD, OP1                    -- Read DP Mem Ptr Lo (DP,X)
714
    FTCH    $,1,1, Nxt,, RD, OP2                        -- Read DP Mem Ptr Hi
715
    BMW     _Nxt,0,1, LDA,, RD, OP1                     -- Read Operand
716
 
717
--------------------------------------------------------------------------------
718
--  Memory Read-Only Post-Indexed Data Page Indirect - xxx (DP), Y
719
--------------------------------------------------------------------------------
720
 
721
_RO_DPIY:
722
    FTCH    $,1,1, DPN,, RD, OP1                        -- Read DP Mem Ptr Lo
723
    FTCH    $,1,1, Nxt,, RD, OP2                        -- Read DP Mem Ptr Hi
724
    BMW     _Nxt,0,1, LDAY,, RD, OP1                    -- Read Operand (DP),Y
725
 
726
--------------------------------------------------------------------------------
727
--  Memory Read-Only Absolute - xxx Abs
728
--------------------------------------------------------------------------------
729
 
730
_RO_Abs:
731
    FTCH    $,0,1,, Pls, IF, OP2                        -- Read Mem Ptr Hi
732
    BMW     _Nxt,0,1, LDA,, RD, OP1                     -- Read Operand
733
 
734
--------------------------------------------------------------------------------
735
--  Memory Read-Only Pre-Indexed Absolute - xxx Abs, X
736
--------------------------------------------------------------------------------
737
 
738
_RO_AbsX:
739
    FTCH    $,0,1,, Pls, IF, OP2                        -- Read Mem Ptr Hi
740
    BMW     _Nxt,0,1, LDAX,, RD, OP1                    -- Read Operand Abs,X
741
 
742
--------------------------------------------------------------------------------
743
--  Memory Read-Only Post-Indexed Absolute - xxx Abs, Y
744
--------------------------------------------------------------------------------
745
 
746
_RO_AbsY:
747
    FTCH    $,0,1,, Pls, IF, OP2                        -- Read Mem Ptr Hi
748
    BMW     _Nxt,0,1, LDAY,, RD, OP1                    -- Read Operand Abs,Y
749
 
750
--------------------------------------------------------------------------------
751
--  Memory Write-Only Data Page Direct - xxx DP
752
--------------------------------------------------------------------------------
753
 
754
_WO_DP:
755
    BMW     _Nxt,1,1, DPN,, WR                          -- Write to DP
756
 
757
-----------------------------------------------------------------------------
758
--  Memory Write-Only Pre-Indexed Data Page Direct - xxx DP, X
759
--------------------------------------------------------------------------------
760
 
761
_WO_DPX:
762
    BMW    _Nxt,1,1, DPX,, WR                          -- Write to DP,X
763
 
764
-----------------------------------------------------------------------------
765
--  Memory Write-Only Post-Indexed Data Page Direct - xxx DP, Y
766
--------------------------------------------------------------------------------
767
 
768
_WO_DPY:
769
    BMW     _Nxt,1,1, DPY,, WR                          -- Write to DP,Y
770
 
771
--------------------------------------------------------------------------------
772
--  Memory Write-Only Data Page Indirect - xxx (DP)
773
--------------------------------------------------------------------------------
774
 
775
_WO_DPI:
776
    FTCH    $,1,1, DPN,, RD, OP1                        -- Read DP Mem Ptr Lo
777
    FTCH    $,1,1, Nxt,, RD, OP2                        -- Read DP Mem Ptr Hi
778
    BMW     _Nxt,0,1, LDA,, WR                          -- Write to (DP)
779
 
780
--------------------------------------------------------------------------------
781
--  Memory Write-Only Data Page Indirect - xxx (DP, X)
782
--------------------------------------------------------------------------------
783
 
784
_WO_DPXI:
785
    FTCH    $,1,1, DPX,, RD, OP1                        -- Read DP Mem Ptr Lo
786
    FTCH    $,1,1, Nxt,, RD, OP2                        -- Read DP Mem Ptr Hi
787
    BMW     _Nxt,0,1, LDA,, WR                          -- Write to (DP)
788
 
789
--------------------------------------------------------------------------------
790
--  Memory Write-Only Post-Indexed Data Page Indirect - xxx (DP), Y
791
--------------------------------------------------------------------------------
792
 
793
_WO_DPIY:
794
    FTCH    $,1,1, DPN,, RD, OP1                        -- Read DP Mem Ptr Lo
795
    FTCH    $,1,1, Nxt,, RD, OP2                        -- Read DP Mem Ptr Hi
796
    BMW     _Nxt,0,1, LDAY,, WR                         -- Write to (DP)
797
 
798
--------------------------------------------------------------------------------
799
--  Memory Write-Only Absolute - xxx Abs
800
--------------------------------------------------------------------------------
801
 
802
_WO_Abs:
803
    FTCH    $,0,1,, Pls, IF, OP2                        -- Read Mem Ptr Hi
804
    BMW     _Nxt,0,1, LDA,, WR                          -- Write to Abs
805
 
806
--------------------------------------------------------------------------------
807
--  Memory Write-Only Pre-Indexed Absolute - xxx Abs, X
808
--------------------------------------------------------------------------------
809
 
810
_WO_AbsX:
811
    FTCH    $,0,1,, Pls, IF, OP2                        -- Read Mem Ptr Hi
812
    BMW     _Nxt,0,1, LDAX,, WR                         -- Write to Abs,X
813
 
814
--------------------------------------------------------------------------------
815
--  Memory Write-Only Post-Indexed Absolute - xxx Abs, Y
816
--------------------------------------------------------------------------------
817
 
818
_WO_AbsY:
819
    FTCH    $,0,1,, Pls, IF, OP2                        -- Read Mem Ptr Hi
820
    BMW     _Nxt,0,1, LDAY,, WR                         -- Write to Abs,Y
821
 
822
--------------------------------------------------------------------------------
823
--  2-way Read-Modify-Write Instruction/Interrupt Jump Table
824
--------------------------------------------------------------------------------
825
 
826
_RMW:       .org    96
827
    BRV1    _RMW,0,1,, Pls, IF, IR                  -- Instruction Fetch/Execute
828
    BRV2    _Brk,0,1, Stk, , WR, PCH, Psh           -- Push PCH, capture Vector
829
 
830
--------------------------------------------------------------------------------
831
--  Memory Read-Modify-Write Data Page Direct - xxx DP
832
--------------------------------------------------------------------------------
833
 
834
_RMW_DP:
835
    FTCH    $,1,1, DPN,, RD, OP1                        -- Read from DP
836
    BMW     _RMW,1,1, MAR,, WR,,,WE_R                   -- Write to DP
837
 
838
--------------------------------------------------------------------------------
839
--  Memory Read-Modify-Write Pre-Indexed Data Page Direct - xxx DP, X
840
--------------------------------------------------------------------------------
841
 
842
_RMW_DPX:
843
    FTCH    $,1,1, DPX,, RD, OP1                        -- Read from DP,X
844
    BMW     _RMW,1,1, MAR,, WR,,,WE_R                   -- Write to DP,X
845
 
846
--------------------------------------------------------------------------------
847
--  Memory Read-Modify-Write Post-Indexed Data Page Direct - xxx DP, Y
848
--------------------------------------------------------------------------------
849
 
850
_RMW_DPY:
851
    FTCH    $,1,1, DPY,, RD, OP1                        -- Read from DP,Y
852
    BMW     _RMW,1,1, MAR,, WR,,,WE_R                   -- Write to DP,Y
853
 
854
--------------------------------------------------------------------------------
855
--  Memory Read-Modify-Write Absolute - xxx Abs
856
--------------------------------------------------------------------------------
857
 
858
_RMW_Abs:
859
    FTCH    $,0,1,, Pls, IF, OP2                        -- Read Mem Ptr Hi
860
    FTCH    $,0,1, LDA,, RD, OP1                        -- Read from Abs
861
    BMW     _RMW,0,1, MAR,, WR,,,WE_R                   -- Write to Abs
862
 
863
--------------------------------------------------------------------------------
864
--  Memory Read-Modify-Write Pre-Indexed Absolute - xxx Abs, X
865
--------------------------------------------------------------------------------
866
 
867
_RMW_AbsX:
868
    FTCH    $,0,1,, Pls, IF, OP2                        -- Read Mem Ptr Hi
869
    FTCH    $,0,1, LDAX,, RD, OP1                       -- Read from Abs,X
870
    BMW     _RMW,0,1, MAR,, WR,,,WE_R                   -- Write to Abs,X
871
 
872
--------------------------------------------------------------------------------
873
--  Memory Read-Modify-Write Post-Indexed Absolute - xxx Abs, Y
874
--------------------------------------------------------------------------------
875
 
876
_RMW_AbsY:
877
    FTCH    $,0,1,, Pls, IF, OP2                        -- Read Mem Ptr Hi
878
    FTCH    $,0,1, LDAY,, RD, OP1                       -- Read from Abs,Y
879
    BMW     _RMW,0,1, MAR,, WR,,,WE_R                   -- Write to Abs,Y
880
 
881
--------------------------------------------------------------------------------
882
--  Rockwell BBRx/BBSx dp,rel instructions
883
--------------------------------------------------------------------------------
884
 
885
_BByx_dp_rel:
886
    FTCH    $,1,1, DPN,, RD, OP1                        -- Read from DP
887
    BRV0    _Nxt,0,1,, Rel, IF, OP1                     -- Read rel value
888
 
889
--------------------------------------------------------------------------------
890
--  End of Microprogram Routines for Normal Instructions
891
--------------------------------------------------------------------------------
892
 
893
_End_uPgm:
894
 
895
--------------------------------------------------------------------------------
896
--  WAI - Wait for Interrupt
897
--------------------------------------------------------------------------------
898
 
899
_WAI:       .org    252     -- Set up 4-way table for WAI instruction
900
    BMW     _WAI,0,1        -- No external interrupts asserted
901
    BRV0    _Int,0,1        -- Int asserted by NMI, do NMI interrupt
902
    BRV0    _Nxt,0,1        -- xIRQ asserted with IRQ_Msk asserted, continue
903
    BRV0    _Int,0,1        -- Int asserted by xIRQ, do IRQ interrupt
904
 
905
_IDEC_Start:    .org    256
906
 
907
--------------------------------------------------------------------------------
908
--  Start of Instruction Decode Table (Entry for each Opcode)
909
--
910
--  Instead of being organized in numerical order, the table is organized by
911
--  rows: the least significant nibble and the most significant nibble of the
912
--  opcode are swapped. This organization more clearly shows the arrangement of
913
--  the addressing modes of the WDC W65C02 microprocessor being emulated. It al-
914
--  so more clearly shows the regularity of the ALU instructions that are imple-
915
--  mented. The implementation of the microprogram is first based on the addres-
916
--  sing mode, and then on the ALU function. Single cycle instructions will be
917
--  easily recognized in the following table because their table entry use the
918
--  BRV3 MPC instruction. Multi-cycle instructions use the BRV0 MPC instruction
919
--  to vector a microroutine in the lower 256 words of the microprogram ROM/RAM.
920
--  Single byte instructions such as BRK, RTS, RTI, and register push/pull in-
921
--  structions (PHA, PLA, PHP, PLP, PHX, PLX, PHY, PLY), and multi-byte instruc-
922
--  tions like JSR abs are implemented with special microroutines that perform
923
--  the necessary stack accesses. The remainder of the microroutines are orga-
924
--  nized by addressing mode, and whether the mode is used in a RO, WO, or RMW
925
--  manner.
926
--
927
--  Microprogram Word Format:
928
--
929
--  I   BA, Wt, En, NA, PC, IO, DI, SP, Reg_WE, ISR
930
--
931
--------------------------------------------------------------------------------
932
 
933
--------------------------------------------------------------------------------
934
--  Row 0 : 0x00-0xF0 (All Bcc/JMP/JSR/RTS/RTI implemented as uninterruptable)
935
--  I   BA, Wt, En, NA, PC, IO, DI, SP, Reg_WE, ISR
936
--------------------------------------------------------------------------------
937
_BRK_imm:
938
    BRV2    _Brk,0,1, Stk,, WR, PCH, Psh, WE_P      -- Start Break Handler
939
_BPL_rel:
940
    BRV0    _Rel,0,1,, Rel, IF, OP1                 -- Read rel Value
941
_JSR_abs:
942
    BRV0    _JSR,0,1,, Pls, IF, OP1                 -- Read Dst Ptr Lo
943
_BMI_rel:
944
    BRV0    _Rel,0,1,, Rel, IF, OP1                 -- Read rel Value
945
_RTI_imp:
946
    BRV0    _RTI,0,1, Stk,, RD, OP1, Pop            -- Read PSW from Stack
947
_BVC_rel:
948
    BRV0    _Rel,0,1,, Rel, IF, OP1                 -- Read rel Value
949
_RTS_imp:
950
    BRV0    _RTS,0,1, Stk,, RD, OP1, Pop            -- Read PCL from Stack
951
_BVS_rel:
952
    BRV0    _Rel,0,1,, Rel, IF, OP1                 -- Read rel Value
953
_BRA_rel:
954
    BRV0    _Rel,0,1,, Rel, IF, OP1                 -- Read rel Value
955
_BCC_rel
956
    BRV0    _Rel,0,1,, Rel, IF, OP1                 -- Read rel Value
957
_LDY_imm:
958
    BMW     _Imm,0,1,, Pls, IF, OP1                 -- Read #imm Value
959
_BCS_rel:
960
    BRV0    _Rel,0,1,, Rel, IF, OP1                 -- Read rel Value
961
_CPY_imm:
962
    BMW     _Imm,0,1,, Pls, IF, OP1                 -- Read #imm Value
963
_BNE_rel:
964
    BRV0    _Rel,0,1,, Rel, IF, OP1                 -- Read rel Value
965
_CPX_imm:
966
    BMW     _Imm,0,1,, Pls, IF, OP1                 -- Read #imm Value
967
_BEQ_rel:
968
    BRV0    _Rel,0,1,, Rel, IF, OP1                 -- Read rel Value
969
--------------------------------------------------------------------------------
970
-- Row 1 : 0x01-0xF1
971
--  I   BA, Wt, En, NA, PC, IO, DI, SP, Reg_WE, ISR
972
--------------------------------------------------------------------------------
973
_ORA_dpXi:
974
    BRV0    _RO_DPXI,0,1,, Pls, IF, OP1             -- Read DP Ptr
975
_ORA_dpiY:
976
    BRV0    _RO_DPIY,0,1,, Pls, IF, OP1             -- Read DP Ptr
977
_AND_dpXi:
978
    BRV0    _RO_DPXI,0,1,, Pls, IF, OP1             -- Read DP Ptr
979
_AND_dpiY:
980
    BRV0    _RO_DPIY,0,1,, Pls, IF, OP1             -- Read DP Ptr
981
_EOR_dpXi:
982
    BRV0    _RO_DPXI,0,1,, Pls, IF, OP1             -- Read DP Ptr
983
_EOR_dpiY:
984
    BRV0    _RO_DPIY,0,1,, Pls, IF, OP1             -- Read DP Ptr
985
_ADC_dpXi:
986
    BRV0    _RO_DPXI,0,1,, Pls, IF, OP1             -- Read DP Ptr
987
_ADC_dpiY:
988
    BRV0    _RO_DPIY,0,1,, Pls, IF, OP1             -- Read DP Ptr
989
_STA_dpXi:
990
    BRV0    _WO_DPXI,0,1,, Pls, IF, OP1             -- Read DP Ptr
991
_STA_dpiY:
992
    BRV0    _WO_DPIY,0,1,, Pls, IF, OP1             -- Read DP Ptr
993
_LDA_dpXi:
994
    BRV0    _RO_DPXI,0,1,, Pls, IF, OP1             -- Read DP Ptr
995
_LDA_dpiY:
996
    BRV0    _RO_DPIY,0,1,, Pls, IF, OP1             -- Read DP Ptr
997
_CMP_dpXi:
998
    BRV0    _RO_DPXI,0,1,, Pls, IF, OP1             -- Read DP Ptr
999
_CMP_dpiY:
1000
    BRV0    _RO_DPIY,0,1,, Pls, IF, OP1             -- Read DP Ptr
1001
_SBC_dpXi:
1002
    BRV0    _RO_DPXI,0,1,, Pls, IF, OP1             -- Read DP Ptr
1003
_SBC_dpiY:
1004
    BRV0    _RO_DPIY,0,1,, Pls, IF, OP1             -- Read DP Ptr
1005
--------------------------------------------------------------------------------
1006
-- Row 2 : 0x02-0xF2
1007
--  I   BA, Wt, En, NA, PC, IO, DI, SP, Reg_WE, ISR
1008
--------------------------------------------------------------------------------
1009
_NOP_02:
1010
    BRV3    $,0,1,, Pls, IF, IR                     -- Skip Invalid Instruction
1011
_ORA_dpi:
1012
    BRV0    _RO_DPI,0,1,, Pls, IF, OP1              -- Read DP
1013
_NOP_22:
1014
    BRV3    $,0,1,, Pls, IF, IR                     -- Skip Invalid Instruction
1015
_AND_dpi:
1016
    BRV0    _RO_DPI,0,1,, Pls, IF, OP1              -- Read DP
1017
_NOP_42:
1018
    BRV3    $,0,1,, Pls, IF, IR                     -- Skip Invalid Instruction
1019
_EOR_dpi:
1020
    BRV0    _RO_DPI,0,1,, Pls, IF, OP1              -- Read DP
1021
_NOP_62:
1022
    BRV3    $,0,1,, Pls, IF, IR                     -- Skip Invalid Instruction
1023
_ADC_dpi:
1024
    BRV0    _RO_DPI,0,1,, Pls, IF, OP1              -- Read DP
1025
_NOP_82:
1026
    BRV3    $,0,1,, Pls, IF, IR                     -- Skip Invalid Instruction
1027
_STA_dpi:
1028
    BRV0    _WO_DPI,0,1,, Pls, IF, OP1              -- Read DP
1029
_LDX_imm:
1030
    BMW     _Imm,0,1,, Pls, IF, OP1                 -- Read #imm Value
1031
_LDA_dpi:
1032
    BRV0    _RO_DPI,0,1,, Pls, IF, OP1              -- Read DP
1033
_NOP_C2:
1034
    BRV3    $,0,1,, Pls, IF, IR                     -- Skip Invalid Instruction
1035
_CMP_dpi:
1036
    BRV0    _RO_DPI,0,1,, Pls, IF, OP1              -- Read DP
1037
_NOP_E2:
1038
    BRV3    $,0,1,, Pls, IF, IR                     -- Skip Invalid Instruction
1039
_SBC_dpi:
1040
    BRV0    _RO_DPI,0,1,, Pls, IF, OP1              -- Read DP
1041
--------------------------------------------------------------------------------
1042
-- Row 3 : 0x03-0xF3
1043
--  I   BA, Wt, En, NA, PC, IO, DI, SP, Reg_WE, ISR
1044
--------------------------------------------------------------------------------
1045
_NOP_03:
1046
    BRV3    $,0,1,, Pls, IF, IR                     -- Skip Invalid Instruction
1047
_NOP_13:
1048
    BRV3    $,0,1,, Pls, IF, IR                     -- Skip Invalid Instruction
1049
_NOP_23:
1050
    BRV3    $,0,1,, Pls, IF, IR                     -- Skip Invalid Instruction
1051
_NOP_33:
1052
    BRV3    $,0,1,, Pls, IF, IR                     -- Skip Invalid Instruction
1053
_NOP_43:
1054
    BRV3    $,0,1,, Pls, IF, IR                     -- Skip Invalid Instruction
1055
_NOP_53:
1056
    BRV3    $,0,1,, Pls, IF, IR                     -- Skip Invalid Instruction
1057
_NOP_63:
1058
    BRV3    $,0,1,, Pls, IF, IR                     -- Skip Invalid Instruction
1059
_NOP_73:
1060
    BRV3    $,0,1,, Pls, IF, IR                     -- Skip Invalid Instruction
1061
_NOP_83:
1062
    BRV3    $,0,1,, Pls, IF, IR                     -- Skip Invalid Instruction
1063
_NOP_93:
1064
    BRV3    $,0,1,, Pls, IF, IR                     -- Skip Invalid Instruction
1065
_NOP_A3:
1066
    BRV3    $,0,1,, Pls, IF, IR                     -- Skip Invalid Instruction
1067
_NOP_B3:
1068
    BRV3    $,0,1,, Pls, IF, IR                     -- Skip Invalid Instruction
1069
_NOP_C3:
1070
    BRV3    $,0,1,, Pls, IF, IR                     -- Skip Invalid Instruction
1071
_NOP_D3:
1072
    BRV3    $,0,1,, Pls, IF, IR                     -- Skip Invalid Instruction
1073
_NOP_E3:
1074
    BRV3    $,0,1,, Pls, IF, IR                     -- Skip Invalid Instruction
1075
_NOP_F3:
1076
    BRV3    $,0,1,, Pls, IF, IR                     -- Skip Invalid Instruction
1077
--------------------------------------------------------------------------------
1078
-- Row 4 : 0x04-0xF4
1079
--  I   BA, Wt, En, NA, PC, IO, DI, SP, Reg_WE, ISR
1080
--------------------------------------------------------------------------------
1081
_TSB_dp:
1082
    BRV0    _RMW_DP,0,1,, Pls, IF, OP1              -- Read DP
1083
_TRB_dp:
1084
    BRV0    _RMW_DP,0,1,, Pls, IF, OP1              -- Read DP
1085
_BIT_dp:
1086
    BRV0    _RO_DP,0,1,, Pls, IF, OP1               -- Read DP
1087
_BIT_dpX:
1088
    BRV0    _RO_DPX,0,1,, Pls, IF, OP1              -- Read DP
1089
_NOP_44:
1090
    BRV3    $,0,1,, Pls, IF, IR                     -- Skip Invalid Instruction
1091
_NOP_54:
1092
    BRV3    $,0,1,, Pls, IF, IR                     -- Skip Invalid Instruction
1093
_STZ_dp:
1094
    BRV0    _WO_DP,0,1,, Pls, IF, OP1               -- Read DP
1095
_STZ_dpX:
1096
    BRV0    _WO_DPX,0,1,, Pls, IF, OP1              -- Read DP
1097
_STY_dp:
1098
    BRV0    _WO_DP,0,1,, Pls, IF, OP1               -- Read DP
1099
_STY_dpX:
1100
    BRV0    _WO_DPX,0,1,, Pls, IR, OP1              -- Read DP
1101
_LDY_dp:
1102
    BRV0    _RO_DP,0,1,, Pls, IR, OP1               -- Read DP
1103
_LDY_dpX:
1104
    BRV0    _RO_DPX,0,1,, Pls, IF, OP1              -- Read DP
1105
_CPY_dp:
1106
    BRV0    _RO_DP,0,1,, Pls, IF, OP1               -- Read DP
1107
_NOP_D4:
1108
    BRV3    $,0,1,, Pls, IF, IR                     -- Skip Invalid Instruction
1109
_CPX_dp:
1110
    BRV0    _RO_DP,0,1,, Pls, IF, OP1               -- Read DP
1111
_NOP_F4:
1112
    BRV3    $,0,1,, Pls, IF, IR                     -- Skip Invalid Instruction
1113
--------------------------------------------------------------------------------
1114
-- Row 5 : 0x05-0xF5
1115
--  I   BA, Wt, En, NA, PC, IO, DI, SP, Reg_WE, ISR
1116
--------------------------------------------------------------------------------
1117
_ORA_dp:
1118
    BRV0    _RO_DP,0,1,, Pls, IF, OP1               -- Read DP
1119
_ORA_dpX:
1120
    BRV0    _RO_DPX,0,1,, Pls, IF, OP1              -- Read DP
1121
_AND_dp:
1122
    BRV0    _RO_DP,0,1,, Pls, IF, OP1               -- Read DP
1123
_AND_dpX:
1124
    BRV0    _RO_DPX,0,1,, Pls, IF, OP1              -- Read DP
1125
_EOR_dp:
1126
    BRV0    _RO_DP,0,1,, Pls, IF, OP1               -- Read DP
1127
_EOR_dpX:
1128
    BRV0    _RO_DPX,0,1,, Pls, IF, OP1              -- Read DP
1129
_ADC_dp:
1130
    BRV0    _RO_DP,0,1,, Pls, IF, OP1               -- Read DP
1131
_ADC_dpX:
1132
    BRV0    _RO_DPX,0,1,, Pls, IF, OP1              -- Read DP
1133
_STA_dp:
1134
    BRV0    _WO_DP,0,1,, Pls, IF, OP1               -- Read DP
1135
_STA_dpX:
1136
    BRV0    _WO_DPX,0,1,, Pls, IF, OP1              -- Read DP
1137
_LDA_dp:
1138
    BRV0    _RO_DP,0,1,, Pls, IF, OP1               -- Read DP
1139
_LDA_dpX:
1140
    BRV0    _RO_DPX,0,1,, Pls, IF, OP1              -- Read DP
1141
_CMP_dp:
1142
    BRV0    _RO_DP,0,1,, Pls, IF, OP1               -- Read DP
1143
_CMP_dpX:
1144
    BRV0    _RO_DPX,0,1,, Pls, IF, OP1              -- Read DP
1145
_SBC_dp:
1146
    BRV0    _RO_DP,0,1,, Pls, IF, OP1               -- Read DP
1147
_SBC_dpX:
1148
    BRV0    _RO_DPX,0,1,, Pls, IF, OP1              -- Read DP
1149
--------------------------------------------------------------------------------
1150
-- Row 6 : 0x06-0xF6
1151
--  I   BA, Wt, En, NA, PC, IO, DI, SP, Reg_WE, ISR
1152
--------------------------------------------------------------------------------
1153
_ASL_dp:
1154
    BRV0    _RMW_DP,0,1,, Pls, IF, OP1              -- Read DP
1155
_ASL_dpX:
1156
    BRV0    _RMW_DPX,0,1,, Pls, IF, OP1             -- Read DP
1157
_ROL_dp:
1158
    BRV0    _RMW_DP,0,1,, Pls, IF, OP1              -- Read DP
1159
_ROL_dpX:
1160
    BRV0    _RMW_DPX,0,1,, Pls, IF, OP1             -- Read DP
1161
_LSR_dp:
1162
    BRV0    _RMW_DP,0,1,, Pls, IF, OP1              -- Read DP
1163
_LSR_dpX:
1164
    BRV0    _RMW_DPX,0,1,, Pls, IF, OP1             -- Read DP
1165
_ROR_dp:
1166
    BRV0    _RMW_DP,0,1,, Pls, IF, OP1              -- Read DP
1167
_ROR_dpX:
1168
    BRV0    _RMW_DPX,0,1,, Pls, IF, OP1             -- Read DP
1169
_STX_dp:
1170
    BRV0    _WO_DP,0,1,, Pls, IF, OP1               -- Read DP
1171
_STX_dpY:
1172
    BRV0    _WO_DPY,0,1,, Pls, IF, OP1              -- Read DP
1173
_LDX_dp:
1174
    BRV0    _RO_DP,0,1,, Pls, IF, OP1               -- Read DP
1175
_LDX_dpY:
1176
    BRV0    _RO_DPY,0,1,, Pls, IF, OP1              -- Read DP
1177
_DEC_dp:
1178
    BRV0    _RMW_DP,0,1,, Pls, IF, OP1              -- Read DP
1179
_DEC_dpX:
1180
    BRV0    _RMW_DPX,0,1,, Pls, IF, OP1             -- Read DP
1181
_INC_dp:
1182
    BRV0    _RMW_DP,0,1,, Pls, IF, OP1              -- Read DP
1183
_INC_dpX:
1184
    BRV0    _RMW_DPX,0,1,, Pls, IF, OP1             -- Read DP
1185
--------------------------------------------------------------------------------
1186
-- Row 7 : 0x07-0xF7 (Rockwell Instructions: RMBx/SMBx dp)
1187
--  I   BA, Wt, En, NA, PC, IO, DI, SP, Reg_WE, ISR
1188
--------------------------------------------------------------------------------
1189
_RMB0_dp:
1190
    BRV0    _RMW_DP,0,1,, Pls, IF, OP1              -- Read DP
1191
_RMB1_dp:
1192
    BRV0    _RMW_DP,0,1,, Pls, IF, OP1              -- Read DP
1193
_RMB2_dp:
1194
    BRV0    _RMW_DP,0,1,, Pls, IF, OP1              -- Read DP
1195
_RMB3_dp:
1196
    BRV0    _RMW_DP,0,1,, Pls, IF, OP1              -- Read DP
1197
_RMB4_dp:
1198
    BRV0    _RMW_DP,0,1,, Pls, IF, OP1              -- Read DP
1199
_RMB5_dp:
1200
    BRV0    _RMW_DP,0,1,, Pls, IF, OP1              -- Read DP
1201
_RMB6_dp:
1202
    BRV0    _RMW_DP,0,1,, Pls, IF, OP1              -- Read DP
1203
_RMB7_dp:
1204
    BRV0    _RMW_DP,0,1,, Pls, IF, OP1              -- Read DP
1205
_SMB0_dp:
1206
    BRV0    _RMW_DP,0,1,, Pls, IF, OP1              -- Read DP
1207
_SMB1_dp:
1208
    BRV0    _RMW_DP,0,1,, Pls, IF, OP1              -- Read DP
1209
_SMB2_dp:
1210
    BRV0    _RMW_DP,0,1,, Pls, IF, OP1              -- Read DP
1211
_SMB3_dp:
1212
    BRV0    _RMW_DP,0,1,, Pls, IF, OP1              -- Read DP
1213
_SMB4_dp:
1214
    BRV0    _RMW_DP,0,1,, Pls, IF, OP1              -- Read DP
1215
_SMB5_dp:
1216
    BRV0    _RMW_DP,0,1,, Pls, IF, OP1              -- Read DP
1217
_SMB6_dp:
1218
    BRV0    _RMW_DP,0,1,, Pls, IF, OP1              -- Read DP
1219
_SMB7_dp:
1220
    BRV0    _RMW_DP,0,1,, Pls, IF, OP1              -- Read DP
1221
--------------------------------------------------------------------------------
1222
-- Row 8 : 0x08-0xF8
1223
--  I   BA, Wt, En, NA, PC, IO, DI, SP, Reg_WE, ISR
1224
--------------------------------------------------------------------------------
1225
_PHP:
1226
    BRV0    _Psh,0,1, Stk,, WR,, Psh                -- Push P
1227
_CLC:
1228
    BRV3    $,0,1,, Pls, IF, IR,, WE_P              -- Clear Carry Flag
1229
_PLP:
1230
    BRV0    _Pop,0,1, Stk,, RD, OP1, Pop            -- Pop P
1231
_SEC:
1232
    BRV3    $,0,1,, Pls, IF, IR,, WE_P              -- Set Carry Flag
1233
_PHA:
1234
    BRV0    _Psh,0,1, Stk,, WR,, Psh                -- Push A
1235
_CLI:
1236
    BRV1    $,0,1,, Pls, IF, IR,, WE_P              -- Clear Interrupt Mask Flg
1237
_PLA:
1238
    BRV0    _Pop,0,1, Stk,, RD, OP1, Pop            -- Pop A
1239
_SEI:
1240
    BRV1    $,0,1,, Pls, IF, IR,, WE_P              -- Set Interrupt Mask Flag
1241
_DEY:
1242
    BRV3    $,0,1,, Pls, IF, IR,, WE_Y              -- Decrement Y
1243
_TYA:
1244
    BRV3    $,0,1,, Pls, IF, IR,, WE_A              -- Transfer Y to A
1245
_TAY:
1246
    BRV3    $,0,1,, Pls, IF, IR,, WE_Y              -- Transfer A to Y
1247
_CLV:
1248
    BRV3    $,0,1,, Pls, IF, IR,, WE_P              -- Clear oVerflow Flag
1249
_INY:
1250
    BRV3    $,0,1,, Pls, IF, IR,, WE_Y              -- Increment Y
1251
_CLD:
1252
    BRV3    $,0,1,, Pls, IF, IR,, WE_P              -- Clear Decimal Mode Flag
1253
_INX:
1254
    BRV3    $,0,1,, Pls, IF, IR,, WE_X              -- Increment X
1255
_SED:
1256
    BRV3    $,0,1,, Pls, IF, IR,, WE_P              -- Set Decimal Mode Flag
1257
--------------------------------------------------------------------------------
1258
-- Row 9 : 0x09-0xF9
1259
--  I   BA, Wt, En, NA, PC, IO, DI, SP, Reg_WE, ISR
1260
--------------------------------------------------------------------------------
1261
_ORA_imm:
1262
    BMW     _Imm,0,1,, Pls, IF, OP1                 -- Read Immediate Operand
1263
_ORA_absY:
1264
    BRV0    _RO_AbsY,0,1,, Pls, IF, OP1             -- Read Mem Ptr Lo
1265
_AND_imm:
1266
    BMW     _Imm,0,1,, Pls, IF, OP1                 -- Read Immediate Operand
1267
_AND_absY:
1268
    BRV0    _RO_AbsY,0,1,, Pls, IF, OP1             -- Read Mem Ptr Lo
1269
_EOR_imm:
1270
    BMW     _Imm,0,1,, Pls, IF, OP1                 -- Read Immediate Operand
1271
_EOR_absY:
1272
    BRV0    _RO_AbsY,0,1,, Pls, IF, OP1             -- Read Mem Ptr Lo
1273
_ADC_imm:
1274
    BMW     _Imm,0,1,, Pls, IF, OP1                 -- Read Immediate Operand
1275
_ADC_absY:
1276
    BRV0    _RO_AbsY,0,1,, Pls, IF, OP1             -- Read Mem Ptr Lo
1277
_BIT_imm:
1278
    BMW     _Imm,0,1,, Pls, IF, OP1                 -- Read Immediate Operand
1279
_STA_absY:
1280
    BRV0    _WO_AbsY,0,1,, Pls, IF, OP1             -- Read Mem Ptr Lo
1281
_LDA_imm:
1282
    BMW     _Imm,0,1,, Pls, IF, OP1                 -- Read Immediate Operand
1283
_LDA_absY:
1284
    BRV0    _RO_AbsY,0,1,, Pls, IF, OP1             -- Read Mem Ptr Lo
1285
_CMP_imm:
1286
    BMW     _Imm,0,1,, Pls, IF, OP1                 -- Read Immediate Operand
1287
_CMP_absY:
1288
    BRV0    _RO_AbsY,0,1,, Pls, IF, OP1             -- Read Mem Ptr Lo
1289
_SBC_imm:
1290
    BMW     _Imm,0,1,, Pls, IF, OP1                 -- Read Immediate Operand
1291
_SBC_absY:
1292
    BRV0    _RO_AbsY,0,1,, Pls, IF, OP1             -- Read Mem Ptr Lo
1293
--------------------------------------------------------------------------------
1294
-- Row A : 0x0A-0xFA
1295
--  I   BA, Wt, En, NA, PC, IO, DI, SP, Reg_WE, ISR
1296
--------------------------------------------------------------------------------
1297
_ASL_A:
1298
    BRV3    $,0,1,, Pls, IF, IR,, WE_A              -- Arithmetic Shift A Left
1299
_INC_A:
1300
    BRV3    $,0,1,, Pls, IF, IR,, WE_A              -- Increment A
1301
_ROL_A:
1302
    BRV3    $,0,1,, Pls, IF, IR,, WE_A              -- Rotate A Left
1303
_DEC_A:
1304
    BRV3    $,0,1,, Pls, IF, IR,, WE_A              -- Decrement A
1305
_LSR_A:
1306
    BRV3    $,0,1,, Pls, IF, IR,, WE_A              -- Logical Shift A Right
1307
_PHY:
1308
    BRV0    _Psh,0,1, Stk,, WR,, Psh                -- Push Y
1309
_ROR_A:
1310
    BRV3    $,0,1,, Pls, IF, IR,, WE_A              -- Rotate A Right
1311
_PLY:
1312
    BRV0    _Pop,0,1, Stk,, RD, OP1, Pop            -- Pop Y
1313
_TXA:
1314
    BRV3    $,0,1,, Pls, IF, IR,, WE_A              -- Transfer X to A
1315
_TXS:
1316
    BRV3    $,0,1,, Pls, IF, IR,, WE_S              -- Transfer X to S
1317
_TAX:
1318
    BRV3    $,0,1,, Pls, IF, IR,, WE_X              -- Transfer A to X
1319
_TSX:
1320
    BRV3    $,0,1,, Pls, IF, IR,, WE_X              -- Transfer S to X
1321
_DEX:
1322
    BRV3    $,0,1,, Pls, IF, IR,, WE_X              -- Decrement X
1323
_PHX:
1324
    BRV0    _Psh,0,1, Stk,, WR,, Psh                -- Push X
1325
_NOP:   -- the real NOP
1326
    BRV3    $,0,1,, Pls, IF, IR                     -- Skip True NOP Instruction
1327
_PLX:
1328
    BRV0    _Pop,0,1, Stk,, RD, OP1, Pop            -- Pop X
1329
--------------------------------------------------------------------------------
1330
-- Row B : 0x0B-0xFB
1331
--  I   BA, Wt, En, NA, PC, IO, DI, SP, Reg_WE, ISR
1332
--------------------------------------------------------------------------------
1333
_NOP_0B:
1334
    BRV3    $,0,1,, Pls, IF, IR                     -- Skip Invalid Instruction
1335
_NOP_1B:
1336
    BRV3    $,0,1,, Pls, IF, IR                     -- Skip Invalid Instruction
1337
_NOP_2B:
1338
    BRV3    $,0,1,, Pls, IF, IR                     -- Skip Invalid Instruction
1339
_NOP_3B:
1340
    BRV3    $,0,1,, Pls, IF, IR                     -- Skip Invalid Instruction
1341
_NOP_4B:
1342
    BRV3    $,0,1,, Pls, IF, IR                     -- Skip Invalid Instruction
1343
_NOP_5B:
1344
    BRV3    $,0,1,, Pls, IF, IR                     -- Skip Invalid Instruction
1345
_NOP_6B:
1346
    BRV3    $,0,1,, Pls, IF, IR                     -- Skip Invalid Instruction
1347
_NOP_7B:
1348
    BRV3    $,0,1,, Pls, IF, IR                     -- Skip Invalid Instruction
1349
_NOP_8B:
1350
    BRV3    $,0,1,, Pls, IF, IR                     -- Skip Invalid Instruction
1351
_NOP_9B:
1352
    BRV3    $,0,1,, Pls, IF, IR                     -- Skip Invalid Instruction
1353
_NOP_AB:
1354
    BRV3    $,0,1,, Pls, IF, IR                     -- Skip Invalid Instruction
1355
_NOP_BB:
1356
    BRV3    $,0,1,, Pls, IF, IR                     -- Skip Invalid Instruction
1357
_WAI_CB:
1358
    BRV0    _WAI,0,1                                -- Wait for Interrupt
1359
_STP_DB:
1360
    BRV0    $,0,1                                   -- Stop Processor Execution
1361
_NOP_EB:
1362
    BRV3    $,0,1,, Pls, IF, IR                     -- Skip Invalid Instruction
1363
_NOP_FB:
1364
    BRV3    $,0,1,, Pls, IF, IR                     -- Skip Invalid Instruction
1365
--------------------------------------------------------------------------------
1366
-- Row C : 0x0C-0xFC
1367
--  I   BA, Wt, En, NA, PC, IO, DI, SP, Reg_WE, ISR
1368
--------------------------------------------------------------------------------
1369
_TSB_abs:
1370
    BRV0    _RMW_Abs,0,1,, Pls, IF, OP1             -- Read Dst Ptr Lo
1371
_TRB_abs:
1372
    BRV0    _RMW_Abs,0,1,, Pls, IF, OP1             -- Read Dst Ptr Lo
1373
_BIT_abs:
1374
    BRV0    _RO_Abs,0,1,, Pls, IF, OP1              -- Read Dst Ptr Lo
1375
_BIT_absX:
1376
    BRV0    _RO_AbsX,0,1,, Pls, IF, OP1             -- Read Dst Ptr Lo
1377
_JMP_abs:
1378
    BRV0    _Jmp,0,1,, Pls, IF, OP1                 -- Read Dst Ptr Lo
1379
_NOP_5C:
1380
    BRV3    $,0,1,, Pls, IF, IR                     -- Skip Invalid Instruction
1381
_JMP_absi:
1382
    BRV0    _JmpI,0,1,, Pls, IF, OP1                -- Read Dst Ptr Lo
1383
_JMP_absXi:
1384
    BRV0    _JmpXI,0,1,, Pls, IF, OP1               -- Read Dst Ptr Lo
1385
_STY_abs:
1386
    BRV0    _WO_Abs,0,1,, Pls, IF, OP1              -- Read Dst Ptr Lo
1387
_STZ_abs:
1388
    BRV0    _WO_Abs,0,1,, Pls, IF, OP1              -- Read Dst Ptr Lo
1389
_LDY_abs:
1390
    BRV0    _RO_Abs,0,1,, Pls, IF, OP1              -- Read Dst Ptr Lo
1391
_LDY_absX:
1392
    BRV0    _RO_AbsX,0,1,, Pls, IF, OP1             -- Read Dst Ptr Lo
1393
_CPY_abs:
1394
    BRV0    _RO_Abs,0,1,, Pls, IF, OP1              -- Read Dst Ptr Lo
1395
_NOP_DC:
1396
    BRV3    $,0,1,, Pls, IF, IR                     -- Skip Invalid Instruction
1397
_CPX_abs:
1398
    BRV0    _RO_Abs,0,1,, Pls, IF, OP1              -- Read Dst Ptr Lo
1399
_NOP_FC:
1400
    BRV3    $,0,1,, Pls, IF, IR                     -- Skip Invalid Instruction
1401
--------------------------------------------------------------------------------
1402
-- Row D : 0x0D-0xFD
1403
--  I   BA, Wt, En, NA, PC, IO, DI, SP, Reg_WE, ISR
1404
--------------------------------------------------------------------------------
1405
_ORA_abs:
1406
    BRV0    _RO_Abs,0,1,, Pls, IF, OP1              -- Read Dst Ptr Lo
1407
_ORA_absX:
1408
    BRV0    _RO_AbsX,0,1,, Pls, IF, OP1             -- Read Dst Ptr Lo
1409
_AND_abs:
1410
    BRV0    _RO_Abs,0,1,, Pls, IF, OP1              -- Read Dst Ptr Lo
1411
_AND_absX:
1412
    BRV0    _RO_AbsX,0,1,, Pls, IF, OP1             -- Read Dst Ptr Lo
1413
_EOR_abs:
1414
    BRV0    _RO_Abs,0,1,, Pls, IF, OP1              -- Read Dst Ptr Lo
1415
_EOR_absX:
1416
    BRV0    _RO_AbsX,0,1,, Pls, IF, OP1             -- Read Dst Ptr Lo
1417
_ADC_abs:
1418
    BRV0    _RO_Abs,0,1,, Pls, IF, OP1              -- Read Dst Ptr Lo
1419
_ADC_absX:
1420
    BRV0    _RO_AbsX,0,1,, Pls, IF, OP1             -- Read Dst Ptr Lo
1421
_STA_abs:
1422
    BRV0    _WO_Abs,0,1,, Pls, IF, OP1              -- Read Dst Ptr Lo
1423
_STA_absX:
1424
    BRV0    _WO_AbsX,0,1,, Pls, IF, OP1             -- Read Dst Ptr Lo
1425
_LDA_abs:
1426
    BRV0    _RO_Abs,0,1,, Pls, IF, OP1              -- Read Dst Ptr Lo
1427
_LDA_absX:
1428
    BRV0    _RO_AbsX,0,1,, Pls, IF, OP1             -- Read Dst Ptr Lo
1429
_CMP_abs:
1430
    BRV0    _RO_Abs,0,1,, Pls, IF, OP1              -- Read Dst Ptr Lo
1431
_CMP_absX:
1432
    BRV0    _RO_AbsX,0,1,, Pls, IF, OP1             -- Read Dst Ptr Lo
1433
_SBC_abs:
1434
    BRV0    _RO_Abs,0,1,, Pls, IF, OP1              -- Read Dst Ptr Lo
1435
_SBC_absX:
1436
    BRV0    _RO_AbsX,0,1,, Pls, IF, OP1             -- Read Dst Ptr Lo
1437
--------------------------------------------------------------------------------
1438
-- Row E : 0x0E-0xFE
1439
--  I   BA, Wt, En, NA, PC, IO, DI, SP, Reg_WE, ISR
1440
--------------------------------------------------------------------------------
1441
_ASL_abs:
1442
    BRV0    _RMW_Abs,0,1,, Pls, IF, OP1             -- Read Dst Ptr Lo
1443
_ASL_absX:
1444
    BRV0    _RMW_AbsX,0,1,, Pls, IF, OP1            -- Read Dst Ptr Lo
1445
_ROL_abs:
1446
    BRV0    _RMW_Abs,0,1,, Pls, IF, OP1             -- Read Dst Ptr Lo
1447
_ROL_absX:
1448
    BRV0    _RMW_AbsX,0,1,, Pls, IF, OP1            -- Read Dst Ptr Lo
1449
_LSR_abs:
1450
    BRV0    _RMW_Abs,0,1,, Pls, IF, OP1             -- Read Dst Ptr Lo
1451
_LSR_absX:
1452
    BRV0    _RMW_AbsX,0,1,, Pls, IF, OP1            -- Read Dst Ptr Lo
1453
_ROR_abs:
1454
    BRV0    _RMW_Abs,0,1,, Pls, IF, OP1             -- Read Dst Ptr Lo
1455
_ROR_absX:
1456
    BRV0    _RMW_AbsX,0,1,, Pls, IF, OP1            -- Read Dst Ptr Lo
1457
_STX_abs:
1458
    BRV0    _WO_Abs,0,1,, Pls, IF, OP1              -- Read Dst Ptr Lo
1459
_STZ_absX:
1460
    BRV0    _WO_AbsX,0,1,, Pls, IF, OP1             -- Read Dst Ptr Lo
1461
_LDX_abs:
1462
    BRV0    _RO_Abs,0,1,, Pls, IF, OP1              -- Read Dst Ptr Lo
1463
_LDX_absY:
1464
    BRV0    _RO_AbsY,0,1,, Pls, IF, OP1             -- Read Dst Ptr Lo
1465
_DEC_abs:
1466
    BRV0    _RMW_Abs,0,1,, Pls, IF, OP1             -- Read Dst Ptr Lo
1467
_DEC_absX:
1468
    BRV0    _RMW_AbsX,0,1,, Pls, IF, OP1            -- Read Dst Ptr Lo
1469
_INC_abs:
1470
    BRV0    _RMW_Abs,0,1,, Pls, IF, OP1             -- Read Dst Ptr Lo
1471
_INC_absX:
1472
    BRV0    _RMW_AbsX,0,1,, Pls, IF, OP1            -- Read Dst Ptr Lo
1473
--------------------------------------------------------------------------------
1474
-- Row F : 0x0F-0xFF (Rockwell Instructions: BBRx/BBSx dp,rel)
1475
--  I   BA, Wt, En, NA, PC, IO, DI, SP, Reg_WE, ISR
1476
--------------------------------------------------------------------------------
1477
_BBR0_dp_rel:
1478
    BRV0    _BByx_dp_rel,0,1,, Pls, IF, OP1         -- Read DP
1479
_BBR1_dp_rel:
1480
    BRV0    _BByx_dp_rel,0,1,, Pls, IF, OP1         -- Read DP
1481
_BBR2_dp_rel:
1482
    BRV0    _BByx_dp_rel,0,1,, Pls, IF, OP1         -- Read DP
1483
_BBR3_dp_rel:
1484
    BRV0    _BByx_dp_rel,0,1,, Pls, IF, OP1         -- Read DP
1485
_BBR4_dp_rel:
1486
    BRV0    _BByx_dp_rel,0,1,, Pls, IF, OP1         -- Read DP
1487
_BBR5_dp_rel:
1488
    BRV0    _BByx_dp_rel,0,1,, Pls, IF, OP1         -- Read DP
1489
_BBR6_dp_rel:
1490
    BRV0    _BByx_dp_rel,0,1,, Pls, IF, OP1         -- Read DP
1491
_BBR7_dp_rel:
1492
    BRV0    _BByx_dp_rel,0,1,, Pls, IF, OP1         -- Read DP
1493
_BBS0_dp_rel:
1494
    BRV0    _BByx_dp_rel,0,1,, Pls, IF, OP1         -- Read DP
1495
_BBS1_dp_rel:
1496
    BRV0    _BByx_dp_rel,0,1,, Pls, IF, OP1         -- Read DP
1497
_BBS2_dp_rel:
1498
    BRV0    _BByx_dp_rel,0,1,, Pls, IF, OP1         -- Read DP
1499
_BBS3_dp_rel:
1500
    BRV0    _BByx_dp_rel,0,1,, Pls, IF, OP1         -- Read DP
1501
_BBS4_dp_rel:
1502
    BRV0    _BByx_dp_rel,0,1,, Pls, IF, OP1         -- Read DP
1503
_BBS5_dp_rel:
1504
    BRV0    _BByx_dp_rel,0,1,, Pls, IF, OP1         -- Read DP
1505
_BBS6_dp_rel:
1506
    BRV0    _BByx_dp_rel,0,1,, Pls, IF, OP1         -- Read DP
1507
_BBS7_dp_rel:
1508
    BRV0    _BByx_dp_rel,0,1,, Pls, IF, OP1         -- Read DP
1509
--------------------------------------------------------------------------------
1510
--  End of Instruction Decode Table
1511
--------------------------------------------------------------------------------
1512
 
1513
_Last:  .org 512
1514
 
1515
_end:

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.