home *** CD-ROM | disk | FTP | other *** search
/ The Unsorted BBS Collection / thegreatunsorted.tar / thegreatunsorted / misc / emulate.asm < prev    next >
Assembly Source File  |  1990-03-30  |  177KB  |  4,529 lines

  1.     Page    58,132
  2.     Title    EMULATE.ASM    65C02 Emulator (65C02 Processor)
  3. ;******************************************************************************
  4. ;
  5. ;   Name:    EMULATE.ASM    65C02 Emulator (65C02 Processor)
  6. ;
  7. ;   Group:    Emulator
  8. ;
  9. ;   Revision:    1.00
  10. ;
  11. ;   Date:    January 30, 1988
  12. ;
  13. ;   Author:    Randy W. Spurlock
  14. ;
  15. ;******************************************************************************
  16. ;
  17. ;  Module Functional Description:
  18. ;
  19. ;        This module contains all the code for the 65C02 CPU
  20. ;    emulation. This module MUST be linked first as the placement
  21. ;    of the opcode routines is instrumental in execution.
  22. ;
  23. ;    The following register convention holds true for all opcode routines:
  24. ;
  25. ;    Registers on Entry:
  26. ;
  27. ;        BX    - 65C02 Stack pointer register (BH = 01)
  28. ;        CH    - 65C02 X index register
  29. ;        CL    - 65C02 Y index register
  30. ;        DH    - 65C02 processor flags register
  31. ;        DL    - 65C02 Accumulator register
  32. ;        SI    - 65C02 Program counter register
  33. ;        DI    - 65C02 Effective address
  34. ;        DS    - Apple RAM segment
  35. ;        ES    - Video memory segment
  36. ;        FL    - Direction flag is cleared (Move forward)
  37. ;
  38. ;    Registers on Exit:
  39. ;
  40. ;        DH    - 65C02 processor flags updated
  41. ;
  42. ;******************************************************************************
  43. ;
  44. ;  Changes:
  45. ;
  46. ;    DATE     REVISION                DESCRIPTION
  47. ;  --------   --------    -------------------------------------------------------
  48. ;   1/30/88    1.00    Original
  49. ;
  50. ;******************************************************************************
  51.     Page
  52. ;
  53. ;  Public Declarations
  54. ;
  55.     Public    Emulator        ; Emulator entry point
  56.     Public    Op_Fetch        ; Fetch next opcode entry point
  57. ;
  58. ;  External Declarations
  59. ;
  60.     Extrn    Initialize:Near     ; Emulator initialization    (APPLE)
  61.     Extrn    Read_Memory:Near    ; Read 65C02 memory routine    (APPLE)
  62.     Extrn    Write_Memory:Near    ; Write 65C02 memory routine    (APPLE)
  63.     Extrn    Interrupt:Near        ; Interrupt processing routine      (INT)
  64.     Extrn    Flag_Encode:Byte    ; CPU flag encoding table     (DATA)
  65.     Extrn    Flag_Decode:Byte    ; CPU flag decoding table     (DATA)
  66. ;
  67. ;  LOCAL Equates
  68. ;
  69. OP_SIZE     Equ    80h        ; Op-code work area size (128 Bytes)
  70. OP_BASE     Equ    07h        ; Op-code work area base (Op_Size Log 2)
  71. ;
  72. ;  Define any include files needed
  73. ;
  74.     Include     Macros.inc    ; Include the macro definitions
  75.     Include     Equates.inc    ; Include the equate definitions
  76.     .286c                ; Include 80286 instructions
  77.     Page
  78. ;
  79. ;  Define the emulator code segment
  80. ;
  81. Emulate Segment Word Public 'EMULATE'   ; Emulator code segment
  82.     Assume    cs:Emulate, ds:Nothing, es:Nothing
  83.     Subttl    Opcode 00 - BRK Stack/Interrupt
  84.     Page    +
  85. ;******************************************************************************
  86. ;
  87. ;    Op_BRK ()    Software Break
  88. ;
  89. ;        Increment program counter past the signature byte
  90. ;        Push the program counter onto stack
  91. ;        Set the b (Software break) and r (Reserved) flag bits
  92. ;        Encode flag bits from 80x86 to 65C02
  93. ;        Push the processor flags onto stack
  94. ;        Set the i (Interrupt disable) flag bit
  95. ;        Load program counter with interrupt vector (FFFEh)
  96. ;        Fetch the next instruction
  97. ;
  98. ;******************************************************************************
  99. Op_BRK        Proc    Near        ; Software break procedure
  100.     inc    si            ; Increment past signature byte
  101.     mov    ax,si            ; Get the program counter
  102.     Push_16             ; Push program counter onto stack
  103.     mov    al,dh            ; Get the 65C02 status flags
  104.     or    al,CPU_R + CPU_B    ; Set the b and r flag bits
  105.     xor    ah,ah            ; Convert flag value to full word
  106.     mov    bp,ax            ; Setup to encode the flag value
  107.     mov    al,cs:[bp + Flag_Encode]; Get the encoded flag value
  108.     Push_8                ; Push the 65C02 flags onto stack
  109.     or    dh,CPU_I        ; Set the i flag bit
  110.     mov    si,ds:[BRK_VECTOR]    ; Load PC with interrupt vector
  111.     Fetch                ; Fetch and execute next instruction
  112. Op_BRK        Endp            ; End of software break procedure
  113.     LineUp    Op_Size         ; Align the next opcode procedure
  114.     Subttl    Opcode 01 - ORA DP Indexed Indirect, X
  115.     Page    +
  116. ;******************************************************************************
  117. ;
  118. ;    Op_ORA_DIIX ()    OR Accumulator with Memory
  119. ;
  120. ;        Setup the effective address
  121. ;        Do the ORA operation (Update flag bits n, z)
  122. ;        Fetch the next instruction
  123. ;
  124. ;******************************************************************************
  125. Op_ORA_DIIX    Proc    Near        ; OR accumulator with memory procedure
  126.     DoDIIX                ; Setup the effective address
  127.     OpORA                ; Do the ORA operation (Update n,z)
  128.     Fetch                ; Fetch and execute next instruction
  129. Op_ORA_DIIX    Endp            ; End of OR accumulator procedure
  130.     LineUp    Op_Size         ; Align the next opcode procedure
  131.     Subttl    Opcode 02 - COP Stack/Interrupt         (ILLEGAL)
  132.     Page    +
  133. ;******************************************************************************
  134. ;
  135. ;    Op_COP ()    Co-processor Enable
  136. ;
  137. ;        Increment to the next opcode
  138. ;        Fetch the next instruction
  139. ;
  140. ;******************************************************************************
  141. Op_COP        Proc    Near        ; Co-processor enable procedure
  142.     inc    si            ; Increment to the next opcode
  143.     Fetch                ; Fetch and execute next instruction
  144. Op_COP        Endp            ; End of co-processor enable procedure
  145.     LineUp    Op_Size         ; Align the next opcode procedure
  146.     Subttl    Opcode 03 - ORA Stack Relative            (ILLEGAL)
  147.     Page    +
  148. ;******************************************************************************
  149. ;
  150. ;    Op_ORA_S ()    OR Accumulator with Memory
  151. ;
  152. ;        Increment to the next opcode
  153. ;        Fetch the next instruction
  154. ;
  155. ;******************************************************************************
  156. Op_ORA_S    Proc    Near        ; OR accumulator with memory procedure
  157.     inc    si            ; Increment to the next opcode
  158.     Fetch                ; Fetch and execute next instruction
  159. Op_ORA_S    Endp            ; End of OR accumulator procedure
  160.     LineUp    Op_Size         ; Align the next opcode procedure
  161.     Subttl    Opcode 04 - TSB Direct Page            (65C02 ONLY)
  162.     Page    +
  163. ;******************************************************************************
  164. ;
  165. ;    Op_TSB_DP ()    Test and Set Memory Bits Against Accumulator
  166. ;
  167. ;        Setup the effective address
  168. ;        Do the TSB operation (Update flag bit z)
  169. ;        Fetch the next instruction
  170. ;
  171. ;******************************************************************************
  172. Op_TSB_DP    Proc    Near        ; Test and set memory bits procedure
  173.     DoDP                ; Setup the effective address
  174.     OpTSB                ; Do the TSB operation (Update z)
  175.     Fetch                ; Fetch and execute next instruction
  176. Op_TSB_DP    Endp            ; End of test and set bits procedure
  177.     LineUp    Op_Size         ; Align the next opcode procedure
  178.     Subttl    Opcode 05 - ORA Direct Page
  179.     Page    +
  180. ;******************************************************************************
  181. ;
  182. ;    Op_ORA_DP ()    OR Accumulator with Memory
  183. ;
  184. ;        Setup the effective address
  185. ;        Do the ORA operation (Update flag bits n, z)
  186. ;        Fetch the next instruction
  187. ;
  188. ;******************************************************************************
  189. Op_ORA_DP    Proc    Near        ; OR accumulator with memory procedure
  190.     DoDP                ; Setup the effective address
  191.     OpORA                ; Do the ORA operation (Update n,z)
  192.     Fetch                ; Fetch and execute next instruction
  193. Op_ORA_DP    Endp            ; End of OR accumulator procedure
  194.     LineUp    Op_Size         ; Align the next opcode procedure
  195.     Subttl    Opcode 06 - ASL Direct Page
  196.     Page    +
  197. ;******************************************************************************
  198. ;
  199. ;    Op_ASL_DP ()    Shift Memory Left
  200. ;
  201. ;        Setup the effective address
  202. ;        Do the ASL operation (Update flag bits n, z, c)
  203. ;        Fetch the next instruction
  204. ;
  205. ;******************************************************************************
  206. Op_ASL_DP    Proc    Near        ; Shift memory left procedure
  207.     DoDP                ; Setup the effective address
  208.     OpASL                ; Do the ASL operation (Update n,v,z,c)
  209.     Fetch                ; Fetch and execute next instruction
  210. Op_ASL_DP    Endp            ; End of shift memory left procedure
  211.     LineUp    Op_Size         ; Align the next opcode procedure
  212.     Subttl    Opcode 07 - ORA DP Indirect Long        (ILLEGAL)
  213.     Page    +
  214. ;******************************************************************************
  215. ;
  216. ;    Op_ORA_DIL ()    OR Accumulator with Memory
  217. ;
  218. ;        Increment to the next opcode
  219. ;        Fetch the next instruction
  220. ;
  221. ;******************************************************************************
  222. Op_ORA_DIL    Proc    Near        ; OR Accumulator with memory procedure
  223.     inc    si            ; Increment to the next opcode
  224.     Fetch                ; Fetch and execute next instruction
  225. Op_ORA_DIL    Endp            ; End of OR accumulator procedure
  226.     LineUp    Op_Size         ; Align the next opcode procedure
  227.     Subttl    Opcode 08 - PHP Stack/Push
  228.     Page    +
  229. ;******************************************************************************
  230. ;
  231. ;    Op_PHP ()    Push Processor Status Register
  232. ;
  233. ;        Set the r (Reserved) flag bit
  234. ;        Encode flag bits from 80x86 to 65C02
  235. ;        Push 65C02 status flags onto stack
  236. ;        Fetch the next instruction
  237. ;
  238. ;******************************************************************************
  239. Op_PHP        Proc    Near        ; Push processor status procedure
  240.     mov    al,dh            ; Get the 65C02 processor flags
  241.     or    al,CPU_R        ; Make sure reserved bit is set
  242.     xor    ah,ah            ; Convert flag value to full word
  243.     mov    bp,ax            ; Setup to encode the flag value
  244.     mov    al,cs:[bp + Flag_Encode]; Get the encoded flag value
  245.     Push_8                ; Push 65C02 status flags onto stack
  246.     Fetch                ; Fetch and execute next instruction
  247. Op_PHP        Endp            ; End of push processor status procedure
  248.     LineUp    Op_Size         ; Align the next opcode procedure
  249.     Subttl    Opcode 09 - ORA Immediate
  250.     Page    +
  251. ;******************************************************************************
  252. ;
  253. ;    Op_ORA_I ()    OR Accumulator with Memory
  254. ;
  255. ;        Setup the effective address
  256. ;        Do the ORA operation (Update flag bits n, z)
  257. ;        Fetch the next instruction
  258. ;
  259. ;******************************************************************************
  260. Op_ORA_I    Proc    Near        ; OR accumulator with memory procedure
  261.     DoImm                ; Setup the effective address
  262.     OpORA                ; Do the ORA operation (Update n,z)
  263.     Fetch                ; Fetch and execute next instruction
  264. Op_ORA_I    Endp            ; End of OR accumulator procedure
  265.     LineUp    Op_Size         ; Align the next opcode procedure
  266.     Subttl    Opcode 0A - ASL Accumulator
  267.     Page    +
  268. ;******************************************************************************
  269. ;
  270. ;    Op_ASL ()    Shift Accumulator Left
  271. ;
  272. ;        Shift the accumulator left
  273. ;        Update the 65C02 processor flags (n, z, c)
  274. ;        Fetch the next instruction
  275. ;
  276. ;******************************************************************************
  277. Op_ASL        Proc    Near        ; Shift accumulator left procedure
  278.     shl    dl,1            ; Shift the accumulator left
  279.     Flgnzc                ; Update the n, z, and c flags
  280.     Fetch                ; Fetch and execute next instruction
  281. Op_ASL        Endp            ; End shift accumulator left procedure
  282.     LineUp    Op_Size         ; Align the next opcode procedure
  283.     Subttl    Opcode 0B - PHD Stack/Push            (ILLEGAL)
  284.     Page    +
  285. ;******************************************************************************
  286. ;
  287. ;    Op_PHD ()    Push Direct Page Register
  288. ;
  289. ;        Fetch the next instruction
  290. ;
  291. ;******************************************************************************
  292. Op_PHD        Proc    Near        ; Push direct page register procedure
  293.     Fetch                ; Fetch and execute next instruction
  294. Op_PHD        Endp            ; End of push direct page procedure
  295.     LineUp    Op_Size         ; Align the next opcode procedure
  296.     Subttl    Opcode 0C - TSB Absolute            (65C02 ONLY)
  297.     Page    +
  298. ;******************************************************************************
  299. ;
  300. ;    Op_TSB_A ()    Test and Set Memory Bits Against Accumulator
  301. ;
  302. ;        Setup the effective address
  303. ;        Do the TSB operation (Update flag bit z)
  304. ;        Fetch the next instruction
  305. ;
  306. ;******************************************************************************
  307. Op_TSB_A    Proc    Near        ; Test and set memory bits procedure
  308.     DoAbs                ; Setup the effective address
  309.     OpTSB                ; Do the TSB operation (Update z)
  310.     Fetch                ; Fetch and execute next instruction
  311. Op_TSB_A    Endp            ; End of test and set bits procedure
  312.     LineUp    Op_Size         ; Align the next opcode procedure
  313.     Subttl    Opcode 0D - ORA Absolute
  314.     Page    +
  315. ;******************************************************************************
  316. ;
  317. ;    Op_ORA_A ()    OR Accumulator with Memory
  318. ;
  319. ;        Setup the effective address
  320. ;        Do the ORA operation (Update flag bits n, z)
  321. ;        Fetch the next instruction
  322. ;
  323. ;******************************************************************************
  324. Op_ORA_A    Proc    Near        ; OR accumulator with memory procedure
  325.     DoAbs                ; Setup the effective address
  326.     OpORA                ; Do the ORA operation (Update n,z)
  327.     Fetch                ; Fetch and execute next instruction
  328. Op_ORA_A    Endp            ; End of OR accumulator procedure
  329.     LineUp    Op_Size         ; Align the next opcode procedure
  330.     Subttl    Opcode 0E - ASL Absolute
  331.     Page    +
  332. ;******************************************************************************
  333. ;
  334. ;    Op_ASL_A ()    Shift Memory Left
  335. ;
  336. ;        Setup the effective address
  337. ;        Do the ASL operation (Update flag bits n, z, c)
  338. ;        Fetch the next instruction
  339. ;
  340. ;******************************************************************************
  341. Op_ASL_A    Proc    Near        ; Shift memory left procedure
  342.     DoAbs                ; Setup the effective address
  343.     OpASL                ; Do the ASL operation (Update n,z,c)
  344.     Fetch                ; Fetch and execute next instruction
  345. Op_ASL_A    Endp            ; End of shift memory left procedure
  346.     LineUp    Op_Size         ; Align the next opcode procedure
  347.     Subttl    Opcode 0F - ORA Absolute Long            (ILLEGAL)
  348.     Page    +
  349. ;******************************************************************************
  350. ;
  351. ;    Op_ORA_AL ()    OR Accumulator with Memory
  352. ;
  353. ;        Increment to the next opcode
  354. ;        Fetch the next instruction
  355. ;
  356. ;******************************************************************************
  357. Op_ORA_AL    Proc    Near        ; OR accumulator with memory procedure
  358.     add    si,3            ; Increment to the next opcode
  359.     Fetch                ; Fetch and execute next instruction
  360. Op_ORA_AL    Endp            ; End of OR accumulator procedure
  361.     LineUp    Op_Size         ; Align the next opcode procedure
  362.     Subttl    Opcode 10 - BPL Program Counter Relative
  363.     Page    +
  364. ;******************************************************************************
  365. ;
  366. ;    Op_BPL ()    Branch if Plus
  367. ;
  368. ;        Get the program counter offset byte
  369. ;        If the n flag is clear
  370. ;            Update the program counter
  371. ;        Endif
  372. ;        Fetch the next instruction
  373. ;
  374. ;******************************************************************************
  375. Op_BPL        Proc    Near        ; Branch if plus procedure
  376.     lodsb                ; Get the program counter offset
  377.     test    dh,CPU_N        ; Check the 65C02 n (Negative) flag
  378.     jnz    _BPL            ; Jump if the n flag is set (Negative)
  379.     cbw                ; Convert offset into a full word
  380.     add    si,ax            ; Compute the new program counter
  381. _BPL:
  382.     Fetch                ; Fetch and execute next instruction
  383. Op_BPL        Endp            ; End of branch if plus procedure
  384.     LineUp    Op_Size         ; Align the next opcode procedure
  385.     Subttl    Opcode 11 - ORA DP Indirect Indexed, Y
  386.     Page    +
  387. ;******************************************************************************
  388. ;
  389. ;    Op_ORA_DIIY ()    OR Accumulator with Memory
  390. ;
  391. ;        Setup the effective address
  392. ;        Do the ORA operation (Update flag bits n, z)
  393. ;        Fetch the next instruction
  394. ;
  395. ;******************************************************************************
  396. Op_ORA_DIIY    Proc    Near        ; OR accumulator with memory procedure
  397.     DoDIIY                ; Setup the effective address
  398.     OpORA                ; Do the ORA operation (Update n,z)
  399.     Fetch                ; Fetch and execute next instruction
  400. Op_ORA_DIIY    Endp            ; End of OR accumulator procedure
  401.     LineUp    Op_Size         ; Align the next opcode procedure
  402.     Subttl    Opcode 12 - ORA DP Indirect            (65C02 ONLY)
  403.     Page    +
  404. ;******************************************************************************
  405. ;
  406. ;    Op_ORA_DI ()    OR Acumulator with Memory
  407. ;
  408. ;        Setup the effective address
  409. ;        Do the ORA operation (Update flag bits n, z)
  410. ;        Fetch the next instruction
  411. ;
  412. ;******************************************************************************
  413. Op_ORA_DI    Proc    Near        ; OR accumulator with memory procedure
  414.     DoDI                ; Setup the effective address
  415.     OpORA                ; Do the ORA operation (Update n,z)
  416.     Fetch                ; Fetch and execute next instruction
  417. Op_ORA_DI    Endp            ; End of OR accumulator procedure
  418.     LineUp    Op_Size         ; Align the next opcode procedure
  419.     Subttl    Opcode 13 - ORA SR Indirect Indexed, Y        (ILLEGAL)
  420.     Page    +
  421. ;******************************************************************************
  422. ;
  423. ;    Op_ORA_SIIY ()    OR Accumulator with Memory
  424. ;
  425. ;        Increment to the next opcode
  426. ;        Fetch the next instruction
  427. ;
  428. ;******************************************************************************
  429. Op_ORA_SIIY    Proc    Near        ; OR accumulator with memory procedure
  430.     inc    si            ; Increment to the next opcode
  431.     Fetch                ; Fetch and execute next instruction
  432. Op_ORA_SIIY    Endp            ; End of OR accumulator procedure
  433.     LineUp    Op_Size         ; Align the next opcode procedure
  434.     Subttl    Opcode 14 - TRB Direct Page            (65C02 ONLY)
  435.     Page    +
  436. ;******************************************************************************
  437. ;
  438. ;    Op_TRB_DP ()    Test and Reset Memory Bits Against Accumulator
  439. ;
  440. ;        Setup the effective address
  441. ;        Do the TRB operation (Update flag bit z)
  442. ;        Fetch the next instruction
  443. ;
  444. ;******************************************************************************
  445. Op_TRB_DP    Proc    Near        ; Test and reset memory bits procedure
  446.     DoDP                ; Setup the effective address
  447.     OpTRB                ; Do the TRB operation (Update z)
  448.     Fetch                ; Fetch and execute next instruction
  449. Op_TRB_DP    Endp            ; End of test and reset procedure
  450.     LineUp    Op_Size         ; Align the next opcode procedure
  451.     Subttl    Opcode 15 - ORA DP Indexed, X
  452.     Page    +
  453. ;******************************************************************************
  454. ;
  455. ;    Op_ORA_DIX ()    OR Accumulator with Memory
  456. ;
  457. ;        Setup the effective address
  458. ;        Do the ORA operation (Update flag bits n, z)
  459. ;        Fetch the next instruction
  460. ;
  461. ;******************************************************************************
  462. Op_ORA_DIX    Proc    Near        ; OR accumulator with memory procedure
  463.     DoDIX                ; Setup the effective address
  464.     OpORA                ; Do the ORA operation (Update n,z)
  465.     Fetch                ; Fetch and execute next instruction
  466. Op_ORA_DIX    Endp            ; End of OR accumulator procedure
  467.     LineUp    Op_Size         ; Align the next opcode procedure
  468.     Subttl    Opcode 16 - ASL DP Indexed, X
  469.     Page    +
  470. ;******************************************************************************
  471. ;
  472. ;    Op_ASL_DIX ()    Shift Memory Left
  473. ;
  474. ;        Setup the effective address
  475. ;        Do the ASL operation (Update flag bits n, z, c)
  476. ;        Fetch the next instruction
  477. ;
  478. ;******************************************************************************
  479. Op_ASL_DIX    Proc    Near        ; Shift memory left procedure
  480.     DoDIX                ; Setup the effective address
  481.     OpASL                ; Do the ASL operation (Update n,z,c)
  482.     Fetch                ; Fetch and execute next instruction
  483. Op_ASL_DIX    Endp            ; End of shift memory left procedure
  484.     LineUp    Op_Size         ; Align the next opcode procedure
  485.     Subttl    Opcode 17 - ORA DP Indirect Long Indexed, Y    (ILLEGAL)
  486.     Page    +
  487. ;******************************************************************************
  488. ;
  489. ;    Op_ORA_DILIY () OR Accumulator with Memory
  490. ;
  491. ;        Increment to the next opcode
  492. ;        Fetch the next instruction
  493. ;
  494. ;******************************************************************************
  495. Op_ORA_DILIY    Proc    Near        ; OR accumulator with memory procedure
  496.     inc    si            ; Increment to the next opcode
  497.     Fetch                ; Fetch and execute next instruction
  498. Op_ORA_DILIY    Endp            ; End of OR accumulator procedure
  499.     LineUp    Op_Size         ; Align the next opcode procedure
  500.     Subttl    Opcode 18 - CLC Implied
  501.     Page    +
  502. ;******************************************************************************
  503. ;
  504. ;    Op_CLC ()    Clear Carry Flag
  505. ;
  506. ;        Clear the 65C02 carry flag
  507. ;        Fetch the next instruction
  508. ;
  509. ;******************************************************************************
  510. Op_CLC        Proc    Near        ; Clear carry flag procedure
  511.     and    dh,Not CPU_C        ; Clear the 65C02 carry flag
  512.     Fetch                ; Fetch and execute next instruction
  513. Op_CLC        Endp            ; End of clear carry flag procedure
  514.     LineUp    Op_Size         ; Align the next opcode procedure
  515.     Subttl    Opcode 19 - ORA Absolute Indexed, Y
  516.     Page    +
  517. ;******************************************************************************
  518. ;
  519. ;    Op_ORA_AIY ()    OR Accumulator with Memory
  520. ;
  521. ;        Setup the effective address
  522. ;        Do the ORA operation (Update flag bits n, z)
  523. ;        Fetch the next instruction
  524. ;
  525. ;******************************************************************************
  526. Op_ORA_AIY    Proc    Near        ; OR accumulator with memory procedure
  527.     DoAIY                ; Setup the effective address
  528.     OpORA                ; Do the ORA operation (Update n,z)
  529.     Fetch                ; Fetch and execute next instruction
  530. Op_ORA_AIY    Endp            ; End of OR accumulator procedure
  531.     LineUp    Op_Size         ; Align the next opcode procedure
  532.     Subttl    Opcode 1A - INC Accumulator            (65C02 ONLY)
  533.     Page    +
  534. ;******************************************************************************
  535. ;
  536. ;    Op_INC ()    Increment the Accumulator
  537. ;
  538. ;        Increment the accumulator
  539. ;        Update the 65C02 processor flags (n, z)
  540. ;        Fetch the next instruction
  541. ;
  542. ;******************************************************************************
  543. Op_INC        Proc    Near        ; Increment the accumulator procedure
  544.     inc    dl            ; Increment the accumulator
  545.     Flgnz                ; Update the n and z flags
  546.     Fetch                ; Fetch and execute next instruction
  547. Op_INC        Endp            ; End of increment accumulator procedure
  548.     LineUp    Op_Size         ; Align the next opcode procedure
  549.     Subttl    Opcode 1B - TCS Implied             (ILLEGAL)
  550.     Page    +
  551. ;******************************************************************************
  552. ;
  553. ;    Op_TCS ()    Transfer Accumulator to Stack Pointer
  554. ;
  555. ;        Fetch the next instruction
  556. ;
  557. ;******************************************************************************
  558. Op_TCS        Proc    Near        ; Transfer accumulator/stack procedure
  559.     Fetch                ; Fetch and execute next instruction
  560. Op_TCS        Endp            ; End of transfer accumulator procedure
  561.     LineUp    Op_Size         ; Align the next opcode procedure
  562.     Subttl    Opcode 1C - TRB Absolute            (65C02 ONLY)
  563.     Page    +
  564. ;******************************************************************************
  565. ;
  566. ;    Op_TRB_A ()    Test and Reset Memory Bits Against Accumulator
  567. ;
  568. ;        Setup the effective address
  569. ;        Do the TRB operation (Update flag bit z)
  570. ;        Fetch the next instruction
  571. ;
  572. ;******************************************************************************
  573. Op_TRB_A    Proc    Near        ; Test and reset memory bits procedure
  574.     DoAbs                ; Setup the effective address
  575.     OpTRB                ; Do the TRB operation (Update z)
  576.     Fetch                ; Fetch and execute next instruction
  577. Op_TRB_A    Endp            ; End of test and reset bits procedure
  578.     LineUp    Op_Size         ; Align the next opcode procedure
  579.     Subttl    Opcode 1D - ORA Absolute Indexed, X
  580.     Page    +
  581. ;******************************************************************************
  582. ;
  583. ;    Op_ORA_AIX ()    OR Accumulator with Memory
  584. ;
  585. ;        Setup the effective address
  586. ;        Do the ORA operation (Update flag bits n, z)
  587. ;        Fetch the next instruction
  588. ;
  589. ;******************************************************************************
  590. Op_ORA_AIX    Proc    Near        ; OR accumulator with memory procedure
  591.     DoAIX                ; Setup the effective address
  592.     OpORA                ; Do the ORA operation (Update n,z)
  593.     Fetch                ; Fetch and execute next instruction
  594. Op_ORA_AIX    Endp            ; End of OR accumulator procedure
  595.     LineUp    Op_Size         ; Align the next opcode procedure
  596.     Subttl    Opcode 1E - ASL Absolute Indexed, X
  597.     Page    +
  598. ;******************************************************************************
  599. ;
  600. ;    Op_ASL_AIX ()    Shift Memory Left
  601. ;
  602. ;        Setup the effective address
  603. ;        Do the ASL operation (Update flag bits n, z, c)
  604. ;        Fetch the next instruction
  605. ;
  606. ;******************************************************************************
  607. Op_ASL_AIX    Proc    Near        ; Shift memory left procedure
  608.     DoAIX                ; Setup the effective address
  609.     OpASL                ; Do the ASL operation (Update n,z,c)
  610.     Fetch                ; Fetch and execute next instruction
  611. Op_ASL_AIX    Endp            ; End of shift memory left procedure
  612.     LineUp    Op_Size         ; Align the next opcode procedure
  613.     Subttl    Opcode 1F - ORA Absolute Long Indexed, X    (ILLEGAL)
  614.     Page    +
  615. ;******************************************************************************
  616. ;
  617. ;    Op_ORA_ALIX ()    OR Accumulator with Memory
  618. ;
  619. ;        Increment to the next opcode
  620. ;        Fetch the next instruction
  621. ;
  622. ;******************************************************************************
  623. Op_ORA_ALIX    Proc    Near        ; OR accumulator with memory procedure
  624.     add    si,3            ; Increment to the next opcode
  625.     Fetch                ; Fetch and execute next instruction
  626. Op_ORA_ALIX    Endp            ; End of OR accumulator procedure
  627.     LineUp    Op_Size         ; Align the next opcode procedure
  628.     Subttl    Opcode 20 - JSR Absolute
  629.     Page    +
  630. ;******************************************************************************
  631. ;
  632. ;    Op_JSR_A ()    Jump to Subroutine
  633. ;
  634. ;        Setup the effective address
  635. ;        Do the JMP operation
  636. ;        Fetch the next instruction
  637. ;
  638. ;******************************************************************************
  639. Op_JSR_A    Proc    Near        ; Jump to subroutine procedure
  640.     DoAbs                ; Setup the effective address
  641.     OpJSR                ; Do the JSR operation
  642.     Fetch                ; Fetch and execute next instruction
  643. Op_JSR_A    Endp            ; End of jump to subroutine procedure
  644.     LineUp    Op_Size         ; Align the next opcode procedure
  645.     Subttl    Opcode 21 - AND DP Indexed Indirect, X
  646.     Page    +
  647. ;******************************************************************************
  648. ;
  649. ;    Op_AND_DIIX ()    AND Accumulator with Memory
  650. ;
  651. ;        Setup the effective address
  652. ;        Do the AND operation (Update flag bits n, z)
  653. ;        Fetch the next instruction
  654. ;
  655. ;******************************************************************************
  656. Op_AND_DIIX    Proc    Near        ; AND accumulator with memory procedure
  657.     DoDIIX                ; Setup the effective address
  658.     OpAND                ; Do the AND operation (Update n,z)
  659.     Fetch                ; Fetch and execute next instruction
  660. Op_AND_DIIX    Endp            ; End of AND accumulator procedure
  661.     LineUp    Op_Size         ; Align the next opcode procedure
  662.     Subttl    Opcode 22 - JSR Absolute Long            (ILLEGAL)
  663.     Page    +
  664. ;******************************************************************************
  665. ;
  666. ;    Op_JSL_AL ()    Jump to Subroutine
  667. ;
  668. ;        Increment to the next opcode
  669. ;        Fetch the next instruction
  670. ;
  671. ;******************************************************************************
  672. Op_JSL_AL    Proc    Near        ; Jump to subroutine procedure
  673.     add    si,3            ; Increment to the next opcode
  674.     Fetch                ; Fetch and execute next instruction
  675. Op_JSL_AL    Endp            ; End of jump to subroutine procedure
  676.     LineUp    Op_Size         ; Align the next opcode procedure
  677.     Subttl    Opcode 23 - AND Stack Relative            (ILLEGAL)
  678.     Page    +
  679. ;******************************************************************************
  680. ;
  681. ;    Op_AND_S ()    AND Accumulator with Memory
  682. ;
  683. ;        Increment to the next opcode
  684. ;        Fetch the next instruction
  685. ;
  686. ;******************************************************************************
  687. Op_AND_S    Proc    Near        ; AND accumulator with memory procedure
  688.     inc    si            ; Increment to the next opcode
  689.     Fetch                ; Fetch and execute next instruction
  690. Op_AND_S    Endp            ; End of AND accumulator procedure
  691.     LineUp    Op_Size         ; Align the next opcode procedure
  692.     Subttl    Opcode 24 - BIT Direct Page
  693.     Page    +
  694. ;******************************************************************************
  695. ;
  696. ;    Op_BIT_DP ()    Test Memory Bits Against Accumulator
  697. ;
  698. ;        Setup the effective address
  699. ;        Do the BIT operation (Update flag bits n, v, z)
  700. ;        Fetch the next instruction
  701. ;
  702. ;******************************************************************************
  703. Op_BIT_DP    Proc    Near        ; Test memory bits procedure
  704.     DoDP                ; Setup the effective address
  705.     OpBIT                ; Do the BIT operation (Update n,v,z)
  706.     Fetch                ; Fetch and execute next instruction
  707. Op_BIT_DP    Endp            ; End of test memory bits procedure
  708.     LineUp    Op_Size         ; Align the next opcode procedure
  709.     Subttl    Opcode 25 - AND Direct Page
  710.     Page    +
  711. ;******************************************************************************
  712. ;
  713. ;    Op_AND_DP ()    AND Accumulator with Memory
  714. ;
  715. ;        Setup the effective address
  716. ;        Do the AND operation (Update flag bits n, z)
  717. ;        Fetch the next instruction
  718. ;
  719. ;******************************************************************************
  720. Op_AND_DP    Proc    Near        ; AND accumulator with memory procedure
  721.     DoDP                ; Setup the effective address
  722.     OpAND                ; Do the AND operation (Update n,z)
  723.     Fetch                ; Fetch and execute next instruction
  724. Op_AND_DP    Endp            ; End of AND accumulator procedure
  725.     LineUp    Op_Size         ; Align the next opcode procedure
  726.     Subttl    Opcode 26 - ROL Direct Page
  727.     Page    +
  728. ;******************************************************************************
  729. ;
  730. ;    Op_ROL_DP ()    Rotate Memory Left
  731. ;
  732. ;        Setup the effective address
  733. ;        Do the ROL operation (Update flag bits n, z, c)
  734. ;        Fetch the next instruction
  735. ;
  736. ;******************************************************************************
  737. Op_ROL_DP    Proc    Near        ; Rotate memory left procedure
  738.     DoDP                ; Setup the effective address
  739.     OpROL                ; Do the ROL operation (Update n,z,c)
  740.     Fetch                ; Fetch and execute next instruction
  741. Op_ROL_DP    Endp            ; End of rotate memory left procedure
  742.     LineUp    Op_Size         ; Align the next opcode procedure
  743.     Subttl    Opcode 27 - AND DP Indirect Long        (ILLEGAL)
  744.     Page    +
  745. ;******************************************************************************
  746. ;
  747. ;    Op_AND_DIL ()    AND Accumulator with Memory
  748. ;
  749. ;        Increment to the next opcode
  750. ;        Fetch the next instruction
  751. ;
  752. ;******************************************************************************
  753. Op_AND_DIL    Proc    Near        ; AND accumulator with memory procedure
  754.     inc    si            ; Increment to the next opcode
  755.     Fetch                ; Fetch and execute next instruction
  756. Op_AND_DIL    Endp            ; End of AND accumulator procedure
  757.     LineUp    Op_Size         ; Align the next opcode procedure
  758.     Subttl    Opcode 28 - PLP Stack/Pull
  759.     Page    +
  760. ;******************************************************************************
  761. ;
  762. ;    Op_PLP ()    Pull Processor Status Register
  763. ;
  764. ;        Pop the 65C02 status flags from stack
  765. ;        Clear the r (Reserved) flag bit
  766. ;        Decode flag bits from 65c02 to 80x86
  767. ;        Fetch the next instruction
  768. ;
  769. ;******************************************************************************
  770. Op_PLP        Proc    Near        ; Pull processor status procedure
  771.     Pop_8                ; Pop 65C02 status flags from stack
  772.     and    al,Not CPU_R        ; Make sure reserved bit is clear
  773.     xor    ah,ah            ; Convert flag value to full word
  774.     mov    bp,ax            ; Setup to decode the flag value
  775.     mov    al,cs:[bp + Flag_Decode]; Get the decoded flag value
  776.     mov    dh,al            ; Update 65C02 processor status flags
  777.     Fetch                ; Fetch and execute next instruction
  778. Op_PLP        Endp            ; End of pull processor status procedure
  779.     LineUp    Op_Size         ; Align the next opcode procedure
  780.     Subttl    Opcode 29 - AND Immediate
  781.     Page    +
  782. ;******************************************************************************
  783. ;
  784. ;    Op_AND_I ()    AND Accumulator with Memory
  785. ;
  786. ;        Setup the effective address
  787. ;        Do the AND operation (Update flag bits n, z)
  788. ;        Fetch the next instruction
  789. ;
  790. ;******************************************************************************
  791. Op_AND_I    Proc    Near        ; AND accumulator with memory procedure
  792.     DoImm                ; Setup the effective address
  793.     OpAND                ; Do the AND operation (Update n,z)
  794.     Fetch                ; Fetch and execute next instruction
  795. Op_AND_I    Endp            ; End of AND accumulator procedure
  796.     LineUp    Op_Size         ; Align the next opcode procedure
  797.     Subttl    Opcode 2A - ROL Accumulator
  798.     Page    +
  799. ;******************************************************************************
  800. ;
  801. ;    Op_ROL ()    Rotate Accumulator Left
  802. ;
  803. ;        Move 65C02 carry flag into real carry
  804. ;        Rotate the accumulator left
  805. ;        Update the 65C02 processor flags (n, z, c)
  806. ;        Fetch the next instruction
  807. ;
  808. ;******************************************************************************
  809. Op_ROL        Proc    Near        ; Rotate accumulator left procedure
  810.     mov    al,dh            ; Get 65C02 processor status flags
  811.     shr    al,1            ; Move 65C02 carry flag into real carry
  812.     rcl    dl,1            ; Rotate the accumulator left
  813.     rcr    al,1            ; Save carry result in AL register
  814.     or    dl,dl            ; Set the n and z flags correctly
  815.     rcl    al,1            ; Restore the carry result
  816.     Flgnzc                ; Update the n, z, and c flags
  817.     Fetch                ; Fetch and execute next instruction
  818. Op_ROL        Endp            ; End of rotate accumulator procedure
  819.     LineUp    Op_Size         ; Align the next opcode procedure
  820.     Subttl    Opcode 2B - PLD Stack/Pull            (ILLEGAL)
  821.     Page    +
  822. ;******************************************************************************
  823. ;
  824. ;    Op_PLD ()    Pull Direct Page Register
  825. ;
  826. ;        Fetch the next instruction
  827. ;
  828. ;******************************************************************************
  829. Op_PLD        Proc    Near        ; Pull direct page register procedure
  830.     Fetch                ; Fetch and execute next instruction
  831. Op_PLD        Endp            ; End of pull direct page procedure
  832.     LineUp    Op_Size         ; Align the next opcode procedure
  833.     Subttl    Opcode 2C - BIT Absolute
  834.     Page    +
  835. ;******************************************************************************
  836. ;
  837. ;    Op_BIT_A ()    Test Memory Bits Against Accumulator
  838. ;
  839. ;        Setup the effective address
  840. ;        Do the BIT operation (Update flag bits n, v, z)
  841. ;        Fetch the next instruction
  842. ;
  843. ;******************************************************************************
  844. Op_BIT_A    Proc    Near        ; Test memory bits procedure
  845.     DoAbs                ; Setup the effective address
  846.     OpBIT                ; Do the BIT operation (Update n,v,z)
  847.     Fetch                ; Fetch and execute next instruction
  848. Op_BIT_A    Endp            ; End of test memory bits procedure
  849.     LineUp    Op_Size         ; Align the next opcode procedure
  850.     Subttl    Opcode 2D - AND Absolute
  851.     Page    +
  852. ;******************************************************************************
  853. ;
  854. ;    Op_AND_A ()    AND Accumulator with Memory
  855. ;
  856. ;        Setup the effective address
  857. ;        Do the AND operation (Update flag bits n, z)
  858. ;        Fetch the next instruction
  859. ;
  860. ;******************************************************************************
  861. Op_AND_A    Proc    Near        ; AND accumulator with memory procedure
  862.     DoAbs                ; Setup the effective address
  863.     OpAND                ; Do the AND operation (Update n,z)
  864.     Fetch                ; Fetch and execute next instruction
  865. Op_AND_A    Endp            ; End of AND accumulator procedure
  866.     LineUp    Op_Size         ; Align the next opcode procedure
  867.     Subttl    Opcode 2E - ROL Absolute
  868.     Page    +
  869. ;******************************************************************************
  870. ;
  871. ;    Op_ROL_A ()    Rotate Memory Left
  872. ;
  873. ;        Setup the effective address
  874. ;        Do the ROL operation (Update flag bits n, z, c)
  875. ;        Fetch the next instruction
  876. ;
  877. ;******************************************************************************
  878. Op_ROL_A    Proc    Near        ; Rotate memory left procedure
  879.     DoAbs                ; Setup the effective address
  880.     OpROL                ; Do the ROL operation (Update n,z,c)
  881.     Fetch                ; Fetch and execute next instruction
  882. Op_ROL_A    Endp            ; End of rotate memory left procedure
  883.     LineUp    Op_Size         ; Align the next opcode procedure
  884.     Subttl    Opcode 2F - AND Absolute Long            (ILLEGAL)
  885.     Page    +
  886. ;******************************************************************************
  887. ;
  888. ;    Op_AND_AL ()    AND Accumulator with Memory
  889. ;
  890. ;        Increment to the next opcode
  891. ;        Fetch the next instruction
  892. ;
  893. ;******************************************************************************
  894. Op_AND_AL    Proc    Near        ; AND accumulator with memory procedure
  895.     add    si,3            ; Increment to the next opcode
  896.     Fetch                ; Fetch and execute next instruction
  897. Op_AND_AL    Endp            ; End of AND accumulator procedure
  898.     LineUp    Op_Size         ; Align the next opcode procedure
  899.     Subttl    Opcode 30 - BMI Program Counter Relative
  900.     Page    +
  901. ;******************************************************************************
  902. ;
  903. ;    Op_BMI ()    Branch if Minus
  904. ;
  905. ;        Get the program counter offset byte
  906. ;        If the n flag is set
  907. ;            Update the program counter
  908. ;        Endif
  909. ;        Fetch the next instruction
  910. ;
  911. ;******************************************************************************
  912. Op_BMI        Proc    Near        ; Branch if minus procedure
  913.     lodsb                ; Get the program counter offset
  914.     test    dh,CPU_N        ; Check the 65C02 n (Negative) flag
  915.     jz    _BMI            ; Jump if n flag is clear (Positive)
  916.     cbw                ; Convert offset into a full word
  917.     add    si,ax            ; Compute the new program counter
  918. _BMI:
  919.     Fetch                ; Fetch and execute next instruction
  920. Op_BMI        Endp            ; End of branch if minus procedure
  921.     LineUp    Op_Size         ; Align the next opcode procedure
  922.     Subttl    Opcode 31 - AND DP Indirect Indexed, Y
  923.     Page    +
  924. ;******************************************************************************
  925. ;
  926. ;    Op_AND_DIIY ()    AND Accumulator with Memory
  927. ;
  928. ;        Setup the effective address
  929. ;        Do the AND operation (Update flag bits n, z)
  930. ;        Fetch the next instruction
  931. ;
  932. ;******************************************************************************
  933. Op_AND_DIIY    Proc    Near        ; AND accumulator with memory procedure
  934.     DoDIIY                ; Setup the effective address
  935.     OpAND                ; Do the AND operation (Update n,z)
  936.     Fetch                ; Fetch and execute next instruction
  937. Op_AND_DIIY    Endp            ; End of AND accumulator procedure
  938.     LineUp    Op_Size         ; Align the next opcode procedure
  939.     Subttl    Opcode 32 - AND DP Indirect            (65C02 ONLY)
  940.     Page    +
  941. ;******************************************************************************
  942. ;
  943. ;    Op_AND_DI ()    AND Accumulator with Memory
  944. ;
  945. ;        Setup the effective address
  946. ;        Do the AND operation (Update flag bits n, z)
  947. ;        Fetch the next instruction
  948. ;
  949. ;******************************************************************************
  950. Op_AND_DI    Proc    Near        ; AND accumulator with memory procedure
  951.     DoDI                ; Setup the effective address
  952.     OpAND                ; Do the AND operation (Update n,z)
  953.     Fetch                ; Fetch and execute next instruction
  954. Op_AND_DI    Endp            ; End of AND accumulator procedure
  955.     LineUp    Op_Size         ; Align the next opcode procedure
  956.     Subttl    Opcode 33 - AND SR Indirect Indexed, Y        (ILLEGAL)
  957.     Page    +
  958. ;******************************************************************************
  959. ;
  960. ;    Op_AND_SIIY ()    AND Accumulator with Memory
  961. ;
  962. ;        Increment to the next opcode
  963. ;        Fetch the next instruction
  964. ;
  965. ;******************************************************************************
  966. Op_AND_SIIY    Proc    Near        ; AND accumulator with memory procedure
  967.     inc    si            ; Increment to the next opcode
  968.     Fetch                ; Fetch and execute next instruction
  969. Op_AND_SIIY    Endp            ; End of AND accumulator procedure
  970.     LineUp    Op_Size         ; Align the next opcode procedure
  971.     Subttl    Opcode 34 - BIT DP Indexed, X            (65C02 ONLY)
  972.     Page    +
  973. ;******************************************************************************
  974. ;
  975. ;    Op_BIT_DIX ()    Test Memory Bits Against Accumulator
  976. ;
  977. ;        Setup the effective address
  978. ;        Do the BIT operation (Update flag bits n, v, z)
  979. ;        Fetch the next instruction
  980. ;
  981. ;******************************************************************************
  982. Op_BIT_DIX    Proc    Near        ; Test memory bits procedure
  983.     DoDIX                ; Setup the effective address
  984.     OpBIT                ; Do the BIT operation (Update n,v,z)
  985.     Fetch                ; Fetch and execute next instruction
  986. Op_BIT_DIX    Endp            ; End of test memory bits procedure
  987.     LineUp    Op_Size         ; Align the next opcode procedure
  988.     Subttl    Opcode 35 - AND DP Indexed, X
  989.     Page    +
  990. ;******************************************************************************
  991. ;
  992. ;    Op_AND_DIX ()    AND Accumulator with Memory
  993. ;
  994. ;        Setup the effective address
  995. ;        Do the AND operation (Update flag bits n, z)
  996. ;        Fetch the next instruction
  997. ;
  998. ;******************************************************************************
  999. Op_AND_DIX    Proc    Near        ; AND accumulator with memory procedure
  1000.     DoDIX                ; Setup the effective address
  1001.     OpAND                ; Do the AND operation (Update n,z)
  1002.     Fetch                ; Fetch and execute next instruction
  1003. Op_AND_DIX    Endp            ; End of AND accumulator procedure
  1004.     LineUp    Op_Size         ; Align the next opcode procedure
  1005.     Subttl    Opcode 36 - ROL DP Indexed, X
  1006.     Page    +
  1007. ;******************************************************************************
  1008. ;
  1009. ;    Op_ROL_DIX ()    Rotate Memory Left
  1010. ;
  1011. ;        Setup the effective address
  1012. ;        Do the ROL operation (Update flag bits n, z, c)
  1013. ;        Fetch the next instruction
  1014. ;
  1015. ;******************************************************************************
  1016. Op_ROL_DIX    Proc    Near        ; Rotate memory left procedure
  1017.     DoDIX                ; Setup the effective address
  1018.     OpROL                ; Do the ROL operation (Update n,z,c)
  1019.     Fetch                ; Fetch and execute next instruction
  1020. Op_ROL_DIX    Endp            ; End of rotate memory left procedure
  1021.     LineUp    Op_Size         ; Align the next opcode procedure
  1022.     Subttl    Opcode 37 - AND DP Indirect Long Indexed, Y    (ILLEGAL)
  1023.     Page    +
  1024. ;******************************************************************************
  1025. ;
  1026. ;    Op_AND_DILIY () AND Accumulator with Memory
  1027. ;
  1028. ;        Increment to the next opcode
  1029. ;        Fetch the next instruction
  1030. ;
  1031. ;******************************************************************************
  1032. Op_AND_DILIY    Proc    Near        ; AND accumulator with memory procedure
  1033.     inc    si            ; Increment to the next opcode
  1034.     Fetch                ; Fetch and execute next instruction
  1035. Op_AND_DILIY    Endp            ; End of AND accumulator procedure
  1036.     LineUp    Op_Size         ; Align the next opcode procedure
  1037.     Subttl    Opcode 38 - SEC Implied
  1038.     Page    +
  1039. ;******************************************************************************
  1040. ;
  1041. ;    Op_SEC ()    Set Carry Flag
  1042. ;
  1043. ;        Set the 65C02 carry flag
  1044. ;        Fetch the next instruction
  1045. ;
  1046. ;******************************************************************************
  1047. Op_SEC        Proc    Near        ; Set carry flag procedure
  1048.     or    dh,CPU_C        ; Set the 65C02 carry flag
  1049.     Fetch                ; Fetch and execute next instruction
  1050. Op_SEC        Endp            ; End of set carry flag procedure
  1051.     LineUp    Op_Size         ; Align the next opcode procedure
  1052.     Subttl    Opcode 39 - AND Absolute Indexed, Y
  1053.     Page    +
  1054. ;******************************************************************************
  1055. ;
  1056. ;    Op_AND_AIY ()    AND Accumulator with Memroy
  1057. ;
  1058. ;        Setup the effective address
  1059. ;        Do the AND operation (Update flag bits n, z)
  1060. ;        Fetch the next instruction
  1061. ;
  1062. ;******************************************************************************
  1063. Op_AND_AIY    Proc    Near        ; AND accumulator with memory procedure
  1064.     DoAIY                ; Setup the effective address
  1065.     OpAND                ; Do the AND operation (Update n,z)
  1066.     Fetch                ; Fetch and execute next instruction
  1067. Op_AND_AIY    Endp            ; End of AND accumulator procedure
  1068.     LineUp    Op_Size         ; Align the next opcode procedure
  1069.     Subttl    Opcode 3A - DEC Accumulator            (65C02 ONLY)
  1070.     Page    +
  1071. ;******************************************************************************
  1072. ;
  1073. ;    Op_DEC ()    Decrement the Accumulator
  1074. ;
  1075. ;        Decrement the accumulator
  1076. ;        Update the 65C02 processor flags (n, z)
  1077. ;        Fetch the next instruction
  1078. ;
  1079. ;******************************************************************************
  1080. Op_DEC        Proc    Near        ; Decrement the accumulator procedure
  1081.     dec    dl            ; Decrement the accumulator
  1082.     Flgnz                ; Update the n and z flags
  1083.     Fetch                ; Fetch and execute next instruction
  1084. Op_DEC        Endp            ; End of decrement accumulator procedure
  1085.     LineUp    Op_Size         ; Align the next opcode procedure
  1086.     Subttl    Opcode 3B - TSC Implied             (ILLEGAL)
  1087.     Page    +
  1088. ;******************************************************************************
  1089. ;
  1090. ;    Op_TSC ()    Transfer Stack Pointer to Accumulator (16-Bit)
  1091. ;
  1092. ;        Fetch the next instruction
  1093. ;
  1094. ;******************************************************************************
  1095. Op_TSC        Proc    Near        ; Transfer stack > accumulator procedure
  1096.     Fetch                ; Fetch and execute next instruction
  1097. Op_TSC        Endp            ; End of transfer stack procedure
  1098.     LineUp    Op_Size         ; Align the next opcode procedure
  1099.     Subttl    Opcode 3C - BIT Absolute Indexed, X        (65C02 ONLY)
  1100.     Page    +
  1101. ;******************************************************************************
  1102. ;
  1103. ;    Op_BIT_AIX ()    Test Memory Bits Against Accumulator
  1104. ;
  1105. ;        Setup the effective address
  1106. ;        Do the BIT operation (Update flag bits n, v, z)
  1107. ;        Fetch the next instruction
  1108. ;
  1109. ;******************************************************************************
  1110. Op_BIT_AIX    Proc    Near        ; Test memory bits procedure
  1111.     DoAIX                ; Setup the effective address
  1112.     OpBIT                ; Do the BIT operation (Update n,v,z)
  1113.     Fetch                ; Fetch and execute next instruction
  1114. Op_BIT_AIX    Endp            ; End of test memory bits procedure
  1115.     LineUp    Op_Size         ; Align the next opcode procedure
  1116.     Subttl    Opcode 3D - AND Absolute Indexed, X
  1117.     Page    +
  1118. ;******************************************************************************
  1119. ;
  1120. ;    Op_AND_AIX ()    AND Accumulator with Memory
  1121. ;
  1122. ;        Setup the effective address
  1123. ;        Do the AND operation (Update flag bits n, z)
  1124. ;        Fetch the next instruction
  1125. ;
  1126. ;******************************************************************************
  1127. Op_AND_AIX    Proc    Near        ; AND accumulator with memory procedure
  1128.     DoAIX                ; Setup the effective address
  1129.     OpAND                ; Do the AND operation (Update n,z)
  1130.     Fetch                ; Fetch and execute next instruction
  1131. Op_AND_AIX    Endp            ; End of AND accumulator procedure
  1132.     LineUp    Op_Size         ; Align the next opcode procedure
  1133.     Subttl    Opcode 3E - ROL Absolute Indexed, X
  1134.     Page    +
  1135. ;******************************************************************************
  1136. ;
  1137. ;    Op_ROL_AIX ()    Rotate Memory Left
  1138. ;
  1139. ;        Setup the effective address
  1140. ;        Do the ROL operation (Update flag bits n, z, c)
  1141. ;        Fetch the next instruction
  1142. ;
  1143. ;******************************************************************************
  1144. Op_ROL_AIX    Proc    Near        ; Rotate memory left procedure
  1145.     DoAIX                ; Setup the effective address
  1146.     OpROL                ; Do the ROL operation (Update n,z,c)
  1147.     Fetch                ; Fetch and execute next instruction
  1148. Op_ROL_AIX    Endp            ; End of rotate memory left procedure
  1149.     LineUp    Op_Size         ; Align the next opcode procedure
  1150.     Subttl    Opcode 3F - AND Absolute Long Indexed, X    (ILLEGAL)
  1151.     Page    +
  1152. ;******************************************************************************
  1153. ;
  1154. ;    Op_AND_ALIX ()    AND Accumulator with Memory
  1155. ;
  1156. ;        Increment to the next opcode
  1157. ;        Fetch the next instruction
  1158. ;
  1159. ;******************************************************************************
  1160. Op_AND_ALIX    Proc    Near        ; AND accumulator with memory procedure
  1161.     add    si,3            ; Increment to the next opcode
  1162.     Fetch                ; Fetch and execute next instruction
  1163. Op_AND_ALIX    Endp            ; End of AND accumulator procedure
  1164.     LineUp    Op_Size         ; Align the next opcode procedure
  1165.     Subttl    Opcode 40 - RTI Stack/RTI
  1166.     Page    +
  1167. ;******************************************************************************
  1168. ;
  1169. ;    Op_RTI ()    Return from Interrupt
  1170. ;
  1171. ;        Pop the 65C02 processor flags from stack
  1172. ;        Clear the r (Reserved) flag bit
  1173. ;        Decode flag bits from 65c02 to 80x86
  1174. ;        Pop the return address from the stack
  1175. ;        Fetch the next instruction
  1176. ;
  1177. ;******************************************************************************
  1178. Op_RTI        Proc    Near        ; Return from interrupt procedure
  1179.     Pop_8                ; Pop 65C02 processor flags from stack
  1180.     and    al,Not CPU_R        ; Make sure reserved bit is clear
  1181.     xor    ah,ah            ; Convert flag value to full word
  1182.     mov    bp,ax            ; Setup to decode the flag value
  1183.     mov    al,cs:[bp + Flag_Decode]; Get the decoded flag value
  1184.     mov    dh,al            ; Update 65C02 processor status flags
  1185.     Pop_16                ; Pop the return address from the stack
  1186.     mov    si,ax            ; Update the program counter
  1187.     Fetch                ; Fetch and execute next instruction
  1188. Op_RTI        Endp            ; End of interrupt return procedure
  1189.     LineUp    Op_Size         ; Align the next opcode procedure
  1190.     Subttl    Opcode 41 - EOR DP Indexed Indirect, X
  1191.     Page    +
  1192. ;******************************************************************************
  1193. ;
  1194. ;    Op_EOR_DIIX ()    Exclusive-OR Accumulator with Memory
  1195. ;
  1196. ;        Setup the effective address
  1197. ;        Do the EOR operation (Update flag bits n, z)
  1198. ;        Fetch the next instruction
  1199. ;
  1200. ;******************************************************************************
  1201. Op_EOR_DIIX    Proc    Near        ; XOR accumulator with memory procedure
  1202.     DoDIIX                ; Setup the effective address
  1203.     OpEOR                ; Do the EOR operation (Update n,z)
  1204.     Fetch                ; Fetch and execute next instruction
  1205. Op_EOR_DIIX    Endp            ; End of XOR accumulator procedure
  1206.     LineUp    Op_Size         ; Align the next opcode procedure
  1207.     Subttl    Opcode 42 - WDM Implied             (ILLEGAL)
  1208.     Page    +
  1209. ;******************************************************************************
  1210. ;
  1211. ;    Op_WDM ()    Reserved for Future Expansion
  1212. ;
  1213. ;        Increment to the next opcode
  1214. ;        Fetch the next instruction
  1215. ;
  1216. ;******************************************************************************
  1217. Op_WDM        Proc    Near        ; Future expansion procedure
  1218.     inc    si            ; Increment to the next opcode
  1219.     Fetch                ; Fetch and execute next instruction
  1220. Op_WDM        Endp            ; End of future expansion procedure
  1221.     LineUp    Op_Size         ; Align the next opcode procedure
  1222.     Subttl    Opcode 43 - EOR Stack Relative            (ILLEGAL)
  1223.     Page    +
  1224. ;******************************************************************************
  1225. ;
  1226. ;    Op_EOR_S ()    Exclusive-OR Accumulator with Memory
  1227. ;
  1228. ;        Increment to the next opcode
  1229. ;        Fetch the next instruction
  1230. ;
  1231. ;******************************************************************************
  1232. Op_EOR_S    Proc    Near        ; XOR accumulator with memory procedure
  1233.     inc    si            ; Increment to the next opcode
  1234.     Fetch                ; Fetch and execute next instruction
  1235. Op_EOR_S    Endp            ; End of XOR accumulator procedure
  1236.     LineUp    Op_Size         ; Align the next opcode procedure
  1237.     Subttl    Opcode 44 - MVP Implied             (ILLEGAL)
  1238.     Page    +
  1239. ;******************************************************************************
  1240. ;
  1241. ;    Op_MVP ()    Block Move Previous
  1242. ;
  1243. ;        Increment to the next opcode
  1244. ;        Fetch the next instruction
  1245. ;
  1246. ;******************************************************************************
  1247. Op_MVP        Proc    Near        ; Block move previous procedure
  1248.     add    si,2            ; Increment to the next opcode
  1249.     Fetch                ; Fetch and execute next instruction
  1250. Op_MVP        Endp            ; End of block move previous procedure
  1251.     LineUp    Op_Size         ; Align the next opcode procedure
  1252.     Subttl    Opcode 45 - EOR Direct Page
  1253.     Page    +
  1254. ;******************************************************************************
  1255. ;
  1256. ;    Op_EOR_D ()    Exclusive-OR Accumulator with Memory
  1257. ;
  1258. ;        Setup the effective address
  1259. ;        Do the EOR operation (Update flag bits n, z)
  1260. ;        Fetch the next instruction
  1261. ;
  1262. ;******************************************************************************
  1263. Op_EOR_D    Proc    Near        ; XOR accumulator with memory procedure
  1264.     DoDP                ; Setup the effective address
  1265.     OpEOR                ; Do the EOR operation (Update n,z)
  1266.     Fetch                ; Fetch and execute next instruction
  1267. Op_EOR_D    Endp            ; End of XOR accumulator procedure
  1268.     LineUp    Op_Size         ; Align the next opcode procedure
  1269.     Subttl    Opcode 46 - LSR Direct Page
  1270.     Page    +
  1271. ;******************************************************************************
  1272. ;
  1273. ;    Op_LSR_D ()    Logical Shift Memory Right
  1274. ;
  1275. ;        Setup the effective address
  1276. ;        Do the LSR operation (Update flag bits n, z, c)
  1277. ;        Fetch the next instruction
  1278. ;
  1279. ;******************************************************************************
  1280. Op_LSR_D    Proc    Near        ; Logical shift memory right procedure
  1281.     DoDP                ; Setup the effective address
  1282.     OpLSR                ; Do the LSR operation (Update n,z,c)
  1283.     Fetch                ; Fetch and execute next instruction
  1284. Op_LSR_D    Endp            ; End of shift memory right procedure
  1285.     LineUp    Op_Size         ; Align the next opcode procedure
  1286.     Subttl    Opcode 47 - EOR DP Indirect Long        (ILLEGAL)
  1287.     Page    +
  1288. ;******************************************************************************
  1289. ;
  1290. ;    Op_EOR_DIL ()    Exclusive-OR Accumulator with Memory
  1291. ;
  1292. ;        Increment to the next opcode
  1293. ;        Fetch the next instruction
  1294. ;
  1295. ;******************************************************************************
  1296. Op_EOR_DIL    Proc    Near        ; XOR accumulator with memory procedure
  1297.     inc    si            ; Increment to the next opcode
  1298.     Fetch                ; Fetch and execute next instruction
  1299. Op_EOR_DIL    Endp            ; End of XOR accumulator procedure
  1300.     LineUp    Op_Size         ; Align the next opcode procedure
  1301.     Subttl    Opcode 48 - PHA Stack/Push
  1302.     Page    +
  1303. ;******************************************************************************
  1304. ;
  1305. ;    Op_PHA ()    Push Accumulator
  1306. ;
  1307. ;        Push accumulator onto the stack
  1308. ;        Fetch the next instruction
  1309. ;
  1310. ;******************************************************************************
  1311. Op_PHA        Proc    Near        ; Push accumulator procedure
  1312.     mov    al,dl            ; Get the accumulator value
  1313.     Push_8                ; Push accumulator onto the stack
  1314.     Fetch                ; Fetch and execute next instruction
  1315. Op_PHA        Endp            ; End of push accumulator procedure
  1316.     LineUp    Op_Size         ; Align the next opcode procedure
  1317.     Subttl    Opcode 49 - EOR Immediate
  1318.     Page    +
  1319. ;******************************************************************************
  1320. ;
  1321. ;    Op_EOR_I ()    Exclusive-OR Accumulator with Memory
  1322. ;
  1323. ;        Setup the effective address
  1324. ;        Do the EOR operation (Update flag bits n, z)
  1325. ;        Fetch the next instruction
  1326. ;
  1327. ;******************************************************************************
  1328. Op_EOR_I    Proc    Near        ; XOR accumulator with memory procedure
  1329.     DoImm                ; Setup the effective address
  1330.     OpEOR                ; Do the EOR operation (Update n,z)
  1331.     Fetch                ; Fetch and execute next instruction
  1332. Op_EOR_I    Endp            ; End of XOR accumulator procedure
  1333.     LineUp    Op_Size         ; Align the next opcode procedure
  1334.     Subttl    Opcode 4A - LSR Accumulator
  1335.     Page    +
  1336. ;******************************************************************************
  1337. ;
  1338. ;    Op_LSR ()    Logical Shift Accumulator Right
  1339. ;
  1340. ;        Shift the accumulator right
  1341. ;        Update the 65C02 processor flags (n, z, c)
  1342. ;        Fetch the next instruction
  1343. ;
  1344. ;******************************************************************************
  1345. Op_LSR        Proc    Near        ; Shift accumulator right procedure
  1346.     shr    dl,1            ; Shift the accumulator right
  1347.     Flgnzc                ; Update the n, z, and c flags
  1348.     Fetch                ; Fetch and execute next instruction
  1349. Op_LSR        Endp            ; End of accumulator shift procedure
  1350.     LineUp    Op_Size         ; Align the next opcode procedure
  1351.     Subttl    Opcode 4B - PHK Stack/Push            (ILLEGAL)
  1352.     Page    +
  1353. ;******************************************************************************
  1354. ;
  1355. ;    Op_PHK ()    Push Program Bank Register
  1356. ;
  1357. ;        Fetch the next instruction
  1358. ;
  1359. ;******************************************************************************
  1360. Op_PHK        Proc    Near        ; Push bank register procedure
  1361.     Fetch                ; Fetch and execute next instruction
  1362. Op_PHK        Endp            ; End of push bank register procedure
  1363.     LineUp    Op_Size         ; Align the next opcode procedure
  1364.     Subttl    Opcode 4C - JMP Absolute
  1365.     Page    +
  1366. ;******************************************************************************
  1367. ;
  1368. ;    Op_JMP_A ()    Jump
  1369. ;
  1370. ;        Setup the effective address
  1371. ;        Do the JMP operation
  1372. ;        Fetch the next instruction
  1373. ;
  1374. ;******************************************************************************
  1375. Op_JMP_A    Proc    Near        ; Jump procedure
  1376.     DoAbs                ; Setup the effective address
  1377.     OpJMP                ; Do the JMP operation
  1378.     Fetch                ; Fetch and execute next instruction
  1379. Op_JMP_A    Endp            ; End of jump procedure
  1380.     LineUp    Op_Size         ; Align the next opcode procedure
  1381.     Subttl    Opcode 4D - EOR Absolute
  1382.     Page    +
  1383. ;******************************************************************************
  1384. ;
  1385. ;    Op_EOR_A ()    Exclusive-OR Accumulator with Memory
  1386. ;
  1387. ;        Setup the effective address
  1388. ;        Do the EOR operation (Update flag bits n, z)
  1389. ;        Fetch the next instruction
  1390. ;
  1391. ;******************************************************************************
  1392. Op_EOR_A    Proc    Near        ; XOR accumulator with memory procedure
  1393.     DoAbs                ; Setup the effective address
  1394.     OpEOR                ; Do the EOR operation (Update n,z)
  1395.     Fetch                ; Fetch and execute next instruction
  1396. Op_EOR_A    Endp            ; End of XOR accumulator procedure
  1397.     LineUp    Op_Size         ; Align the next opcode procedure
  1398.     Subttl    Opcode 4E - LSR Absolute
  1399.     Page    +
  1400. ;******************************************************************************
  1401. ;
  1402. ;    Op_LSR_A ()    Logical Shift Memory Right
  1403. ;
  1404. ;        Setup the effective address
  1405. ;        Do the LSR operation (Update flag bits n, z, c)
  1406. ;        Fetch the next instruction
  1407. ;
  1408. ;******************************************************************************
  1409. Op_LSR_A    Proc    Near        ; Logical shift memory right  procedure
  1410.     DoAbs                ; Setup the effective address
  1411.     OpLSR                ; Do the LSR operation (Update n,z,c)
  1412.     Fetch                ; Fetch and execute next instruction
  1413. Op_LSR_A    Endp            ; End of shift memory right procedure
  1414.     LineUp    Op_Size         ; Align the next opcode procedure
  1415.     Subttl    Opcode 4F - EOR Absolute Long            (ILLEGAL)
  1416.     Page    +
  1417. ;******************************************************************************
  1418. ;
  1419. ;    Op_EOR_AL ()    Exclusive-OR Accumulator with Memory
  1420. ;
  1421. ;        Increment to the next opcode
  1422. ;        Fetch the next instruction
  1423. ;
  1424. ;******************************************************************************
  1425. Op_EOR_AL    Proc    Near        ; XOR accumulator with memory procedure
  1426.     add    si,3            ; Increment to the next opcode
  1427.     Fetch                ; Fetch and execute next instruction
  1428. Op_EOR_AL    Endp            ; End of XOR accumulator procedure
  1429.     LineUp    Op_Size         ; Align the next opcode procedure
  1430.     Subttl    Opcode 50 - BVC Program Counter Relative
  1431.     Page    +
  1432. ;******************************************************************************
  1433. ;
  1434. ;    Op_BVC ()    Branch if Overflow Clear
  1435. ;
  1436. ;        Get the program counter offset byte
  1437. ;        If the v flag is clear
  1438. ;            Update the program counter
  1439. ;        Endif
  1440. ;        Fetch the next instruction
  1441. ;
  1442. ;******************************************************************************
  1443. Op_BVC        Proc    Near        ; Branch if overflow clear procedure
  1444.     lodsb                ; Get the program counter offset
  1445.     test    dh,CPU_V        ; Check the 65C02 v (Overflow) flag
  1446.     jnz    _BVC            ; Jump if v flag is set (Overflow)
  1447.     cbw                ; Convert offset into a full word
  1448.     add    si,ax            ; Compute the new program counter
  1449. _BVC:
  1450.     Fetch                ; Fetch and execute next instruction
  1451. Op_BVC        Endp            ; End of overflow branch procedure
  1452.     LineUp    Op_Size         ; Align the next opcode procedure
  1453.     Subttl    Opcode 51 - EOR DP Indirect Indexed, Y
  1454.     Page    +
  1455. ;******************************************************************************
  1456. ;
  1457. ;    Op_EOR_DIIY ()    Exclusive-OR Accumulator with Memory
  1458. ;
  1459. ;        Setup the effective address
  1460. ;        Do the EOR operation (Update flag bits n, z)
  1461. ;        Fetch the next instruction
  1462. ;
  1463. ;******************************************************************************
  1464. Op_EOR_DIIY    Proc    Near        ; XOR accumulator with memory procedure
  1465.     DoDIIY                ; Setup the effective address
  1466.     OpEOR                ; Do the EOR operation (Update n,z)
  1467.     Fetch                ; Fetch and execute next instruction
  1468. Op_EOR_DIIY    Endp            ; End of XOR accumulator procedure
  1469.     LineUp    Op_Size         ; Align the next opcode procedure
  1470.     Subttl    Opcode 52 - EOR DP Indirect            (65C02 ONLY)
  1471.     Page    +
  1472. ;******************************************************************************
  1473. ;
  1474. ;    Op_EOR_D ()    Exclusive-OR Accumulator with Memory
  1475. ;
  1476. ;        Setup the effective address
  1477. ;        Do the EOR operation (Update flag bits n, z)
  1478. ;        Fetch the next instruction
  1479. ;
  1480. ;******************************************************************************
  1481. Op_EOR_DI    Proc    Near        ; XOR accumulatoe with memory procedure
  1482.     DoDI                ; Setup the effective address
  1483.     OpEOR                ; Do the EOR operation (Update n,z)
  1484.     Fetch                ; Fetch and execute next instruction
  1485. Op_EOR_DI    Endp            ; End of XOR accumulator procedure
  1486.     LineUp    Op_Size         ; Align the next opcode procedure
  1487.     Subttl    Opcode 53 - EOR SR Indirect Indexed, Y        (ILLEGAL)
  1488.     Page    +
  1489. ;******************************************************************************
  1490. ;
  1491. ;    Op_EOR_SIIY ()    Exclusive-OR Accumulator with Memory
  1492. ;
  1493. ;        Increment to the next opcode
  1494. ;        Fetch the next instruction
  1495. ;
  1496. ;******************************************************************************
  1497. Op_EOR_SIIY    Proc    Near        ; XOR accumulator with memory procedure
  1498.     inc    si            ; Increment to the next opcode
  1499.     Fetch                ; Fetch and execute next instruction
  1500. Op_EOR_SIIY    Endp            ; End of XOR accumulator procedure
  1501.     LineUp    Op_Size         ; Align the next opcode procedure
  1502.     Subttl    Opcode 54 - MVN Implied             (ILLEGAL)
  1503.     Page    +
  1504. ;******************************************************************************
  1505. ;
  1506. ;    Op_MVN ()    Block Move Next
  1507. ;
  1508. ;        Increment to the next opcode
  1509. ;        Fetch the next instruction
  1510. ;
  1511. ;******************************************************************************
  1512. Op_MVN        Proc    Near        ; Block move next procedure
  1513.     add    si,2            ; Increment to the next opcode
  1514.     Fetch                ; Fetch and execute next instruction
  1515. Op_MVN        Endp            ; End of block move next procedure
  1516.     LineUp    Op_Size         ; Align the next opcode procedure
  1517.     Subttl    Opcode 55 - EOR DP Indexed, X
  1518.     Page    +
  1519. ;******************************************************************************
  1520. ;
  1521. ;    Op_EOR_DIX ()    Exclusive-OR Accumulator with Memory
  1522. ;
  1523. ;        Setup the effective address
  1524. ;        Do the EOR operation (Update flag bits n, z)
  1525. ;        Fetch the next instruction
  1526. ;
  1527. ;******************************************************************************
  1528. Op_EOR_DIX    Proc    Near        ; XOR accumulator with memory procedure
  1529.     DoDIX                ; Setup the effective address
  1530.     OpEOR                ; Do the EOR operation (Update n,z)
  1531.     Fetch                ; Fetch and execute next instruction
  1532. Op_EOR_DIX    Endp            ; End of XOR accumulator procedure
  1533.     LineUp    Op_Size         ; Align the next opcode procedure
  1534.     Subttl    Opcode 56 - LSR DP Indexed, X
  1535.     Page    +
  1536. ;******************************************************************************
  1537. ;
  1538. ;    Op_LSR_DIX ()    Logical Shift Memory Right
  1539. ;
  1540. ;        Setup the effective address
  1541. ;        Do the LSR operation (Update flag bits n, z, c)
  1542. ;        Fetch the next instruction
  1543. ;
  1544. ;******************************************************************************
  1545. Op_LSR_DIX    Proc    Near        ; Logical shift memory right procedure
  1546.     DoDIX                ; Setup the effective address
  1547.     OpLSR                ; Do the LSR operation (Update n,z,c)
  1548.     Fetch                ; Fetch and execute next instruction
  1549. Op_LSR_DIX    Endp            ; End of shift memory right procedure
  1550.     LineUp    Op_Size         ; Align the next opcode procedure
  1551.     Subttl    Opcode 57 - EOR DP Indirect Long Indexed, Y    (ILLEGAL)
  1552.     Page    +
  1553. ;******************************************************************************
  1554. ;
  1555. ;    Op_EOR_DILIY () Exclusive-OR Accumulator with Memory
  1556. ;
  1557. ;        Increment to the next opcode
  1558. ;        Fetch the next instruction
  1559. ;
  1560. ;******************************************************************************
  1561. Op_EOR_DILIY    Proc    Near        ; XOR accumulator with memory procedure
  1562.     inc    si            ; Increment to the next opcode
  1563.     Fetch                ; Fetch and execute next instruction
  1564. Op_EOR_DILIY    Endp            ; End of XOR accumulator procedure
  1565.     LineUp    Op_Size         ; Align the next opcode procedure
  1566.     Subttl    Opcode 58 - CLI Implied
  1567.     Page    +
  1568. ;******************************************************************************
  1569. ;
  1570. ;    Op_CLI ()    Clear Interrupt Disable Flag
  1571. ;
  1572. ;        Clear the interrupt disable flag
  1573. ;        Fetch the next instruction
  1574. ;
  1575. ;******************************************************************************
  1576. Op_CLI        Proc    Near        ; Clear interrupt disable procedure
  1577.     and    dh,Not CPU_I        ; Clear the interrupt disable flag
  1578.     Fetch                ; Fetch and execute next instruction
  1579. Op_CLI        Endp            ; End of clear interrupt procedure
  1580.     LineUp    Op_Size         ; Align the next opcode procedure
  1581.     Subttl    Opcode 59 - EOR Absolute Indexed, Y
  1582.     Page    +
  1583. ;******************************************************************************
  1584. ;
  1585. ;    Op_EOR_AIY ()    Exclusive-OR Accumulator with Memory
  1586. ;
  1587. ;        Setup the effective address
  1588. ;        Do the EOR operation (Update flag bits n, z)
  1589. ;        Fetch the next instruction
  1590. ;
  1591. ;******************************************************************************
  1592. Op_EOR_AIY    Proc    Near        ; XOR accumulator with memory procedure
  1593.     DoAIY                ; Setup the effective address
  1594.     OpEOR                ; Do the EOR operation (Update n,z)
  1595.     Fetch                ; Fetch and execute next instruction
  1596. Op_EOR_AIY    Endp            ; End of XOR accumulator procedure
  1597.     LineUp    Op_Size         ; Align the next opcode procedure
  1598.     Subttl    Opcode 5A - PHY Stack/Push            (65C02 ONLY)
  1599.     Page    +
  1600. ;******************************************************************************
  1601. ;
  1602. ;    Op_PHY ()    Push Y Index Register
  1603. ;
  1604. ;        Push Y index register onto stack
  1605. ;        Fetch the next instruction
  1606. ;
  1607. ;******************************************************************************
  1608. Op_PHY        Proc    Near        ; Push Y index register procedure
  1609.     mov    al,cl            ; Get the Y index register value
  1610.     Push_8                ; Push Y index register onto stack
  1611.     Fetch                ; Fetch and execute next instruction
  1612. Op_PHY        Endp            ; End of push Y index procedure
  1613.     LineUp    Op_Size         ; Align the next opcode procedure
  1614.     Subttl    Opcode 5B - TCD Implied             (ILLEGAL)
  1615.     Page    +
  1616. ;******************************************************************************
  1617. ;
  1618. ;    Op_TCD ()    Transfer Accumulator (16-Bit) to Direct Page Register
  1619. ;
  1620. ;        Fetch the next instruction
  1621. ;
  1622. ;******************************************************************************
  1623. Op_TCD        Proc    Near        ; Transfer acc. to direct page procedure
  1624.     Fetch                ; Fetch and execute next instruction
  1625. Op_TCD        Endp            ; End of transfer accumulator procedure
  1626.     LineUp    Op_Size         ; Align the next opcode procedure
  1627.     Subttl    Opcode 5C - JMP Absolute Long            (ILLEGAL)
  1628.     Page    +
  1629. ;******************************************************************************
  1630. ;
  1631. ;    Op_JMP_AL ()    Jump
  1632. ;
  1633. ;        Increment to the next opcode
  1634. ;        Fetch the next instruction
  1635. ;
  1636. ;******************************************************************************
  1637. Op_JMP_AL    Proc    Near        ; Jump procedure
  1638.     add    si,3            ; Increment to the next opcode
  1639.     Fetch                ; Fetch and execute next instruction
  1640. Op_JMP_AL    Endp            ; End of jump procedure
  1641.     LineUp    Op_Size         ; Align the next opcode procedure
  1642.     Subttl    Opcode 5D - EOR Absolute Indexed, X
  1643.     Page    +
  1644. ;******************************************************************************
  1645. ;
  1646. ;    Op_EOR_AIX ()    Exclusive-OR Accumulator with Memory
  1647. ;
  1648. ;        Setup the effective address
  1649. ;        Do the EOR operation (Update flag bits n, z)
  1650. ;        Fetch the next instruction
  1651. ;
  1652. ;******************************************************************************
  1653. Op_EOR_AIX    Proc    Near        ; XOR accumulator with memory procedure
  1654.     DoAIX                ; Setup the effective address
  1655.     OpEOR                ; Do the EOR operation (Update n,z)
  1656.     Fetch                ; Fetch and execute next instruction
  1657. Op_EOR_AIX    Endp            ; End of XOR accumulator procedure
  1658.     LineUp    Op_Size         ; Align the next opcode procedure
  1659.     Subttl    Opcode 5E - LSR Absolute Indexed, X
  1660.     Page    +
  1661. ;******************************************************************************
  1662. ;
  1663. ;    Op_LSR_AIX ()    Logical Shift Memory Right
  1664. ;
  1665. ;        Setup the effective address
  1666. ;        Do the LSR operation (Update flag bits n, z, c)
  1667. ;        Fetch the next instruction
  1668. ;
  1669. ;******************************************************************************
  1670. Op_LSR_AIX    Proc    Near        ; Logical shift memory right procedure
  1671.     DoAIX                ; Setup the effective address
  1672.     OpLSR                ; Do the LSR operation (Update n,z,c)
  1673.     Fetch                ; Fetch and execute next instruction
  1674. Op_LSR_AIX    Endp            ; End of shift memory right procedure
  1675.     LineUp    Op_Size         ; Align the next opcode procedure
  1676.     Subttl    Opcode 5F - EOR Absolute Long Indexed, X    (ILLEGAL)
  1677.     Page    +
  1678. ;******************************************************************************
  1679. ;
  1680. ;    Op_EOR_ALIX ()    Exclusive-OR Accumulator with Memory
  1681. ;
  1682. ;        Increment to the next opcode
  1683. ;        Fetch the next instruction
  1684. ;
  1685. ;******************************************************************************
  1686. Op_EOR_ALIX    Proc    Near        ; XOR accumulator with memory procedure
  1687.     add    si,3            ; Increment to the next opcode
  1688.     Fetch                ; Fetch and execute next instruction
  1689. Op_EOR_ALIX    Endp            ; End of XOR accumulator procedure
  1690.     LineUp    Op_Size         ; Align the next opcode procedure
  1691.     Subttl    Opcode 60 - RTS Stack/RTS
  1692.     Page    +
  1693. ;******************************************************************************
  1694. ;
  1695. ;    Op_RTS ()    Return from Subroutine
  1696. ;
  1697. ;        Pop the return address from the stack
  1698. ;        Increment the return address
  1699. ;        Update the program counter
  1700. ;        Fetch the next instruction
  1701. ;
  1702. ;******************************************************************************
  1703. Op_RTS        Proc    Near        ; Return from subroutine procedure
  1704.     Pop_16                ; Pop return address from the stack
  1705.     inc    ax            ; Increment the return address value
  1706.     mov    si,ax            ; Update the program counter
  1707.     Fetch                ; Fetch and execute next instruction
  1708. Op_RTS        Endp            ; End of subroutine return procedure
  1709.     LineUp    Op_Size         ; Align the next opcode procedure
  1710.     Subttl    Opcode 61 - ADC DP Indexed Indirect, X
  1711.     Page    +
  1712. ;******************************************************************************
  1713. ;
  1714. ;    Op_ADC_DIIX ()    Add to Accumulator with Carry
  1715. ;
  1716. ;        Setup the effective address
  1717. ;        If in decimal (BCD) mode
  1718. ;            Do the ADC decimal operation (Update flags n, v, z, c)
  1719. ;        Else in binary mode
  1720. ;            Do the ADC binary operation (Update flags n, v, z, c)
  1721. ;        Endif
  1722. ;        Fetch the next instruction
  1723. ;
  1724. ;******************************************************************************
  1725. Op_ADC_DIIX    Proc    Near        ; Add with carry procedure
  1726.     DoDIIX                ; Setup the effective address
  1727.     test    dh,CPU_M        ; Check for in decimal mode (BCD)
  1728.     jnz    ADC_DIIX_DEC        ; Jump if in decimal (BCD) mode
  1729. ADC_DIIX_BIN:
  1730.     OpADCb                ; Do the ADC operation (Update n,v,z,c)
  1731.     Fetch                ; Fetch and execute next instruction
  1732. ADC_DIIX_DEC:
  1733.     OpADCd                ; Do the ADC operation (Update n,v,z,c)
  1734.     Fetch                ; Fetch and execute next instruction
  1735. Op_ADC_DIIX    Endp            ; End of add with carry procedure
  1736.     LineUp    Op_Size         ; Align the next opcode procedure
  1737.     Subttl    Opcode 62 - PER Stack/PC Relative Long        (ILLEGAL)
  1738.     Page    +
  1739. ;******************************************************************************
  1740. ;
  1741. ;    Op_PER ()    Push Effective PC Relative Indirect Address
  1742. ;
  1743. ;        Increment to the next opcode
  1744. ;        Fetch the next instruction
  1745. ;
  1746. ;******************************************************************************
  1747. Op_PER        Proc    Near        ; Push relative address procedure
  1748.     add    si,2            ; Increment to the next opcode
  1749.     Fetch                ; Fetch and execute next instruction
  1750. Op_PER        Endp            ; End of push relative address procedure
  1751.     LineUp    Op_Size         ; Align the next opcode procedure
  1752.     Subttl    Opcode 63 - ADC Stack Relative            (ILLEGAL)
  1753.     Page    +
  1754. ;******************************************************************************
  1755. ;
  1756. ;    Op_ADC_S ()    Add to Accumulator with Carry
  1757. ;
  1758. ;        Increment to the next opcode
  1759. ;        Fetch the next instruction
  1760. ;
  1761. ;******************************************************************************
  1762. Op_ADC_S    Proc    Near        ; Add with carry procedure
  1763.     inc    si            ; Increment to the next opcode
  1764.     Fetch                ; Fetch and execute next instruction
  1765. Op_ADC_S    Endp            ; End of add with carry procedure
  1766.     LineUp    Op_Size         ; Align the next opcode procedure
  1767.     Subttl    Opcode 64 - STZ Direct Page            (65C02 ONLY)
  1768.     Page    +
  1769. ;******************************************************************************
  1770. ;
  1771. ;    Op_STZ_D ()    Store Zero to Memory
  1772. ;
  1773. ;        Setup the effective address
  1774. ;        Do the STZ operation
  1775. ;        Fetch the next instruction
  1776. ;
  1777. ;******************************************************************************
  1778. Op_STZ_D    Proc    Near        ; Store zero to memory procedure
  1779.     DoDP                ; Setup the effective address
  1780.     OpSTZ                ; Do the STZ operation
  1781.     Fetch                ; Fetch and execute next instruction
  1782. Op_STZ_D    Endp            ; End of store zero procedure
  1783.     LineUp    Op_Size         ; Align the next opcode procedure
  1784.     Subttl    Opcode 65 - ADC Direct Page
  1785.     Page    +
  1786. ;******************************************************************************
  1787. ;
  1788. ;    Op_ADC_D ()    Add to Accumulator with Carry
  1789. ;
  1790. ;        Setup the effective address
  1791. ;        If in decimal (BCD) mode
  1792. ;            Do the ADC decimal operation (Update flags n, v, z, c)
  1793. ;        Else in binary mode
  1794. ;            Do the ADC binary operation (Update flags n, v, z, c)
  1795. ;        Endif
  1796. ;        Fetch the next instruction
  1797. ;
  1798. ;******************************************************************************
  1799. Op_ADC_D    Proc    Near        ; Add with carry procedure
  1800.     DoDP                ; Setup the effective address
  1801.     test    dh,CPU_M        ; Check for in decimal mode (BCD)
  1802.     jnz    ADC_D_DEC        ; Jump if in decimal (BCD) mode
  1803. ADC_D_BIN:
  1804.     OpADCb                ; Do the ADC operation (Update n,v,z,c)
  1805.     Fetch                ; Fetch and execute next instruction
  1806. ADC_D_DEC:
  1807.     OpADCd                ; Do the ADC operation (Update n,v,z,c)
  1808.     Fetch                ; Fetch and execute next instruction
  1809. Op_ADC_D    Endp            ; End of add with carry procedure
  1810.     LineUp    Op_Size         ; Align the next opcode procedure
  1811.     Subttl    Opcode 66 - ROR Direct Page
  1812.     Page    +
  1813. ;******************************************************************************
  1814. ;
  1815. ;    Op_ROR_D ()    Rotate Memory Right
  1816. ;
  1817. ;        Setup the effective address
  1818. ;        Do the ROR operation (Update flag bits n, z, c)
  1819. ;        Fetch the next instruction
  1820. ;
  1821. ;******************************************************************************
  1822. Op_ROR_D    Proc    Near        ; Rotate memory right procedure
  1823.     DoDP                ; Setup the effective address
  1824.     OpROR                ; Do the ROR operation (Update n,z,c)
  1825.     Fetch                ; Fetch and execute next instruction
  1826. Op_ROR_D    Endp            ; End of rotate memory right  procedure
  1827.     LineUp    Op_Size         ; Align the next opcode procedure
  1828.     Subttl    Opcode 67 - ADC DP Indirect Long        (ILLEGAL)
  1829.     Page    +
  1830. ;******************************************************************************
  1831. ;
  1832. ;    Op_ADC_DIL ()    Add to Accumulator with Carry
  1833. ;
  1834. ;        Increment to the next opcode
  1835. ;        Fetch the next instruction
  1836. ;
  1837. ;******************************************************************************
  1838. Op_ADC_DIL    Proc    Near        ; Add with carry procedure
  1839.     inc    si            ; Increment to the next opcode
  1840.     Fetch                ; Fetch and execute next instruction
  1841. Op_ADC_DIL    Endp            ; End of add with carry procedure
  1842.     LineUp    Op_Size         ; Align the next opcode procedure
  1843.     Subttl    Opcode 68 - PLA Stack/Pull
  1844.     Page    +
  1845. ;******************************************************************************
  1846. ;
  1847. ;    Op_PLA ()    Pull Accumulator from Stack
  1848. ;
  1849. ;        Pop accumulator from stack
  1850. ;        Update the 65C02 processor flags (n, z)
  1851. ;        Fetch the next instruction
  1852. ;
  1853. ;******************************************************************************
  1854. Op_PLA        Proc    Near        ; Pull accumulator from stack procedure
  1855.     Pop_8                ; Pop accumulator from the stack
  1856.     mov    dl,al            ; Update the accumulator value
  1857.     or    dl,dl            ; Set the status flags correctly
  1858.     Flgnz                ; Update the 65C02 processor flags
  1859.     Fetch                ; Fetch and execute next instruction
  1860. Op_PLA        Endp            ; End of pull accumulator procedure
  1861.     LineUp    Op_Size         ; Align the next opcode procedure
  1862.     Subttl    Opcode 69 - ADC Immediate
  1863.     Page    +
  1864. ;******************************************************************************
  1865. ;
  1866. ;    Op_ADC_I ()    Add to Accumulator with Carry
  1867. ;
  1868. ;        Setup the effective address
  1869. ;        If in decimal (BCD) mode
  1870. ;            Do the ADC decimal operation (Update flags n, v, z, c)
  1871. ;        Else in binary mode
  1872. ;            Do the ADC binary operation (Update flags n, v, z, c)
  1873. ;        Endif
  1874. ;        Fetch the next instruction
  1875. ;
  1876. ;******************************************************************************
  1877. Op_ADC_I    Proc    Near        ; Add with carry procedure
  1878.     DoImm                ; Setup the effective address
  1879.     test    dh,CPU_M        ; Check for in decimal mode (BCD)
  1880.     jnz    ADC_I_DEC        ; Jump if in decimal (BCD) mode
  1881. ADC_I_BIN:
  1882.     OpADCb                ; Do the ADC operation (Update n,v,z,c)
  1883.     Fetch                ; Fetch and execute next instruction
  1884. ADC_I_DEC:
  1885.     OpADCd                ; Do the ADC operation (Update n,v,z,c)
  1886.     Fetch                ; Fetch and execute next instruction
  1887. Op_ADC_I    Endp            ; End of add with carry procedure
  1888.     LineUp    Op_Size         ; Align the next opcode procedure
  1889.     Subttl    Opcode 6A - ROR Accumulator
  1890.     Page    +
  1891. ;******************************************************************************
  1892. ;
  1893. ;    Op_ROR ()    Rotate Accumulator Right
  1894. ;
  1895. ;        Move 65C02 carry flag into real carry
  1896. ;        Rotate the accumulator right
  1897. ;        Update the 65C02 processor flags (n, z, c)
  1898. ;        Fetch the next instruction
  1899. ;
  1900. ;******************************************************************************
  1901. Op_ROR        Proc    Near        ; Rotate accumulator right procedure
  1902.     mov    al,dh            ; Get 65C02 processor status flags
  1903.     shr    al,1            ; Move 65C02 carry flag into real carry
  1904.     rcr    dl,1            ; Rotate the accumulator right
  1905.     rcr    al,1            ; Save carry result in AL register
  1906.     or    dl,dl            ; Set the n and z flags correctly
  1907.     rcl    al,1            ; Restore the carry result
  1908.     Flgnzc                ; Update the n, z, and c flags
  1909.     Fetch                ; Fetch and execute next instruction
  1910. Op_ROR        Endp            ; End of rotate accumulator procedure
  1911.     LineUp    Op_Size         ; Align the next opcode procedure
  1912.     Subttl    Opcode 6B - RTL Stack/RTL            (ILLEGAL)
  1913.     Page    +
  1914. ;******************************************************************************
  1915. ;
  1916. ;    Op_RTL ()    Return from Subroutine
  1917. ;
  1918. ;        Fetch the next instruction
  1919. ;
  1920. ;******************************************************************************
  1921. Op_RTL        Proc    Near        ; Return from subroutine procedure
  1922.     Fetch                ; Fetch and execute next instruction
  1923. Op_RTL        Endp            ; End of subroutine return procedure
  1924.     LineUp    Op_Size         ; Align the next opcode procedure
  1925.     Subttl    Opcode 6C - JMP Absolute Indirect
  1926.     Page    +
  1927. ;******************************************************************************
  1928. ;
  1929. ;    Op_JMP_AI ()    Jump
  1930. ;
  1931. ;        Setup the effective address
  1932. ;        Do the JMP operation
  1933. ;        Fetch the next instruction
  1934. ;
  1935. ;******************************************************************************
  1936. Op_JMP_AI    Proc    Near        ; Jump procedure
  1937.     DoAI                ; Setup the effective address
  1938.     OpJMP                ; Do the JMP operation
  1939.     Fetch                ; Fetch and execute next instruction
  1940. Op_JMP_AI    Endp            ; End of jump procedure
  1941.     LineUp    Op_Size         ; Align the next opcode procedure
  1942.     Subttl    Opcode 6D - ADC Absolute
  1943.     Page    +
  1944. ;******************************************************************************
  1945. ;
  1946. ;    Op_ADC_A ()    Add to Accumulator with Carry
  1947. ;
  1948. ;        Setup the effective address
  1949. ;        If in decimal (BCD) mode
  1950. ;            Do the ADC decimal operation (Update flags n, v, z, c)
  1951. ;        Else in binary mode
  1952. ;            Do the ADC binary operation (Update flags n, v, z, c)
  1953. ;        Endif
  1954. ;        Fetch the next instruction
  1955. ;
  1956. ;******************************************************************************
  1957. Op_ADC_A    Proc    Near        ; Add with carry procedure
  1958.     DoAbs                ; Setup the effective address
  1959.     test    dh,CPU_M        ; Check for in decimal mode (BCD)
  1960.     jnz    ADC_A_DEC        ; Jump if in decimal (BCD) mode
  1961. ADC_A_BIN:
  1962.     OpADCb                ; Do the ADC operation (Update n,v,z,c)
  1963.     Fetch                ; Fetch and execute next instruction
  1964. ADC_A_DEC:
  1965.     OpADCd                ; Do the ADC operation (Update n,v,z,c)
  1966.     Fetch                ; Fetch and execute next instruction
  1967. Op_ADC_A    Endp            ; End of add with carry procedure
  1968.     LineUp    Op_Size         ; Align the next opcode procedure
  1969.     Subttl    Opcode 6E - ROR Absolute
  1970.     Page    +
  1971. ;******************************************************************************
  1972. ;
  1973. ;    Op_ROR_A ()    Rotate Memory Right
  1974. ;
  1975. ;        Setup the effective address
  1976. ;        Do the ROR operation (Update flag bits n, z, c)
  1977. ;        Fetch the next instruction
  1978. ;
  1979. ;******************************************************************************
  1980. Op_ROR_A    Proc    Near        ; Rotate memory right procedure
  1981.     DoAbs                ; Setup the effective address
  1982.     OpROR                ; Do the ROR operation (Update n,z,c)
  1983.     Fetch                ; Fetch and execute next instruction
  1984. Op_ROR_A    Endp            ; End of rotate memory right procedure
  1985.     LineUp    Op_Size         ; Align the next opcode procedure
  1986.     Subttl    Opcode 6F - ADC Absolute Long            (ILLEGAL)
  1987.     Page    +
  1988. ;******************************************************************************
  1989. ;
  1990. ;    Op_ADC_AL ()    Add to Accumulator with Carry
  1991. ;
  1992. ;        Increment to the next opcode
  1993. ;        Fetch the next instruction
  1994. ;
  1995. ;******************************************************************************
  1996. Op_ADC_AL    Proc    Near        ; Add with carry procedure
  1997.     add    si,3            ; Increment to the next opcode
  1998.     Fetch                ; Fetch and execute next instruction
  1999. Op_ADC_AL    Endp            ; End of add with carry procedure
  2000.     LineUp    Op_Size         ; Align the next opcode procedure
  2001.     Subttl    Opcode 70 - BVS Program Counter Relative
  2002.     Page    +
  2003. ;******************************************************************************
  2004. ;
  2005. ;    Op_BVS ()    Branch if Overflow Set
  2006. ;
  2007. ;        Get the program counter offset byte
  2008. ;        If the v flag is set
  2009. ;            Update the program counter
  2010. ;        Endif
  2011. ;        Fetch the next instruction
  2012. ;
  2013. ;******************************************************************************
  2014. Op_BVS        Proc    Near        ; Branch if overflow is set procedure
  2015.     lodsb                ; Get the program counter offset
  2016.     test    dh,CPU_V        ; Check the 65C02 v (Overflow) flag
  2017.     jz    _BVS            ; Jump if v flag is clear (No overflow)
  2018.     cbw                ; Convert offset into a full word
  2019.     add    si,ax            ; Compute the new program counter
  2020. _BVS:
  2021.     Fetch                ; Fetch and execute next instruction
  2022. Op_BVS        Endp            ; End of overflow branch procedure
  2023.     LineUp    Op_Size         ; Align the next opcode procedure
  2024.     Subttl    Opcode 71 - ADC DP Indirect Indexed, Y
  2025.     Page    +
  2026. ;******************************************************************************
  2027. ;
  2028. ;    Op_ADC_DIIY ()    Add to Accumulator with Carry
  2029. ;
  2030. ;        Setup the effective address
  2031. ;        If in decimal (BCD) mode
  2032. ;            Do the ADC decimal operation (Update flags n, v, z, c)
  2033. ;        Else in binary mode
  2034. ;            Do the ADC binary operation (Update flags n, v, z, c)
  2035. ;        Endif
  2036. ;        Fetch the next instruction
  2037. ;
  2038. ;******************************************************************************
  2039. Op_ADC_DIIY    Proc    Near        ; Add with carry procedure
  2040.     DoDIIY                ; Setup the effective address
  2041.     test    dh,CPU_M        ; Check for in decimal mode (BCD)
  2042.     jnz    ADC_DIIY_DEC        ; Jump if in decimal (BCD) mode
  2043. ADC_DIIY_BIN:
  2044.     OpADCb                ; Do the ADC operation (Update n,v,z,c)
  2045.     Fetch                ; Fetch and execute next instruction
  2046. ADC_DIIY_DEC:
  2047.     OpADCd                ; Do the ADC operation (Update n,v,z,c)
  2048.     Fetch                ; Fetch and execute next instruction
  2049. Op_ADC_DIIY    Endp            ; End of add with carry procedure
  2050.     LineUp    Op_Size         ; Align the next opcode procedure
  2051.     Subttl    Opcode 72 - ADC DP Indirect            (65C02 ONLY)
  2052.     Page    +
  2053. ;******************************************************************************
  2054. ;
  2055. ;    Op_ADC_DI ()    Add to Accumulator with Carry
  2056. ;
  2057. ;        Setup the effective address
  2058. ;        If in decimal (BCD) mode
  2059. ;            Do the ADC decimal operation (Update flags n, v, z, c)
  2060. ;        Else in binary mode
  2061. ;            Do the ADC binary operation (Update flags n, v, z, c)
  2062. ;        Endif
  2063. ;        Fetch the next instruction
  2064. ;
  2065. ;******************************************************************************
  2066. Op_ADC_DI    Proc    Near        ; Add with carry procedure
  2067.     DoDI                ; Setup the effective address
  2068.     test    dh,CPU_M        ; Check for in decimal mode (BCD)
  2069.     jnz    ADC_DI_DEC        ; Jump if in decimal (BCD) mode
  2070. ADC_DI_BIN:
  2071.     OpADCb                ; Do the ADC operation (Update n,v,z,c)
  2072.     Fetch                ; Fetch and execute next instruction
  2073. ADC_DI_DEC:
  2074.     OpADCd                ; Do the ADC operation (Update n,v,z,c)
  2075.     Fetch                ; Fetch and execute next instruction
  2076. Op_ADC_DI    Endp            ; End of add with carry procedure
  2077.     LineUp    Op_Size         ; Align the next opcode procedure
  2078.     Subttl    Opcode 73 - ADC SR Indirect Indexed, Y        (ILLEGAL)
  2079.     Page    +
  2080. ;******************************************************************************
  2081. ;
  2082. ;    Op_ADC_SIIY ()    Add to Accumulator with Carry
  2083. ;
  2084. ;        Increment to the next opcode
  2085. ;        Fetch the next instruction
  2086. ;
  2087. ;******************************************************************************
  2088. Op_ADC_SIIY    Proc    Near        ; Add with carry procedure
  2089.     inc    si            ; Increment to the next opcode
  2090.     Fetch                ; Fetch and execute next instruction
  2091. Op_ADC_SIIY    Endp            ; End of add with carry procedure
  2092.     LineUp    Op_Size         ; Align the next opcode procedure
  2093.     Subttl    Opcode 74 - STZ Direct Page Indexed, X        (65C02 ONLY)
  2094.     Page    +
  2095. ;******************************************************************************
  2096. ;
  2097. ;    Op_STZ_DIX ()    Store Zero to Memory
  2098. ;
  2099. ;        Setup the effective address
  2100. ;        Do the STZ operation
  2101. ;        Fetch the next instruction
  2102. ;
  2103. ;******************************************************************************
  2104. Op_STZ_DIX    Proc    Near        ; Store zero to memory procedure
  2105.     DoDIX                ; Setup the effective address
  2106.     OpSTZ                ; Do the STZ operation
  2107.     Fetch                ; Fetch and execute next instruction
  2108. Op_STZ_DIX    Endp            ; End of store zero procedure
  2109.     LineUp    Op_Size         ; Align the next opcode procedure
  2110.     Subttl    Opcode 75 - ADC DP Indexed, X
  2111.     Page    +
  2112. ;******************************************************************************
  2113. ;
  2114. ;    Op_ADC_DIX ()    Add to Accumulator with Carry
  2115. ;
  2116. ;        Setup the effective address
  2117. ;        If in decimal (BCD) mode
  2118. ;            Do the ADC decimal operation (Update flags n, v, z, c)
  2119. ;        Else in binary mode
  2120. ;            Do the ADC binary operation (Update flags n, v, z, c)
  2121. ;        Endif
  2122. ;        Fetch the next instruction
  2123. ;
  2124. ;******************************************************************************
  2125. Op_ADC_DIX    Proc    Near        ; Add with carry procedure
  2126.     DoDIX                ; Setup the effective address
  2127.     test    dh,CPU_M        ; Check for in decimal mode (BCD)
  2128.     jnz    ADC_DIX_DEC        ; Jump if in decimal (BCD) mode
  2129. ADC_DIX_BIN:
  2130.     OpADCb                ; Do the ADC operation (Update n,v,z,c)
  2131.     Fetch                ; Fetch and execute next instruction
  2132. ADC_DIX_DEC:
  2133.     OpADCd                ; Do the ADC operation (Update n,v,z,c)
  2134.     Fetch                ; Fetch and execute next instruction
  2135. Op_ADC_DIX    Endp            ; End of add with carry procedure
  2136.     LineUp    Op_Size         ; Align the next opcode procedure
  2137.     Subttl    Opcode 76 - ROR DP Indexed, X
  2138.     Page    +
  2139. ;******************************************************************************
  2140. ;
  2141. ;    Op_ROR_DIX ()    Rotate Memory Right
  2142. ;
  2143. ;        Setup the effective address
  2144. ;        Do the ROR operation (Update flag bits n, z, c)
  2145. ;        Fetch the next instruction
  2146. ;
  2147. ;******************************************************************************
  2148. Op_ROR_DIX    Proc    Near        ; Rotate memory right procedure
  2149.     DoDIX                ; Setup the effective address
  2150.     OpROR                ; Do the ROR operation (Update n,z,c)
  2151.     Fetch                ; Fetch and execute next instruction
  2152. Op_ROR_DIX    Endp            ; End of rotate memory right procedure
  2153.     LineUp    Op_Size         ; Align the next opcode procedure
  2154.     Subttl    Opcode 77 - ADC DP Indirect Long Indexed, Y    (ILLEGAL)
  2155.     Page    +
  2156. ;******************************************************************************
  2157. ;
  2158. ;    Op_ADC_DILIY () Add to Accumulator with Carry
  2159. ;
  2160. ;        Increment to the next opcode
  2161. ;        Fetch the next instruction
  2162. ;
  2163. ;******************************************************************************
  2164. Op_ADC_DILIY    Proc    Near        ; Add with carry procedure
  2165.     inc    si            ; Increment to the next opcode
  2166.     Fetch                ; Fetch and execute next instruction
  2167. Op_ADC_DILIY    Endp            ; End of add with carry procedure
  2168.     LineUp    Op_Size         ; Align the next opcode procedure
  2169.     Subttl    Opcode 78 - SEI Implied
  2170.     Page    +
  2171. ;******************************************************************************
  2172. ;
  2173. ;    Op_SEI ()    Set Interrupt Disable Flag
  2174. ;
  2175. ;        Set the interrupt disable flag
  2176. ;        Fetch the next instruction
  2177. ;
  2178. ;******************************************************************************
  2179. Op_SEI        Proc    Near        ; Set interrupt disable flag procedure
  2180.     or    dh,CPU_I        ; Set the interrupt disable flag
  2181.     Fetch                ; Fetch and execute next instruction
  2182. Op_SEI        Endp            ; End of set interrupt flag procedure
  2183.     LineUp    Op_Size         ; Align the next opcode procedure
  2184.     Subttl    Opcode 79 - ADC Absolute Indexed, Y
  2185.     Page    +
  2186. ;******************************************************************************
  2187. ;
  2188. ;    Op_ADC_AIY ()    Add to Accumulator with Carry
  2189. ;
  2190. ;        Setup the effective address
  2191. ;        If in decimal (BCD) mode
  2192. ;            Do the ADC decimal operation (Update flags n, v, z, c)
  2193. ;        Else in binary mode
  2194. ;            Do the ADC binary operation (Update flags n, v, z, c)
  2195. ;        Endif
  2196. ;        Fetch the next instruction
  2197. ;
  2198. ;******************************************************************************
  2199. Op_ADC_AIY    Proc    Near        ; Add with carry procedure
  2200.     DoAIY                ; Setup the effective address
  2201.     test    dh,CPU_M        ; Check for in decimal mode (BCD)
  2202.     jnz    ADC_AIY_DEC        ; Jump if in decimal (BCD) mode
  2203. ADC_AIY_BIN:
  2204.     OpADCb                ; Do the ADC operation (Update n,v,z,c)
  2205.     Fetch                ; Fetch and execute next instruction
  2206. ADC_AIY_DEC:
  2207.     OpADCd                ; Do the ADC operation (Update n,v,z,c)
  2208.     Fetch                ; Fetch and execute next instruction
  2209. Op_ADC_AIY    Endp            ; End of add with carry procedure
  2210.     LineUp    Op_Size         ; Align the next opcode procedure
  2211.     Subttl    Opcode 7A - PLY Stack/Pull            (65C02 ONLY)
  2212.     Page    +
  2213. ;******************************************************************************
  2214. ;
  2215. ;    Op_PLY ()    Pull Y Index Register from Stack
  2216. ;
  2217. ;        Pop Y index register from the stack
  2218. ;        Fetch the next instruction
  2219. ;
  2220. ;******************************************************************************
  2221. Op_PLY        Proc    Near        ; Pull Y index from stack procedure
  2222.     Pop_8                ; Pop Y index register from the stack
  2223.     mov    cl,al            ; Update the Y index register value
  2224.     Fetch                ; Fetch and execute next instruction
  2225. Op_PLY        Endp            ; End of pull Y index procedure
  2226.     LineUp    Op_Size         ; Align the next opcode procedure
  2227.     Subttl    Opcode 7B - TDC Implied             (ILLEGAL)
  2228.     Page    +
  2229. ;******************************************************************************
  2230. ;
  2231. ;    Op_TDC ()    Transfer Direct Page Register to Accumulator (16-Bit)
  2232. ;
  2233. ;        Fetch the next instruction
  2234. ;
  2235. ;******************************************************************************
  2236. Op_TDC        Proc    Near        ; Transfer direct page to acc. procedure
  2237.     Fetch                ; Fetch and execute next instruction
  2238. Op_TDC        Endp            ; End of transfer direct page procedure
  2239.     LineUp    Op_Size         ; Align the next opcode procedure
  2240.     Subttl    Opcode 7C - JMP Absolute Indexed Indirect, X    (65C02 ONLY)
  2241.     Page    +
  2242. ;******************************************************************************
  2243. ;
  2244. ;    Op_JMP_AIIX ()    Jump
  2245. ;
  2246. ;        Setup the effective address
  2247. ;        Do the JMP operation
  2248. ;        Fetch the next instruction
  2249. ;
  2250. ;******************************************************************************
  2251. Op_JMP_AIIX    Proc    Near        ; Jump procedure
  2252.     DoAIIX                ; Setup the effective address
  2253.     OpJMP                ; Do the JMP operation
  2254.     Fetch                ; Fetch and execute next instruction
  2255. Op_JMP_AIIX    Endp            ; End of jump procedure
  2256.     LineUp    Op_Size         ; Align the next opcode procedure
  2257.     Subttl    Opcode 7D - ADC Absolute Indexed, X
  2258.     Page    +
  2259. ;******************************************************************************
  2260. ;
  2261. ;    Op_ADC_AIX ()    Add to Accumulator with Carry
  2262. ;
  2263. ;        Setup the effective address
  2264. ;        If in decimal (BCD) mode
  2265. ;            Do the ADC decimal operation (Update flags n, v, z, c)
  2266. ;        Else in binary mode
  2267. ;            Do the ADC binary operation (Update flags n, v, z, c)
  2268. ;        Endif
  2269. ;        Fetch the next instruction
  2270. ;
  2271. ;******************************************************************************
  2272. Op_ADC_AIX    Proc    Near        ; Add with carry procedure
  2273.     DoAIX                ; Setup the effective address
  2274.     test    dh,CPU_M        ; Check for in decimal mode (BCD)
  2275.     jnz    ADC_AIX_DEC        ; Jump if in decimal (BCD) mode
  2276. ADC_AIX_BIN:
  2277.     OpADCb                ; Do the ADC operation (Update n,v,z,c)
  2278.     Fetch                ; Fetch and execute next instruction
  2279. ADC_AIX_DEC:
  2280.     OpADCd                ; Do the ADC operation (Update n,v,z,c)
  2281.     Fetch                ; Fetch and execute next instruction
  2282. Op_ADC_AIX    Endp            ; End of add with carry procedure
  2283.     LineUp    Op_Size         ; Align the next opcode procedure
  2284.     Subttl    Opcode 7E - ROR Absolute Indexed, X
  2285.     Page    +
  2286. ;******************************************************************************
  2287. ;
  2288. ;    Op_ROR_AIX ()    Rotate Memory Right
  2289. ;
  2290. ;        Setup the effective address
  2291. ;        Do the ROR operation (Update flag bits n, z, c)
  2292. ;        Fetch the next instruction
  2293. ;
  2294. ;******************************************************************************
  2295. Op_ROR_AIX    Proc    Near        ; Rotate memory right procedure
  2296.     DoAIX                ; Setup the effective address
  2297.     OpROR                ; Do the ROR operation (Update n,z,c)
  2298.     Fetch                ; Fetch and execute next instruction
  2299. Op_ROR_AIX    Endp            ; End of rotate memory right procedure
  2300.     LineUp    Op_Size         ; Align the next opcode procedure
  2301.     Subttl    Opcode 7F - ADC Absolute Long Indexed, X    (ILLEGAL)
  2302.     Page    +
  2303. ;******************************************************************************
  2304. ;
  2305. ;    Op_ADC_ALIX ()    Add to Accumulator with Carry
  2306. ;
  2307. ;        Increment to the next opcode
  2308. ;        Fetch the next instruction
  2309. ;
  2310. ;******************************************************************************
  2311. Op_ADC_ALIX    Proc    Near        ; Add with carry procedure
  2312.     add    si,3            ; Increment to the next opcode
  2313.     Fetch                ; Fetch and execute next instruction
  2314. Op_ADC_ALIX    Endp            ; End of add with carry procedure
  2315.     LineUp    Op_Size         ; Align the next opcode procedure
  2316.     Subttl    Opcode 80 - BRA Program Counter Relative    (65C02 ONLY)
  2317.     Page    +
  2318. ;******************************************************************************
  2319. ;
  2320. ;    Op_BRA ()    Branch Always
  2321. ;
  2322. ;        Get the program counter offset byte
  2323. ;        Update the program counter
  2324. ;        Fetch the next instruction
  2325. ;
  2326. ;******************************************************************************
  2327. Op_BRA        Proc    Near        ; Branch always procedure
  2328.     lodsb                ; Get the program counter offset
  2329.     cbw                ; Convert offset into a full word
  2330.     add    si,ax            ; Compute the new program counter
  2331.     Fetch                ; Fetch and execute next instruction
  2332. Op_BRA        Endp            ; End of branch always procedure
  2333.     LineUp    Op_Size         ; Align the next opcode procedure
  2334.     Subttl    Opcode 81 - STA DP Indexed Indirect, X
  2335.     Page    +
  2336. ;******************************************************************************
  2337. ;
  2338. ;    Op_STA_DIIX ()    Store Accumulator
  2339. ;
  2340. ;        Setup the effective address
  2341. ;        Do the STA operation
  2342. ;        Fetch the next instruction
  2343. ;
  2344. ;******************************************************************************
  2345. Op_STA_DIIX    Proc    Near        ; Store accumulator procedure
  2346.     DoDIIX                ; Setup the effective address
  2347.     OpSTA                ; Do the STA operation
  2348.     Fetch                ; Fetch and execute next instruction
  2349. Op_STA_DIIX    Endp            ; End of store accumulator procedure
  2350.     LineUp    Op_Size         ; Align the next opcode procedure
  2351.     Subttl    Opcode 82 - BRL Program Counter Relative Long    (ILLEGAL)
  2352.     Page    +
  2353. ;******************************************************************************
  2354. ;
  2355. ;    Op_BRL ()    Branch Always Long
  2356. ;
  2357. ;        Increment to the next opcode
  2358. ;        Fetch the next instruction
  2359. ;
  2360. ;******************************************************************************
  2361. Op_BRL        Proc    Near        ; Branch always procedure
  2362.     add    si,2            ; Increment to the next opcode
  2363.     Fetch                ; Fetch and execute next instruction
  2364. Op_BRL        Endp            ; End of branch always procedure
  2365.     LineUp    Op_Size         ; Align the next opcode procedure
  2366.     Subttl    Opcode 83 - STA Stack Relative            (ILLEGAL)
  2367.     Page    +
  2368. ;******************************************************************************
  2369. ;
  2370. ;    Op_STA_S ()    Store Accumulator
  2371. ;
  2372. ;        Increment to the next opcode
  2373. ;        Fetch the next instruction
  2374. ;
  2375. ;******************************************************************************
  2376. Op_STA_S    Proc    Near        ; Store accumulator procedure
  2377.     inc    si            ; Increment to the next opcode
  2378.     Fetch                ; Fetch and execute next instruction
  2379. Op_STA_S    Endp            ; End of store accumulator procedure
  2380.     LineUp    Op_Size         ; Align the next opcode procedure
  2381.     Subttl    Opcode 84 - STY Direct Page
  2382.     Page    +
  2383. ;******************************************************************************
  2384. ;
  2385. ;    Op_STY_D ()    Store Y Index Register
  2386. ;
  2387. ;        Setup the effective address
  2388. ;        Do the STY operation
  2389. ;        Fetch the next instruction
  2390. ;
  2391. ;******************************************************************************
  2392. Op_STY_D    Proc    Near        ; Store Y index register procedure
  2393.     DoDP                ; Setup the effective address
  2394.     OpSTY                ; Do the STY operation
  2395.     Fetch                ; Fetch and execute next instruction
  2396. Op_STY_D    Endp            ; End of store Y index procedure
  2397.     LineUp    Op_Size         ; Align the next opcode procedure
  2398.     Subttl    Opcode 85 - STA Direct Page
  2399.     Page    +
  2400. ;******************************************************************************
  2401. ;
  2402. ;    Op_STA_D ()    Store Accumulator
  2403. ;
  2404. ;        Setup the effective address
  2405. ;        Do the STA operation
  2406. ;        Fetch the next instruction
  2407. ;
  2408. ;******************************************************************************
  2409. Op_STA_D    Proc    Near        ; Store accumulator procedure
  2410.     DoDP                ; Setup the effective address
  2411.     OPSTA                ; Do the STA operation
  2412.     Fetch                ; Fetch and execute next instruction
  2413. Op_STA_D    Endp            ; End of store accumulator procedure
  2414.     LineUp    Op_Size         ; Align the next opcode procedure
  2415.     Subttl    Opcode 86 - STX Direct Page
  2416.     Page    +
  2417. ;******************************************************************************
  2418. ;
  2419. ;    Op_STX_D ()    Store X Index Register
  2420. ;
  2421. ;        Setup the effective address
  2422. ;        Do the STX operation
  2423. ;        Fetch the next instruction
  2424. ;
  2425. ;******************************************************************************
  2426. Op_STX_D    Proc    Near        ; Store X index register procedure
  2427.     DoDP                ; Setup the effective address
  2428.     OpSTX                ; Do the STX operation
  2429.     Fetch                ; Fetch and execute next instruction
  2430. Op_STX_D    Endp            ; End of store X index procedure
  2431.     LineUp    Op_Size         ; Align the next opcode procedure
  2432.     Subttl    Opcode 87 - STA DP Indirect Long        (ILLEGAL)
  2433.     Page    +
  2434. ;******************************************************************************
  2435. ;
  2436. ;    Op_STA_DIL ()    Store Accumulator
  2437. ;
  2438. ;        Increment to the next opcode
  2439. ;        Fetch the next instruction
  2440. ;
  2441. ;******************************************************************************
  2442. Op_STA_DIL    Proc    Near        ; Store accumulator procedure
  2443.     inc    si            ; Increment to the next opcode
  2444.     Fetch                ; Fetch and execute next instruction
  2445. Op_STA_DIL    Endp            ; End of store accumulator procedure
  2446.     LineUp    Op_Size         ; Align the next opcode procedure
  2447.     Subttl    Opcode 88 - DEY Implied
  2448.     Page    +
  2449. ;******************************************************************************
  2450. ;
  2451. ;    Op_DEY ()    Decrement Y Index Register
  2452. ;
  2453. ;        Decrement the Y index register
  2454. ;        Update the 65C02 processor flags (n, z)
  2455. ;        Fetch the next instruction
  2456. ;
  2457. ;******************************************************************************
  2458. Op_DEY        Proc    Near        ; Decrement Y index register procedure
  2459.     dec    cl            ; Decrement the I index register
  2460.     Flgnz                ; Update the n and z flags
  2461.     Fetch                ; Fetch and execute next instruction
  2462. Op_DEY        Endp            ; End of decrement Y index procedure
  2463.     LineUp    Op_Size         ; Align the next opcode procedure
  2464.     Subttl    Opcode 89 - BIT Immediate            (65C02 ONLY)
  2465.     Page    +
  2466. ;******************************************************************************
  2467. ;
  2468. ;    Op_BIT_I ()    Test Memory Bits Against Accumulator
  2469. ;
  2470. ;        Setup the effective address
  2471. ;        Do the BIT operation (Update flag bit z)
  2472. ;        Fetch the next instruction
  2473. ;
  2474. ;******************************************************************************
  2475. Op_BIT_I    Proc    Near        ; Test memory bits procedure
  2476.     DoImm                ; Setup the effective address
  2477.     OpBITz                ; Do the BIT operation (Update z)
  2478.     Fetch                ; Fetch and execute next instruction
  2479. Op_BIT_I    Endp            ; End of test memory bits procedure
  2480.     LineUp    Op_Size         ; Align the next opcode procedure
  2481.     Subttl    Opcode 8A - TXA Implied
  2482.     Page    +
  2483. ;******************************************************************************
  2484. ;
  2485. ;    Op_TXA ()    Transfer X Index Register to Accumulator
  2486. ;
  2487. ;        Transfer X index register to accumulator
  2488. ;        Update the 65C02 processor flags (n, z)
  2489. ;        Fetch the next instruction
  2490. ;
  2491. ;******************************************************************************
  2492. Op_TXA        Proc    Near        ; Transfer X index to acc. procedure
  2493.     mov    dl,ch            ; Transfer X index to accumulator
  2494.     or    dl,dl            ; Set the n and z flags correctly
  2495.     Flgnz                ; Update the n and z flags
  2496.     Fetch                ; Fetch and execute next instruction
  2497. Op_TXA        Endp            ; End of transfer X index procedure
  2498.     LineUp    Op_Size         ; Align the next opcode procedure
  2499.     Subttl    Opcode 8B - PHB Stack/Push            (ILLEGAL)
  2500.     Page    +
  2501. ;******************************************************************************
  2502. ;
  2503. ;    Op_PHB ()    Push Data Bank Register
  2504. ;
  2505. ;        Fetch the next instruction
  2506. ;
  2507. ;******************************************************************************
  2508. Op_PHB        Proc    Near        ; Push data bank procedure
  2509.     Fetch                ; Fetch and execute next instruction
  2510. Op_PHB        Endp            ; End of push data bank procedure
  2511.     LineUp    Op_Size         ; Align the next opcode procedure
  2512.     Subttl    Opcode 8C - STY Absolute
  2513.     Page    +
  2514. ;******************************************************************************
  2515. ;
  2516. ;    Op_STY_A ()    Store Y Index Register
  2517. ;
  2518. ;        Setup the effective address
  2519. ;        Do the STY operation
  2520. ;        Fetch the next instruction
  2521. ;
  2522. ;******************************************************************************
  2523. Op_STY_A    Proc    Near        ; Store Y index register procedure
  2524.     DoAbs                ; Setup the effective address
  2525.     OpSTY                ; Do the STY operation
  2526.     Fetch                ; Fetch and execute next instruction
  2527. Op_STY_A    Endp            ; End of store Y index procedure
  2528.     LineUp    Op_Size         ; Align the next opcode procedure
  2529.     Subttl    Opcode 8D - STA Absolute
  2530.     Page    +
  2531. ;******************************************************************************
  2532. ;
  2533. ;    Op_STA_A ()    Store Accumulator
  2534. ;
  2535. ;        Setup the effective address
  2536. ;        Do the STA operation
  2537. ;        Fetch the next instruction
  2538. ;
  2539. ;******************************************************************************
  2540. Op_STA_A    Proc    Near        ; Store accumulator procedure
  2541.     DoAbs                ; Setup the effective address
  2542.     OpSTA                ; Do the STA operation
  2543.     Fetch                ; Fetch and execute next instruction
  2544. Op_STA_A    Endp            ; End of store accumulator procedure
  2545.     LineUp    Op_Size         ; Align the next opcode procedure
  2546.     Subttl    Opcode 8E - STX Absolute
  2547.     Page    +
  2548. ;******************************************************************************
  2549. ;
  2550. ;    Op_STX_A ()    Store X Index Register
  2551. ;
  2552. ;        Setup the effective address
  2553. ;        Do the STX operation
  2554. ;        Fetch the next instruction
  2555. ;
  2556. ;******************************************************************************
  2557. Op_STX_A    Proc    Near        ; Store X index register procedure
  2558.     DoAbs                ; Setup the effective address
  2559.     OpSTX                ; Do the STX operation
  2560.     Fetch                ; Fetch and execute next instruction
  2561. Op_STX_A    Endp            ; End of store X index procedure
  2562.     LineUp    Op_Size         ; Align the next opcode procedure
  2563.     Subttl    Opcode 8F - STA Absolute Long            (ILLEGAL)
  2564.     Page    +
  2565. ;******************************************************************************
  2566. ;
  2567. ;    Op_STA_AL ()    Store Accumulator
  2568. ;
  2569. ;        Increment to the next opcode
  2570. ;        Fetch the next instruction
  2571. ;
  2572. ;******************************************************************************
  2573. Op_STA_AL    Proc    Near        ; Store accumulator procedure
  2574.     add    si,3            ; Increment to the next opcode
  2575.     Fetch                ; Fetch and execute next instruction
  2576. Op_STA_AL    Endp            ; End of store accumulator procedure
  2577.     LineUp    Op_Size         ; Align the next opcode procedure
  2578.     Subttl    Opcode 90 - BCC Program Counter Relative
  2579.     Page    +
  2580. ;******************************************************************************
  2581. ;
  2582. ;    Op_BCC ()    Branch if Carry Clear
  2583. ;
  2584. ;        Get the program counter offset byte
  2585. ;        If the c flag is clear
  2586. ;            Update the program counter
  2587. ;        Endif
  2588. ;        Fetch the next instruction
  2589. ;
  2590. ;******************************************************************************
  2591. Op_BCC        Proc    Near        ; Branch if carry clear procedure
  2592.     lodsb                ; Get the program counter offset
  2593.     test    dh,CPU_C        ; Check the 65C02 c (Carry) flag
  2594.     jnz    _BCC            ; Jump if c flag is set (Carry)
  2595.     cbw                ; Convert offset into a full word
  2596.     add    si,ax            ; Compute the new program counter
  2597. _BCC:
  2598.     Fetch                ; Fetch and execute next instruction
  2599. Op_BCC        Endp            ; End of branch if carry clear procedure
  2600.     LineUp    Op_Size         ; Align the next opcode procedure
  2601.     Subttl    Opcode 91 - STA DP Indirect Indexed, Y
  2602.     Page    +
  2603. ;******************************************************************************
  2604. ;
  2605. ;    Op_STA_DIIY ()    Store Accumulator
  2606. ;
  2607. ;        Setup the effective address
  2608. ;        Do the STA operation
  2609. ;        Fetch the next instruction
  2610. ;
  2611. ;******************************************************************************
  2612. Op_STA_DIIY    Proc    Near        ; Store accumulator procedure
  2613.     DoDIIY                ; Setup the effective address
  2614.     OpSTA                ; Do the STA operation
  2615.     Fetch                ; Fetch and execute next instruction
  2616. Op_STA_DIIY    Endp            ; End of store accumulator procedure
  2617.     LineUp    Op_Size         ; Align the next opcode procedure
  2618.     Subttl    Opcode 92 - STA DP Indirect            (65C02 ONLY)
  2619.     Page    +
  2620. ;******************************************************************************
  2621. ;
  2622. ;    Op_STA_DI ()    Store Accumulator
  2623. ;
  2624. ;        Setup the effective address
  2625. ;        Do the STA operation
  2626. ;        Fetch the next instruction
  2627. ;
  2628. ;******************************************************************************
  2629. Op_STA_DI    Proc    Near        ; Store accumulator procedure
  2630.     DoDI                ; Setup the effective address
  2631.     OpSTA                ; Do the STA operation
  2632.     Fetch                ; Fetch and execute next instruction
  2633. Op_STA_DI    Endp            ; End of store accumulator procedure
  2634.     LineUp    Op_Size         ; Align the next opcode procedure
  2635.     Subttl    Opcode 93 - STA SR Indirect Indexed, Y        (ILLEGAL)
  2636.     Page    +
  2637. ;******************************************************************************
  2638. ;
  2639. ;    Op_STA_SIIY ()    Store Accumulator
  2640. ;
  2641. ;        Increment to the next opcode
  2642. ;        Fetch the next instruction
  2643. ;
  2644. ;******************************************************************************
  2645. Op_STA_SIIY    Proc    Near        ; Store accumulator procedure
  2646.     inc    si            ; Increment to the next opcode
  2647.     Fetch                ; Fetch and execute next instruction
  2648. Op_STA_SIIY    Endp            ; End of store accumulator procedure
  2649.     LineUp    Op_Size         ; Align the next opcode procedure
  2650.     Subttl    Opcode 94 - STY Direct Page Indexed, X
  2651.     Page    +
  2652. ;******************************************************************************
  2653. ;
  2654. ;    Op_STY_DIX ()    Store Y Index Register
  2655. ;
  2656. ;        Setup the effective address
  2657. ;        Do the STY operation
  2658. ;        Fetch the next instruction
  2659. ;
  2660. ;******************************************************************************
  2661. Op_STY_DIX    Proc    Near        ; Store Y index register procedure
  2662.     DoDIX                ; Setup the effective address
  2663.     OpSTY                ; Do the STY operation
  2664.     Fetch                ; Fetch and execute next instruction
  2665. Op_STY_DIX    Endp            ; End of store Y index procedure
  2666.     LineUp    Op_Size         ; Align the next opcode procedure
  2667.     Subttl    Opcode 95 - STA Direct Page Indexed, X
  2668.     Page    +
  2669. ;******************************************************************************
  2670. ;
  2671. ;    Op_STA_DIX ()    Store Accumulator
  2672. ;
  2673. ;        Setup the effective address
  2674. ;        Do the STA operation
  2675. ;        Fetch the next instruction
  2676. ;
  2677. ;******************************************************************************
  2678. Op_STA_DIX    Proc    Near        ; Store accumulator procedure
  2679.     DoDIX                ; Setup the effective address
  2680.     OpSTA                ; Do the STA operation
  2681.     Fetch                ; Fetch and execute next instruction
  2682. Op_STA_DIX    Endp            ; End of store accumulator procedure
  2683.     LineUp    Op_Size         ; Align the next opcode procedure
  2684.     Subttl    Opcode 96 - STX Direct Page Indexed, Y
  2685.     Page    +
  2686. ;******************************************************************************
  2687. ;
  2688. ;    Op_STX_DIY ()    Store X Index Register
  2689. ;
  2690. ;        Setup the effective address
  2691. ;        Do the STX operation
  2692. ;        Fetch the next instruction
  2693. ;
  2694. ;******************************************************************************
  2695. Op_STX_DIY    Proc    Near        ; Store X index register procedure
  2696.     DoDIY                ; Setup the effective address
  2697.     OpSTX                ; Do the STX operation
  2698.     Fetch                ; Fetch and execute next instruction
  2699. Op_STX_DIY    Endp            ; End of store X index procedure
  2700.     LineUp    Op_Size         ; Align the next opcode procedure
  2701.     Subttl    Opcode 97 - STA DP Indirect Long Indexed, Y    (ILLEGAL)
  2702.     Page    +
  2703. ;******************************************************************************
  2704. ;
  2705. ;    Op_STA_DILIY () Store Accumulator
  2706. ;
  2707. ;        Increment to the next opcode
  2708. ;        Fetch the next instruction
  2709. ;
  2710. ;******************************************************************************
  2711. Op_STA_DILIY    Proc    Near        ; Store accumulator procedure
  2712.     inc    si            ; Increment to the next opcode
  2713.     Fetch                ; Fetch and execute next instruction
  2714. Op_STA_DILIY    Endp            ; End of store accumulator procedure
  2715.     LineUp    Op_Size         ; Align the next opcode procedure
  2716.     Subttl    Opcode 98 - TYA Implied
  2717.     Page    +
  2718. ;******************************************************************************
  2719. ;
  2720. ;    Op_TYA ()    Transfer Y Index Register to Accumulator
  2721. ;
  2722. ;        Transfer Y index register to accumulator
  2723. ;        Update the 65C02 processor flags (n, z)
  2724. ;        Fetch the next instruction
  2725. ;
  2726. ;******************************************************************************
  2727. Op_TYA        Proc    Near        ; Transfer Y index to acc. procedure
  2728.     mov    dl,cl            ; Transfer Y index to accumulator
  2729.     or    dl,dl            ; Set the n and z flags correctly
  2730.     Flgnz                ; Update the n and z flags
  2731.     Fetch                ; Fetch and execute next instruction
  2732. Op_TYA        Endp            ; End of transfer Y index procedure
  2733.     LineUp    Op_Size         ; Align the next opcode procedure
  2734.     Subttl    Opcode 99 - STA Absolute Index, Y
  2735.     Page    +
  2736. ;******************************************************************************
  2737. ;
  2738. ;    Op_STA_AIY ()    Store Accumulator
  2739. ;
  2740. ;        Setup the effective address
  2741. ;        Do the STA operation
  2742. ;        Fetch the next instruction
  2743. ;
  2744. ;******************************************************************************
  2745. Op_STA_AIY    Proc    Near        ; Store accumulator procedure
  2746.     DoAIY                ; Setup the effective address
  2747.     OpSTA                ; Do the STA operation
  2748.     Fetch                ; Fetch and execute next instruction
  2749. Op_STA_AIY    Endp            ; End of store accumulator procedure
  2750.     LineUp    Op_Size         ; Align the next opcode procedure
  2751.     Subttl    Opcode 9A - TXS Implied
  2752.     Page    +
  2753. ;******************************************************************************
  2754. ;
  2755. ;    Op_TXS ()    Transfer X Index Register to Stack Pointer
  2756. ;
  2757. ;        Transfer X index register to stack pointer
  2758. ;        Fetch the next instruction
  2759. ;
  2760. ;******************************************************************************
  2761. Op_TXS        Proc    Near        ; Transfer X index to stack procedure
  2762.     mov    bl,ch            ; Transfer X index to stack pointer
  2763.     Fetch                ; Fetch and execute next instruction
  2764. Op_TXS        Endp            ; End of transfer X index procedure
  2765.     LineUp    Op_Size         ; Align the next opcode procedure
  2766.     Subttl    Opcode 9B - TXY Implied             (ILLEGAL)
  2767.     Page    +
  2768. ;******************************************************************************
  2769. ;
  2770. ;    Op_TXY ()    Transfer X Index Register to Y Index Register
  2771. ;
  2772. ;        Fetch the next instruction
  2773. ;
  2774. ;******************************************************************************
  2775. Op_TXY        Proc    Near        ; Transfer X index to Y index procedure
  2776.     Fetch                ; Fetch and execute next instruction
  2777. Op_TXY        Endp            ; End of transfer X index procedure
  2778.     LineUp    Op_Size         ; Align the next opcode procedure
  2779.     Subttl    Opcode 9C - STZ Absolute            (65C02 ONLY)
  2780.     Page    +
  2781. ;******************************************************************************
  2782. ;
  2783. ;    Op_STZ_A ()    Store Zero
  2784. ;
  2785. ;        Setup the effective address
  2786. ;        Do the STZ operation
  2787. ;        Fetch the next instruction
  2788. ;
  2789. ;******************************************************************************
  2790. Op_STZ_A    Proc    Near        ; Store zero procedure
  2791.     DoAbs                ; Setup the effective address
  2792.     OpSTZ                ; Do the STZ operation
  2793.     Fetch                ; Fetch and execute next instruction
  2794. Op_STZ_A    Endp            ; End of store zero procedure
  2795.     LineUp    Op_Size         ; Align the next opcode procedure
  2796.     Subttl    Opcode 9D - STA Absolute Indexed, X
  2797.     Page    +
  2798. ;******************************************************************************
  2799. ;
  2800. ;    Op_STA_AIX ()    Store Accumulator
  2801. ;
  2802. ;        Setup the effective address
  2803. ;        Do the STA operation
  2804. ;        Fetch the next instruction
  2805. ;
  2806. ;******************************************************************************
  2807. Op_STA_AIX    Proc    Near        ; Store accumulator procedure
  2808.     DoAIX                ; Setup the effective address
  2809.     OpSTA                ; Do the STA operation
  2810.     Fetch                ; Fetch and execute next instruction
  2811. Op_STA_AIX    Endp            ; End of store accumulator procedure
  2812.     LineUp    Op_Size         ; Align the next opcode procedure
  2813.     Subttl    Opcode 9E - STZ Absolute Indexed, X        (65C02 ONLY)
  2814.     Page    +
  2815. ;******************************************************************************
  2816. ;
  2817. ;    Op_STZ_AIX ()    Store Zero
  2818. ;
  2819. ;        Setup the effective address
  2820. ;        Do the STZ operation
  2821. ;        Fetch the next instruction
  2822. ;
  2823. ;******************************************************************************
  2824. Op_STZ_AIX    Proc    Near        ; Store zero procedure
  2825.     DoAIX                ; Setup the effective address
  2826.     OpSTZ                ; Do the STZ operation
  2827.     Fetch                ; Fetch and execute next instruction
  2828. Op_STZ_AIX    Endp            ; End of store zero procedure
  2829.     LineUp    Op_Size         ; Align the next opcode procedure
  2830.     Subttl    Opcode 9F - STA Absolute Long Indexed, X    (ILLEGAL)
  2831.     Page    +
  2832. ;******************************************************************************
  2833. ;
  2834. ;    Op_STA_ALIX ()    Store Accumulator
  2835. ;
  2836. ;        Increment to the next opcode
  2837. ;        Fetch the next instruction
  2838. ;
  2839. ;******************************************************************************
  2840. Op_STA_ALIX    Proc    Near        ; Store accumulator procedure
  2841.     add    si,3            ; Increment to the next opcode
  2842.     Fetch                ; Fetch and execute next instruction
  2843. Op_STA_ALIX    Endp            ; End of store accumulator procedure
  2844.     LineUp    Op_Size         ; Align the next opcode procedure
  2845.     Subttl    Opcode A0 - LDY Immediate
  2846.     Page    +
  2847. ;******************************************************************************
  2848. ;
  2849. ;    Op_LDY_I ()    Load Y Index Register
  2850. ;
  2851. ;        Setup the effective address
  2852. ;        Do the LDY operation (Update flag bits n, z)
  2853. ;        Fetch the next instruction
  2854. ;
  2855. ;******************************************************************************
  2856. Op_LDY_I    Proc    Near        ; Load Y index register procedure
  2857.     DoImm                ; Setup the effective address
  2858.     OpLDY                ; Do the LDY operation (Update n,z)
  2859.     Fetch                ; Fetch and execute next instruction
  2860. Op_LDY_I    Endp            ; End of load Y index procedure
  2861.     LineUp    Op_Size         ; Align the next opcode procedure
  2862.     Subttl    Opcode A1 - LDA DP Indexed Indirect, X
  2863.     Page    +
  2864. ;******************************************************************************
  2865. ;
  2866. ;    Op_LDA_DIIX ()    Load Accumulator
  2867. ;
  2868. ;        Setup the effective address
  2869. ;        Do the LDA operation (Update flag bits n, z)
  2870. ;        Fetch the next instruction
  2871. ;
  2872. ;******************************************************************************
  2873. Op_LDA_DIIX    Proc    Near        ; Load accumulator procedure
  2874.     DoDIIX                ; Setup the effective address
  2875.     OpLDA                ; Do the LDA operation (Update n,z)
  2876.     Fetch                ; Fetch and execute next instruction
  2877. Op_LDA_DIIX    Endp            ; End of load accumulator procedure
  2878.     LineUp    Op_Size         ; Align the next opcode procedure
  2879.     Subttl    Opcode A2 - LDX Immediate
  2880.     Page    +
  2881. ;******************************************************************************
  2882. ;
  2883. ;    Op_LDX_I ()    Load X Index Register
  2884. ;
  2885. ;        Setup the effective address
  2886. ;        Do the LDX operation (Update flag bits n, z)
  2887. ;        Fetch the next instruction
  2888. ;
  2889. ;******************************************************************************
  2890. Op_LDX_I    Proc    Near        ; Load X index register procedure
  2891.     DoImm                ; Setup the effective address
  2892.     OpLDX                ; Do the LDX operation (Update n,z)
  2893.     Fetch                ; Fetch and execute next instruction
  2894. Op_LDX_I    Endp            ; End of load X index procedure
  2895.     LineUp    Op_Size         ; Align the next opcode procedure
  2896.     Subttl    Opcode A3 - LDA Stack Relative            (ILLEGAL)
  2897.     Page    +
  2898. ;******************************************************************************
  2899. ;
  2900. ;    Op_LDA_S ()    Load Accumulator
  2901. ;
  2902. ;        Increment to the next opcode
  2903. ;        Fetch the next instruction
  2904. ;
  2905. ;******************************************************************************
  2906. Op_LDA_S    Proc    Near        ; Load accumulator procedure
  2907.     inc    si            ; Increment to the next opcode
  2908.     Fetch                ; Fetch and execute next instruction
  2909. Op_LDA_S    Endp            ; End of load accumulator procedure
  2910.     LineUp    Op_Size         ; Align the next opcode procedure
  2911.     Subttl    Opcode A4 - LDY Direct Page
  2912.     Page    +
  2913. ;******************************************************************************
  2914. ;
  2915. ;    Op_LDY_D ()    Load Y Index Register
  2916. ;
  2917. ;        Setup the effective address
  2918. ;        Do the LDY operation (Update flag bits n, z)
  2919. ;        Fetch the next instruction
  2920. ;
  2921. ;******************************************************************************
  2922. Op_LDY_D    Proc    Near        ; Load Y index register procedure
  2923.     DoDP                ; Setup the effective address
  2924.     OpLDY                ; Do the LDY operation (Update n,z)
  2925.     Fetch                ; Fetch and execute next instruction
  2926. Op_LDY_D    Endp            ; End of load Y index procedure
  2927.     LineUp    Op_Size         ; Align the next opcode procedure
  2928.     Subttl    Opcode A5 - LDA Direct Page
  2929.     Page    +
  2930. ;******************************************************************************
  2931. ;
  2932. ;    Op_LDA_D ()    Load Accumulator
  2933. ;
  2934. ;        Setup the effective address
  2935. ;        Do the LDA operation (Update flag bits n, z)
  2936. ;        Fetch the next instruction
  2937. ;
  2938. ;******************************************************************************
  2939. Op_LDA_D    Proc    Near        ; Load accumulator procedure
  2940.     DoDP                ; Setup the effective address
  2941.     OpLDA                ; Do the LDA operation (Update n,z)
  2942.     Fetch                ; Fetch and execute next instruction
  2943. Op_LDA_D    Endp            ; End of load accumulator procedure
  2944.     LineUp    Op_Size         ; Align the next opcode procedure
  2945.     Subttl    Opcode A6 - LDX Direct Page
  2946.     Page    +
  2947. ;******************************************************************************
  2948. ;
  2949. ;    Op_LDX_D ()    Load X Index Register
  2950. ;
  2951. ;        Setup the effective address
  2952. ;        Do the LDX operation (Update flag bits n, z)
  2953. ;        Fetch the next instruction
  2954. ;
  2955. ;******************************************************************************
  2956. Op_LDX_D    Proc    Near        ; Load X index register procedure
  2957.     DoDP                ; Setup the effective address
  2958.     OpLDX                ; Do the LDX operation (Update n,z)
  2959.     Fetch                ; Fetch and execute next instruction
  2960. Op_LDX_D    Endp            ; End of load X index procedure
  2961.     LineUp    Op_Size         ; Align the next opcode procedure
  2962.     Subttl    Opcode A7 - LDA DP Indirect Long        (ILLEGAL)
  2963.     Page    +
  2964. ;******************************************************************************
  2965. ;
  2966. ;    Op_LDA_DIL ()    Load Accumulator
  2967. ;
  2968. ;        Increment to the next opcode
  2969. ;        Fetch the next instruction
  2970. ;
  2971. ;******************************************************************************
  2972. Op_LDA_DIL    Proc    Near        ; Load accumulator procedure
  2973.     inc    si            ; Increment to the next opcode
  2974.     Fetch                ; Fetch and execute next instruction
  2975. Op_LDA_DIL    Endp            ; End of load accumulator procedure
  2976.     LineUp    Op_Size         ; Align the next opcode procedure
  2977.     Subttl    Opcode A8 - TAY Implied
  2978.     Page    +
  2979. ;******************************************************************************
  2980. ;
  2981. ;    Op_TAY ()    Transfer Accumulator to Y Index Register
  2982. ;
  2983. ;        Transfer accumulator to Y index register
  2984. ;        Update the 65C02 processor flags (n, z)
  2985. ;        Fetch the next instruction
  2986. ;
  2987. ;******************************************************************************
  2988. Op_TAY        Proc    Near        ; Transfer acc. to Y index procedure
  2989.     mov    cl,dl            ; Transfer accumulator to Y index
  2990.     or    cl,cl            ; Set the n and z flags correctly
  2991.     Flgnz                ; Update the n and z flags
  2992.     Fetch                ; Fetch and execute next instruction
  2993. Op_TAY        Endp            ; End of transfer accumulator procedure
  2994.     LineUp    Op_Size         ; Align the next opcode procedure
  2995.     Subttl    Opcode A9 - LDA Immediate
  2996.     Page    +
  2997. ;******************************************************************************
  2998. ;
  2999. ;    Op_LDA_I ()    Load Accumulator
  3000. ;
  3001. ;        Setup the effective address
  3002. ;        Do the LDA operation (Update flag bits n, z)
  3003. ;        Fetch the next instruction
  3004. ;
  3005. ;******************************************************************************
  3006. Op_LDA_I    Proc    Near        ; Load accumulator procedure
  3007.     DoImm                ; Setup the effective address
  3008.     OpLDA                ; Do the LDA operation (Update n,z)
  3009.     Fetch                ; Fetch and execute next instruction
  3010. Op_LDA_I    Endp            ; End of load accumulator procedure
  3011.     LineUp    Op_Size         ; Align the next opcode procedure
  3012.     Subttl    Opcode AA - TAX Implied
  3013.     Page    +
  3014. ;******************************************************************************
  3015. ;
  3016. ;    Op_TAX ()    Transfer Accumulator to X Index Register
  3017. ;
  3018. ;        Transfer accumulator to X index register
  3019. ;        Update the 65C02 processor flags (n, z)
  3020. ;        Fetch the next instruction
  3021. ;
  3022. ;******************************************************************************
  3023. Op_TAX        Proc    Near        ; Transfer acc. to X index procedure
  3024.     mov    ch,dl            ; Transfer accumulator to X index
  3025.     or    ch,ch            ; Set the n and z flags correctly
  3026.     Flgnz                ; Update the n and z flags
  3027.     Fetch                ; Fetch and execute next instruction
  3028. Op_TAX        Endp            ; End of transfer accumulator procedure
  3029.     LineUp    Op_Size         ; Align the next opcode procedure
  3030.     Subttl    Opcode AB - PLB Stack/Pull            (ILLEGAL)
  3031.     Page    +
  3032. ;******************************************************************************
  3033. ;
  3034. ;    Op_PLB ()    Pull Data Bank Register
  3035. ;
  3036. ;        Fetch the next instruction
  3037. ;
  3038. ;******************************************************************************
  3039. Op_PLB        Proc    Near        ; Pull data bank register procedure
  3040.     Fetch                ; Fetch and execute next instruction
  3041. Op_PLB        Endp            ; End of pull data bank procedure
  3042.     LineUp    Op_Size         ; Align the next opcode procedure
  3043.     Subttl    Opcode AC - LDY Absolute
  3044.     Page    +
  3045. ;******************************************************************************
  3046. ;
  3047. ;    Op_LDY_A ()    Load Y Index Register
  3048. ;
  3049. ;        Setup the effective address
  3050. ;        Do the LDY operation (Update flag bits n, z)
  3051. ;        Fetch the next instruction
  3052. ;
  3053. ;******************************************************************************
  3054. Op_LDY_A    Proc    Near        ; Load Y index register procedure
  3055.     DoAbs                ; Setup the effective address
  3056.     OpLDY                ; Do the LDY operation (Update n,z)
  3057.     Fetch                ; Fetch and execute next instruction
  3058. Op_LDY_A    Endp            ; End of load Y index procedure
  3059.     LineUp    Op_Size         ; Align the next opcode procedure
  3060.     Subttl    Opcode AD - LDA Absolute
  3061.     Page    +
  3062. ;******************************************************************************
  3063. ;
  3064. ;    Op_LDA_A ()    Load Accumulator
  3065. ;
  3066. ;        Setup the effective address
  3067. ;        Do the LDA operation (Update flag bits n, z)
  3068. ;        Fetch the next instruction
  3069. ;
  3070. ;******************************************************************************
  3071. Op_LDA_A    Proc    Near        ; Load accumulator procedure
  3072.     DoAbs                ; Setup the effective address
  3073.     OpLDA                ; Do the LDA operation (Update n,z)
  3074.     Fetch                ; Fetch and execute next instruction
  3075. Op_LDA_A    Endp            ; End of load accumulator procedure
  3076.     LineUp    Op_Size         ; Align the next opcode procedure
  3077.     Subttl    Opcode AE - LDX Absolute
  3078.     Page    +
  3079. ;******************************************************************************
  3080. ;
  3081. ;    Op_LDX_A ()    Load X Index Register
  3082. ;
  3083. ;        Setup the effective address
  3084. ;        Do the LDX operation (Update flag bits n, z)
  3085. ;        Fetch the next instruction
  3086. ;
  3087. ;******************************************************************************
  3088. Op_LDX_A    Proc    Near        ; Load X index register procedure
  3089.     DoAbs                ; Setup the effective address
  3090.     OpLDX                ; Do the LDX operation (Update n,z)
  3091.     Fetch                ; Fetch and execute next instruction
  3092. Op_LDX_A    Endp            ; End of load X index procedure
  3093.     LineUp    Op_Size         ; Align the next opcode procedure
  3094.     Subttl    Opcode AF - LDA Absolute Long            (ILLEGAL)
  3095.     Page    +
  3096. ;******************************************************************************
  3097. ;
  3098. ;    Op_LDA_AL ()    Load Accumulator
  3099. ;
  3100. ;        Increment to the next opcode
  3101. ;        Fetch the next instruction
  3102. ;
  3103. ;******************************************************************************
  3104. Op_LDA_AL    Proc    Near        ; Load accumulator procedure
  3105.     add    si,3            ; Increment to the next opcode
  3106.     Fetch                ; Fetch and execute next instruction
  3107. Op_LDA_AL    Endp            ; End of load accumulator procedure
  3108.     LineUp    Op_Size         ; Align the next opcode procedure
  3109.     Subttl    Opcode B0 - BCS Program Counter Relative
  3110.     Page    +
  3111. ;******************************************************************************
  3112. ;
  3113. ;    Op_BCS ()    Branch if Carry Set
  3114. ;
  3115. ;        Get the program counter offset byte
  3116. ;        If the c flag is set
  3117. ;            Update the program counter
  3118. ;        Endif
  3119. ;        Fetch the next instruction
  3120. ;
  3121. ;******************************************************************************
  3122. Op_BCS        Proc    Near        ; Branch if carry flag set procedure
  3123.     lodsb                ; Get the program counter offset
  3124.     test    dh,CPU_C        ; Check the 65C02 c (Carry) flag
  3125.     jz    _BCS            ; Jump if c flag is clear (No carry)
  3126.     cbw                ; Convert offset into a full word
  3127.     add    si,ax            ; Compute the new program counter
  3128. _BCS:
  3129.     Fetch                ; Fetch and execute next instruction
  3130. Op_BCS        Endp            ; End of branch if carry set procedure
  3131.     LineUp    Op_Size         ; Align the next opcode procedure
  3132.     Subttl    Opcode B1 - LDA DP Indirect Indexed, Y
  3133.     Page    +
  3134. ;******************************************************************************
  3135. ;
  3136. ;    Op_LDA_DIIY ()    Load Accumulator
  3137. ;
  3138. ;        Setup the effective address
  3139. ;        Do the LDA operation (Update flag bits n, z)
  3140. ;        Fetch the next instruction
  3141. ;
  3142. ;******************************************************************************
  3143. Op_LDA_DIIY    Proc    Near        ; Load Accumulator procedure
  3144.     DoDIIY                ; Setup the effective address
  3145.     OpLDA                ; Do the LDA operation (Update n,z)
  3146.     Fetch                ; Fetch and execute next instruction
  3147. Op_LDA_DIIY    Endp            ; End of load accumulator procedure
  3148.     LineUp    Op_Size         ; Align the next opcode procedure
  3149.     Subttl    Opcode B2 - LDA DP Indirect            (65C02 ONLY)
  3150.     Page    +
  3151. ;******************************************************************************
  3152. ;
  3153. ;    Op_LDA_DI ()    Load Accumulator
  3154. ;
  3155. ;        Setup the effective address
  3156. ;        Do the LDA operation (Update flag bits n, z)
  3157. ;        Fetch the next instruction
  3158. ;
  3159. ;******************************************************************************
  3160. Op_LDA_DI    Proc    Near        ; Load accumulator procedure
  3161.     DoDI                ; Setup the effective address
  3162.     OpLDA                ; Do the LDA operation (Update n,z)
  3163.     Fetch                ; Fetch and execute next instruction
  3164. Op_LDA_DI    Endp            ; End of load accumulator procedure
  3165.     LineUp    Op_Size         ; Align the next opcode procedure
  3166.     Subttl    Opcode B3 - LDA SR Indirect Indexed, Y        (ILLEGAL)
  3167.     Page    +
  3168. ;******************************************************************************
  3169. ;
  3170. ;    Op_LDA_SIIY ()    Load Accumulator
  3171. ;
  3172. ;        Increment to the next opcode
  3173. ;        Fetch the next instruction
  3174. ;
  3175. ;******************************************************************************
  3176. Op_LDA_SIIY    Proc    Near        ; Load accumulator procedure
  3177.     inc    si            ; Increment to the next opcode
  3178.     Fetch                ; Fetch and execute next instruction
  3179. Op_LDA_SIIY    Endp            ; End of load accumulator procedure
  3180.     LineUp    Op_Size         ; Align the next opcode procedure
  3181.     Subttl    Opcode B4 - LDY DP Indexed, X
  3182.     Page    +
  3183. ;******************************************************************************
  3184. ;
  3185. ;    Op_LDY_DIX ()    Load Y Index Register
  3186. ;
  3187. ;        Setup the effective address
  3188. ;        Do the LDY operation (Update flag bits n, z)
  3189. ;        Fetch the next instruction
  3190. ;
  3191. ;******************************************************************************
  3192. Op_LDY_DIX    Proc    Near        ; Load Y index register procedure
  3193.     DoDIX                ; Setup the effective address
  3194.     OpLDY                ; Do the LDY operation (Update n,z)
  3195.     Fetch                ; Fetch and execute next instruction
  3196. Op_LDY_DIX    Endp            ; End of load Y index procedure
  3197.     LineUp    Op_Size         ; Align the next opcode procedure
  3198.     Subttl    Opcode B5 - LDA DP Indexed, X
  3199.     Page    +
  3200. ;******************************************************************************
  3201. ;
  3202. ;    Op_LDA_DIX ()    Load Accumulator
  3203. ;
  3204. ;        Setup the effective address
  3205. ;        Do the LDA operation (Update flag bits n, z)
  3206. ;        Fetch the next instruction
  3207. ;
  3208. ;******************************************************************************
  3209. Op_LDA_DIX    Proc    Near        ; Load accumulator procedure
  3210.     DoDIX                ; Setup the effective address
  3211.     OpLDA                ; Do the LDA operation (Update n,z)
  3212.     Fetch                ; Fetch and execute next instruction
  3213. Op_LDA_DIX    Endp            ; End of load accumulator procedure
  3214.     LineUp    Op_Size         ; Align the next opcode procedure
  3215.     Subttl    Opcode B6 - LDX DP Indexed, Y
  3216.     Page    +
  3217. ;******************************************************************************
  3218. ;
  3219. ;    Op_LDX_DIY ()    Load X Index Register
  3220. ;
  3221. ;        Setup the effective address
  3222. ;        Do the LDX operation (Update flag bits n, z)
  3223. ;        Fetch the next instruction
  3224. ;
  3225. ;******************************************************************************
  3226. Op_LDX_DIY    Proc    Near        ; Load X index register procedure
  3227.     DoDIY                ; Setup the effective address
  3228.     OpLDX                ; Do the LDX operation (Update n,z)
  3229.     Fetch                ; Fetch and execute next instruction
  3230. Op_LDX_DIY    Endp            ; End of load X index procedure
  3231.     LineUp    Op_Size         ; Align the next opcode procedure
  3232.     Subttl    Opcode B7 - LDA DP Indirect Long Indexed, Y    (ILLEGAL)
  3233.     Page    +
  3234. ;******************************************************************************
  3235. ;
  3236. ;    Op_LDA_DILIY () Load Accumulator
  3237. ;
  3238. ;        Increment to the next opcode
  3239. ;        Fetch the next instruction
  3240. ;
  3241. ;******************************************************************************
  3242. Op_LDA_DILIY    Proc    Near        ; Load accumulator procedure
  3243.     inc    si            ; Increment to the next opcode
  3244.     Fetch                ; Fetch and execute next instruction
  3245. Op_LDA_DILIY    Endp            ; End of load accumulator procedure
  3246.     LineUp    Op_Size         ; Align the next opcode procedure
  3247.     Subttl    Opcode B8 - CLV Implied
  3248.     Page    +
  3249. ;******************************************************************************
  3250. ;
  3251. ;    Op_CLV ()    Clear Overflow Flag
  3252. ;
  3253. ;        Clear the overflow flag
  3254. ;        Fetch the next instruction
  3255. ;
  3256. ;******************************************************************************
  3257. Op_CLV        Proc    Near        ; Clear overflow flag procedure
  3258.     and    dh,Not CPU_V        ; Clear the overflow flag bit
  3259.     Fetch                ; Fetch and execute next instruction
  3260. Op_CLV        Endp            ; End of clear overflow procedure
  3261.     LineUp    Op_Size         ; Align the next opcode procedure
  3262.     Subttl    Opcode B9 - LDA Absolute Indexed, Y
  3263.     Page    +
  3264. ;******************************************************************************
  3265. ;
  3266. ;    Op_LDA_AIY ()    Load Accumulator
  3267. ;
  3268. ;        Setup the effective address
  3269. ;        Do the LDA operation (Update flag bits n, z)
  3270. ;        Fetch the next instruction
  3271. ;
  3272. ;******************************************************************************
  3273. Op_LDA_AIY    Proc    Near        ; Load accumulator procedure
  3274.     DoAIY                ; Setup the effective address
  3275.     OpLDA                ; Do the LDA operation (Update n,z)
  3276.     Fetch                ; Fetch and execute next instruction
  3277. Op_LDA_AIY    Endp            ; End of load accumulator procedure
  3278.     LineUp    Op_Size         ; Align the next opcode procedure
  3279.     Subttl    Opcode BA - TSX Implied
  3280.     Page    +
  3281. ;******************************************************************************
  3282. ;
  3283. ;    Op_TSX ()    Transfer Stack Pointer to X Index Register
  3284. ;
  3285. ;        Transfer stack pointer to X index register
  3286. ;        Update the 65C02 processor flags (n, z)
  3287. ;        Fetch the next instruction
  3288. ;
  3289. ;******************************************************************************
  3290. Op_TSX        Proc    Near        ; Transfer stack to X index procedure
  3291.     mov    ch,bl            ; Transfer stack pointer to X index
  3292.     or    ch,ch            ; Set the n and z flags correctly
  3293.     Flgnz                ; Update the n and z flags
  3294.     Fetch                ; Fetch and execute next instruction
  3295. Op_TSX        Endp            ; End of transfer stack procedure
  3296.     LineUp    Op_Size         ; Align the next opcode procedure
  3297.     Subttl    Opcode BB - TYX Implied             (ILLEGAL)
  3298.     Page    +
  3299. ;******************************************************************************
  3300. ;
  3301. ;    Op_TYX ()    Transfer Y Index Register to X Index Register
  3302. ;
  3303. ;        Fetch the next instruction
  3304. ;
  3305. ;******************************************************************************
  3306. Op_TYX        Proc    Near        ; Transfer Y index to X index procedure
  3307.     Fetch                ; Fetch and execute next instruction
  3308. Op_TYX        Endp            ; End of transfer Y index procedure
  3309.     LineUp    Op_Size         ; Align the next opcode procedure
  3310.     Subttl    Opcode BC - LDY Absolute Indexed, X
  3311.     Page    +
  3312. ;******************************************************************************
  3313. ;
  3314. ;    Op_LDY_AIX ()    Load Y Index Register
  3315. ;
  3316. ;        Setup the effective address
  3317. ;        Do the LDY operation (Update flag bits n, z)
  3318. ;        Fetch the next instruction
  3319. ;
  3320. ;******************************************************************************
  3321. Op_LDY_AIX    Proc    Near        ; Load Y index register procedure
  3322.     DoAIX                ; Setup the effective address
  3323.     OpLDY                ; Do the LDY operation (Update n,z)
  3324.     Fetch                ; Fetch and execute next instruction
  3325. Op_LDY_AIX    Endp            ; End of load Y index procedure
  3326.     LineUp    Op_Size         ; Align the next opcode procedure
  3327.     Subttl    Opcode BD - LDA Absolute Indexed, X
  3328.     Page    +
  3329. ;******************************************************************************
  3330. ;
  3331. ;    Op_LDA_AIX ()    Load Accumulator
  3332. ;
  3333. ;        Setup the effective address
  3334. ;        Do the LDA operation (Update flag bits n, z)
  3335. ;        Fetch the next instruction
  3336. ;
  3337. ;******************************************************************************
  3338. Op_LDA_AIX    Proc    Near        ; Load accumulator procedure
  3339.     DoAIX                ; Setup the effective address
  3340.     OpLDA                ; Do the LDA operation (Update n,z)
  3341.     Fetch                ; Fetch and execute next instruction
  3342. Op_LDA_AIX    Endp            ; End of load accumulator procedure
  3343.     LineUp    Op_Size         ; Align the next opcode procedure
  3344.     Subttl    Opcode BE - LDX Absolute Indexed, Y
  3345.     Page    +
  3346. ;******************************************************************************
  3347. ;
  3348. ;    Op_LDX_AIY ()    Load X Index Register
  3349. ;
  3350. ;        Setup the effective address
  3351. ;        Do the LDX operation (Update flag bits n, z)
  3352. ;        Fetch the next instruction
  3353. ;
  3354. ;******************************************************************************
  3355. Op_LDX_AIY    Proc    Near        ; Load X index register procedure
  3356.     DoAIY                ; Setup the effective address
  3357.     OpLDX                ; Do the LDX operation (Update n,z)
  3358.     Fetch                ; Fetch and execute next instruction
  3359. Op_LDX_AIY    Endp            ; End of load X index procedure
  3360.     LineUp    Op_Size         ; Align the next opcode procedure
  3361.     Subttl    Opcode BF - LDA Absolute Long Indexed, X    (ILLEGAL)
  3362.     Page    +
  3363. ;******************************************************************************
  3364. ;
  3365. ;    Op_LDA_ALIX ()    Load Accumulator
  3366. ;
  3367. ;        Increment to the next opcode
  3368. ;        Fetch the next instruction
  3369. ;
  3370. ;******************************************************************************
  3371. Op_LDA_ALIX    Proc    Near        ; Load accumulator procedure
  3372.     add    si,3            ; Increment to the next opcode
  3373.     Fetch                ; Fetch and execute next instruction
  3374. Op_LDA_ALIX    Endp            ; End of load accumulator procedure
  3375.     LineUp    Op_Size         ; Align the next opcode procedure
  3376.     Subttl    Opcode C0 - CPY Immediate
  3377.     Page    +
  3378. ;******************************************************************************
  3379. ;
  3380. ;    Op_CPY_I ()    Compare Y Index Register with Memory
  3381. ;
  3382. ;        Setup the effective address
  3383. ;        Do the CPY operation (Update flag bits n, z, c)
  3384. ;        Fetch the next instruction
  3385. ;
  3386. ;******************************************************************************
  3387. Op_CPY_I    Proc    Near        ; Compare Y index with memory procedure
  3388.     DoImm                ; Setup the effective address
  3389.     OpCPY                ; Do the CPY operation (Update n,z,c)
  3390.     Fetch                ; Fetch and execute next instruction
  3391. Op_CPY_I    Endp            ; End of compare Y index procedure
  3392.     LineUp    Op_Size         ; Align the next opcode procedure
  3393.     Subttl    Opcode C1 - CMP DP Indexed Indirect, X
  3394.     Page    +
  3395. ;******************************************************************************
  3396. ;
  3397. ;    Op_CMP_DIIX ()    Compare Accumulator with Memory
  3398. ;
  3399. ;        Setup the effective address
  3400. ;        Do the CMP operation (Update flag bits n, z, c)
  3401. ;        Fetch the next instruction
  3402. ;
  3403. ;******************************************************************************
  3404. Op_CMP_DIIX    Proc    Near        ; Compare acc. with memory procedure
  3405.     DoDIIX                ; Setup the effective address
  3406.     OpCMP                ; Do the CMP operation (Update n,z,c)
  3407.     Fetch                ; Fetch and execute next instruction
  3408. Op_CMP_DIIX    Endp            ; End of compare accumulator procedure
  3409.     LineUp    Op_Size         ; Align the next opcode procedure
  3410.     Subttl    Opcode C2 - REP Implied             (ILLEGAL)
  3411.     Page    +
  3412. ;******************************************************************************
  3413. ;
  3414. ;    Op_REP ()    Reset Status Bits
  3415. ;
  3416. ;        Increment to the next opcode
  3417. ;        Fetch the next instruction
  3418. ;
  3419. ;******************************************************************************
  3420. Op_REP        Proc    Near        ; Reset status bits procedure
  3421.     inc    si            ; Increment to the next opcode
  3422.     Fetch                ; Fetch and execute next instruction
  3423. Op_REP        Endp            ; End of reset status bits procedure
  3424.     LineUp    Op_Size         ; Align the next opcode procedure
  3425.     Subttl    Opcode C3 - CMP Stack Relative            (ILLEGAL)
  3426.     Page    +
  3427. ;******************************************************************************
  3428. ;
  3429. ;    Op_CMP_S ()    Compare Accumulator to Memory
  3430. ;
  3431. ;        Increment to the next opcode
  3432. ;        Fetch the next instruction
  3433. ;
  3434. ;******************************************************************************
  3435. Op_CMP_S    Proc    Near        ; Compare acc. with memory procedure
  3436.     inc    si            ; Increment to the next opcode
  3437.     Fetch                ; Fetch and execute next instruction
  3438. Op_CMP_S    Endp            ; End of compare accumulator procedure
  3439.     LineUp    Op_Size         ; Align the next opcode procedure
  3440.     Subttl    Opcode C4 - CPY Direct Page
  3441.     Page    +
  3442. ;******************************************************************************
  3443. ;
  3444. ;    Op_CPY_D ()    Compare Y Index Register with Memory
  3445. ;
  3446. ;        Setup the effective address
  3447. ;        Do the CPY operation (Update flag bits n, z, c)
  3448. ;        Fetch the next instruction
  3449. ;
  3450. ;******************************************************************************
  3451. Op_CPY_D    Proc    Near        ; Compare Y index with memory procedure
  3452.     DoDP                ; Setup the effective address
  3453.     OpCPY                ; Do the CPY operation (Update n,z,c)
  3454.     Fetch                ; Fetch and execute next instruction
  3455. Op_CPY_D    Endp            ; End of compare Y index procedure
  3456.     LineUp    Op_Size         ; Align the next opcode procedure
  3457.     Subttl    Opcode C5 - CMP Direct Page
  3458.     Page    +
  3459. ;******************************************************************************
  3460. ;
  3461. ;    Op_CMP_D ()    Compare Accumulator with Memory
  3462. ;
  3463. ;        Setup the effective address
  3464. ;        Do the CMP operation (Update flag bits n, z, c)
  3465. ;        Fetch the next instruction
  3466. ;
  3467. ;******************************************************************************
  3468. Op_CMP_D    Proc    Near        ; Compare acc. with memory procedure
  3469.     DoDP                ; Setup the effective address
  3470.     OpCMP                ; Do the CMP operation (Update n,z,c)
  3471.     Fetch                ; Fetch and execute next instruction
  3472. Op_CMP_D    Endp            ; End of compare accumulator procedure
  3473.     LineUp    Op_Size         ; Align the next opcode procedure
  3474.     Subttl    Opcode C6 - DEC Direct Page
  3475.     Page    +
  3476. ;******************************************************************************
  3477. ;
  3478. ;    Op_DEC_D ()    Decrement Memory
  3479. ;
  3480. ;        Setup the effective address
  3481. ;        Do the DEC operation (Update flag bits n, z)
  3482. ;        Fetch the next instruction
  3483. ;
  3484. ;******************************************************************************
  3485. Op_DEC_D    Proc    Near        ; Decrement memory procedure
  3486.     DoDP                ; Setup the effective address
  3487.     OpDEC                ; Do the DEC operation (Update n,z)
  3488.     Fetch                ; Fetch and execute next instruction
  3489. Op_DEC_D    Endp            ; End of decrement memory procedure
  3490.     LineUp    Op_Size         ; Align the next opcode procedure
  3491.     Subttl    Opcode C7 - CMP DP Indirect Long        (ILLEGAL)
  3492.     Page    +
  3493. ;******************************************************************************
  3494. ;
  3495. ;    Op_CMP_DIL ()    Compare Accumulator with Memory
  3496. ;
  3497. ;        Increment to the next opcode
  3498. ;        Fetch the next instruction
  3499. ;
  3500. ;******************************************************************************
  3501. Op_CMP_DIL    Proc    Near        ; Compare acc. with memory procedure
  3502.     inc    si            ; Increment to the next opcode
  3503.     Fetch                ; Fetch and execute next instruction
  3504. Op_CMP_DIL    Endp            ; End of compare accumulator procedure
  3505.     LineUp    Op_Size         ; Align the next opcode procedure
  3506.     Subttl    Opcode C8 - INY Implied
  3507.     Page    +
  3508. ;******************************************************************************
  3509. ;
  3510. ;    Op_INY ()    Increment Y Index Register
  3511. ;
  3512. ;        Increment the Y index register
  3513. ;        Update the 65C02 processor flags (n, z)
  3514. ;        Fetch the next instruction
  3515. ;
  3516. ;******************************************************************************
  3517. Op_INY        Proc    Near        ; Increment Y index register procedure
  3518.     inc    cl            ; Increment the Y index register
  3519.     Flgnz                ; Update the n and z flags
  3520.     Fetch                ; Fetch and execute next instruction
  3521. Op_INY        Endp            ; End of increment Y index procedure
  3522.     LineUp    Op_Size         ; Align the next opcode procedure
  3523.     Subttl    Opcode C9 - CMP Immediate
  3524.     Page    +
  3525. ;******************************************************************************
  3526. ;
  3527. ;    Op_CMP_I ()    Compare Accumulator with Memory
  3528. ;
  3529. ;        Setup the effective address
  3530. ;        Do the CMP operation (Update flag bits n, z, c)
  3531. ;        Fetch the next instruction
  3532. ;
  3533. ;******************************************************************************
  3534. Op_CMP_I    Proc    Near        ; Compare acc. with memory procedure
  3535.     DoImm                ; Setup the effective address
  3536.     OpCMP                ; Do the CMP operation (Update n,z,c)
  3537.     Fetch                ; Fetch and execute next instruction
  3538. Op_CMP_I    Endp            ; End of compare accumulator procedure
  3539.     LineUp    Op_Size         ; Align the next opcode procedure
  3540.     Subttl    Opcode CA - DEX Implied
  3541.     Page    +
  3542. ;******************************************************************************
  3543. ;
  3544. ;    Op_DEX ()    Decrement X Index Register
  3545. ;
  3546. ;        Decrement the X index register
  3547. ;        Update the 65C02 processor flags (n, z)
  3548. ;        Fetch the next instruction
  3549. ;
  3550. ;******************************************************************************
  3551. Op_DEX        Proc    Near        ; Decrement X index register procedure
  3552.     dec    ch            ; Decrement the X index register
  3553.     Flgnz                ; Update the n and z flags
  3554.     Fetch                ; Fetch and execute next instruction
  3555. Op_DEX        Endp            ; End of decrement X index procedure
  3556.     LineUp    Op_Size         ; Align the next opcode procedure
  3557.     Subttl    Opcode CB - WAI Implied             (ILLEGAL)
  3558.     Page    +
  3559. ;******************************************************************************
  3560. ;
  3561. ;    Op_WAI ()    Wait for Interrupt
  3562. ;
  3563. ;        Fetch the next instruction
  3564. ;
  3565. ;******************************************************************************
  3566. Op_WAI        Proc    Near        ; Wait for interrupt procedure
  3567.     Fetch                ; Fetch and execute next instruction
  3568. Op_WAI        Endp            ; End of wait for interrupt procedure
  3569.     LineUp    Op_Size         ; Align the next opcode procedure
  3570.     Subttl    Opcode CC - CPY Absolute
  3571.     Page    +
  3572. ;******************************************************************************
  3573. ;
  3574. ;    Op_CPY_A ()    Compare Y Index with Memory
  3575. ;
  3576. ;        Setup the effective address
  3577. ;        Do the CPY operation (Update flag bits n, z, c)
  3578. ;        Fetch the next instruction
  3579. ;
  3580. ;******************************************************************************
  3581. Op_CPY_A    Proc    Near        ; Compare Y index with memory procedure
  3582.     DoAbs                ; Setup the effective address
  3583.     OpCPY                ; Do the CPY operation (Update n,z,c)
  3584.     Fetch                ; Fetch and execute next instruction
  3585. Op_CPY_A    Endp            ; End of compare Y index procedure
  3586.     LineUp    Op_Size         ; Align the next opcode procedure
  3587.     Subttl    Opcode CD - CMP Absolute
  3588.     Page    +
  3589. ;******************************************************************************
  3590. ;
  3591. ;    Op_CMP_A ()    Compare Accumulator with Memory
  3592. ;
  3593. ;        Setup the effective address
  3594. ;        Do the CMP operation (Update flag bits n, z, c)
  3595. ;        Fetch the next instruction
  3596. ;
  3597. ;******************************************************************************
  3598. Op_CMP_A    Proc    Near        ; Compare acc. with memory procedure
  3599.     DoAbs                ; Setup the effective address
  3600.     OpCMP                ; Do the CMP operation (Update n,z,c)
  3601.     Fetch                ; Fetch and execute next instruction
  3602. Op_CMP_A    Endp            ; End of compare accumulator procedure
  3603.     LineUp    Op_Size         ; Align the next opcode procedure
  3604.     Subttl    Opcode CE - DEC Absolute
  3605.     Page    +
  3606. ;******************************************************************************
  3607. ;
  3608. ;    Op_DEC_A ()    Decrement Memory
  3609. ;
  3610. ;        Setup the effective address
  3611. ;        Do the DEC operation (Update flag bits n, z)
  3612. ;        Fetch the next instruction
  3613. ;
  3614. ;******************************************************************************
  3615. Op_DEC_A    Proc    Near        ; Decrement memory procedure
  3616.     DoAbs                ; Setup the effective address
  3617.     OpDEC                ; Do the DEC operation (Update n,z)
  3618.     Fetch                ; Fetch and execute next instruction
  3619. Op_DEC_A    Endp            ; End of decrement memory procedure
  3620.     LineUp    Op_Size         ; Align the next opcode procedure
  3621.     Subttl    Opcode CF - CMP Absolute Long            (ILLEGAL)
  3622.     Page    +
  3623. ;******************************************************************************
  3624. ;
  3625. ;    Op_CMP_AL ()    Compare Accumulator with Memory
  3626. ;
  3627. ;        Increment to the next opcode
  3628. ;        Fetch the next instruction
  3629. ;
  3630. ;******************************************************************************
  3631. Op_CMP_AL    Proc    Near        ; Compare acc. with memory procedure
  3632.     add    si,3            ; Increment to the next opcode
  3633.     Fetch                ; Fetch and execute next instruction
  3634. Op_CMP_AL    Endp            ; End of compare accumulator procedure
  3635.     LineUp    Op_Size         ; Align the next opcode procedure
  3636.     Subttl    Opcode D0 - BNE Program Counter Relative
  3637.     Page    +
  3638. ;******************************************************************************
  3639. ;
  3640. ;    Op_BNE ()    Branch if Not Equal
  3641. ;
  3642. ;        Get the program counter offset byte
  3643. ;        If the z flag is clear
  3644. ;            Update the program counter
  3645. ;        Endif
  3646. ;        Fetch the next instruction
  3647. ;
  3648. ;******************************************************************************
  3649. Op_BNE        Proc    Near        ; Branch if not equal procedure
  3650.     lodsb                ; Get the program counter offset
  3651.     test    dh,CPU_Z        ; Check the 65C02 z (Zero) flag
  3652.     jnz    _BNE            ; Jump if z flag is set (Equal)
  3653.     cbw                ; Convert offset into a full word
  3654.     add    si,ax            ; Compute the new program counter
  3655. _BNE:
  3656.     Fetch                ; Fetch and execute next instruction
  3657. Op_BNE        Endp            ; End of branch if not equal procedure
  3658.     LineUp    Op_Size         ; Align the next opcode procedure
  3659.     Subttl    Opcode D1 - CMP DP Indirect Indexed, Y
  3660.     Page    +
  3661. ;******************************************************************************
  3662. ;
  3663. ;    Op_CMP_DIIY ()    Compare Accumulator with Memory
  3664. ;
  3665. ;        Setup the effective address
  3666. ;        Do the CMP operation (Update flag bits n, z, c)
  3667. ;        Fetch the next instruction
  3668. ;
  3669. ;******************************************************************************
  3670. Op_CMP_DIIY    Proc    Near        ; Compare acc. with memory procedure
  3671.     DoDIIY                ; Setup the effective address
  3672.     OpCMP                ; Do the CMP operation (Update n,z,c)
  3673.     Fetch                ; Fetch and execute next instruction
  3674. Op_CMP_DIIY    Endp            ; End of compare accumulator procedure
  3675.     LineUp    Op_Size         ; Align the next opcode procedure
  3676.     Subttl    Opcode D2 - CMP DP Indirect            (65C02 ONLY)
  3677.     Page    +
  3678. ;******************************************************************************
  3679. ;
  3680. ;    Op_CMP_DI ()    Compare Accumulator with Memory
  3681. ;
  3682. ;        Setup the effective address
  3683. ;        Do the CMP operation (Update flag bits n, z, c)
  3684. ;        Fetch the next instruction
  3685. ;
  3686. ;******************************************************************************
  3687. Op_CMP_DI    Proc    Near        ; Compare acc. with memory procedure
  3688.     DoDI                ; Setup the effective address
  3689.     OpCMP                ; Do the CMP operation (Update n,z,c)
  3690.     Fetch                ; Fetch and execute next instruction
  3691. Op_CMP_DI    Endp            ; End of compare accumulator procedure
  3692.     LineUp    Op_Size         ; Align the next opcode procedure
  3693.     Subttl    Opcode D3 - CMP SR Indirect Indexed, Y        (ILLEGAL)
  3694.     Page    +
  3695. ;******************************************************************************
  3696. ;
  3697. ;    Op_CMP_SIIY ()    Compare Accumulator with Memory
  3698. ;
  3699. ;        Increment to the next opcode
  3700. ;        Fetch the next instruction
  3701. ;
  3702. ;******************************************************************************
  3703. Op_CMP_SIIY    Proc    Near        ; Compare acc. with memory procedure
  3704.     inc    si            ; Increment to the next opcode
  3705.     Fetch                ; Fetch and execute next instruction
  3706. Op_CMP_SIIY    Endp            ; End of compare accumulator procedure
  3707.     LineUp    Op_Size         ; Align the next opcode procedure
  3708.     Subttl    Opcode D4 - PEI Stack                (ILLEGAL)
  3709.     Page    +
  3710. ;******************************************************************************
  3711. ;
  3712. ;    Op_PEI ()    Push Effective Indirect Address
  3713. ;
  3714. ;        Increment to the next opcode
  3715. ;        Fetch the next instruction
  3716. ;
  3717. ;******************************************************************************
  3718. Op_PEI        Proc    Near        ; Push indirect address procedure
  3719.     inc    si            ; Increment to the next opcode
  3720.     Fetch                ; Fetch and execute next instruction
  3721. Op_PEI        Endp            ; End of push indirect address procedure
  3722.     LineUp    Op_Size         ; Align the next opcode procedure
  3723.     Subttl    Opcode D5 - CMP DP Indexed, X
  3724.     Page    +
  3725. ;******************************************************************************
  3726. ;
  3727. ;    Op_CMP_DIX ()    Compare Accumulator with Memory
  3728. ;
  3729. ;        Setup the effective address
  3730. ;        Do the CMP operation (Update flag bits n, z, c)
  3731. ;        Fetch the next instruction
  3732. ;
  3733. ;******************************************************************************
  3734. Op_CMP_DIX    Proc    Near        ; Compare acc. with memory procedure
  3735.     DoDIX                ; Setup the effective address
  3736.     OpCMP                ; Do the CMP operation (Update n,z,c)
  3737.     Fetch                ; Fetch and execute next instruction
  3738. Op_CMP_DIX    Endp            ; End of compare accumulator procedure
  3739.     LineUp    Op_Size         ; Align the next opcode procedure
  3740.     Subttl    Opcode D6 - DEC DP Indexed, X
  3741.     Page    +
  3742. ;******************************************************************************
  3743. ;
  3744. ;    Op_DEC_DIX ()    Decrement Memory
  3745. ;
  3746. ;        Setup the effective address
  3747. ;        Do the DEC operation (Update flag bits n, z)
  3748. ;        Fetch the next instruction
  3749. ;
  3750. ;******************************************************************************
  3751. Op_DEC_DIX    Proc    Near        ; Decrement memory procedure
  3752.     DoDIX                ; Setup the effective address
  3753.     OpDEC                ; Do the DEC operation (Update n,z)
  3754.     Fetch                ; Fetch and execute next instruction
  3755. Op_DEC_DIX    Endp            ; End of decrement memory procedure
  3756.     LineUp    Op_Size         ; Align the next opcode procedure
  3757.     Subttl    Opcode D7 - CMP DP Indirect Long Indexed, Y    (ILLEGAL)
  3758.     Page    +
  3759. ;******************************************************************************
  3760. ;
  3761. ;    Op_CMP_DILIY () Compare Accumulator with Memory
  3762. ;
  3763. ;        Increment to the next opcode
  3764. ;        Fetch the next instruction
  3765. ;
  3766. ;******************************************************************************
  3767. Op_CMP_DILIY    Proc    Near        ; Compare acc. with memory procedure
  3768.     inc    si            ; Increment to the next opcode
  3769.     Fetch                ; Fetch and execute next instruction
  3770. Op_CMP_DILIY    Endp            ; End of compare accumulator procedure
  3771.     LineUp    Op_Size         ; Align the next opcode procedure
  3772.     Subttl    Opcode D8 - CLD Implied
  3773.     Page    +
  3774. ;******************************************************************************
  3775. ;
  3776. ;    Op_CLD ()    Clear Decimal Mode Flag
  3777. ;
  3778. ;        Clear the decimal mode flag
  3779. ;        Fetch the next instruction
  3780. ;
  3781. ;******************************************************************************
  3782. Op_CLD        Proc    Near        ; Clear decimal mode flag procedure
  3783.     and    dh,Not CPU_M        ; Clear the decimal mode flag bit
  3784.     Fetch                ; Fetch and execute next instruction
  3785. Op_CLD        Endp            ; End of clear decimal mode procedure
  3786.     LineUp    Op_Size         ; Align the next opcode procedure
  3787.     Subttl    Opcode D9 - CMP Absolute Indexed, Y
  3788.     Page    +
  3789. ;******************************************************************************
  3790. ;
  3791. ;    Op_CMP_AIY ()    Compare Accumulator with Memory
  3792. ;
  3793. ;        Setup the effective address
  3794. ;        Do the CMP operation (Update flag bits n, z, c)
  3795. ;        Fetch the next instruction
  3796. ;
  3797. ;******************************************************************************
  3798. Op_CMP_AIY    Proc    Near        ; Compare acc. with memory procedure
  3799.     DoAIY                ; Setup the effective address
  3800.     OpCMP                ; Do the CMP operation (Update n,z,c)
  3801.     Fetch                ; Fetch and execute next instruction
  3802. Op_CMP_AIY    Endp            ; End of compare accumulator procedure
  3803.     LineUp    Op_Size         ; Align the next opcode procedure
  3804.     Subttl    Opcode DA - PHX Stack/Push            (65C02 ONLY)
  3805.     Page    +
  3806. ;******************************************************************************
  3807. ;
  3808. ;    Op_PHX ()    Push X Index Register
  3809. ;
  3810. ;        Push the X index register onto stack
  3811. ;        Fetch the next instruction
  3812. ;
  3813. ;******************************************************************************
  3814. Op_PHX        Proc    Near        ; Push X index register procedure
  3815.     mov    al,ch            ; Get the X index register value
  3816.     Push_8                ; Push X index register onto the stack
  3817.     Fetch                ; Fetch and execute next instruction
  3818. Op_PHX        Endp            ; End of push X index procedure
  3819.     LineUp    Op_Size         ; Align the next opcode procedure
  3820.     Subttl    Opcode DB - STP Implied             (ILLEGAL)
  3821.     Page    +
  3822. ;******************************************************************************
  3823. ;
  3824. ;    Op_STP ()    Stop the Processor
  3825. ;
  3826. ;        Fetch the next instruction
  3827. ;
  3828. ;******************************************************************************
  3829. Op_STP        Proc    Near        ; Stop the processor procedure
  3830.     Fetch                ; Fetch and execute next instruction
  3831. Op_STP        Endp            ; End of stop processor procedure
  3832.     LineUp    Op_Size         ; Align the next opcode procedure
  3833.     Subttl    Opcode DC - JMP Absolute Indirect Long        (ILLEGAL)
  3834.     Page    +
  3835. ;******************************************************************************
  3836. ;
  3837. ;    Op_JMP_AIL ()    Jump
  3838. ;
  3839. ;        Increment to the next opcode
  3840. ;        Fetch the next instruction
  3841. ;
  3842. ;******************************************************************************
  3843. Op_JMP_AIL    Proc    Near        ; Jump procedure
  3844.     add    si,2            ; Increment to the next opcode
  3845.     Fetch                ; Fetch and execute next instruction
  3846. Op_JMP_AIL    Endp            ; End of jump procedure
  3847.     LineUp    Op_Size         ; Align the next opcode procedure
  3848.     Subttl    Opcode DD - CMP Absolute Indexed, X
  3849.     Page    +
  3850. ;******************************************************************************
  3851. ;
  3852. ;    Op_CMP_AIX ()    Compare Accumulator with Memory
  3853. ;
  3854. ;        Setup the effective address
  3855. ;        Do the CMP operation (Update flag bits n, z, c)
  3856. ;        Fetch the next instruction
  3857. ;
  3858. ;******************************************************************************
  3859. Op_CMP_AIX    Proc    Near        ; Compare acc. with memory procedure
  3860.     DoAIX                ; Setup the effective address
  3861.     OpCMP                ; Do the CMP operation (Update n,z,c)
  3862.     Fetch                ; Fetch and execute next instruction
  3863. Op_CMP_AIX    Endp            ; End of compare accumulator procedure
  3864.     LineUp    Op_Size         ; Align the next opcode procedure
  3865.     Subttl    Opcode DE - DEC Absolute Indexed, X
  3866.     Page    +
  3867. ;******************************************************************************
  3868. ;
  3869. ;    Op_DEC_AIX ()    Decrement Memory
  3870. ;
  3871. ;        Setup the effective address
  3872. ;        Do the DEC operation (Update flag bits n, z)
  3873. ;        Fetch the next instruction
  3874. ;
  3875. ;******************************************************************************
  3876. Op_DEC_AIX    Proc    Near        ; Decrement memory procedure
  3877.     DoAIX                ; Setup the effective address
  3878.     OpDEC                ; Do the DEC operation (Update n,z)
  3879.     Fetch                ; Fetch and execute next instruction
  3880. Op_DEC_AIX    Endp            ; End of decrement memory procedure
  3881.     LineUp    Op_Size         ; Align the next opcode procedure
  3882.     Subttl    Opcode DF - CMP Absolute Long Indexed, X    (ILLEGAL)
  3883.     Page    +
  3884. ;******************************************************************************
  3885. ;
  3886. ;    Op_CMP_ALIX ()    Compare Accumulator with Memory
  3887. ;
  3888. ;        Increment to the next opcode
  3889. ;        Fetch the next instruction
  3890. ;
  3891. ;******************************************************************************
  3892. Op_CMP_ALIX    Proc    Near        ; Compare acc. with memory procedure
  3893.     add    si,3            ; Increment to the next opcode
  3894.     Fetch                ; Fetch and execute next instruction
  3895. Op_CMP_ALIX    Endp            ; End of compare accumulator procedure
  3896.     LineUp    Op_Size         ; Align the next opcode procedure
  3897.     Subttl    Opcode E0 - CPX Immediate
  3898.     Page    +
  3899. ;******************************************************************************
  3900. ;
  3901. ;    Op_CPX_I ()    Compare X Index Register with Memory
  3902. ;
  3903. ;        Setup the effective address
  3904. ;        Do the CPX operation (Update flag bits n, z, c)
  3905. ;        Fetch the next instruction
  3906. ;
  3907. ;******************************************************************************
  3908. Op_CPX_I    Proc    Near        ; Compare X index with memory procedure
  3909.     DoImm                ; Setup the effective address
  3910.     OpCPX                ; Do the CPX operation (Update n,z,c)
  3911.     Fetch                ; Fetch and execute next instruction
  3912. Op_CPX_I    Endp            ; End of compare X index procedure
  3913.     LineUp    Op_Size         ; Align the next opcode procedure
  3914.     Subttl    Opcode E1 - SBC DP Indexed Indirect, X
  3915.     Page    +
  3916. ;******************************************************************************
  3917. ;
  3918. ;    Op_SBC_DIIX ()    Subtract from Accumulator with Carry
  3919. ;
  3920. ;        Setup the effective address
  3921. ;        If in decimal mode
  3922. ;            Do the SBC decimal operation (Update flags n, v, z, c)
  3923. ;        Else in binary mode
  3924. ;            Do the SBC binary operation (Update flags n, v, z, c)
  3925. ;        Endif
  3926. ;        Fetch the next instruction
  3927. ;
  3928. ;******************************************************************************
  3929. Op_SBC_DIIX    Proc    Near        ; Subtract with carry procedure
  3930.     DoDIIX                ; Setup the effective address
  3931.     test    dh,CPU_M        ; Check for in decimal mode (BCD)
  3932.     jnz    SBC_DIIX_DEC        ; Jump if in decimal (BCD) mode
  3933. SBC_DIIX_BIN:
  3934.     OpSBCb                ; Do the SBC operation (Update n,v,z,c)
  3935.     Fetch                ; Fetch and execute next instruction
  3936. SBC_DIIX_DEC:
  3937.     OpSBCd                ; Do the SBC operation (Update n,v,z,c)
  3938.     Fetch                ; Fetch and execute next instruction
  3939. Op_SBC_DIIX    Endp            ; End of subtract with carry procedure
  3940.     LineUp    Op_Size         ; Align the next opcode procedure
  3941.     Subttl    Opcode E2 - SEP Immediate            (ILLEGAL)
  3942.     Page    +
  3943. ;******************************************************************************
  3944. ;
  3945. ;    Op_SEP ()    Set Status Bits
  3946. ;
  3947. ;        Increment to the next opcode
  3948. ;        Fetch the next instruction
  3949. ;
  3950. ;******************************************************************************
  3951. Op_SEP        Proc    Near        ; Set status bits procedure
  3952.     inc    si            ; Increment to the next opcode
  3953.     Fetch                ; Fetch and execute next instruction
  3954. Op_SEP        Endp            ; End of set status bits procedure
  3955.     LineUp    Op_Size         ; Align the next opcode procedure
  3956.     Subttl    Opcode E3 - SBC Stack Relative            (ILLEGAL)
  3957.     Page    +
  3958. ;******************************************************************************
  3959. ;
  3960. ;    Op_SBC_S ()    Subtract from Accumulator with Carry
  3961. ;
  3962. ;        Increment to the next opcode
  3963. ;        Fetch the next instruction
  3964. ;
  3965. ;******************************************************************************
  3966. Op_SBC_S    Proc    Near        ; Subtract with carry procedure
  3967.     inc    si            ; Increment to the next opcode
  3968.     Fetch                ; Fetch and execute next instruction
  3969. Op_SBC_S    Endp            ; End of subtract with carry procedure
  3970.     LineUp    Op_Size         ; Align the next opcode procedure
  3971.     Subttl    Opcode E4 - CPX Direct Page
  3972.     Page    +
  3973. ;******************************************************************************
  3974. ;
  3975. ;    Op_CPX_D ()    Compare X Index Register with Memory
  3976. ;
  3977. ;        Setup the effective address
  3978. ;        Do the CPX operation (Update flag bits n, z, c)
  3979. ;        Fetch the next instruction
  3980. ;
  3981. ;******************************************************************************
  3982. Op_CPX_D    Proc    Near        ; Compare X index with memory procedure
  3983.     DoDP                ; Setup the effective address
  3984.     OpCPX                ; Do the CPX operation (Update n,z,c)
  3985.     Fetch                ; Fetch and execute next instruction
  3986. Op_CPX_D    Endp            ; End of compare X index procedure
  3987.     LineUp    Op_Size         ; Align the next opcode procedure
  3988.     Subttl    Opcode E5 - SBC Direct Page
  3989.     Page    +
  3990. ;******************************************************************************
  3991. ;
  3992. ;    Op_SBC_D ()    Subtract from Accumulator with Carry
  3993. ;
  3994. ;        Setup the effective address
  3995. ;        If in decimal mode
  3996. ;            Do the SBC decimal operation (Update flags n, v, z, c)
  3997. ;        Else in binary mode
  3998. ;            Do the SBC binary operation (Update flags n, v, z, c)
  3999. ;        Endif
  4000. ;        Fetch the next instruction
  4001. ;
  4002. ;******************************************************************************
  4003. Op_SBC_D    Proc    Near        ; Subtract with carry procedure
  4004.     DoDP                ; Setup the effective address
  4005.     test    dh,CPU_M        ; Check for in decimal mode (BCD)
  4006.     jnz    SBC_DP_DEC        ; Jump if in decimal (BCD) mode
  4007. SBC_DP_BIN:
  4008.     OpSBCb                ; Do the SBC operation (Update n,v,z,c)
  4009.     Fetch                ; Fetch and execute next instruction
  4010. SBC_DP_DEC:
  4011.     OpSBCd                ; Do the SBC operation (Update n,v,z,c)
  4012.     Fetch                ; Fetch and execute next instruction
  4013. Op_SBC_D    Endp            ; End of subtract with carry procedure
  4014.     LineUp    Op_Size         ; Align the next opcode procedure
  4015.     Subttl    Opcode E6 - INC Direct Page
  4016.     Page    +
  4017. ;******************************************************************************
  4018. ;
  4019. ;    Op_INC_D ()    Increment Memory
  4020. ;
  4021. ;        Setup the effective address
  4022. ;        Do the INC operation (Update flag bits n, z)
  4023. ;        Fetch the next instruction
  4024. ;
  4025. ;******************************************************************************
  4026. Op_INC_D    Proc    Near        ; Increment memory procedure
  4027.     DoDP                ; Setup the effective address
  4028.     OpINC                ; Do the INC operation (Update n,z)
  4029.     Fetch                ; Fetch and execute next instruction
  4030. Op_INC_D    Endp            ; End of increment memory procedure
  4031.     LineUp    Op_Size         ; Align the next opcode procedure
  4032.     Subttl    Opcode E7 - SBC DP Indirect Long        (ILLEGAL)
  4033.     Page    +
  4034. ;******************************************************************************
  4035. ;
  4036. ;    Op_SBC_DIL ()    Subtract from Accumulator with Carry
  4037. ;
  4038. ;        Increment to the next opcode
  4039. ;        Fetch the next instruction
  4040. ;
  4041. ;******************************************************************************
  4042. Op_SBC_DIL    Proc    Near        ; Subtract with carry procedure
  4043.     inc    si            ; Increment to the next opcode
  4044.     Fetch                ; Fetch and execute next instruction
  4045. Op_SBC_DIL    Endp            ; End of subtract with carry procedure
  4046.     LineUp    Op_Size         ; Align the next opcode procedure
  4047.     Subttl    Opcode E8 - INX Implied
  4048.     Page    +
  4049. ;******************************************************************************
  4050. ;
  4051. ;    Op_INX ()    Increment X Index Register
  4052. ;
  4053. ;        Increment the X index register
  4054. ;        Update the 65C02 processor flags (n, z)
  4055. ;        Fetch the next instruction
  4056. ;
  4057. ;******************************************************************************
  4058. Op_INX        Proc    Near        ; Increment X index register procedure
  4059.     inc    ch            ; Increment the X index register
  4060.     Flgnz                ; Update the n and z flags
  4061.     Fetch                ; Fetch and execute next instruction
  4062. Op_INX        Endp            ; End of increment X index procedure
  4063.     LineUp    Op_Size         ; Align the next opcode procedure
  4064.     Subttl    Opcode E9 - SBC Immediate
  4065.     Page    +
  4066. ;******************************************************************************
  4067. ;
  4068. ;    Op_SBC_I ()    Subtract from Accumulator with Carry
  4069. ;
  4070. ;        Setup the effective address
  4071. ;        If in decimal mode
  4072. ;            Do the SBC decimal operation (Update flags n, v, z, c)
  4073. ;        Else in binary mode
  4074. ;            Do the SBC binary operation (Update flags n, v, z, c)
  4075. ;        Endif
  4076. ;        Fetch the next instruction
  4077. ;
  4078. ;******************************************************************************
  4079. Op_SBC_I    Proc    Near        ; Subtract with carry procedure
  4080.     DoImm                ; Setup the effective address
  4081.     test    dh,CPU_M        ; Check for in decimal mode (BCD)
  4082.     jnz    SBC_I_DEC        ; Jump if in decimal (BCD) mode
  4083. SBC_I_BIN:
  4084.     OpSBCb                ; Do the SBC operation (Update n,v,z,c)
  4085.     Fetch                ; Fetch and execute next instruction
  4086. SBC_I_DEC:
  4087.     OpSBCd                ; Do the SBC operation (Update n,v,z,c)
  4088.     Fetch                ; Fetch and execute next instruction
  4089. Op_SBC_I    Endp            ; End of subtract with carry procedure
  4090.     LineUp    Op_Size         ; Align the next opcode procedure
  4091.     Subttl    Opcode EA - NOP Implied
  4092.     Page    +
  4093. ;******************************************************************************
  4094. ;
  4095. ;    Op_NOP ()    No Operation
  4096. ;
  4097. ;        Fetch the next instruction
  4098. ;
  4099. ;******************************************************************************
  4100. Op_NOP        Proc    Near        ; No operation procedure
  4101.     Fetch                ; Fetch and execute next instruction
  4102. Op_NOP        Endp            ; End of no operation procedure
  4103.     LineUp    Op_Size         ; Align the next opcode procedure
  4104.     Subttl    Opcode EB - XBA Implied             (ILLEGAL)
  4105.     Page    +
  4106. ;******************************************************************************
  4107. ;
  4108. ;    Op_XBA ()    Exchange the A and B Accumulators
  4109. ;
  4110. ;        Fetch the next instruction
  4111. ;
  4112. ;******************************************************************************
  4113. Op_XBA        Proc    Near        ; Exchange A & B accumulators procedure
  4114.     Fetch                ; Fetch and execute next instruction
  4115. Op_XBA        Endp            ; End of exchange accumulators procedure
  4116.     LineUp    Op_Size         ; Align the next opcode procedure
  4117.     Subttl    Opcode EC - CPX Absolute
  4118.     Page    +
  4119. ;******************************************************************************
  4120. ;
  4121. ;    Op_CPX_A ()    Compare X Index Register with Memory
  4122. ;
  4123. ;        Setup the effective address
  4124. ;        Do the CPX operation (Update flag bits n, z, c)
  4125. ;        Fetch the next instruction
  4126. ;
  4127. ;******************************************************************************
  4128. Op_CPX_A    Proc    Near        ; Compare X index with memory procedure
  4129.     DoAbs                ; Setup the effective address
  4130.     OpCPX                ; Do the CPX operation (Update n,z,c)
  4131.     Fetch                ; Fetch and execute next instruction
  4132. Op_CPX_A    Endp            ; End of compare X index procedure
  4133.     LineUp    Op_Size         ; Align the next opcode procedure
  4134.     Subttl    Opcode ED - SBC Absolute
  4135.     Page    +
  4136. ;******************************************************************************
  4137. ;
  4138. ;    Op_SBC_A ()    Subtract from Accumulator with Carry
  4139. ;
  4140. ;        Setup the effective address
  4141. ;        If in decimal mode
  4142. ;            Do the SBC decimal operation (Update flags n, v, z, c)
  4143. ;        Else in binary mode
  4144. ;            Do the SBC binary operation (Update flags n, v, z, c)
  4145. ;        Endif
  4146. ;        Fetch the next instruction
  4147. ;
  4148. ;******************************************************************************
  4149. Op_SBC_A    Proc    Near        ; Subtract with carry procedure
  4150.     DoAbs                ; Setup the effective address
  4151.     test    dh,CPU_M        ; Check for in decimal mode (BCD)
  4152.     jnz    SBC_A_DEC        ; Jump if in decimal (BCD) mode
  4153. SBC_A_BIN:
  4154.     OpSBCb                ; Do the SBC operation (Update n,v,z,c)
  4155.     Fetch                ; Fetch and execute next instruction
  4156. SBC_A_DEC:
  4157.     OpSBCd                ; Do the SBC operation (Update n,v,z,c)
  4158.     Fetch                ; Fetch and execute next instruction
  4159. Op_SBC_A    Endp            ; End of subtract with carry procedure
  4160.     LineUp    Op_Size         ; Align the next opcode procedure
  4161.     Subttl    Opcode EE - INC Absolute
  4162.     Page    +
  4163. ;******************************************************************************
  4164. ;
  4165. ;    Op_INC_A ()    Increment Memory
  4166. ;
  4167. ;        Setup the effective address
  4168. ;        Do the INC operation (Update flag bits n, z)
  4169. ;        Fetch the next instruction
  4170. ;
  4171. ;******************************************************************************
  4172. Op_INC_A    Proc    Near        ; Increment memory procedure
  4173.     DoAbs                ; Setup the effective address
  4174.     OpINC                ; Do the INC operation (Update n,z)
  4175.     Fetch                ; Fetch and execute next instruction
  4176. Op_INC_A    Endp            ; End of increment memory procedure
  4177.     LineUp    Op_Size         ; Align the next opcode procedure
  4178.     Subttl    Opcode EF - SBC Absolute Long            (ILLEGAL)
  4179.     Page    +
  4180. ;******************************************************************************
  4181. ;
  4182. ;    Op_SBC_AL ()    Subtract from Accumulator with Carry
  4183. ;
  4184. ;        Increment to the next opcode
  4185. ;        Fetch the next instruction
  4186. ;
  4187. ;******************************************************************************
  4188. Op_SBC_AL    Proc    Near        ; Subtract with carry procedure
  4189.     add    si,3            ; Increment to the next opcode
  4190.     Fetch                ; Fetch and execute next instruction
  4191. Op_SBC_AL    Endp            ; End of subtract with carry procedure
  4192.     LineUp    Op_Size         ; Align the next opcode procedure
  4193.     Subttl    Opcode F0 - BEQ Program Counter Relative
  4194.     Page    +
  4195. ;******************************************************************************
  4196. ;
  4197. ;    Op_BEQ ()    Branch if Equal
  4198. ;
  4199. ;        Get the program counter offset byte
  4200. ;        If the z flag is set
  4201. ;            Update the program counter
  4202. ;        Endif
  4203. ;        Fetch the next instruction
  4204. ;
  4205. ;******************************************************************************
  4206. Op_BEQ        Proc    Near        ; Branch if equal procedure
  4207.     lodsb                ; Get the program counter offset
  4208.     test    dh,CPU_Z        ; Check the 65C02 z (Zero) flag
  4209.     jz    _BEQ            ; Jump if z flag is clear (Not equal)
  4210.     cbw                ; Convert offset into a full word
  4211.     add    si,ax            ; Compute the new program counter
  4212. _BEQ:
  4213.     Fetch                ; Fetch and execute next instruction
  4214. Op_BEQ        Endp            ; End of branch if equal procedure
  4215.     LineUp    Op_Size         ; Align the next opcode procedure
  4216.     Subttl    Opcode F1 - SBC DP Indirect Indexed, Y
  4217.     Page    +
  4218. ;******************************************************************************
  4219. ;
  4220. ;    Op_SBC_DIIY ()    Subtract from Accumulator with Carry
  4221. ;
  4222. ;        Setup the effective address
  4223. ;        If in decimal mode
  4224. ;            Do the SBC decimal operation (Update flags n, v, z, c)
  4225. ;        Else in binary mode
  4226. ;            Do the SBC binary operation (Update flags n, v, z, c)
  4227. ;        Endif
  4228. ;        Fetch the next instruction
  4229. ;
  4230. ;******************************************************************************
  4231. Op_SBC_DIIY    Proc    Near        ; Subtract with carry procedure
  4232.     DoDIIY                ; Setup the effective address
  4233.     test    dh,CPU_M        ; Check for in decimal mode (BCD)
  4234.     jnz    SBC_DIIY_DEC        ; Jump if in decimal (BCD) mode
  4235. SBC_DIIY_BIN:
  4236.     OpSBCb                ; Do the SBC operation (Update n,v,z,c)
  4237.     Fetch                ; Fetch and execute next instruction
  4238. SBC_DIIY_DEC:
  4239.     OpSBCd                ; Do the SBC operation (Update n,v,z,c)
  4240.     Fetch                ; Fetch and execute next instruction
  4241. Op_SBC_DIIY    Endp            ; End of subtract with carry procedure
  4242.     LineUp    Op_Size         ; Align the next opcode procedure
  4243.     Subttl    Opcode F2 - SBC DP Indirect            (65C02 ONLY)
  4244.     Page    +
  4245. ;******************************************************************************
  4246. ;
  4247. ;    Op_SBC_DI ()    Subtract from Accumulator with Carry
  4248. ;
  4249. ;        Setup the effective address
  4250. ;        If in decimal mode
  4251. ;            Do the SBC decimal operation (Update flags n, v, z, c)
  4252. ;        Else in binary mode
  4253. ;            Do the SBC binary operation (Update flags n, v, z, c)
  4254. ;        Endif
  4255. ;        Fetch the next instruction
  4256. ;
  4257. ;******************************************************************************
  4258. Op_SBC_DI    Proc    Near        ; Subtract with carry procedure
  4259.     DoDI                ; Setup the effective address
  4260.     test    dh,CPU_M        ; Check for in decimal mode (BCD)
  4261.     jnz    SBC_DI_DEC        ; Jump if in decimal (BCD) mode
  4262. SBC_DI_BIN:
  4263.     OpSBCb                ; Do the SBC operation (Update n,v,z,c)
  4264.     Fetch                ; Fetch and execute next instruction
  4265. SBC_DI_DEC:
  4266.     OpSBCd                ; Do the SBC operation (Update n,v,z,c)
  4267.     Fetch                ; Fetch and execute next instruction
  4268. Op_SBC_DI    Endp            ; End of subtract with carry procedure
  4269.     LineUp    Op_Size         ; Align the next opcode procedure
  4270.     Subttl    Opcode F3 - SBC SR Indirect Indexed, Y        (ILLEGAL)
  4271.     Page    +
  4272. ;******************************************************************************
  4273. ;
  4274. ;    Op_SBC_SIIY ()    Subtract from Accumulator with Carry
  4275. ;
  4276. ;        Increment to the next opcode
  4277. ;        Fetch the next instruction
  4278. ;
  4279. ;******************************************************************************
  4280. Op_SBC_SIIY    Proc    Near        ; Subtract with carry procedure
  4281.     inc    si            ; Increment to the next opcode
  4282.     Fetch                ; Fetch and execute next instruction
  4283. Op_SBC_SIIY    Endp            ; End of subtract with carry procedure
  4284.     LineUp    Op_Size         ; Align the next opcode procedure
  4285.     Subttl    Opcode F4 - PEA Stack                (ILLEGAL)
  4286.     Page    +
  4287. ;******************************************************************************
  4288. ;
  4289. ;    Op_PEA ()    Push Effective Absolute Address
  4290. ;
  4291. ;        Increment to the next opcode
  4292. ;        Fetch the next instruction
  4293. ;
  4294. ;******************************************************************************
  4295. Op_PEA        Proc    Near        ; Push absolute address procedure
  4296.     add    si,2            ; Increment to the next opcode
  4297.     Fetch                ; Fetch and execute next instruction
  4298. Op_PEA        Endp            ; End of push absolute address procedure
  4299.     LineUp    Op_Size         ; Align the next opcode procedure
  4300.     Subttl    Opcode F5 - SBC DP Indexed, X
  4301.     Page    +
  4302. ;******************************************************************************
  4303. ;
  4304. ;    Op_SBC_DIX ()    Subtract from Accumulator with Carry
  4305. ;
  4306. ;        Setup the effective address
  4307. ;        If in decimal mode
  4308. ;            Do the SBC decimal operation (Update flags n, v, z, c)
  4309. ;        Else in binary mode
  4310. ;            Do the SBC binary operation (Update flags n, v, z, c)
  4311. ;        Endif
  4312. ;        Fetch the next instruction
  4313. ;
  4314. ;******************************************************************************
  4315. Op_SBC_DIX    Proc    Near        ; Subtract with carry procedure
  4316.     DoDIX                ; Setup the effective address
  4317.     test    dh,CPU_M        ; Check for in decimal mode (BCD)
  4318.     jnz    SBC_DIX_DEC        ; Jump if in decimal (BCD) mode
  4319. SBC_DIX_BIN:
  4320.     OpSBCb                ; Do the SBC operation (Update n,v,z,c)
  4321.     Fetch                ; Fetch and execute next instruction
  4322. SBC_DIX_DEC:
  4323.     OpSBCd                ; Do the SBC operation (Update n,v,z,c)
  4324.     Fetch                ; Fetch and execute next instruction
  4325. Op_SBC_DIX    Endp            ; End of subtract with carry procedure
  4326.     LineUp    Op_Size         ; Align the next opcode procedure
  4327.     Subttl    Opcode F6 - INC DP Indexed, X
  4328.     Page    +
  4329. ;******************************************************************************
  4330. ;
  4331. ;    Op_INC_DIX ()    Increment Memory
  4332. ;
  4333. ;        Setup the effective address
  4334. ;        Do the INC operation (Update flag bits n, z)
  4335. ;        Fetch the next instruction
  4336. ;
  4337. ;******************************************************************************
  4338. Op_INC_DIX    Proc    Near        ; Increment memory procedure
  4339.     DoDIX                ; Setup the effective address
  4340.     OpINC                ; Do the INC operation (Update n,z)
  4341.     Fetch                ; Fetch and execute next instruction
  4342. Op_INC_DIX    Endp            ; End of increment memory procedure
  4343.     LineUp    Op_Size         ; Align the next opcode procedure
  4344.     Subttl    Opcode F7 - SBC DP Indirect Long Indexed, Y    (ILLEGAL)
  4345.     Page    +
  4346. ;******************************************************************************
  4347. ;
  4348. ;    Op_SBC_DILIY () Subtract from Accumulator with Carry
  4349. ;
  4350. ;        Increment to the next opcode
  4351. ;        Fetch the next instruction
  4352. ;
  4353. ;******************************************************************************
  4354. Op_SBC_DILIY    Proc    Near        ; Subtract with carry procedure
  4355.     inc    si            ; Increment to the next opcode
  4356.     Fetch                ; Fetch and execute next instruction
  4357. Op_SBC_DILIY    Endp            ; End of subtract with carry procedure
  4358.     LineUp    Op_Size         ; Align the next opcode procedure
  4359.     Subttl    Opcode F8 - SED Implied
  4360.     Page    +
  4361. ;******************************************************************************
  4362. ;
  4363. ;    Op_SED ()    Set Decimal Mode Flag
  4364. ;
  4365. ;        Set the decimal mode flag
  4366. ;        Fetch the next instruction
  4367. ;
  4368. ;******************************************************************************
  4369. Op_SED        Proc    Near        ; Set decimal mode flag procedure
  4370.     or    dh,CPU_M        ; Set the decimal mode flag bit
  4371.     Fetch                ; Fetch and execute next instruction
  4372. Op_SED        Endp            ; End of set decimal mode procedure
  4373.     LineUp    Op_Size         ; Align the next opcode procedure
  4374.     Subttl    Opcode F9 - SBC Absolute Indexed, Y
  4375.     Page    +
  4376. ;******************************************************************************
  4377. ;
  4378. ;    Op_SBC_AIY ()    Subtract from Accumulator with Carry
  4379. ;
  4380. ;        Setup the effective address
  4381. ;        If in decimal mode
  4382. ;            Do the SBC decimal operation (Update flags n, v, z, c)
  4383. ;        Else in binary mode
  4384. ;            Do the SBC binary operation (Update flags n, v, z, c)
  4385. ;        Endif
  4386. ;        Fetch the next instruction
  4387. ;
  4388. ;******************************************************************************
  4389. Op_SBC_AIY    Proc    Near        ; Subtract with carry procedure
  4390.     DoAIY                ; Setup the effective address
  4391.     test    dh,CPU_M        ; Check for in decimal mode (BCD)
  4392.     jnz    SBC_AIY_DEC        ; Jump if in decimal (BCD) mode
  4393. SBC_AIY_BIN:
  4394.     OpSBCb                ; Do the SBC operation (Update n,v,z,c)
  4395.     Fetch                ; Fetch and execute next instruction
  4396. SBC_AIY_DEC:
  4397.     OpSBCd                ; Do the SBC operation (Update n,v,z,c)
  4398.     Fetch                ; Fetch and execute next instruction
  4399. Op_SBC_AIY    Endp            ; End of subtract with carry procedure
  4400.     LineUp    Op_Size         ; Align the next opcode procedure
  4401.     Subttl    Opcode FA - PLX Stack/Pull            (65C02 ONLY)
  4402.     Page    +
  4403. ;******************************************************************************
  4404. ;
  4405. ;    Op_PLX ()    Pull X Index Register from Stack
  4406. ;
  4407. ;        Pop X index register from stack
  4408. ;        Fetch the next instruction
  4409. ;
  4410. ;******************************************************************************
  4411. Op_PLX        Proc    Near        ; Pull X index from stack procedure
  4412.     Pop_8                ; Get X index register from the stack
  4413.     mov    ch,al            ; Update the X index register value
  4414.     Fetch                ; Fetch and execute next instruction
  4415. Op_PLX        Endp            ; End of pull X index procedure
  4416.     LineUp    Op_Size         ; Align the next opcode procedure
  4417.     Subttl    Opcode FB - XCE Implied             (ILLEGAL)
  4418.     Page    +
  4419. ;******************************************************************************
  4420. ;
  4421. ;    Op_XCE ()    Exchange Carry and Emulation Bits
  4422. ;
  4423. ;        Fetch the next instruction
  4424. ;
  4425. ;******************************************************************************
  4426. Op_XCE        Proc    Near        ; Exchange carry/emulation procedure
  4427.     Fetch                ; Fetch and execute next instruction
  4428. Op_XCE        Endp            ; End of exchange carry procedure
  4429.     LineUp    Op_Size         ; Align the next opcode procedure
  4430.     Subttl    Opcode FC - JSR Absolute Indexed Indirect, X    (ILLEGAL)
  4431.     Page    +
  4432. ;******************************************************************************
  4433. ;
  4434. ;    Op_JSR_AIIX ()    Jump to Subroutine
  4435. ;
  4436. ;        Increment to the next opcode
  4437. ;        Fetch the next instruction
  4438. ;
  4439. ;******************************************************************************
  4440. Op_JSR_AIIX    Proc    Near        ; Jump to subroutine procedure
  4441.     add    si,2            ; Increment to the next opcode
  4442.     Fetch                ; Fetch and execute next instruction
  4443. Op_JSR_AIIX    Endp            ; End of jump to subroutine procedure
  4444.     LineUp    Op_Size         ; Align the next opcode procedure
  4445.     Subttl    Opcode FD - SBC Absolute Indexed, X
  4446.     Page    +
  4447. ;******************************************************************************
  4448. ;
  4449. ;    Op_SBC_AIX ()    Subtract from Accumulator with Carry
  4450. ;
  4451. ;        Setup the effective address
  4452. ;        If in decimal mode
  4453. ;            Do the SBC decimal operation (Update flags n, v, z, c)
  4454. ;        Else in binary mode
  4455. ;            Do the SBC binary operation (Update flags n, v, z, c)
  4456. ;        Endif
  4457. ;        Fetch the next instruction
  4458. ;
  4459. ;******************************************************************************
  4460. Op_SBC_AIX    Proc    Near        ; Subtract with carry procedure
  4461.     DoAIX                ; Setup the effective address
  4462.     test    dh,CPU_M        ; Check for in decimal mode (BCD)
  4463.     jnz    SBC_AIX_DEC        ; Jump if in decimal (BCD) mode
  4464. SBC_AIX_BIN:
  4465.     OpSBCb                ; Do the SBC operation (Update n,v,z,c)
  4466.     Fetch                ; Fetch and execute next instruction
  4467. SBC_AIX_DEC:
  4468.     OpSBCd                ; Do the SBC operation (Update n,v,z,c)
  4469.     Fetch                ; Fetch and execute next instruction
  4470. Op_SBC_AIX    Endp            ; End of subtract with carry procedure
  4471.     LineUp    Op_Size         ; Align the next opcode procedure
  4472.     Subttl    Opcode FE - INC Absolute Indexed, X
  4473.     Page    +
  4474. ;******************************************************************************
  4475. ;
  4476. ;    Op_INC_AIX ()    Increment Memory
  4477. ;
  4478. ;        Setup the effective address
  4479. ;        Do the INC operation (Update flag bits n, z)
  4480. ;        Fetch the next instruction
  4481. ;
  4482. ;******************************************************************************
  4483. Op_INC_AIX    Proc    Near        ; Increment memory procedure
  4484.     DoAIX                ; Setup the effective address
  4485.     OpINC                ; Do the INC operation (Update n,z)
  4486.     Fetch                ; Fetch and execute next instruction
  4487. Op_INC_AIX    Endp            ; End of increment memory procedure
  4488.     LineUp    Op_Size         ; Align the next opcode procedure
  4489.     Subttl    Opcode FF - SBC Absolute Long Indexed, X    (ILLEGAL)
  4490.     Page    +
  4491. ;******************************************************************************
  4492. ;
  4493. ;    Op_SBC_ALIX ()    Subtract from Accumulator with Carry
  4494. ;
  4495. ;        Increment to the next opcode
  4496. ;        Fetch the next instruction
  4497. ;
  4498. ;******************************************************************************
  4499. Op_SBC_ALIX    Proc    Near        ; Subtract with carry procedure
  4500.     add    si,3            ; Increment to the next opcode
  4501.     Fetch                ; Fetch and execute next instruction
  4502. Op_SBC_ALIX    Endp            ; End of subtract with carry procedure
  4503. ;******************************************************************************
  4504. ;
  4505. ;    Define the Emulator Entry Point
  4506. ;
  4507. ;******************************************************************************
  4508.     LineUp    Op_Size         ; Align the emulator entry point
  4509. Emulator    Proc    Near        ; Emulator procedure
  4510.     call    Initialize        ; Call the initialization
  4511. Op_Fetch    Label    Near        ; Fetch opcode entry point
  4512.     Fetch                ; Start the emulator
  4513. Emulator    Endp            ; End of emulator procedure
  4514. ;******************************************************************************
  4515. ;
  4516. ;    Define the end of the Emulator Code Segment
  4517. ;
  4518. ;******************************************************************************
  4519. Emulate Ends
  4520. ;******************************************************************************
  4521. ;
  4522. ;    Define the Emulator Stack Segment
  4523. ;
  4524. ;******************************************************************************
  4525. Stacker Segment Word Stack 'STACK'      ; Emulator stack segment
  4526.     Db    STACK_SIZE dup (?)    ; Define emulator stack (4096 Bytes)
  4527. Stacker Ends
  4528.     End    Emulator        ; End of the Emulate module
  4529.