xiahanlu

MASM_MSVC_X86_6502

Apr 20th, 2018
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         .686                      ; create 32 bit code
  2.         .mmx
  3.         .xmm                    
  4.         .model flat, stdcall      ; 32 bit memory model
  5.         option casemap :none      ; case sensitive
  6.  
  7.        
  8.        
  9.        
  10.        
  11.        
  12.        
  13. ;   ===========================================================================
  14. ;
  15. ;      
  16. ;      
  17. ;   this source is based on VirtuaNES && (\virtuanessrc097\NES\Cpu.cpp)
  18. ;                           nesterJ   && (nesterj_0_51_05_src\gui\SRC\NES\CPU\Nes6502.c)
  19. ;
  20. ;
  21. ;   2A03 Instruction comment from nesdev.com  (nesdev_weekly\www\6502.txt)
  22. ;
  23. ;
  24. ;
  25. ;   ===========================================================================
  26.  
  27.  
  28.  
  29.  
  30.  
  31. ;=======================
  32. ;       Interrupt    
  33. ;=======================
  34.  
  35.         NMI_VECTOR  equ FFFAh       ; nmi    
  36.         RES_VECTOR  equ FFFCh       ; reset
  37.         IRQ_VECTOR  equ FFFEh       ; irq  
  38.  
  39.         NMI_FLAG    equ 2           ; nmi interrupt pending flag
  40.         IRQ_FLAG    equ 1           ; irq interrupt pending flag
  41.        
  42.        
  43.        
  44. ;=======================
  45. ;      Pro Status    
  46. ;=======================
  47.  
  48.  
  49.         C_FLAG      equ 01h             ; 1: carry
  50.         Z_FLAG      equ 02h             ; 1: zero
  51.         I_FLAG      equ 04h             ; 1: intterrupt enable
  52.         D_FLAG      equ 08h             ; 1: dec mode nes did not use this mode
  53.         B_FLAG      equ 10h             ; 1: software intterrupt flag
  54.         R_FLAG      equ 20h             ; 1: this flag is reserved
  55.         V_FLAG      equ 40h             ; 1: overflow flag
  56.         N_FLAG      equ 80h             ; 1: negative flag
  57.        
  58.         INT_C       equ 7
  59.         ; USEASM2A03    equ 0
  60.         DUMMY_SBC_V_TEST equ 0
  61.         byt         equ byte ptr
  62.         wot         equ word ptr
  63.         dwot        equ dword ptr
  64.        
  65.         $a          equ dword ptr[edi] ; 0
  66.         $x          equ dword ptr[edi+4] ; 1
  67.         $y          equ dword ptr[edi+8] ; 2
  68.         $s          equ dword ptr[edi+12] ; 3
  69.         $p          equ dword ptr[edi+16] ; 4
  70.         $pc         equ dword ptr[edi+20] ; 5
  71.         $dma        equ dword ptr[edi+24] ; 6
  72.         $dis        equ dword ptr[edi+28] ; 7
  73.         $t1         equ dword ptr[edi+32] ; 8
  74.         $t2         equ dword ptr[edi+36] ; 9
  75.         $ct         equ dword ptr[edi+40] ; A
  76.        
  77.         PC_1        equ inc esi
  78.         PC_2        equ add esi, 2
  79.         DO_CYC      equ add ebp, 4
  80.         ALIGNXMM    equ align 16
  81.        
  82.        
  83. ;=======================
  84. ;    extern symbols    
  85. ;=======================        
  86.  
  87.     extrn CpuAMread@4:proc
  88.     extrn CpuAMwrite@8:proc
  89.     extrn CpuAMreadW@4:proc
  90.    
  91.     extrn ram:far
  92.     extrn regs:far
  93.     extrn zn_t:far
  94.     extrn dma_c:far
  95.     extrn cpuBanks:far
  96.     extrn int_pending:far
  97.  
  98.    
  99.    
  100. ;===================
  101. ;    Function    
  102. ;===================    
  103.  
  104.     .code
  105.  
  106. FastCall2A03 proc C
  107.              option prologue:none, epilogue:none
  108.              
  109.         push    ebx ;U -  save old frame
  110.         push    esi ;V -  save old frame        
  111.         push    edi ;U -  save old frame
  112.         push    ebp ;V -  save old frame
  113.        
  114.         ; esi edi ebx ebp unscratch regs we can use this to do useful things        
  115.         ; eax ecx edx scratch regs to do logic opr use completion can be discarded
  116.        
  117.         ; ebx <- save now P (nes's PSW reg)
  118.         ; ebp <- save exec Cycles counter
  119.         ; esi <- save now PC (nes's EIP reg)
  120.         ; edi <- save regs root
  121.        
  122.         lea     edi,    regs        ;U -  ebx <- save regs root    
  123.         mov     eax,    dwot[esp+20];V - /N load dispatch Cycles-> arg1
  124.         xor     ebp,    ebp         ;U -  reset Cycles counter
  125.         mov     $dis,   eax         ;V -  write back adjacent mem reduce cache pollute
  126.         mov     esi,    $pc         ;U -  load PC
  127.         mov     ebx,    $p          ;V -  load P
  128.     ALIGNXMM ; align
  129.     main_Loop:
  130.         mov     eax,    $dis        ;U -  load dispatch Cycles
  131.         mov     edx,    ebp         ;V -  copy Now Cycles counter  
  132.         mov     ecx,    $dma        ;U - /N load now DMA Cycles
  133.         mov     ebp,    edx         ;V -  
  134.        
  135.         cmp     eax,    edx         ;U -  dispatch Cycles > Cycles counter ?
  136.         jg      do_DMA_test         ;V -  TRUE:remain Cycles alive do DMA test FALSE:remain burning out
  137.        
  138.         mov     eax,    ebp         ;U -  return now Cycles counter    
  139.         mov     ecx,    edx         ;V -  
  140.         mov     $pc,    esi         ;U -  write back PC
  141.         mov     $p,     ebx         ;V -  write back P
  142.         pop     ebp                 ;U -  thaw old frame
  143.         pop     edi                 ;V -  thaw old frame
  144.         pop     esi                 ;U -  thaw old frame
  145.         pop     ebx                 ;V -  thaw old frame
  146.         ret                         ;N -  proc ret ...
  147.        
  148.         ALIGNXMM        
  149.         do_DMA_test:
  150.             test    ecx,    ecx     ;U -  DMA Cycles active ?
  151.             je      dec_Begin       ;V -  TRUE calc Cycles FALSE:immed decode
  152.            
  153.             sub     eax,    edx     ;U -  remain Cycles
  154.             lea     edi,    [edi]   ;V -        
  155.             cmp     ecx,    eax     ;U -  cmp DMA Cycles/remain Cycles
  156.             jge     remain_Out      ;V -  TRUE:remain Cycles burning out FALSE: DMA Cycles burning out      
  157.            
  158.             add     ebp,    ecx     ;U -  dma buring out
  159.             mov     $dma,   0       ;V -  reset DMA Cycles
  160.             lea     eax,    [eax]   ;U -  
  161.             jmp     dec_Begin       ;V -  jmp decode ... short jmp
  162.  
  163.             ALIGNXMM
  164.             remain_Out:        
  165.                 sub     ecx,    eax ;U -  remain cycles buring out
  166.                 mov     eax,    $dis;V -  Cycles just enough        
  167.                 mov     $dma,   ecx ;U -  write back DMA Cycles
  168.                 mov     $pc,    esi ;U -  write back PC
  169.                 mov     $p,     ebx ;V -  write back P
  170.                 pop     ebp         ;U -  thaw old frame
  171.                 pop     edi         ;V -  thaw old frame
  172.                 pop     esi         ;U -  thaw old frame
  173.                 pop     ebx         ;V -  thaw old frame
  174.                 ret                 ;N -  proc ret ...
  175.  
  176.                 ALIGNXMM
  177.                 dec_Begin:
  178.                     mov     eax,    esi                     ;U -  load PC
  179.                     inc     esi                             ;V -  ++ PC
  180.                     mov     edx,    eax                     ;U -  copy PC
  181.                     and     eax,    0FFFFh                  ;V -  limit bits
  182.                     shr     eax,    13                      ;U -  get Bank ID
  183.                     and     edx,    01FFFh                  ;V -  Bank's interval
  184.                     mov     ecx,    dwot[cpuBanks+eax*4]    ;U -  get Bank ID
  185.                     lea     edx,    [edx]                   ;V -            
  186.                     movzx   eax,    byt[ecx+edx]            ;N -  get PC's val          
  187.                     lea     edx,    [edx+ecx+1]             ;U -  next addr index
  188.                     jmp             [OPTAB+eax*4]           ;V - /N short/far jmp
  189.  
  190.                     ; =======================  
  191.                     ;   instr decode begin
  192.                     ; =======================
  193. ;***
  194. ;   ADC
  195. ;               69: #$              2 cycles
  196. ;               65: ZERO PAGE       3 cycles
  197. ;               75: ZERO PAGE X     4 cycles
  198. ;               6D: ABS             4 cycles
  199. ;               7D: ABS X           4 cycles (crossing page ++ cycles)
  200. ;               79: ABS Y           4 cycles (crossing page ++ cycles)
  201. ;               61: X INDIRECT      6 cycles
  202. ;               71: INDIRECT Y      4 cycles (crossing page ++ cycles)
  203. ;   Algorithm:
  204. ;  
  205. ;           unsigned int temp = src + AC + (IF_CARRY() ? 1 : 0);
  206. ;           SET_ZERO(temp & 0xff);  /* This is not valid in decimal mode */
  207. ;           if (IF_DECIMAL()) {
  208. ;                   if (((AC & 0xf) + (src & 0xf) + (IF_CARRY() ? 1 : 0)) > 9) {
  209. ;                       temp += 6;
  210. ;                   }
  211. ;                   SET_SIGN(temp);
  212. ;                   SET_OVERFLOW(!((AC ^ src) & 0x80) && ((AC ^ temp) & 0x80));
  213. ;                   if (temp > 0x99) {
  214. ;                       temp += 96;
  215. ;                   }
  216. ;                   SET_CARRY(temp > 0x99);
  217. ;           } else {
  218. ;                   SET_SIGN(temp);
  219. ;                   SET_OVERFLOW(!((AC ^ src) & 0x80) && ((AC ^ temp) & 0x80));
  220. ;                   SET_CARRY(temp > 0xff);
  221. ;           }
  222. ;           AC = ((BYTE) temp);
  223. ;*************************************************      
  224.        
  225.         OP69: ; ADC #$ 2 cycles
  226.  
  227.             movzx   ecx,    byt[edx]    ;N -  load #$
  228.             movzx   eax,    byt[edi]    ;N -  load REG A
  229.             and     ebx,    00111101b   ;U -  clr N-V-Z Flags
  230.             lea     esi,    [esi+1]     ;V -  ++ PC
  231.             shr     ebx,    1           ;U -  with C
  232.             lea     ebp,    [ebp+2]     ;V -  2 Cycles
  233.             adc     al,     cl          ;U -  ADC
  234.             mov     dl,     dl          ;V -  
  235.             seto    cl                  ;N -  SETcc set O flag
  236.             rcl     ebx,    1           ;N -  C Flag into NES's Flag REG
  237.             shl     ecx,    6                       ;U -  reset pos (ready to NES's V Flag)
  238.             or      ebx,    dwot[zn_t+eax*4]    ;V -  reset Z-N Flags
  239.             or      ebx,    ecx                     ;U -  reset V Flag
  240.             mov     $a,     eax                     ;V -  write Back REG A
  241.             jmp     PollInt                         ;N -  ...
  242.            
  243.         OP65: ; ADC ZERO PAGE 3 cycles
  244.             movzx   eax,    byt[edx]    ;N -  load addr8Real
  245.             movzx   ecx,    byt[ram+eax];N -  load addr8Real's VAL
  246.             movzx   eax,    byt[edi]    ;N -  load REG A
  247.             and     ebx,    00111101b   ;U -  clr N-V-Z Flags
  248.             lea     esi,    [esi+1]     ;V -  ++ PC
  249.             shr     ebx,    1           ;U -  with C
  250.             lea     ebp,    [ebp+3]     ;V -  3 Cycles
  251.             adc     al,     cl          ;U -  ADC
  252.             mov     dl,     dl          ;V -  
  253.             seto    cl                  ;N -  SETcc set O flag
  254.             rcl     ebx,    1           ;N -  C Flag into NES's Flag REG
  255.             shl     ecx,    6                       ;U -  reset pos (ready to NES's V Flag)
  256.             or      ebx,    dwot[zn_t+eax*4]    ;V -  reset Z-N Flags
  257.             or      ebx,    ecx                     ;U -  reset V Flag
  258.             mov     $a,     eax                     ;V -  write Back REG A
  259.             jmp     PollInt                         ;N -  ...  
  260.            
  261.         OP75: ; ADC ZERO PAGE X 4 cycles        
  262.             movzx   eax,    byt[edx]    ;N -  load addr8Temp
  263.             add     al,     byt[edi+4]  ;U -  get addr8Real
  264.             mov     bl,     bl          ;V -  
  265.             movzx   ecx,    byt[ram+eax];N -  load addr8Real's VAL
  266.             movzx   eax,    byt[edi]    ;N -  load REG A
  267.             and     ebx,    00111101b   ;U -  clr N-V-Z Flags
  268.             lea     esi,    [esi+1]     ;V -  ++ PC
  269.             shr     ebx,    1           ;U -  with C
  270.             lea     ebp,    [ebp+4]     ;V -  4 Cycles
  271.             adc     al,     cl          ;U -  ADC
  272.             mov     dl,     dl          ;V -  
  273.             seto    cl                  ;N -  SETcc set O flag
  274.             rcl     ebx,    1           ;N -  C Flag into NES's Flag REG
  275.             shl     ecx,    6                       ;U -  reset pos (ready to NES's V Flag)
  276.             or      ebx,    dwot[zn_t+eax*4]    ;V -  reset Z-N Flags
  277.             or      ebx,    ecx                     ;U -  reset V Flag
  278.             mov     $a,     eax                     ;V -  write Back REG A
  279.             jmp     PollInt                         ;N -  ...  
  280.  
  281.         OP6D: ; ADC ABS 4 cycles
  282.             mov     ax,     wot[edx]    ;U -  load addr16Real
  283.             add     si,     2           ;V -  ++ PC                  
  284.             push    eax                 ;U -  PUSH addr16Real
  285.             lea     ebp,    [ebp+4]     ;V -  4 Cycles
  286.             call    CpuAMread@4         ;N -  call PROC    
  287.             movzx   ecx,    byt[edi]    ;N -  load REG A
  288.             and     ebx,    00111101b   ;U -  clr N-V-Z Flags
  289.             and     eax,    0FFh        ;V -  limit Bits
  290.             shr     ebx,    1           ;U -  with C
  291.             mov     ebp,    ebp         ;V -  
  292.             adc     cl,     al          ;U -  ADC
  293.             mov     dl,     dl          ;V -  
  294.             seto    al                  ;N -  SETcc set O flag
  295.             rcl     ebx,    1           ;N -  C Flag into NES's Flag REG
  296.             shl     eax,    6                       ;U -  reset pos (ready to NES's V Flag)
  297.             or      ebx,    dwot[zn_t+ecx*4]    ;V -  reset Z-N Flags
  298.             or      ebx,    eax                     ;U -  reset V Flag
  299.             mov     $a,     ecx                     ;V -  write Back REG A
  300.             jmp     PollInt                         ;N -  ...  
  301.  
  302.         OP7D: ; ADC ABS X 4 cycles (corssing page)
  303.             movzx   eax,    wot[edx]    ;N -  load addr16Temp
  304.             movzx   ecx,    byt[edi+4]  ;N -  load REG X
  305.             add     ecx,    eax         ;U -  ABS X
  306.             lea     esi,    [esi+2]     ;V -  ++ PC
  307.             and     bl,     00111101b   ;U -  clr N-V-Z Flags
  308.             sub     ah,     ch          ;V -  test CrossPage
  309.             adc     ebp,    4           ;U -  4/5 Cycles
  310.             push    ecx                 ;V -  PUSH addr16Real
  311.             call    CpuAMread@4         ;N -  call PROC
  312.             movzx   ecx,    byt[edi]    ;N -  load REG A
  313.             and     eax,    0FFh        ;U -  limit Bits
  314.             mov     edx,    edx         ;V -  
  315.             shr     ebx,    1           ;U -  with C
  316.             mov     ebx,    ebx         ;V -  
  317.             adc     cl,     al          ;U -  ADC
  318.             mov     dl,     dl          ;V -  
  319.             seto    al                  ;N -  SETcc set O flag
  320.             rcl     ebx,    1           ;N -  C Flag into NES's Flag REG
  321.             shl     eax,    6                       ;U -  reset pos (ready to NES's V Flag)
  322.             or      ebx,    dwot[zn_t+ecx*4]    ;V -  reset Z-N Flags
  323.             or      ebx,    eax                     ;U -  reset V Flag
  324.             mov     $a,     ecx                     ;V -  write Back REG A
  325.             jmp     PollInt                         ;N -  ...  
  326.        
  327.         OP79: ; ADC ABS Y 4 cycles (corssing page)
  328.             movzx   eax,    wot[edx]    ;N -  load addr16Temp
  329.             movzx   ecx,    byt[edi+8]  ;N -  load REG Y
  330.             add     ecx,    eax         ;U -  ABS Y
  331.             lea     esi,    [esi+2]     ;V -  ++ PC
  332.             and     bl,     00111101b   ;U -  clr N-V-Z Flags
  333.             sub     ah,     ch          ;V -  test CrossPage
  334.             adc     ebp,    4           ;U -  4/5 Cycles
  335.             push    ecx                 ;V -  PUSH addr16Real
  336.             call    CpuAMread@4         ;N -  call PROC
  337.             movzx   ecx,    byt[edi]    ;N -  load REG A
  338.             and     eax,    0FFh        ;U -  limit Bits
  339.             mov     edx,    edx         ;V -  
  340.             shr     ebx,    1           ;U -  with C
  341.             mov     ebx,    ebx         ;V -  
  342.             adc     cl,     al          ;U -  ADC
  343.             mov     dl,     dl          ;V -  
  344.             seto    al                  ;N -  SETcc set O flag
  345.             rcl     ebx,    1           ;N -  C Flag into NES's Flag REG
  346.             shl     eax,    6                       ;U -  reset pos (ready to NES's V Flag)
  347.             or      ebx,    dwot[zn_t+ecx*4]    ;V -  reset Z-N Flags
  348.             or      ebx,    eax                     ;U -  reset V Flag
  349.             mov     $a,     ecx                     ;V -  write Back REG A
  350.             jmp     PollInt                         ;N -  ...  
  351.            
  352.         OP61: ; ADC X INDIRECT 6 cycles
  353.             movzx   eax,    byt[edx]    ;N -  load addr8Temp
  354.             add     al,     byt[edi+4]  ;U -  X INDIRECT
  355.             and     bl,     00111101b   ;V -  clr N-V-Z Flags
  356.             mov     cx,     wot[eax+ram];U -  get addr16Real
  357.             add     bp,     6           ;V -  6 Cycles
  358.             push    ecx                 ;U -  PUSH addr16Real
  359.             lea     esi,    [esi+1]     ;V -  ++ PC
  360.             call    CpuAMread@4         ;N -  call PROC
  361.             movzx   ecx,    byt[edi]    ;N -  load REG A
  362.             and     eax,    0FFh        ;U -  limit Bits
  363.             mov     edx,    edx         ;V -  
  364.             shr     ebx,    1           ;U -  with C
  365.             mov     ebx,    ebx         ;V -  
  366.             adc     cl,     al          ;U -  ADC
  367.             mov     dl,     dl          ;V -  
  368.             seto    al                  ;N -  SETcc set O flag
  369.             rcl     ebx,    1           ;N -  C Flag into NES's Flag REG
  370.             shl     eax,    6                       ;U -  reset pos (ready to NES's V Flag)
  371.             or      ebx,    dwot[zn_t+ecx*4]    ;V -  reset Z-N Flags
  372.             or      ebx,    eax                     ;U -  reset V Flag
  373.             mov     $a,     ecx                     ;V -  write Back REG A
  374.             jmp     PollInt                         ;N -  ...  
  375.        
  376.         OP71: ; ADC INDIRECT Y  
  377.             movzx   edx,    byt[edx]    ;N -  load addr8Real
  378.             movzx   eax,    wot[edx+ram];N -  load addr16Temp
  379.             movzx   ecx,    byt[edi+8]  ;N -  load REG Y
  380.             add     ecx,    eax         ;U -  ABS Y
  381.             lea     esi,    [esi+1]     ;V -  ++ PC
  382.             and     bl,     00111101b   ;U -  clr N-V-Z Flags
  383.             sub     ah,     ch          ;V -  test CrossPage
  384.             adc     ebp,    4           ;U -  4/5 Cycles
  385.             push    ecx                 ;V -  PUSH addr16Real
  386.             call    CpuAMread@4         ;N -  call PROC
  387.             movzx   ecx,    byt[edi]    ;N -  load REG A
  388.             and     eax,    0FFh        ;U -  limit Bits
  389.             mov     edx,    edx         ;V -  
  390.             shr     ebx,    1           ;U -  with C
  391.             mov     ebx,    ebx         ;V -  
  392.             adc     cl,     al          ;U -  ADC
  393.             mov     dl,     dl          ;V -  
  394.             seto    al                  ;N -  SETcc set O flag
  395.             rcl     ebx,    1           ;N -  C Flag into NES's Flag REG
  396.             shl     eax,    6                       ;U -  reset pos (ready to NES's V Flag)
  397.             or      ebx,    dwot[zn_t+ecx*4]    ;V -  reset Z-N Flags
  398.             or      ebx,    eax                     ;U -  reset V Flag
  399.             mov     $a,     ecx                     ;V -  write Back REG A
  400.             jmp     PollInt                         ;N -  ...
  401.  
  402. ;***
  403. ;   SBC
  404. ;               EB: #$              2 cycles (unofficial)
  405. ;               E9: #$              2 cycles
  406. ;               E5: ZERO PAGE       3 cycles
  407. ;               F5: ZERO PAGE X     4 cycles
  408. ;               ED: ABS             4 cycles
  409. ;               FD: ABS X           4 cycles (crossing page ++ cycles)
  410. ;               F9: ABS Y           4 cycles (crossing page ++ cycles)
  411. ;               E1: X INDIRECT      6 cycles
  412. ;               F1: INDIRECT Y      4 cycles (crossing page ++ cycles)
  413. ;   Algorithm:
  414. ;  
  415. ;               unsigned int temp = AC - src - (IF_CARRY() ? 0 : 1);
  416. ;               SET_SIGN(temp);
  417. ;               SET_ZERO(temp & 0xff);  /* Sign and Zero are invalid in decimal mode */
  418. ;               SET_OVERFLOW(((AC ^ temp) & 0x80) && ((AC ^ src) & 0x80));
  419. ;               if (IF_DECIMAL()) {
  420. ;                   if ( ((AC & 0xf) - (IF_CARRY() ? 0 : 1)) < (src & 0xf)) /* EP */ {
  421. ;                       temp -= 6;
  422. ;                   }
  423. ;                   if (temp > 0x99) {
  424. ;                       temp -= 0x60;
  425. ;                   }
  426. ;               }
  427. ;               SET_CARRY(temp < 0x100);
  428. ;               AC = (temp & 0xff);
  429. ;*************************************************
  430.                    
  431.         OPE9: ; SBC #$ 2 cycles
  432.             movzx   ecx,    byt[edx]    ;N -  load #$
  433.             movzx   eax,    byt[edi]    ;N -  load REG A
  434.             and     ebx,    00111101b   ;U -  clr N-V-Z Flags
  435.             lea     esi,    [esi+1]     ;V -  ++ PC
  436.             xor     ebx,    1           ;U -  NEG C
  437.             mov     eax,    eax         ;V -  
  438.             shr     ebx,    1           ;U -  with C
  439.             lea     ebp,    [ebp+2]     ;V -  2 Cycles
  440.             sbb     al,     cl          ;U -  SBC
  441.             mov     dl,     dl          ;V -  
  442. IFDEF DUMMY_SBC_V_TEST
  443.             seto    cl                  ;N -  SETcc set O flag
  444. ELSE    
  445.             setno   cl                  ;N -  SETcc set O flag
  446. ENDIF
  447.             rcl     ebx,    1           ;N -  C Flag into NES's Flag REG
  448.             xor     ebx,    1           ;U -  NEG C
  449.             mov     eax,    eax         ;V -  
  450.             shl     ecx,    6                       ;U -  reset pos (ready to NES's V Flag)
  451.             or      ebx,    dwot[zn_t+eax*4]    ;V -  reset Z-N Flags
  452.             or      ebx,    ecx                     ;U -  reset V Flag
  453.             mov     $a,     eax                     ;V -  write Back REG A
  454.             jmp     PollInt                         ;N -  ...  
  455.            
  456.         OPE5: ; SBC ZERO PAGE 3 cycles  
  457.             movzx   ecx,    byt[edx]    ;N -  load addr8Real
  458.             movzx   ecx,    byt[ram+ecx];N -  load VAL
  459.             movzx   eax,    byt[edi]    ;N -  load REG A
  460.             and     ebx,    00111101b   ;U -  clr N-V-Z Flags
  461.             lea     esi,    [esi+1]     ;V -  ++ PC
  462.             xor     ebx,    1           ;U -  NEG C
  463.             mov     eax,    eax         ;V -  
  464.             shr     ebx,    1           ;U -  with C
  465.             lea     ebp,    [ebp+3]     ;V -  3 Cycles
  466.             sbb     al,     cl          ;U -  SBC
  467.             mov     dl,     dl          ;V -  
  468. IFDEF DUMMY_SBC_V_TEST
  469.             seto    cl                  ;N -  SETcc set O flag
  470. ELSE    
  471.             setno   cl                  ;N -  SETcc set O flag
  472. ENDIF
  473.             rcl     ebx,    1           ;N -  C Flag into NES's Flag REG
  474.             xor     ebx,    1           ;U -  NEG C
  475.             mov     eax,    eax         ;V -  
  476.             shl     ecx,    6                       ;U -  reset pos (ready to NES's V Flag)
  477.             or      ebx,    dwot[zn_t+eax*4]    ;V -  reset Z-N Flags
  478.             or      ebx,    ecx                     ;U -  reset V Flag
  479.             mov     $a,     eax                     ;V -  write Back REG A
  480.             jmp     PollInt                         ;N -  ...  
  481.            
  482.         OPF5: ; SBC ZERO PAGE X  4 cycles
  483.             movzx   ecx,    byt[edx]    ;N -  load addr8Real
  484.             add     cl,     byt[edi+4]  ;U -  ZERO PAGE X
  485.             mov     dl,     dl          ;V -  
  486.             movzx   ecx,    byt[ram+ecx];N -  load VAL
  487.             movzx   eax,    byt[edi]    ;N -  load REG A
  488.             and     ebx,    00111101b   ;U -  clr N-V-Z Flags
  489.             lea     esi,    [esi+1]     ;V -  ++ PC
  490.             xor     ebx,    1           ;U -  NEG C
  491.             mov     eax,    eax         ;V -  
  492.             shr     ebx,    1           ;U -  with C
  493.             lea     ebp,    [ebp+4]     ;V -  4 Cycles
  494.             sbb     al,     cl          ;U -  SBC
  495.             mov     dl,     dl          ;V -  
  496. IFDEF DUMMY_SBC_V_TEST
  497.             seto    cl                  ;N -  SETcc set O flag
  498. ELSE    
  499.             setno   cl                  ;N -  SETcc set O flag
  500. ENDIF
  501.             rcl     ebx,    1           ;N -  C Flag into NES's Flag REG
  502.             xor     ebx,    1           ;U -  NEG C
  503.             mov     eax,    eax         ;V -  
  504.             shl     ecx,    6                       ;U -  reset pos (ready to NES's V Flag)
  505.             or      ebx,    dwot[zn_t+eax*4]    ;V -  reset Z-N Flags
  506.             or      ebx,    ecx                     ;U -  reset V Flag
  507.             mov     $a,     eax                     ;V -  write Back REG A
  508.             jmp     PollInt                         ;N -  ...  
  509.            
  510.         OPED: ; SBC ABS 4 cycles
  511.             mov     ax,     wot[edx]    ;U -  load addr16Real
  512.             add     si,     2           ;V -  ++ PC                  
  513.             push    eax                 ;U -  PUSH addr16Real
  514.             lea     ebp,    [ebp+4]     ;V -  4 Cycles
  515.             call    CpuAMread@4         ;N -  call PROC    
  516.             movzx   ecx,    byt[edi]    ;N -  load REG A
  517.             and     ebx,    00111101b   ;U -  clr N-V-Z Flags
  518.             and     eax,    0FFh        ;V -  limit Bits
  519.             xor     ebx,    1           ;U -  NEG C
  520.             mov     eax,    eax         ;V -  
  521.             shr     ebx,    1           ;U -  with C
  522.             mov     ebp,    ebp         ;V -  
  523.             sbb     cl,     al          ;U -  SBC
  524.             mov     dl,     dl          ;V -  
  525. IFDEF DUMMY_SBC_V_TEST
  526.             seto    al                  ;N -  SETcc set O flag
  527. ELSE    
  528.             setno   al                  ;N -  SETcc set O flag
  529. ENDIF
  530.             rcl     ebx,    1           ;N -  C Flag into NES's Flag REG
  531.             xor     ebx,    1           ;U -  NEG C
  532.             mov     eax,    eax         ;V -  
  533.             shl     eax,    6                       ;U -  reset pos (ready to NES's V Flag)
  534.             or      ebx,    dwot[zn_t+ecx*4]    ;V -  reset Z-N Flags
  535.             or      ebx,    eax                     ;U -  reset V Flag
  536.             mov     $a,     ecx                     ;V -  write Back REG A
  537.             jmp     PollInt                         ;N -  ...  
  538.            
  539.            
  540.         OPFD: ; SBC ABS X 4 cycles (corssing page)
  541.             movzx   eax,    wot[edx]    ;N -  load addr16Temp
  542.             movzx   ecx,    byt[edi+4]  ;N -  load REG X
  543.             add     ecx,    eax         ;U -  ABS X
  544.             lea     esi,    [esi+2]     ;V -  ++ PC
  545.             and     bl,     00111101b   ;U -  clr N-V-Z Flags
  546.             sub     ah,     ch          ;V -  test CrossPage
  547.             adc     ebp,    4           ;U -  4/5 Cycles
  548.             push    ecx                 ;V -  PUSH addr16Real
  549.             call    CpuAMread@4         ;N -  call PROC
  550.             movzx   ecx,    byt[edi]    ;N -  load REG A
  551.             and     eax,    0FFh        ;U -  limit Bits
  552.             xor     ebx,    1           ;V -  NEG C
  553.             shr     ebx,    1           ;U -  with C
  554.             mov     ebx,    ebx         ;V -  
  555.             sbb     cl,     al          ;U -  SBC
  556.             mov     dl,     dl          ;V -  
  557. IFDEF DUMMY_SBC_V_TEST
  558.             seto    al                  ;N -  SETcc set O flag
  559. ELSE    
  560.             setno   al                  ;N -  SETcc set O flag
  561. ENDIF
  562.             rcl     ebx,    1           ;N -  C Flag into NES's Flag REG
  563.             xor     ebx,    1           ;U -  NEG C
  564.             mov     eax,    eax         ;V -  
  565.             shl     eax,    6                       ;U -  reset pos (ready to NES's V Flag)
  566.             or      ebx,    dwot[zn_t+ecx*4]    ;V -  reset Z-N Flags
  567.             or      ebx,    eax                     ;U -  reset V Flag
  568.             mov     $a,     ecx                     ;V -  write Back REG A
  569.             jmp     PollInt                         ;N -  ...  
  570.        
  571.         OPF9: ; SBC ABS Y 4 cycles (corssing page)
  572.             movzx   eax,    wot[edx]    ;N -  load addr16Temp
  573.             movzx   ecx,    byt[edi+8]  ;N -  load REG Y
  574.             add     ecx,    eax         ;U -  ABS Y
  575.             lea     esi,    [esi+2]     ;V -  ++ PC
  576.             and     bl,     00111101b   ;U -  clr N-V-Z Flags
  577.             sub     ah,     ch          ;V -  test CrossPage
  578.             adc     ebp,    4           ;U -  4/5 Cycles
  579.             push    ecx                 ;V -  PUSH addr16Real
  580.             call    CpuAMread@4         ;N -  call PROC
  581.             movzx   ecx,    byt[edi]    ;N -  load REG A
  582.             and     eax,    0FFh        ;U -  limit Bits
  583.             xor     ebx,    1           ;V -  NEG C
  584.             shr     ebx,    1           ;U -  with C
  585.             mov     ebx,    ebx         ;V -  
  586.             sbb     cl,     al          ;U -  SBC
  587.             mov     dl,     dl          ;V -  
  588. IFDEF DUMMY_SBC_V_TEST
  589.             seto    al                  ;N -  SETcc set O flag
  590. ELSE    
  591.             setno   al                  ;N -  SETcc set O flag
  592. ENDIF
  593.             rcl     ebx,    1           ;N -  C Flag into NES's Flag REG
  594.             xor     ebx,    1           ;U -  NEG C
  595.             mov     eax,    eax         ;V -  
  596.             shl     eax,    6                       ;U -  reset pos (ready to NES's V Flag)
  597.             or      ebx,    dwot[zn_t+ecx*4]    ;V -  reset Z-N Flags
  598.             or      ebx,    eax                     ;U -  reset V Flag
  599.             mov     $a,     ecx                     ;V -  write Back REG A
  600.             jmp     PollInt                         ;N -  ...
  601.            
  602.         OPE1: ; SBC X INDIRECT
  603.             movzx   eax,    byt[edx]    ;N -  load addr8Temp
  604.             add     al,     byt[edi+4]  ;U -  X INDIRECT
  605.             and     bl,     00111101b   ;V -  clr N-V-Z Flags
  606.             mov     cx,     wot[eax+ram];U -  get addr16Real
  607.             add     bp,     6           ;V -  6 Cycles
  608.             push    ecx                 ;U -  PUSH addr16Real
  609.             lea     esi,    [esi+1]     ;V -  ++ PC
  610.             call    CpuAMread@4         ;N -  call PROC
  611.             movzx   ecx,    byt[edi]    ;N -  load REG A
  612.             and     eax,    0FFh        ;U -  limit Bits
  613.             xor     ebx,    1           ;V -  NEG C  
  614.             shr     ebx,    1           ;U -  with C
  615.             mov     ebx,    ebx         ;V -  
  616.             sbb     cl,     al          ;U -  SBC
  617.             mov     dl,     dl          ;V -  
  618. IFDEF DUMMY_SBC_V_TEST
  619.             seto    al                  ;N -  SETcc set O flag
  620. ELSE    
  621.             setno   al                  ;N -  SETcc set O flag
  622. ENDIF
  623.             rcl     ebx,    1           ;N -  C Flag into NES's Flag REG
  624.             xor     ebx,    1           ;U -  NEG C
  625.             mov     eax,    eax         ;V -  
  626.             shl     eax,    6                       ;U -  reset pos (ready to NES's V Flag)
  627.             or      ebx,    dwot[zn_t+ecx*4]    ;V -  reset Z-N Flags
  628.             or      ebx,    eax                     ;U -  reset V Flag
  629.             mov     $a,     ecx                     ;V -  write Back REG A
  630.             jmp     PollInt                         ;N -  ...  
  631.        
  632.         OPF1: ; SBC INDIRECT Y
  633.             movzx   edx,    byt[edx]    ;N -  load addr8Real
  634.             movzx   eax,    wot[edx+ram];N -  load addr16Temp
  635.             movzx   ecx,    byt[edi+8]  ;N -  load REG Y
  636.             add     ecx,    eax         ;U -  ABS Y
  637.             lea     esi,    [esi+1]     ;V -  ++ PC
  638.             and     bl,     00111101b   ;U -  clr N-V-Z Flags
  639.             sub     ah,     ch          ;V -  test CrossPage
  640.             adc     ebp,    4           ;U -  4/5 Cycles
  641.             push    ecx                 ;V -  PUSH addr16Real
  642.             call    CpuAMread@4         ;N -  call PROC
  643.             movzx   ecx,    byt[edi]    ;N -  load REG A
  644.             and     eax,    0FFh        ;U -  limit Bits
  645.             xor     ebx,    1           ;V -  NEG C
  646.             shr     ebx,    1           ;U -  with C
  647.             mov     ebx,    ebx         ;V -  
  648.             sbb     cl,     al          ;U -  SBC
  649.             mov     dl,     dl          ;V -  
  650. IFDEF DUMMY_SBC_V_TEST
  651.             seto    al                  ;N -  SETcc set O flag
  652. ELSE    
  653.             setno   al                  ;N -  SETcc set O flag
  654. ENDIF
  655.             rcl     ebx,    1           ;N -  C Flag into NES's Flag REG
  656.             xor     ebx,    1           ;U -  NEG C
  657.             mov     eax,    eax         ;V -  
  658.             shl     eax,    6                       ;U -  reset pos (ready to NES's V Flag)
  659.             or      ebx,    dwot[zn_t+ecx*4]    ;V -  reset Z-N Flags
  660.             or      ebx,    eax                     ;U -  reset V Flag
  661.             mov     $a,     ecx                     ;V -  write Back REG A
  662.             jmp     PollInt                         ;N -  ...
  663. ;***
  664. ;   DEC
  665. ;               C6: ZERO PAGE       5 cycles
  666. ;               D6: ZERO PAGE X     6 cycles
  667. ;               CE: ABS             6 cycles
  668. ;               DE: ABS X           7 cycles
  669. ;           X   CA: REG             2 cycles
  670. ;           Y   88: REG             2 cycles
  671. ;   Algorithm:
  672. ;  
  673. ;               src = (src - 1) & 0xff;
  674. ;               SET_SIGN(src);
  675. ;               SET_ZERO(src);
  676. ;               STORE(address, (src));
  677. ;*************************************************  
  678.  
  679.  
  680.         OPC6: ; DEC ZERO PAGE 5 Cycles
  681.             movzx   eax,    byt[edx]        ;N -  eax <- a8Real
  682.             movzx   ecx,    byt[ram+eax]    ;N -  ecx <- MEM
  683.             dec     ecx                     ;U -  DEC  
  684.             lea     esi,    [esi+1]         ;V -  ++ PC
  685.             and     ecx,    0FFh            ;U -
  686.             lea     ebp,    [ebp+5]         ;V -  5 Cycles  
  687.             mov     byt[ram+eax],   cl      ;U -  MEM <- ecx
  688.             and     bl,     07Dh            ;V -  clr Z-N  
  689.             or      ebx,    dwot[zn_t+ecx*4]    ;U -  set Z-N
  690.             jmp     PollInt                 ;N -  
  691.            
  692.         OPD6: ; DEC ZERO PAGE X 6 cycles
  693.             movzx   eax,    byt[edx]        ;N -  eax <- a8Temp
  694.             add     al,     byt[edi+4]      ;U -  eax <- a8Real
  695.             mov     dl,     dl              ;V -
  696.             movzx   ecx,    byt[ram+eax]    ;N -  ecx <- MEM
  697.             dec     ecx                     ;U -  DEC  
  698.             lea     esi,    [esi+1]         ;V -  ++ PC
  699.             and     ecx,    0FFh            ;U -
  700.             lea     ebp,    [ebp+6]         ;V -  6 Cycles  
  701.             mov     byt[ram+eax],   cl      ;U -  MEM <- ecx
  702.             and     bl,     07Dh            ;V -  clr Z-N  
  703.             or      ebx,    dwot[zn_t+ecx*4]    ;U -  set Z-N
  704.             jmp     PollInt                 ;N -  
  705.            
  706.         OPCE: ; DEC ABS 6 cycles
  707.             movzx   ecx,    wot[edx]        ;N -  load addr16Real
  708.             push    ecx                     ;U -  ready addr16Real<-nes_Read's arg
  709.             mov     $t1,    ecx             ;V -  save old frame
  710.             call    CpuAMread@4             ;N -  call CpuAMread@4
  711.             dec     eax                     ;U -  DEC OPR
  712.             and     ebx,    07Dh            ;V -  clr Z-N Flags
  713.             push    eax                     ;U -  arg2
  714.             push    $t1                     ;V -  arg1
  715.             and     eax,    0FFh            ;U -  limit Bits
  716.             lea     esi,    [esi+2]         ;V -  ++ PC
  717.             or      ebx,    dwot[zn_t+eax*4] ;U -  reset Z-N Flags
  718.             lea     ebp,    [ebp+6]         ;V -  6 Cycles      
  719.             call    CpuAMwrite@8                ;N -  call CpuAMwrite@8
  720.             jmp     PollInt                 ;N -  ...
  721.            
  722.         OPDE: ; DEC ABS X 7 cycles
  723.             movzx   ecx,    wot[edx]        ;N -  load addr16Temp
  724.             movzx   eax,    byt[edi+4]      ;N -  load REG X
  725.             mov     ebx,    ebx             ;U -  
  726.             add     ecx,    eax             ;V -  ABS X get addr16Real
  727.             push    ecx                     ;U -  ready addr16Real<-nes_Read's arg
  728.             mov     $t1,    ecx             ;V -  save old frame
  729.             call    CpuAMread@4             ;N -  call CpuAMread@4
  730.             dec     eax                     ;U -  DEC OPR
  731.             and     ebx,    07Dh            ;V -  clr Z-N Flags
  732.             push    eax                     ;U -  arg2
  733.             push    $t1                     ;V -  arg1
  734.             and     eax,    0FFh            ;U -  limit Bits
  735.             lea     esi,    [esi+2]         ;V -  ++ PC
  736.             or      ebx,    dwot[zn_t+eax*4] ;U -  reset Z-N Flags
  737.             lea     ebp,    [ebp+7]         ;V -  7 Cycles      
  738.             call    CpuAMwrite@8                ;N -  call CpuAMwrite@8
  739.             jmp     PollInt                 ;N -  ...
  740.            
  741.         OPCA: ; DEX 2 cycles
  742.             mov     eax,    $x              ;U -  load REG X
  743.             lea     ebp,    [ebp+2]         ;V -  2 Cycles
  744.             dec     eax                     ;U -  DEC OPR
  745.             and     ebx,    07Dh            ;V -  clr Z-N Flags
  746.             mov     $x,     eax             ;U -  write REG X
  747.             and     eax,    0FFh            ;V -  limit Bits
  748.             or      ebx,    dwot[zn_t+eax*4] ;U -  reset Z-N Flags
  749.             jmp     PollInt                 ;V - /N ...
  750.                
  751.         OP88: ; DEY
  752.             mov     eax,    $y              ;U -  load REG Y
  753.             lea     ebp,    [ebp+2]         ;V -  2 Cycles
  754.             dec     eax                     ;U -  DEC OPR
  755.             and     ebx,    07Dh            ;V -  clr Z-N Flags
  756.             mov     $y,     eax             ;U -  write REG Y
  757.             and     eax,    0FFh            ;V -  limit Bits
  758.             or      ebx,    dwot[zn_t+eax*4] ;U -  reset Z-N Flags
  759.             jmp     PollInt                 ;V - /N ...
  760.  
  761. ;***
  762. ;   INC
  763. ;               E6: ZERO PAGE       5 cycles
  764. ;               F6: ZERO PAGE X     6 cycles
  765. ;               EE: ABS             6 cycles
  766. ;               FE: ABS X           7 cycles
  767. ;           X   E8: REG             2 cycles
  768. ;           Y   C8: REG             2 cycles
  769. ;   Algorithm:
  770. ;  
  771. ;               src = (src + 1) & 0xff;
  772. ;               SET_SIGN(src);
  773. ;               SET_ZERO(src);
  774. ;               STORE(address, (src));
  775. ;*************************************************
  776.  
  777.            
  778.         OPE6: ; INC ZERO PAGE 5 cycles
  779.             movzx   eax,    byt[edx]        ;N -  load ZeroPage Index
  780.             movzx   ecx,    byt[ram+eax]    ;N -  load From MEM ->
  781.             inc     cl                      ;U -  INC OPR  
  782.             mov     ebx,    ebx             ;V -  
  783.             mov     ecx,    ecx             ;U -  
  784.             lea     esi,    [esi+1]         ;V -  ++ PC
  785.             mov     byt[ram+eax],   cl      ;U -  write Back MEM <-
  786.             and     bl,     07Dh            ;V -  clr Z-N Flags
  787.             lea     ebp,    [ebp+5]         ;U -  5 Cycles
  788.             or      ebx,    dwot[zn_t+ecx*4]    ;V -  reset Z-N Flags
  789.             jmp     PollInt                 ;N -  ...
  790.            
  791.         OPF6: ; INC ZERO PAGE X 6 cycles
  792.             movzx   eax,    byt[edx]        ;N -  load ZeroPage Index
  793.             add     al,     byt[edi+4]      ;U -  ZERO PAGE X
  794.             mov     bl,     bl              ;V -  
  795.             movzx   ecx,    byt[ram+eax]    ;N -  load From MEM ->
  796.             inc     cl                      ;U -  INC OPR  
  797.             mov     ebx,    ebx             ;V -  
  798.             mov     ecx,    ecx             ;U -  
  799.             lea     esi,    [esi+1]         ;V -  ++ PC
  800.             mov     byt[ram+eax],   cl      ;U -  write Back MEM <-
  801.             and     bl,     07Dh            ;V -  clr Z-N Flags
  802.             lea     ebp,    [ebp+6]         ;U -  6 Cycles
  803.             or      ebx,    dwot[zn_t+ecx*4]    ;V -  reset Z-N Flags
  804.             jmp     PollInt                 ;N -  ...
  805.            
  806.         OPEE: ; INC ABS 6 cycles
  807.             movzx   ecx,    wot[edx]        ;N -  load addr16Real
  808.             push    ecx                     ;U -  ready addr16Real<-nes_Read's arg
  809.             mov     $t1,    ecx             ;V -  save old frame
  810.             call    CpuAMread@4             ;N -  call CpuAMread@4
  811.             inc     eax                     ;U -  INC OPR
  812.             and     ebx,    07Dh            ;V -  clr Z-N Flags
  813.             push    eax                     ;U -  arg2
  814.             push    $t1                     ;V -  arg1
  815.             and     eax,    0FFh            ;U -  limit Bits
  816.             lea     esi,    [esi+2]         ;V -  ++ PC
  817.             or      ebx,    dwot[zn_t+eax*4] ;U -  reset Z-N Flags
  818.             lea     ebp,    [ebp+6]         ;V -  6 Cycles      
  819.             call    CpuAMwrite@8                ;N -  call CpuAMwrite@8
  820.             jmp     PollInt                 ;N -  ...
  821.            
  822.         OPFE: ; INC ABS X 7 cycles
  823.             movzx   ecx,    wot[edx]        ;N -  load addr16Temp
  824.             movzx   eax,    byt[edi+4]      ;N -  load REG X
  825.             mov     ebx,    ebx             ;U -  
  826.             add     ecx,    eax             ;V -  ABS X get addr16Real
  827.             push    ecx                     ;U -  ready addr16Real<-nes_Read's arg
  828.             mov     $t1,    ecx             ;V -  save old frame
  829.             call    CpuAMread@4             ;N -  call CpuAMread@4
  830.             inc     eax                     ;U -  INC OPR
  831.             and     ebx,    07Dh            ;V -  clr Z-N Flags
  832.             push    eax                     ;U -  arg2
  833.             push    $t1                     ;V -  arg1
  834.             and     eax,    0FFh            ;U -  limit Bits
  835.             lea     esi,    [esi+2]         ;V -  ++ PC
  836.             or      ebx,    dwot[zn_t+eax*4] ;U -  reset Z-N Flags
  837.             lea     ebp,    [ebp+7]         ;V -  7 Cycles      
  838.             call    CpuAMwrite@8                ;N -  call CpuAMwrite@8
  839.             jmp     PollInt                 ;N -  ...
  840.            
  841.         OPE8: ; INX    
  842.             mov     eax,    $x              ;U -  load REG X
  843.             lea     ebp,    [ebp+2]         ;V -  2 Cycles
  844.             inc     eax                     ;U -  INC OPR
  845.             and     ebx,    07Dh            ;V -  clr Z-N Flags
  846.             mov     $x,     eax             ;U -  write REG X
  847.             and     eax,    0FFh            ;V -  limit Bits
  848.             or      ebx,    dwot[zn_t+eax*4] ;U -  reset Z-N Flags
  849.             jmp     PollInt                 ;V - /N ...
  850.    
  851.         OPC8: ; INY
  852.             mov     eax,    $y              ;U -  load REG Y
  853.             lea     ebp,    [ebp+2]         ;V -  2 Cycles
  854.             inc     eax                     ;U -  INC OPR
  855.             and     ebx,    07Dh            ;V -  clr Z-N Flags
  856.             mov     $y,     eax             ;U -  write REG Y
  857.             and     eax,    0FFh            ;V -  limit Bits
  858.             or      ebx,    dwot[zn_t+eax*4] ;U -  reset Z-N Flags
  859.             jmp     PollInt                 ;V - /N ...
  860. ;***
  861. ;   CMP
  862. ;               C9: #$              2 cycles
  863. ;               C5: ZERO PAGE       3 cycles
  864. ;               D5: ZERO PAGE X     4 cycles
  865. ;               CD: ABS             4 cycles
  866. ;               DD: ABS X           4 cycles (crossing page ++ cycles)
  867. ;               D9: ABS Y           4 cycles (crossing page ++ cycles)
  868. ;               C1: X INDIRECT      6 cycles
  869. ;               D1: INDIRECT Y      5 cycles (crossing page ++ cycles)
  870. ;           X   E0: #$              2 cycles
  871. ;           X   E4: ZERO PAGE       3 cycles
  872. ;           X   EC: ABS             4 cycles
  873. ;           Y   C0: #$              2 cycles
  874. ;           Y   C4: ZERO PAGE       3 cycles
  875. ;           Y   CC: ABS             4 cycles
  876. ;
  877. ;   Algorithm:
  878. ;  
  879. ;               src = AC - src;
  880. ;               SET_CARRY(src < 0x100);
  881. ;               SET_SIGN(src);
  882. ;               SET_ZERO(src &= 0xff);
  883. ;*************************************************  
  884.  
  885. ; =====
  886.     ;   A
  887.         ; =====
  888.  
  889.         OPC9: ; CMP #$ 2 cycles
  890.             mov     cl,     byt[edx]    ;U -  ecx <- MEM
  891.             mov     al,     byt[edi]    ;V -  eax <- A
  892.             and     bl,     01111100b   ;U -  clr Z-N-C
  893.             sub     al,     cl          ;V -  CMP
  894.             setnc   cl                  ;N -  get C  
  895.             lea     ebp,    [ebp+2]     ;U -  2 Cycles
  896.             and     eax,    0FFh        ;V -  
  897.             or      ebx,    dwot[zn_t+eax*4] ;U -  set Z-N
  898.             lea     esi,    [esi+1]     ;V -  ++ PC
  899.             or      ebx,    ecx         ;U -  set C
  900.             jmp     PollInt             ;V - /N ...
  901.            
  902.         OPC5: ; CMP ZERO PAGE 3 cycles
  903.             movzx   ecx,    byt[edx]    ;N -  ecx <- a8Real
  904.             mov     cl,     byt[ram+ecx];U -  ecx <- MEM
  905.             mov     al,     byt[edi]    ;V -  eax <- A
  906.             and     bl,     01111100b   ;U -  clr Z-N-C
  907.             sub     al,     cl          ;V -  CMP
  908.             setnc   cl                  ;N -  get C  
  909.             lea     ebp,    [ebp+3]     ;U -  3 Cycles
  910.             and     eax,    0FFh        ;V -  
  911.             or      ebx,    dwot[zn_t+eax*4] ;U -  set Z-N
  912.             lea     esi,    [esi+1]     ;V -  ++ PC
  913.             or      ebx,    ecx         ;U -  set C
  914.             jmp     PollInt             ;V - /N ...
  915.            
  916.         OPD5: ; CMP ZERO PAGE X 4 cycles
  917.             movzx   ecx,    byt[edx]    ;N -  ecx <- a8Temp
  918.             add     cl,     byt[edi+4]  ;U -  ecx <- a8Real
  919.             mov     al,     al          ;V -  
  920.             mov     dl,     byt[ram+ecx];U -  edx <- MEM
  921.             mov     al,     byt[edi]    ;V -  eax <- A
  922.             and     bl,     01111100b   ;U -  clr Z-N-C
  923.             sub     al,     dl          ;V -  CMP
  924.             setnc   dl                  ;N -  
  925.             lea     ebp,    [ebp+4]     ;U -  4 Cycles
  926.             and     eax,    0FFh        ;V -  
  927.             or      ebx,    dwot[zn_t+eax*4] ;U -  set Z-N
  928.             lea     esi,    [esi+1]     ;V -  ++ PC
  929.             or      ebx,    edx         ;U -  set C
  930.             jmp     PollInt             ;V - /N ...
  931.    
  932.         OPCD: ; CMP ABS 4 cycles
  933.             mov     ax,     wot[edx]    ;U -  eax <- a16Real
  934.             add     si,     2           ;V -  ++ PC
  935.             push    eax                 ;U -  
  936.             lea     ebp,    [ebp+4]     ;V -  4 Cycles
  937.             call    CpuAMread@4         ;N -  
  938.             and     bl,     01111100b   ;U -  clr Z-N-C
  939.             mov     cl,     byt[edi]    ;V -  ecx <- A
  940.             sub     cl,     al          ;U -  CMP  
  941.             mov     dl,     dl          ;V -  
  942.             setnc   al                  ;N -  SETcc
  943.             or      ebx,    eax         ;U -  set C
  944.             and     ecx,    0FFh        ;V -  
  945.             or      ebx,    dwot[zn_t+ecx*4] ;U -  set Z-N
  946.             jmp     PollInt             ;V - /N ...
  947.            
  948.        
  949.         OPDD: ; CMP ABS X (test cross page)
  950.             movzx   ecx,    byt[edi+4]  ;N -  ecx <- X
  951.             movzx   eax,    wot[edx]    ;U -  eax <- a16Temp
  952.             add     ecx,    eax         ;U -
  953.             lea     esi,    [esi+2]     ;V -  ++ PC  
  954.             push    ecx                 ;U -
  955.             mov     esi,    esi         ;V -
  956.             sub     ah,     ch          ;U -
  957.             mov     dh,     dh          ;V -
  958.             adc     ebp,    4           ;U -  4/5 Cycles
  959.             mov     eax,    eax         ;V -
  960.             call    CpuAMread@4         ;N -  
  961.             and     bl,     01111100b   ;U -  clr Z-N-C
  962.             mov     cl,     byt[edi]    ;V -  ecx <- A
  963.             sub     cl,     al          ;U -  CMP  
  964.             mov     dl,     dl          ;V -  
  965.             setnc   al                  ;N -  SETcc
  966.             or      ebx,    eax         ;U -  set C
  967.             and     ecx,    0FFh        ;V -  
  968.             or      ebx,    dwot[zn_t+ecx*4] ;U -  set Z-N
  969.             jmp     PollInt             ;V - /N ...
  970.        
  971.         OPD9: ; CMP ABS Y (test cross page)
  972.             movzx   ecx,    byt[edi+8]  ;N -  ecx <- Y
  973.             movzx   eax,    wot[edx]    ;U -  eax <- a16Temp
  974.             add     ecx,    eax         ;U -
  975.             lea     esi,    [esi+2]     ;V -  ++ PC  
  976.             push    ecx                 ;U -
  977.             mov     esi,    esi         ;V -
  978.             sub     ah,     ch          ;U -
  979.             mov     dh,     dh          ;V -
  980.             adc     ebp,    4           ;U -  4/5 Cycles
  981.             mov     eax,    eax         ;V -
  982.             call    CpuAMread@4         ;N -  
  983.             and     bl,     01111100b   ;U -  clr Z-N-C
  984.             mov     cl,     byt[edi]    ;V -  ecx <- A
  985.             sub     cl,     al          ;U -  CMP  
  986.             mov     dl,     dl          ;V -  
  987.             setnc   al                  ;N -  SETcc
  988.             or      ebx,    eax         ;U -  set C
  989.             and     ecx,    0FFh        ;V -  
  990.             or      ebx,    dwot[zn_t+ecx*4] ;U -  set Z-N
  991.             jmp     PollInt             ;V - /N ...
  992.        
  993.         OPC1: ; CMP X INDIRECT 6 cycles
  994.             movzx   eax,    byt[edx]    ;N -  eax <- a8Temp
  995.             add     al,     byt[edi+4]  ;U -  eax <- a8Real
  996.             mov     bl,     bl          ;V -
  997.             movzx   eax,    wot[ram+eax];N -
  998.             lea     esi,    [esi+1]     ;U - ++ PC
  999.             mov     ebx,    ebx         ;V -
  1000.             push    eax                 ;U -  
  1001.             lea     ebp,    [ebp+6]     ;V -  6 Cycles
  1002.             call    CpuAMread@4         ;N -  
  1003.             and     bl,     01111100b   ;U -  clr Z-N-C
  1004.             mov     cl,     byt[edi]    ;V -  ecx <- A
  1005.             sub     cl,     al          ;U -  CMP  
  1006.             mov     dl,     dl          ;V -  
  1007.             setnc   al                  ;N -  SETcc
  1008.             or      ebx,    eax         ;U -  set C
  1009.             and     ecx,    0FFh        ;V -  
  1010.             or      ebx,    dwot[zn_t+ecx*4] ;U -  set Z-N
  1011.             jmp     PollInt             ;V - /N ...
  1012.        
  1013.         OPD1: ; CMP INDIRECT Y (test cross page)
  1014.             movzx   ecx,    byt[edi+8]  ;N -  ecx <- Y
  1015.             movzx   eax,    byt[edx]    ;N -  eax <- a8Real
  1016.             movzx   eax,    wot[ram+eax];N -  eax <- a16Real
  1017.             add     ecx,    eax         ;U -
  1018.             lea     esi,    [esi+1]     ;V -  ++ PC  
  1019.             push    ecx                 ;U -
  1020.             mov     esi,    esi         ;V -
  1021.             sub     ah,     ch          ;U -
  1022.             mov     dh,     dh          ;V -
  1023.             adc     ebp,    5           ;U -  5/6 Cycles
  1024.             mov     eax,    eax         ;V -
  1025.             call    CpuAMread@4         ;N -  
  1026.             and     bl,     01111100b   ;U -  clr Z-N-C
  1027.             mov     cl,     byt[edi]    ;V -  ecx <- A
  1028.             sub     cl,     al          ;U -  CMP  
  1029.             mov     dl,     dl          ;V -  
  1030.             setnc   al                  ;N -  SETcc
  1031.             or      ebx,    eax         ;U -  set C
  1032.             and     ecx,    0FFh        ;V -  
  1033.             or      ebx,    dwot[zn_t+ecx*4] ;U -  set Z-N
  1034.             jmp     PollInt             ;V - /N ...
  1035.  
  1036. ; =====
  1037.     ;   X
  1038.         ; =====
  1039.            
  1040.         OPE0: ; CPX #$
  1041.             mov     cl,     byt[edx]    ;U -  ecx <- MEM
  1042.             mov     al,     byt[edi+4]  ;V -  eax <- X
  1043.             and     bl,     01111100b   ;U -  clr Z-N-C
  1044.             sub     al,     cl          ;V -  CMP
  1045.             setnc   cl                  ;N -  get C  
  1046.             lea     ebp,    [ebp+2]     ;U -  2 Cycles
  1047.             and     eax,    0FFh        ;V -  
  1048.             or      ebx,    dwot[zn_t+eax*4] ;U -  set Z-N
  1049.             lea     esi,    [esi+1]     ;V -  ++ PC
  1050.             or      ebx,    ecx         ;U -  set C
  1051.             jmp     PollInt             ;V - /N ...
  1052.        
  1053.         OPE4: ; CPX ZERO PAGE
  1054.             movzx   ecx,    byt[edx]    ;N -  ecx <- a8Real
  1055.             mov     cl,     byt[ram+ecx];U -  ecx <- MEM
  1056.             mov     al,     byt[edi+4]  ;V -  eax <- X
  1057.             and     bl,     01111100b   ;U -  clr Z-N-C
  1058.             sub     al,     cl          ;V -  CMP
  1059.             setnc   cl                  ;N -  get C  
  1060.             lea     ebp,    [ebp+3]     ;U -  3 Cycles
  1061.             and     eax,    0FFh        ;V -  
  1062.             or      ebx,    dwot[zn_t+eax*4] ;U -  set Z-N
  1063.             lea     esi,    [esi+1]     ;V -  ++ PC
  1064.             or      ebx,    ecx         ;U -  set C
  1065.             jmp     PollInt             ;V - /N ...
  1066.        
  1067.         OPEC: ; CPX ABS
  1068.             mov     ax,     wot[edx]    ;U -  eax <- a16Real
  1069.             add     si,     2           ;V -  ++ PC
  1070.             push    eax                 ;U -  
  1071.             lea     ebp,    [ebp+4]     ;V -  4 Cycles
  1072.             call    CpuAMread@4         ;N -  
  1073.             and     bl,     01111100b   ;U -  clr Z-N-C
  1074.             mov     cl,     byt[edi+4]  ;V -  ecx <- X
  1075.             sub     cl,     al          ;U -  CMP  
  1076.             mov     dl,     dl          ;V -  
  1077.             setnc   al                  ;N -  SETcc
  1078.             or      ebx,    eax         ;U -  set C
  1079.             and     ecx,    0FFh        ;V -  
  1080.             or      ebx,    dwot[zn_t+ecx*4] ;U -  set Z-N
  1081.             jmp     PollInt             ;V - /N ...
  1082. ; =====
  1083.     ;   y
  1084.         ; =====
  1085.  
  1086.            
  1087.         OPC0: ; CPY #$
  1088.             mov     cl,     byt[edx]    ;U -  ecx <- MEM
  1089.             mov     al,     byt[edi+8]  ;V -  eax <- Y
  1090.             and     bl,     01111100b   ;U -  clr Z-N-C
  1091.             sub     al,     cl          ;V -  CMP
  1092.             setnc   cl                  ;N -  get C  
  1093.             lea     ebp,    [ebp+2]     ;U -  2 Cycles
  1094.             and     eax,    0FFh        ;V -  
  1095.             or      ebx,    dwot[zn_t+eax*4] ;U -  set Z-N
  1096.             lea     esi,    [esi+1]     ;V -  ++ PC
  1097.             or      ebx,    ecx         ;U -  set C
  1098.             jmp     PollInt             ;V - /N ...
  1099.        
  1100.         OPC4: ; CPY ZERO PAGE
  1101.             movzx   ecx,    byt[edx]    ;N -  ecx <- a8Real
  1102.             mov     cl,     byt[ram+ecx];U -  ecx <- MEM
  1103.             mov     al,     byt[edi+8]  ;V -  eax <- Y
  1104.             and     bl,     01111100b   ;U -  clr Z-N-C
  1105.             sub     al,     cl          ;V -  CMP
  1106.             setnc   cl                  ;N -  get C  
  1107.             lea     ebp,    [ebp+3]     ;U -  3 Cycles
  1108.             and     eax,    0FFh        ;V -  
  1109.             or      ebx,    dwot[zn_t+eax*4] ;U -  set Z-N
  1110.             lea     esi,    [esi+1]     ;V -  ++ PC
  1111.             or      ebx,    ecx         ;U -  set C
  1112.             jmp     PollInt             ;V - /N ...
  1113.            
  1114.         OPCC: ; CPY ABS    
  1115.             mov     ax,     wot[edx]    ;U -  eax <- a16Real
  1116.             add     si,     2           ;V -  ++ PC
  1117.             push    eax                 ;U -  
  1118.             lea     ebp,    [ebp+4]     ;V -  4 Cycles
  1119.             call    CpuAMread@4         ;N -  
  1120.             and     bl,     01111100b   ;U -  clr Z-N-C
  1121.             mov     cl,     byt[edi+8]  ;V -  ecx <- Y
  1122.             sub     cl,     al          ;U -  CMP  
  1123.             mov     dl,     dl          ;V -  
  1124.             setnc   al                  ;N -  SETcc
  1125.             or      ebx,    eax         ;U -  set C
  1126.             and     ecx,    0FFh        ;V -  
  1127.             or      ebx,    dwot[zn_t+ecx*4] ;U -  set Z-N
  1128.             jmp     PollInt             ;V - /N ...
  1129.        
  1130.         OP90: ; BCC C clr JMP
  1131.             test    ebx,    00000001b
  1132.             je      Fhit
  1133.             jmp     Fnhit
  1134.            
  1135.         OPD0: ; BNE Z clr JMP
  1136.             test    ebx,    00000010b
  1137.             je      Fhit
  1138.             jmp     Fnhit
  1139.            
  1140.         OP10: ; BPL N clr JMP
  1141.             test    ebx,    10000000b
  1142.             je      Fhit
  1143.             jmp     Fnhit
  1144.            
  1145.         OP50: ; BVC V clr JMP
  1146.             test    ebx,    01000000b
  1147.             je      Fhit
  1148.             jmp     Fnhit
  1149.            
  1150.         OPB0: ; BCS C set JMP
  1151.             test    ebx,    00000001b
  1152.             jne     Fhit
  1153.             jmp     Fnhit
  1154.            
  1155.         OPF0: ; BEQ Z set JMP
  1156.             test    ebx,    00000010b
  1157.             jne     Fhit
  1158.             jmp     Fnhit
  1159.            
  1160.         OP30: ; BMI N set JMP
  1161.             test    ebx,    10000000b
  1162.             jne     Fhit
  1163.             jmp     Fnhit  
  1164.            
  1165.         OP70: ; BVS V set JMP
  1166.             test    ebx,    01000000b
  1167.             jne     Fhit
  1168.             jmp     Fnhit  
  1169.            
  1170.             ALIGNXMM
  1171.             Fhit:          
  1172.                 add     ebp,    3 ; hit 3 Cycles            
  1173.                 movsx   ecx,    byt[edx]
  1174.                 lea     esi,    [ecx+esi+1]
  1175.                 jmp     PollInt    
  1176.                
  1177.             ALIGNXMM
  1178.             Fnhit:              
  1179.                 add     ebp,    2 ; miss 2 Cycles
  1180.                 add     esi,    1          
  1181.                 jmp     PollInt
  1182.  
  1183. ;***
  1184. ;   ORA
  1185. ;               09: #$              2 cycles
  1186. ;               05: ZERO PAGE       3 cycles
  1187. ;               15: ZERO PAGE X     4 cycles
  1188. ;               0D: ABS             4 cycles
  1189. ;               1D: ABS X           4 cycles (crossing page ++ cycles)
  1190. ;               19: ABS Y           4 cycles (crossing page ++ cycles)
  1191. ;               01: X INDIRECT      6 cycles
  1192. ;               11: INDIRECT Y      4 cycles (crossing page ++ cycles)
  1193. ;   Algorithm:
  1194. ;  
  1195. ;           src |= AC;
  1196. ;           SET_SIGN(src);
  1197. ;           SET_ZERO(src);
  1198. ;           AC = src;
  1199. ;*************************************************      
  1200.  
  1201.             OP09: ; ORA #$      
  1202.                 movzx   eax,    byt[edx]    ;N -  load #$
  1203.                 movzx   ecx,    byt[edi]    ;N -  load REG A            
  1204.                 or      ecx,    eax         ;U -  ORA OPR
  1205.                 and     ebx,    07Dh        ;V -  clr Z-N Flags
  1206.                 lea     ebp,    [ebp+2]     ;U -  2 Cycles
  1207.                 or      ebx,    dwot[zn_t+ecx*4]    ;V -  reset Z-N Flags
  1208.                 lea     esi,    [esi+1]     ;U -  ++ PC
  1209.                 mov     $a,     ecx         ;V -  write Back REG A
  1210.                 jmp     PollInt             ;N -  ...
  1211.                
  1212.             OP05: ; ORA ZERO PAGE
  1213.                 movzx   ecx,    byt[edx]    ;N -  load addr8Real
  1214.                 movzx   eax,    byt[ram+ecx];N -  load VAL
  1215.                 movzx   ecx,    byt[edi]    ;N -  load REG A            
  1216.                 or      ecx,    eax         ;U -  ORA OPR
  1217.                 and     ebx,    07Dh        ;V -  clr Z-N Flags
  1218.                 lea     ebp,    [ebp+3]     ;U -  3 Cycles
  1219.                 or      ebx,    dwot[zn_t+ecx*4]    ;V -  reset Z-N Flags
  1220.                 lea     esi,    [esi+1]     ;U -  ++ PC
  1221.                 mov     $a,     ecx         ;V -  write Back REG A
  1222.                 jmp     PollInt             ;N -  ...
  1223.                
  1224.             OP15: ; ORA ZERO PAGE X
  1225.                 movzx   ecx,    byt[edx]    ;N -  load addr8Real
  1226.                 add     cl,     byt[edi+4]  ;U -  ZERO PAGE X
  1227.                 mov     dl,     dl          ;V -  
  1228.                 movzx   eax,    byt[ram+ecx];N -  load VAL
  1229.                 movzx   ecx,    byt[edi]    ;N -  load REG A            
  1230.                 or      ecx,    eax         ;U -  ORA OPR
  1231.                 and     ebx,    07Dh        ;V -  clr Z-N Flags
  1232.                 lea     ebp,    [ebp+4]     ;U -  4 Cycles
  1233.                 or      ebx,    dwot[zn_t+ecx*4]    ;V -  reset Z-N Flags
  1234.                 lea     esi,    [esi+1]     ;U -  ++ PC
  1235.                 mov     $a,     ecx         ;V -  write Back REG A
  1236.                 jmp     PollInt             ;N -  ...
  1237.                
  1238.             OP0D: ; ORA ABS
  1239.                 movzx   ecx,    wot[edx]    ;N -  load addr16Real
  1240.                 push    ecx                 ;U -  
  1241.                 lea     ebp,    [ebp+4]     ;V -  4 Cycles
  1242.                 call    CpuAMread@4         ;N -  
  1243.                 movzx   ecx,    byt[edi]    ;N -  load REG A            
  1244.                 or      cl,     al          ;U -  ORA OPR
  1245.                 and     bl,     07Dh        ;V -  clr Z-N Flags
  1246.                 mov     $a,     ecx         ;U -  write Back REG A
  1247.                 lea     esi,    [esi+2]     ;V -  ++ PC
  1248.                 or      ebx,    dwot[zn_t+ecx*4]    ;V -  reset Z-N Flags  
  1249.                 jmp     PollInt             ;V - /N ...
  1250.                
  1251.             OP1D: ; ORA ABS X
  1252.                 movzx   eax,    wot[edx]    ;N -  load addr16Temp
  1253.                 movzx   edx,    byt[edi+4]  ;N -  load REG X
  1254.                 add     dx,     ax          ;U -  ABS X
  1255.                 add     si,     2           ;V -  ++ PC
  1256.                 push    edx                 ;U -  PUSH arg wait call PROC
  1257.                 lea     ebp,    [ebp+4]     ;V -  4 Cycles
  1258.                 and     bl,     07Dh            ;U -  clr Z-N Flags
  1259.                 sub     ah,     dh          ;V -  test CrossPage
  1260.                 adc     ebp,    0           ;U -  
  1261.                 mov     eax,    eax         ;V -  
  1262.                 call    CpuAMread@4         ;N -  call PROC
  1263.                 movzx   ecx,    byt[edi]    ;N -  load REG A            
  1264.                 or      cl,     al          ;U -  ORA OPR
  1265.                 mov     dl,     dl          ;V -  
  1266.                 mov     $a,     ecx         ;U -  write Back REG A
  1267.                 mov     eax,    eax         ;V -  
  1268.                 or      ebx,    dwot[zn_t+ecx*4]    ;V -  reset Z-N Flags  
  1269.                 jmp     PollInt             ;V - /N ...        
  1270.                
  1271.             OP19: ; ORA ABS Y
  1272.                 movzx   eax,    wot[edx]    ;N -  load addr16Temp
  1273.                 movzx   edx,    byt[edi+8]  ;N -  load REG Y
  1274.                 add     dx,     ax          ;U -  ABS Y
  1275.                 add     si,     2           ;V -  ++ PC
  1276.                 push    edx                 ;U -  PUSH arg wait call PROC
  1277.                 lea     ebp,    [ebp+4]     ;V -  4 Cycles
  1278.                 and     bl,     07Dh            ;U -  clr Z-N Flags
  1279.                 sub     ah,     dh          ;V -  test CrossPage
  1280.                 adc     ebp,    0           ;U -  
  1281.                 mov     eax,    eax         ;V -  
  1282.                 call    CpuAMread@4         ;N -  call PROC
  1283.                 movzx   ecx,    byt[edi]    ;N -  load REG A            
  1284.                 or      cl,     al          ;U -  ORA OPR
  1285.                 mov     dl,     dl          ;V -  
  1286.                 mov     $a,     ecx         ;U -  write Back REG A
  1287.                 mov     eax,    eax         ;V -  
  1288.                 or      ebx,    dwot[zn_t+ecx*4]    ;V -  reset Z-N Flags  
  1289.                 jmp     PollInt             ;V - /N ...
  1290.                
  1291.             OP01: ; ORA X INDIRECT
  1292.                 movzx   eax,    byt[edx]    ;N -  load addr8Real
  1293.                 add     al,     byt[edi+4]  ;U -  X INDIRECT
  1294.                 and     bl,     07Dh        ;V -  clr Z-N Flags
  1295.                 mov     dx,     wot[ram+eax];U -  load addr16Real
  1296.                 add     si,     1           ;V -  ++ PC
  1297.                 push    edx                 ;U -  
  1298.                 lea     ebp,    [ebp+6]     ;V -  6 Cycles
  1299.                 call    CpuAMread@4         ;N -  call PROC
  1300.                 movzx   ecx,    byt[edi]    ;N -  load REG A            
  1301.                 or      cl,     al          ;U -  ORA OPR
  1302.                 mov     dl,     dl          ;V -  
  1303.                 mov     $a,     ecx         ;U -  write Back REG A
  1304.                 mov     eax,    eax         ;V -  
  1305.                 or      ebx,    dwot[zn_t+ecx*4]    ;V -  reset Z-N Flags  
  1306.                 jmp     PollInt             ;V - /N ...
  1307.  
  1308.             OP11: ; ORA INDIRECT Y
  1309.                 movzx   ecx,    byt[edx]    ;N -  load addr8Real
  1310.                 movzx   eax,    wot[ram+ecx];N -  load addr16Temp
  1311.                 movzx   edx,    byt[edi+8]  ;N -  load REG Y
  1312.                 add     dx, ax              ;U -  ABS Y
  1313.                 add     si, 1               ;V -  ++ PC
  1314.                 push    edx                 ;U -  PUSH arg wait call PROC
  1315.                 lea     ebp,    [ebp+4]     ;V -  4 Cycles
  1316.                 and     bl,     07Dh            ;U -  clr Z-N Flags
  1317.                 sub     ah,     dh          ;V -  test CrossPage
  1318.                 adc     ebp,    0           ;U -  
  1319.                 mov     eax,    eax         ;V -  
  1320.                 call    CpuAMread@4         ;N -  call PROC
  1321.                 movzx   ecx,    byt[edi]    ;N -  load REG A            
  1322.                 or      cl,     al          ;U -  ORA OPR
  1323.                 mov     dl,     dl          ;V -  
  1324.                 mov     $a,     ecx         ;U -  write Back REG A
  1325.                 mov     eax,    eax         ;V -  
  1326.                 or      ebx,    dwot[zn_t+ecx*4]    ;V -  reset Z-N Flags  
  1327.                 jmp     PollInt             ;V - /N ...
  1328.            
  1329. ;***
  1330. ;   EOR
  1331. ;               49: #$              2 cycles
  1332. ;               45: ZERO PAGE       3 cycles
  1333. ;               55: ZERO PAGE X     4 cycles
  1334. ;               4D: ABS             4 cycles
  1335. ;               5D: ABS X           4 cycles (crossing page ++ cycles)
  1336. ;               59: ABS Y           4 cycles (crossing page ++ cycles)
  1337. ;               41: X INDIRECT      6 cycles
  1338. ;               51: INDIRECT Y      4 cycles (crossing page ++ cycles)
  1339. ;   Algorithm:
  1340. ;  
  1341. ;           src ^= AC;
  1342. ;           SET_SIGN(src);
  1343. ;           SET_ZERO(src);
  1344. ;           AC = src;
  1345. ;*************************************************          
  1346.        
  1347.             OP49: ; EOR #$
  1348.                 movzx   eax,    byt[edx]    ;N -  load #$
  1349.                 movzx   ecx,    byt[edi]    ;N -  load REG A            
  1350.                 xor     ecx,    eax         ;U -  EOR OPR
  1351.                 and     ebx,    07Dh        ;V -  clr Z-N Flags
  1352.                 lea     ebp,    [ebp+2]     ;U -  2 Cycles
  1353.                 or      ebx,    dwot[zn_t+ecx*4]    ;V -  reset Z-N Flags
  1354.                 lea     esi,    [esi+1]     ;U -  ++ PC
  1355.                 mov     $a,     ecx         ;V -  write Back REG A
  1356.                 jmp     PollInt             ;N -  ...
  1357.                
  1358.             OP45: ; EOR ZERO PAGE
  1359.                 movzx   ecx,    byt[edx]    ;N -  load addr8Real
  1360.                 movzx   eax,    byt[ram+ecx];N -  load VAL
  1361.                 movzx   ecx,    byt[edi]    ;N -  load REG A            
  1362.                 xor     ecx,    eax         ;U -  EOR OPR
  1363.                 and     ebx,    07Dh        ;V -  clr Z-N Flags
  1364.                 lea     ebp,    [ebp+3]     ;U -  3 Cycles
  1365.                 or      ebx,    dwot[zn_t+ecx*4]    ;V -  reset Z-N Flags
  1366.                 lea     esi,    [esi+1]     ;U -  ++ PC
  1367.                 mov     $a,     ecx         ;V -  write Back REG A
  1368.                 jmp     PollInt             ;N -  ...
  1369.                
  1370.             OP55: ; EOR ZERO PAGE X
  1371.                 movzx   ecx,    byt[edx]    ;N -  load addr8Real
  1372.                 add     cl,     byt[edi+4]  ;U -  ZERO PAGE X
  1373.                 mov     dl,     dl          ;V -  
  1374.                 movzx   eax,    byt[ram+ecx];N -  load VAL
  1375.                 movzx   ecx,    byt[edi]    ;N -  load REG A            
  1376.                 xor     ecx,    eax         ;U -  EOR OPR
  1377.                 and     ebx,    07Dh        ;V -  clr Z-N Flags
  1378.                 lea     ebp,    [ebp+4]     ;U -  4 Cycles
  1379.                 or      ebx,    dwot[zn_t+ecx*4]    ;V -  reset Z-N Flags
  1380.                 lea     esi,    [esi+1]     ;U -  ++ PC
  1381.                 mov     $a,     ecx         ;V -  write Back REG A
  1382.                 jmp     PollInt             ;N -  ...
  1383.                
  1384.             OP4D: ; EOR ABS
  1385.                 movzx   ecx,    wot[edx]    ;N -  load addr16Real
  1386.                 push    ecx                 ;U -  
  1387.                 lea     ebp,    [ebp+4]     ;V -  4 Cycles
  1388.                 call    CpuAMread@4         ;N -  
  1389.                 movzx   ecx,    byt[edi]    ;N -  load REG A            
  1390.                 xor     cl,     al          ;U -  EOR OPR
  1391.                 and     bl,     07Dh        ;V -  clr Z-N Flags
  1392.                 mov     $a,     ecx         ;U -  write Back REG A
  1393.                 lea     esi,    [esi+2]     ;V -  ++ PC
  1394.                 or      ebx,    dwot[zn_t+ecx*4]    ;V -  reset Z-N Flags  
  1395.                 jmp     PollInt             ;V - /N ...
  1396.                
  1397.             OP5D: ; EOR ABS X
  1398.                 movzx   eax,    wot[edx]    ;N -  load addr16Temp
  1399.                 movzx   edx,    byt[edi+4]  ;N -  load REG X
  1400.                 add     dx,     ax          ;U -  ABS X
  1401.                 add     si,     2           ;V -  ++ PC
  1402.                 push    edx                 ;U -  PUSH arg wait call PROC
  1403.                 lea     ebp,    [ebp+4]     ;V -  4 Cycles
  1404.                 and     bl,     07Dh            ;U -  clr Z-N Flags
  1405.                 sub     ah,     dh          ;V -  test CrossPage
  1406.                 adc     ebp,    0           ;U -  
  1407.                 mov     eax,    eax         ;V -  
  1408.                 call    CpuAMread@4         ;N -  call PROC
  1409.                 movzx   ecx,    byt[edi]    ;N -  load REG A            
  1410.                 xor     cl,     al          ;U -  EOR OPR
  1411.                 mov     dl,     dl          ;V -  
  1412.                 mov     $a,     ecx         ;U -  write Back REG A
  1413.                 mov     eax,    eax         ;V -  
  1414.                 or      ebx,    dwot[zn_t+ecx*4]    ;V -  reset Z-N Flags  
  1415.                 jmp     PollInt             ;V - /N ...
  1416.                
  1417.             OP59: ; EOR ABS Y
  1418.                 movzx   eax,    wot[edx]    ;N -  load addr16Temp
  1419.                 movzx   edx,    byt[edi+8]  ;N -  load REG Y
  1420.                 add     dx,     ax          ;U -  ABS Y
  1421.                 add     si,     2           ;V -  ++ PC
  1422.                 push    edx                 ;U -  PUSH arg wait call PROC
  1423.                 lea     ebp,    [ebp+4]     ;V -  4 Cycles
  1424.                 and     bl,     07Dh            ;U -  clr Z-N Flags
  1425.                 sub     ah,     dh          ;V -  test CrossPage
  1426.                 adc     ebp,    0           ;U -  
  1427.                 mov     eax,    eax         ;V -  
  1428.                 call    CpuAMread@4         ;N -  call PROC
  1429.                 movzx   ecx,    byt[edi]    ;N -  load REG A            
  1430.                 xor     cl,     al          ;U -  EOR OPR
  1431.                 mov     dl,     dl          ;V -  
  1432.                 mov     $a,     ecx         ;U -  write Back REG A
  1433.                 mov     eax,    eax         ;V -  
  1434.                 or      ebx,    dwot[zn_t+ecx*4]    ;V -  reset Z-N Flags  
  1435.                 jmp     PollInt             ;V - /N ...
  1436.                
  1437.             OP41: ; EOR X INDIRECT
  1438.                 movzx   eax,    byt[edx]    ;N -  load addr8Real
  1439.                 add     al,     byt[edi+4]  ;U -  X INDIRECT
  1440.                 and     bl,     07Dh        ;V -  clr Z-N Flags
  1441.                 mov     dx,     wot[ram+eax];U -  load addr16Real
  1442.                 add     si,     1           ;V -  ++ PC
  1443.                 push    edx                 ;U -  
  1444.                 lea     ebp,    [ebp+6]     ;V -  6 Cycles
  1445.                 call    CpuAMread@4         ;N -  call PROC
  1446.                 movzx   ecx,    byt[edi]    ;N -  load REG A            
  1447.                 xor     cl,     al          ;U -  EOR OPR
  1448.                 mov     dl,     dl          ;V -  
  1449.                 mov     $a,     ecx         ;U -  write Back REG A
  1450.                 mov     eax,    eax         ;V -  
  1451.                 or      ebx,    dwot[zn_t+ecx*4]    ;V -  reset Z-N Flags  
  1452.                 jmp     PollInt             ;V - /N ...
  1453.                
  1454.             OP51: ; EOR INDIRECT Y
  1455.                 movzx   ecx,    byt[edx]    ;N -  load addr8Real
  1456.                 movzx   eax,    wot[ram+ecx];N -  load addr16Temp
  1457.                 movzx   edx,    byt[edi+8]  ;N -  load REG Y
  1458.                 add     dx, ax              ;U -  ABS Y
  1459.                 add     si, 1               ;V -  ++ PC
  1460.                 push    edx                 ;U -  PUSH arg wait call PROC
  1461.                 lea     ebp,    [ebp+4]     ;V -  4 Cycles
  1462.                 and     bl,     07Dh            ;U -  clr Z-N Flags
  1463.                 sub     ah,     dh          ;V -  test CrossPage
  1464.                 adc     ebp,    0           ;U -  
  1465.                 mov     eax,    eax         ;V -  
  1466.                 call    CpuAMread@4         ;N -  call PROC
  1467.                 movzx   ecx,    byt[edi]    ;N -  load REG A            
  1468.                 xor     cl,     al          ;U -  EOR OPR
  1469.                 mov     dl,     dl          ;V -  
  1470.                 mov     $a,     ecx         ;U -  write Back REG A
  1471.                 mov     eax,    eax         ;V -  
  1472.                 or      ebx,    dwot[zn_t+ecx*4]    ;V -  reset Z-N Flags  
  1473.                 jmp     PollInt             ;V - /N ...
  1474. ;***
  1475. ;   AND
  1476. ;               29: #$              2 cycles
  1477. ;               25: ZERO PAGE       3 cycles
  1478. ;               35: ZERO PAGE X     4 cycles
  1479. ;               2D: ABS             4 cycles
  1480. ;               3D: ABS X           4 cycles (crossing page ++ cycles)
  1481. ;               39: ABS Y           4 cycles (crossing page ++ cycles)
  1482. ;               21: X INDIRECT      6 cycles
  1483. ;               31: INDIRECT Y      4 cycles (crossing page ++ cycles)
  1484. ;   Algorithm:
  1485. ;  
  1486. ;           src &= AC;
  1487. ;           SET_SIGN(src);
  1488. ;           SET_ZERO(src);
  1489. ;           AC = src;
  1490. ;*************************************************  
  1491.                
  1492.             OP29: ; AND #$
  1493.                 movzx   eax,    byt[edx]    ;N -  load #$
  1494.                 movzx   ecx,    byt[edi]    ;N -  load REG A            
  1495.                 and     ecx,    eax         ;U -  AND OPR
  1496.                 and     ebx,    07Dh        ;V -  clr Z-N Flags
  1497.                 lea     ebp,    [ebp+2]     ;U -  2 Cycles
  1498.                 or      ebx,    dwot[zn_t+ecx*4]    ;V -  reset Z-N Flags
  1499.                 lea     esi,    [esi+1]     ;U -  ++ PC
  1500.                 mov     $a,     ecx         ;V -  write Back REG A
  1501.                 jmp     PollInt             ;N -  ...
  1502.                
  1503.             OP25: ; AND ZERO PAGE
  1504.                 movzx   ecx,    byt[edx]    ;N -  load addr8Real
  1505.                 movzx   eax,    byt[ram+ecx];N -  load VAL
  1506.                 movzx   ecx,    byt[edi]    ;N -  load REG A            
  1507.                 and     ecx,    eax         ;U -  AND OPR
  1508.                 and     ebx,    07Dh        ;V -  clr Z-N Flags
  1509.                 lea     ebp,    [ebp+3]     ;U -  3 Cycles
  1510.                 or      ebx,    dwot[zn_t+ecx*4]    ;V -  reset Z-N Flags
  1511.                 lea     esi,    [esi+1]     ;U -  ++ PC
  1512.                 mov     $a,     ecx         ;V -  write Back REG A
  1513.                 jmp     PollInt             ;N -  ...
  1514.                
  1515.             OP35: ; AND ZERO PAGE X
  1516.                 movzx   ecx,    byt[edx]    ;N -  load addr8Real
  1517.                 add     cl,     byt[edi+4]  ;U -  ZERO PAGE X
  1518.                 mov     dl,     dl          ;V -  
  1519.                 movzx   eax,    byt[ram+ecx];N -  load VAL
  1520.                 movzx   ecx,    byt[edi]    ;N -  load REG A            
  1521.                 and     ecx,    eax         ;U -  AND OPR
  1522.                 and     ebx,    07Dh        ;V -  clr Z-N Flags
  1523.                 lea     ebp,    [ebp+4]     ;U -  4 Cycles
  1524.                 or      ebx,    dwot[zn_t+ecx*4]    ;V -  reset Z-N Flags
  1525.                 lea     esi,    [esi+1]     ;U -  ++ PC
  1526.                 mov     $a,     ecx         ;V -  write Back REG A
  1527.                 jmp     PollInt             ;N -  ...
  1528.                
  1529.             OP2D: ; AND ABS
  1530.                 movzx   ecx,    wot[edx]    ;N -  load addr16Real
  1531.                 push    ecx                 ;U -  
  1532.                 lea     ebp,    [ebp+4]     ;V -  4 Cycles
  1533.                 call    CpuAMread@4         ;N -  
  1534.                 movzx   ecx,    byt[edi]    ;N -  load REG A            
  1535.                 and     cl,     al          ;U -  AND OPR
  1536.                 and     bl,     07Dh        ;V -  clr Z-N Flags
  1537.                 mov     $a,     ecx         ;U -  write Back REG A
  1538.                 lea     esi,    [esi+2]     ;V -  ++ PC
  1539.                 or      ebx,    dwot[zn_t+ecx*4]    ;V -  reset Z-N Flags  
  1540.                 jmp     PollInt             ;V - /N ...
  1541.                
  1542.             OP3D: ; AND ABS X
  1543.                 movzx   eax,    wot[edx]    ;N -  load addr16Temp
  1544.                 movzx   edx,    byt[edi+4]  ;N -  load REG X
  1545.                 add     dx,     ax          ;U -  ABS X
  1546.                 add     si,     2           ;V -  ++ PC
  1547.                 push    edx                 ;U -  PUSH arg wait call PROC
  1548.                 lea     ebp,    [ebp+4]     ;V -  4 Cycles
  1549.                 and     bl,     07Dh            ;U -  clr Z-N Flags
  1550.                 sub     ah,     dh          ;V -  test CrossPage
  1551.                 adc     ebp,    0           ;U -  
  1552.                 mov     eax,    eax         ;V -  
  1553.                 call    CpuAMread@4         ;N -  call PROC
  1554.                 movzx   ecx,    byt[edi]    ;N -  load REG A            
  1555.                 and     cl,     al          ;U -  AND OPR
  1556.                 mov     dl,     dl          ;V -  
  1557.                 mov     $a,     ecx         ;U -  write Back REG A
  1558.                 mov     eax,    eax         ;V -  
  1559.                 or      ebx,    dwot[zn_t+ecx*4]    ;V -  reset Z-N Flags  
  1560.                 jmp     PollInt             ;V - /N ...    
  1561.                
  1562.             OP39: ; AND ABS Y
  1563.                 movzx   eax,    wot[edx]    ;N -  load addr16Temp
  1564.                 movzx   edx,    byt[edi+8]  ;N -  load REG Y
  1565.                 add     dx,     ax          ;U -  ABS Y
  1566.                 add     si,     2           ;V -  ++ PC
  1567.                 push    edx                 ;U -  PUSH arg wait call PROC
  1568.                 lea     ebp,    [ebp+4]     ;V -  4 Cycles
  1569.                 and     bl,     07Dh            ;U -  clr Z-N Flags
  1570.                 sub     ah,     dh          ;V -  test CrossPage
  1571.                 adc     ebp,    0           ;U -  
  1572.                 mov     eax,    eax         ;V -  
  1573.                 call    CpuAMread@4         ;N -  call PROC
  1574.                 movzx   ecx,    byt[edi]    ;N -  load REG A            
  1575.                 and     cl,     al          ;U -  AND OPR
  1576.                 mov     dl,     dl          ;V -  
  1577.                 mov     $a,     ecx         ;U -  write Back REG A
  1578.                 mov     eax,    eax         ;V -  
  1579.                 or      ebx,    dwot[zn_t+ecx*4]    ;V -  reset Z-N Flags  
  1580.                 jmp     PollInt             ;V - /N ...
  1581.                
  1582.             OP21: ; AND X INDIRECT
  1583.                 movzx   eax,    byt[edx]    ;N -  load addr8Real
  1584.                 add     al,     byt[edi+4]  ;U -  X INDIRECT
  1585.                 and     bl,     07Dh        ;V -  clr Z-N Flags
  1586.                 mov     dx,     wot[ram+eax];U -  load addr16Real
  1587.                 add     si,     1           ;V -  ++ PC
  1588.                 push    edx                 ;U -  
  1589.                 lea     ebp,    [ebp+6]     ;V -  6 Cycles
  1590.                 call    CpuAMread@4         ;N -  call PROC
  1591.                 movzx   ecx,    byt[edi]    ;N -  load REG A            
  1592.                 and     cl,     al          ;U -  AND OPR
  1593.                 mov     dl,     dl          ;V -  
  1594.                 mov     $a,     ecx         ;U -  write Back REG A
  1595.                 mov     eax,    eax         ;V -  
  1596.                 or      ebx,    dwot[zn_t+ecx*4]    ;V -  reset Z-N Flags  
  1597.                 jmp     PollInt             ;V - /N ...
  1598.                
  1599.             OP31: ; AND INDIRECT Y
  1600.                 movzx   ecx,    byt[edx]    ;N -  load addr8Real
  1601.                 movzx   eax,    wot[ram+ecx];N -  load addr16Temp
  1602.                 movzx   edx,    byt[edi+8]  ;N -  load REG Y
  1603.                 add     dx, ax              ;U -  ABS Y
  1604.                 add     si, 1               ;V -  ++ PC
  1605.                 push    edx                 ;U -  PUSH arg wait call PROC
  1606.                 lea     ebp,    [ebp+4]     ;V -  4 Cycles
  1607.                 and     bl,     07Dh            ;U -  clr Z-N Flags
  1608.                 sub     ah,     dh          ;V -  test CrossPage
  1609.                 adc     ebp,    0           ;U -  
  1610.                 mov     eax,    eax         ;V -  
  1611.                 call    CpuAMread@4         ;N -  call PROC
  1612.                 movzx   ecx,    byt[edi]    ;N -  load REG A            
  1613.                 and     cl,     al          ;U -  AND OPR
  1614.                 mov     dl,     dl          ;V -  
  1615.                 mov     $a,     ecx         ;U -  write Back REG A
  1616.                 mov     eax,    eax         ;V -  
  1617.                 or      ebx,    dwot[zn_t+ecx*4]    ;V -  reset Z-N Flags  
  1618.                 jmp     PollInt             ;V - /N ...
  1619. ;***
  1620. ;   JMP
  1621. ;               4C: ABS             3 cycles
  1622. ;               6C: inDirect        5 cycles
  1623. ;   Algorithm:
  1624. ;  
  1625. ;               PC = (src);
  1626. ;
  1627. ;*************************************************  
  1628.    
  1629.             OP4C: ; JMP ABS
  1630.                 mov     si,     wot[edx]    ;U -  get PC  
  1631.                 add     bp,     3           ;V -  3 Cycles
  1632.                 jmp     PollInt             ;N -  
  1633.                
  1634.             OP6C:  
  1635.                 ; in-direct JMP expection crossing page boundaries in 6C
  1636.                 ; NES JMP(only 6C)'s BUG: if addr is 0x--FF(Crossing Page) IP's High Bit Will Not Add
  1637.                 ;
  1638.                 ; $2500: 33
  1639.                 ; $25FF: 76
  1640.                 ; $2600: 89
  1641.                 ; $7574: 6C FF 25
  1642.                 ; PC <- $7574
  1643.                 ;
  1644.                 ; Step1-> Get PC's Low  Bit FF
  1645.                 ; Step2-> Get PC's High Bit 25
  1646.                 ; $(25FF-2600) will crossing page so low bit is $25FF high Bit is $2500
  1647.                 ; jmp to $3376 ...  
  1648.                
  1649.                 movzx   eax,    wot[edx]    ;N -  load indirect addr ...        
  1650.                 push    eax                 ;U -  push arg wait call CpuAMread@4/CpuAMreadW@4
  1651.                 add     ebp,    5           ;V -  5 Cycles
  1652.                 cmp     al,     0FFh        ;U -  low addr is FF ?
  1653.                 jne     noCrossPageBUG      ;V -  FF:no jmp else immed read word no CrossPage
  1654.                 mov     $t1,    eax         ;U -  save addr
  1655.                 mov     ebp,    ebp         ;V -  
  1656.                 call    CpuAMread@4             ;N -  call read PROC - BYTE
  1657.                 mov     esi,    eax         ;U -  addr - low bit        
  1658.                 mov     eax,    $t1         ;V -  load org addr  
  1659.                 sub     eax,    0FFh        ;U -  crossPage BUG deal
  1660.                 and     esi,    0FFh        ;V -  limit byte
  1661.                 push    eax                 ;U -  push arg wait call CpuAMread@4
  1662.                 mov     eax,    eax         ;V -  
  1663.                 call    CpuAMread@4         ;N -  call read PROC - BYTE
  1664.                 shl     eax,    8           ;U -  shift to high 8 bits
  1665.                 mov     ecx,    ecx         ;V -  
  1666.                 or      esi,    eax         ;U -  get PC over
  1667.                 jmp     PollInt             ;V - /N
  1668.                 ALIGNXMM
  1669.                 noCrossPageBUG:
  1670.                     call    CpuAMreadW@4    ;   - N call read PROC - WORD
  1671.                     mov     esi,    eax ;   - U PC <- EAX
  1672.                     jmp     PollInt     ;   - V/N
  1673.  
  1674. ;***
  1675. ;   JSR         20: ABS             6 cycles
  1676. ;
  1677. ;
  1678. ;   Algorithm:
  1679. ;  
  1680. ;               PC--;
  1681. ;               PUSH((PC >> 8) & 0xff); /* Push return address onto the stack. */
  1682. ;               PUSH(PC & 0xff);
  1683. ;               PC = (src);
  1684. ;
  1685. ;*************************************************  
  1686.                    
  1687.             OP20: ; JSR            
  1688.                 movzx   eax,    wot[edx]    ;N -  load future PC
  1689.                 mov     ecx,    $s          ;U -  load REG S
  1690.                 add     ebp,    6           ;V -  6 Cycles
  1691.                 and     ecx,    0FFh        ;U -  limits bits
  1692.                 lea     edx,    [esi+1]     ;V -  ++ PC
  1693.                 mov     esi,    eax         ;U -  write back PC    
  1694.                 mov     eax,    eax         ;V -  
  1695.                 mov     wot[ram+0100h+ecx-1],   dx  ;U -  wrte back STACK PC
  1696.                 sub     cx,     2                   ;V - /N STACK --
  1697.                 mov     $s,     ecx                 ;U -  write back STACK
  1698.                 jmp     PollInt                     ;V - /N continue deal interrupt
  1699.  
  1700. ;***
  1701. ;   RTI         40          
  1702. ;
  1703. ;
  1704. ;   Algorithm:
  1705. ;  
  1706. ;               src = PULL();
  1707. ;               SET_SR(src);
  1708. ;               src = PULL();
  1709. ;               src |= (PULL() << 8);   /* Load return address from stack. */
  1710. ;               PC = (src);
  1711. ;
  1712. ;*************************************************  
  1713.            
  1714.             OP40: ; RTI
  1715.                 mov     ecx,    $s      ;U -  load REG S
  1716.                 add     ebp,    6       ;V -  6 Cycles
  1717.                 and     ecx,    0FFh    ;U -  
  1718.                 mov     eax,    eax     ;V -  
  1719.                 lea     ecx,    [ecx+3] ;U -  ++ STACK
  1720.                 mov     ebx,    ebx     ;V -  
  1721.                 mov     bl,     byt[ram+0100h+ecx-2]    ;U -  write back REG P
  1722.                 mov     al,     al                      ;V -    
  1723.                 mov     si,     wot[ram+0100h+ecx-1]    ;U -  write back REG PC
  1724.                 mov     bx,     bx                      ;V -            
  1725.                 mov     $s,     ecx                     ;U -  write back REG S
  1726.                 jmp     PollInt                         ;V - /N continue deal interrupt
  1727.  
  1728. ;***
  1729. ;   RTS         60          
  1730. ;
  1731. ;
  1732. ;   Algorithm:
  1733. ;  
  1734. ;               src = PULL();
  1735. ;               src += ((PULL()) << 8) + 1; /* Load return address from stack and add 1. */
  1736. ;               PC = (src);
  1737. ;
  1738. ;*************************************************  
  1739.  
  1740.             OP60: ; RTS        
  1741.                 mov     ecx,    $s      ;U -  load REG S
  1742.                 add     ebp,    6       ;V -  6 Cycles              
  1743.                 and     ecx,    255     ;U -  limit Bits
  1744.                 mov     eax,    eax     ;V -  
  1745.                 add     ecx,    2       ;U -  ++STACK
  1746.                 mov     eax,    eax     ;V -  
  1747.                 mov     si,     wot[ram+0100h+ecx-1]    ;U -  load PC
  1748.                 mov     ax,     ax                      ;V -  
  1749.                 mov     $s,     ecx                     ;U -  write back S
  1750.                 lea     esi,    [esi+1]                 ;V -  ++ PC
  1751.                 jmp     PollInt                         ;V - /N continue deal interrupt
  1752.         OP18: ; CLC
  1753.             add     ebp,    2
  1754.             and     ebx,    11111110b
  1755.             jmp     PollInt
  1756.            
  1757.         OPD8: ; CLD
  1758.             add     ebp,    2
  1759.             and     ebx,    11110111b
  1760.             jmp     PollInt
  1761.            
  1762.         OP58: ; CLI
  1763.             add     ebp,    2
  1764.             and     ebx,    11111011b
  1765.             jmp     PollInt
  1766.            
  1767.         OPB8: ; CLV
  1768.             add     ebp,    2
  1769.             and     ebx,    10111111b
  1770.             jmp     PollInt
  1771.            
  1772.         OP38: ; SEC
  1773.             add     ebp,    2
  1774.             or      ebx,    00000001b
  1775.             jmp     PollInt
  1776.            
  1777.         OPF8: ; SED
  1778.             add     ebp,    2
  1779.             or      ebx,    00001000b
  1780.             jmp     PollInt
  1781.            
  1782.         OP78: ; SEI
  1783.             add     ebp,    2
  1784.             or      ebx,    00000100b
  1785.             jmp     PollInt
  1786. ;***
  1787. ;   LDA  
  1788. ;               A9: ACC             2 cycles
  1789. ;               A5: ZERO PAGE       3 cycles
  1790. ;               B5: ZERO PAGE X     4 cycles
  1791. ;               AD: ABS             4 cycles
  1792. ;               BD: ABS X           4 cycles (test cross page)
  1793. ;               B9: ABS Y           4 cycles (test cross page)
  1794. ;               A1: X INDIRECT      6 cycles
  1795. ;               B1: INDIRECT Y      5 cycles (test cross page)  
  1796. ;           X   A5: X REG           2 cycles
  1797. ;           X   A6: ZERO PAGE       3 cycles
  1798. ;           X   B6: ZERO PAGE Y     4 cycles
  1799. ;           X   AE: ABS             4 cycles
  1800. ;           X   BE: ABS Y           4 cycles (test cross page)
  1801. ;           Y   A0: Y REG           2 cycles
  1802. ;           Y   A4: ZERO PAGE       3 cycles
  1803. ;           Y   B4: ZERO PAGE X     4 cycles
  1804. ;           Y   AC: ABS             4 cycles
  1805. ;           Y   BC: ABS X           4 cycles (test cross page)
  1806. ;
  1807. ;   Algorithm:
  1808. ;  
  1809. ;           SET_SIGN(src);
  1810. ;           SET_ZERO(src);
  1811. ;           AC = (src);
  1812. ;
  1813. ;*************************************************
  1814.  
  1815. ; =====
  1816.     ;   A
  1817.         ; =====
  1818.        
  1819.         OPA9: ; LDA #$  
  1820.             movzx   eax,    byt[edx]    ;N -  eax <- #$
  1821.             mov     $a,     eax         ;U -  A <- eax
  1822.             and     ebx,    07Dh        ;V -  clr Z-N
  1823.             lea     ebp,    [ebp+2]     ;U -  2 Cycles
  1824.             lea     esi,    [esi+1]     ;V -  ++ PC
  1825.             or      ebx,    dwot[zn_t+eax*4]    ;U -  set Z-N
  1826.             jmp     PollInt                         ;V -
  1827.                        
  1828.         OPA5: ; LDA ZERO PAGE
  1829.             movzx   eax,    byt[edx]        ;N -  eax <- a8Real  
  1830.             mov     al,     byt[ram+eax]    ;U -  eax <- MEM  
  1831.             and     bl,     07Dh            ;V -  clr Z-N
  1832.             mov     $a,     eax             ;U -  A <- MEM
  1833.             lea     ebp,    [ebp+3]         ;V -  3 Cycles
  1834.             lea     esi,    [esi+1]         ;U -  ++ PC
  1835.             or      ebx,    dwot[zn_t+eax*4]    ;V -  set Z-N
  1836.             jmp     PollInt                         ;N -  
  1837.  
  1838.         OPB5: ; LDA ZERO PAGE X
  1839.             movzx   eax,    byt[edx]        ;N -  eax <- a8Temp
  1840.             add     al,     byt[edi+4]      ;U -  eax <- a8Real
  1841.             mov     dl,     dl              ;V -
  1842.             mov     al,     byt[ram+eax]    ;U -  eax <- MEM  
  1843.             and     bl,     07Dh            ;V -  clr Z-N
  1844.             mov     $a,     eax             ;U -  A <- MEM
  1845.             lea     ebp,    [ebp+4]         ;V -  4 Cycles
  1846.             lea     esi,    [esi+1]         ;U -  ++ PC
  1847.             or      ebx,    dwot[zn_t+eax*4]    ;V -  set Z-N
  1848.             jmp     PollInt                         ;N -  
  1849.                        
  1850.         OPAD: ; LDA ABS --
  1851.             movzx   eax,    wot[edx]        ;N -  eax <- a16Real
  1852.             push    eax                     ;U -  
  1853.             lea     ebp,    [ebp+4]         ;V -  4 Cycles
  1854.             call    CpuAMread@4             ;N -  
  1855.             and     eax,    0FFh            ;U -  
  1856.             mov     edx,    edx             ;V -  
  1857.             and     ebx,    07Dh            ;U -  clr Z-N
  1858.             mov     $a,     eax             ;V -  A <- MEM
  1859.             or      ebx,    dwot[zn_t+eax*4] ;U -  set Z-N
  1860.             lea     esi,    [esi+2]         ;V -  ++ PC
  1861.             jmp     PollInt                 ;N -
  1862.                            
  1863.         OPBD: ; LDA ABS X
  1864.             movzx   eax,    wot[edx]        ;N -  eax <- a16Temp
  1865.             movzx   ecx,    byt[edi+4]      ;N -  ecx <- X
  1866.             add     ecx,    eax             ;U -
  1867.             lea     esi,    [esi+2]         ;V -  ++ PC  
  1868.             push    ecx                     ;U -
  1869.             mov     eax,    eax             ;V -            
  1870.             and     bl,     07Dh            ;U -  clr Z-N
  1871.             sub     ah,     ch              ;V -  test CrossPage
  1872.             adc     ebp,    4               ;U -
  1873.             mov     ebx,    ebx             ;V -
  1874.             call    CpuAMread@4             ;N -  
  1875.             mov     $a,     eax             ;U -  A <- MEM
  1876.             and     eax,    0FFh            ;V -  
  1877.             or      ebx,    dwot[zn_t+eax*4] ;U -  set Z-N
  1878.             jmp     PollInt                 ;V/N -
  1879.            
  1880.  
  1881.         OPB9: ; LDA ABS Y
  1882.             movzx   eax,    wot[edx]        ;N -  eax <- a16Temp
  1883.             movzx   ecx,    byt[edi+8]      ;N -  ecx <- Y
  1884.             add     ecx,    eax             ;U -
  1885.             lea     esi,    [esi+2]         ;V -  ++ PC  
  1886.             push    ecx                     ;U -
  1887.             mov     eax,    eax             ;V -            
  1888.             and     bl,     07Dh            ;U -  clr Z-N
  1889.             sub     ah,     ch              ;V -  test CrossPage
  1890.             adc     ebp,    4               ;U -
  1891.             mov     ebx,    ebx             ;V -
  1892.             call    CpuAMread@4             ;N -  
  1893.             mov     $a,     eax             ;U -  A <- MEM
  1894.             and     eax,    0FFh            ;V -  
  1895.             or      ebx,    dwot[zn_t+eax*4] ;U -  set Z-N
  1896.             jmp     PollInt                 ;V/N -
  1897.        
  1898.         OPA1: ; LDA X INDIRECT
  1899.             movzx   eax,    byt[edx]        ;N -  eax <- a8Temp  
  1900.             add     al,     byt[edi+4]      ;U -  eax <- a8Real
  1901.             and     bl,     07Dh            ;V -  clr Z-N
  1902.             mov     cx,     wot[ram+eax]    ;U -  ecx <- a16Real
  1903.             add     bp,     6               ;V -  6 Cycles
  1904.             push    ecx                     ;U -  
  1905.             lea     esi,    [esi+1]         ;V -  ++ PC
  1906.             call    CpuAMread@4             ;N -
  1907.             mov     $a,     eax             ;U -  A <- MEM
  1908.             and     eax,    0FFh            ;V -  
  1909.             or      ebx,    dwot[zn_t+eax*4] ;U -  set Z-N
  1910.             jmp     PollInt                 ;V - /N ...
  1911.  
  1912.         OPB1: ; LDA INDIRECT Y
  1913.             movzx   eax,    byt[edx]        ;N -  eax <- a8Real
  1914.             movzx   eax,    wot[ram+eax]    ;N -  eax <- a16Temp
  1915.             movzx   ecx,    byt[edi+8]      ;N -  ecx <- Y
  1916.             add     ecx,    eax             ;U -
  1917.             lea     esi,    [esi+1]         ;V -  ++ PC  
  1918.             push    ecx                     ;U -
  1919.             mov     eax,    eax             ;V -            
  1920.             and     bl,     07Dh            ;U -  clr Z-N
  1921.             sub     ah,     ch              ;V -  test CrossPage
  1922.             adc     ebp,    5               ;U -  
  1923.             mov     ebx,    ebx             ;V -
  1924.             call    CpuAMread@4             ;N -  
  1925.             mov     $a,     eax             ;U -  A <- MEM
  1926.             and     eax,    0FFh            ;V -  
  1927.             or      ebx,    dwot[zn_t+eax*4] ;U -  set Z-N
  1928.             jmp     PollInt                 ;V/N -
  1929.            
  1930. ; =====
  1931.     ;   X
  1932.         ; =====
  1933.        
  1934.         OPA2: ; LDX #$
  1935.             movzx   eax,    byt[edx]    ;N -  eax <- #$
  1936.             mov     $x,     eax         ;U -  X <- eax
  1937.             and     ebx,    07Dh        ;V -  clr Z-N
  1938.             lea     ebp,    [ebp+2]     ;U -  2 Cycles
  1939.             lea     esi,    [esi+1]     ;V -  ++ PC
  1940.             or      ebx,    dwot[zn_t+eax*4]    ;U -  set Z-N
  1941.             jmp     PollInt                         ;V -
  1942.            
  1943.         OPA6: ; LDX ZERO PAGE
  1944.             movzx   eax,    byt[edx]        ;N -  eax <- a8Real  
  1945.             mov     al,     byt[ram+eax]    ;U -  eax <- MEM  
  1946.             and     bl,     07Dh            ;V -  clr Z-N
  1947.             mov     $x,     eax             ;U -  X <- MEM
  1948.             lea     ebp,    [ebp+3]         ;V -  3 Cycles
  1949.             lea     esi,    [esi+1]         ;U -  ++ PC
  1950.             or      ebx,    dwot[zn_t+eax*4]    ;V -  set Z-N
  1951.             jmp     PollInt                         ;N -  
  1952.            
  1953.         OPB6: ; LDX ZERO PAGE Y
  1954.             movzx   eax,    byt[edx]        ;N -  eax <- a8Temp
  1955.             add     al,     byt[edi+8]      ;U -  eax <- a8Real
  1956.             mov     dl,     dl              ;V -
  1957.             mov     al,     byt[ram+eax]    ;U -  eax <- MEM  
  1958.             and     bl,     07Dh            ;V -  clr Z-N
  1959.             mov     $x,     eax             ;U -  X <- MEM
  1960.             lea     ebp,    [ebp+4]         ;V -  4 Cycles
  1961.             lea     esi,    [esi+1]         ;U -  ++ PC
  1962.             or      ebx,    dwot[zn_t+eax*4]    ;V -  set Z-N
  1963.             jmp     PollInt                         ;N -  
  1964.                
  1965.         OPAE: ; LDX ABS
  1966.             movzx   eax,    wot[edx]        ;N -  eax <- a16Real
  1967.             push    eax                     ;U -  
  1968.             lea     ebp,    [ebp+4]         ;V -  4 Cycles
  1969.             call    CpuAMread@4             ;N -  
  1970.             and     eax,    0FFh            ;U -  
  1971.             mov     edx,    edx             ;V -  
  1972.             and     ebx,    07Dh            ;U -  clr Z-N
  1973.             mov     $x,     eax             ;V -  X <- MEM
  1974.             or      ebx,    dwot[zn_t+eax*4] ;U -  set Z-N
  1975.             lea     esi,    [esi+2]         ;V -  ++ PC
  1976.             jmp     PollInt                 ;N -
  1977.                
  1978.         OPBE: ; LDX ABS Y
  1979.             movzx   eax,    wot[edx]        ;N -  eax <- a16Temp
  1980.             movzx   ecx,    byt[edi+8]      ;N -  ecx <- Y
  1981.             add     ecx,    eax             ;U -
  1982.             lea     esi,    [esi+2]         ;V -  ++ PC  
  1983.             push    ecx                     ;U -
  1984.             mov     eax,    eax             ;V -            
  1985.             and     bl,     07Dh            ;U -  clr Z-N
  1986.             sub     ah,     ch              ;V -  test CrossPage
  1987.             adc     ebp,    4               ;U -
  1988.             mov     ebx,    ebx             ;V -
  1989.             call    CpuAMread@4             ;N -  
  1990.             mov     $x,     eax             ;U -  X <- MEM
  1991.             and     eax,    0FFh            ;V -  
  1992.             or      ebx,    dwot[zn_t+eax*4] ;U -  set Z-N
  1993.             jmp     PollInt                 ;V/N -
  1994.            
  1995. ; =====
  1996.     ;   y
  1997.         ; =====
  1998.        
  1999.         OPA0: ; LDY #$
  2000.             movzx   eax,    byt[edx]    ;N -  eax <- #$
  2001.             mov     $y,     eax         ;U -  Y <- eax
  2002.             and     ebx,    07Dh        ;V -  clr Z-N
  2003.             lea     ebp,    [ebp+2]     ;U -  2 Cycles
  2004.             lea     esi,    [esi+1]     ;V -  ++ PC
  2005.             or      ebx,    dwot[zn_t+eax*4]    ;U -  set Z-N
  2006.             jmp     PollInt                         ;V -
  2007.  
  2008.         OPA4: ; LDY ZERO PAGE
  2009.             movzx   eax,    byt[edx]        ;N -  eax <- a8Real  
  2010.             mov     al,     byt[ram+eax]    ;U -  eax <- MEM  
  2011.             and     bl,     07Dh            ;V -  clr Z-N
  2012.             mov     $y,     eax             ;U -  Y <- MEM
  2013.             lea     ebp,    [ebp+3]         ;V -  3 Cycles
  2014.             lea     esi,    [esi+1]         ;U -  ++ PC
  2015.             or      ebx,    dwot[zn_t+eax*4]    ;V -  set Z-N
  2016.             jmp     PollInt                         ;N -  
  2017.            
  2018.         OPB4: ; LDY ZERO PAGE X
  2019.             movzx   eax,    byt[edx]        ;N -  eax <- a8Temp
  2020.             add     al,     byt[edi+4]      ;U -  eax <- a8Real
  2021.             mov     dl,     dl              ;V -
  2022.             mov     al,     byt[ram+eax]    ;U -  eax <- MEM  
  2023.             and     bl,     07Dh            ;V -  clr Z-N
  2024.             mov     $y,     eax             ;U -  Y <- MEM
  2025.             lea     ebp,    [ebp+4]         ;V -  4 Cycles
  2026.             lea     esi,    [esi+1]         ;U -  ++ PC
  2027.             or      ebx,    dwot[zn_t+eax*4]    ;V -  set Z-N
  2028.             jmp     PollInt                         ;N -  
  2029.                        
  2030.         OPAC: ; LDY ABS
  2031.             movzx   eax,    wot[edx]        ;N -  eax <- a16Real
  2032.             push    eax                     ;U -  
  2033.             lea     ebp,    [ebp+4]         ;V -  4 Cycles
  2034.             call    CpuAMread@4             ;N -  
  2035.             and     eax,    0FFh            ;U -  
  2036.             mov     edx,    edx             ;V -  
  2037.             and     ebx,    07Dh            ;U -  clr Z-N
  2038.             mov     $y,     eax             ;V -  Y <- MEM
  2039.             or      ebx,    dwot[zn_t+eax*4] ;U -  set Z-N
  2040.             lea     esi,    [esi+2]         ;V -  ++ PC
  2041.             jmp     PollInt                 ;N -
  2042.            
  2043.         OPBC: ; LDY ABS X
  2044.             movzx   eax,    wot[edx]        ;N -  eax <- a16Temp
  2045.             movzx   ecx,    byt[edi+4]      ;N -  ecx <- X
  2046.             add     ecx,    eax             ;U -
  2047.             lea     esi,    [esi+2]         ;V -  ++ PC  
  2048.             push    ecx                     ;U -
  2049.             mov     eax,    eax             ;V -            
  2050.             and     bl,     07Dh            ;U -  clr Z-N
  2051.             sub     ah,     ch              ;V -  test CrossPage
  2052.             adc     ebp,    4               ;U -
  2053.             mov     ebx,    ebx             ;V -
  2054.             call    CpuAMread@4             ;N -  
  2055.             mov     $y,     eax             ;U -  Y <- MEM
  2056.             and     eax,    0FFh            ;V -  
  2057.             or      ebx,    dwot[zn_t+eax*4] ;U -  set Z-N
  2058.             jmp     PollInt                 ;V/N -
  2059.                
  2060.  
  2061. OP02:
  2062. OP03:
  2063. OP04:
  2064. OP07:
  2065. OP0B:
  2066. OP0C:
  2067. OP0F:
  2068. OP12:
  2069. OP13:
  2070. OP14:
  2071. OP17:
  2072. OP1A:
  2073. OP1B:
  2074. OP1C:
  2075. OP1F:
  2076. OP22:
  2077. OP23:
  2078. OP27:
  2079. OP2B:
  2080. OP2F:
  2081. OP32:
  2082. OP33:
  2083. OP34:
  2084. OP37:
  2085. OP3A:
  2086. OP3B:
  2087. OP3C:
  2088. OP3F:
  2089. OP42:
  2090. OP43:
  2091. OP44:
  2092. OP47:
  2093. OP4B:
  2094. OP4F:
  2095. OP52:
  2096. OP53:
  2097. OP54:
  2098. OP57:
  2099. OP5A:
  2100. OP5B:
  2101. OP5C:
  2102. OP5F:
  2103. OP62:
  2104. OP63:
  2105. OP64:
  2106. OP67:
  2107. OP6B:
  2108. OP6F:
  2109. OP72:
  2110. OP73:
  2111. OP74:
  2112. OP77:
  2113. OP7A:
  2114. OP7B:
  2115. OP7C:
  2116. OP7F:
  2117. OP80:
  2118. OP82:
  2119. OP83:
  2120. OP87:
  2121. OP89:
  2122. OP8B:
  2123. OP8F:
  2124. OP92:
  2125. OP93:
  2126. OP97:
  2127. OP9B:
  2128. OP9C:
  2129. OP9E:
  2130. OP9F:
  2131. OPA3:
  2132. OPA7:
  2133. OPAB:
  2134. OPAF:
  2135. OPB2:
  2136. OPB3:
  2137. OPB7:
  2138. OPBB:
  2139. OPBF:
  2140. OPC2:
  2141. OPC3:
  2142. OPC7:
  2143. OPCB:
  2144. OPCF:
  2145. OPD2:
  2146. OPD3:
  2147. OPD4:
  2148. OPD7:
  2149. OPDA:
  2150. OPDB:
  2151. OPDC:
  2152. OPDF:
  2153. OPE2:
  2154. OPE3:
  2155. OPE7:
  2156. OPEB:
  2157. OPEF:
  2158. OPF2:
  2159. OPF3:
  2160. OPF4:
  2161. OPF7:
  2162. OPFA:
  2163. OPFB:
  2164. OPFC:
  2165. OPFF:
  2166.     int 3
  2167.         ALIGNXMM
  2168. OPTAB   dd  OP00, OP01, OP02, OP03, OP04, OP05, OP06, OP07, OP08, OP09, OP0A, OP0B, OP0C, OP0D, OP0E, OP0F
  2169.         dd  OP10, OP11, OP12, OP13, OP14, OP15, OP16, OP17, OP18, OP19, OP1A, OP1B, OP1C, OP1D, OP1E, OP1F
  2170.         dd  OP20, OP21, OP22, OP23, OP24, OP25, OP26, OP27, OP28, OP29, OP2A, OP2B, OP2C, OP2D, OP2E, OP2F
  2171.         dd  OP30, OP31, OP32, OP33, OP34, OP35, OP36, OP37, OP38, OP39, OP3A, OP3B, OP3C, OP3D, OP3E, OP3F
  2172.         dd  OP40, OP41, OP42, OP43, OP44, OP45, OP46, OP47, OP48, OP49, OP4A, OP4B, OP4C, OP4D, OP4E, OP4F
  2173.         dd  OP50, OP51, OP52, OP53, OP54, OP55, OP56, OP57, OP58, OP59, OP5A, OP5B, OP5C, OP5D, OP5E, OP5F
  2174.         dd  OP60, OP61, OP62, OP63, OP64, OP65, OP66, OP67, OP68, OP69, OP6A, OP6B, OP6C, OP6D, OP6E, OP6F
  2175.         dd  OP70, OP71, OP72, OP73, OP74, OP75, OP76, OP77, OP78, OP79, OP7A, OP7B, OP7C, OP7D, OP7E, OP7F
  2176.         dd  OP80, OP81, OP82, OP83, OP84, OP85, OP86, OP87, OP88, OP89, OP8A, OP8B, OP8C, OP8D, OP8E, OP8F
  2177.         dd  OP90, OP91, OP92, OP93, OP94, OP95, OP96, OP97, OP98, OP99, OP9A, OP9B, OP9C, OP9D, OP9E, OP9F
  2178.         dd  OPA0, OPA1, OPA2, OPA3, OPA4, OPA5, OPA6, OPA7, OPA8, OPA9, OPAA, OPAB, OPAC, OPAD, OPAE, OPAF
  2179.         dd  OPB0, OPB1, OPB2, OPB3, OPB4, OPB5, OPB6, OPB7, OPB8, OPB9, OPBA, OPBB, OPBC, OPBD, OPBE, OPBF
  2180.         dd  OPC0, OPC1, OPC2, OPC3, OPC4, OPC5, OPC6, OPC7, OPC8, OPC9, OPCA, OPCB, OPCC, OPCD, OPCE, OPCF
  2181.         dd  OPD0, OPD1, OPD2, OPD3, OPD4, OPD5, OPD6, OPD7, OPD8, OPD9, OPDA, OPDB, OPDC, OPDD, OPDE, OPDF
  2182.         dd  OPE0, OPE1, OPE2, OPE3, OPE4, OPE5, OPE6, OPE7, OPE8, OPE9, OPEA, OPEB, OPEC, OPED, OPEE, OPEF
  2183.         dd  OPF0, OPF1, OPF2, OPF3, OPF4, OPF5, OPF6, OPF7, OPF8, OPF9, OPFA, OPFB, OPFC, OPFD, OPFE, OPFF
  2184. ; trans REG to REG
  2185. ; tXN
  2186. ;   X source REG
  2187. ;   N target REG
  2188. ; TXS not set Z-N flag (only this.. other must set Z-N flag)...
  2189. ; cycles all 2 cycles ...
  2190.  
  2191.         OPAA: ; TAX
  2192.             and     ebx,    07Dh                ;U -
  2193.             mov     eax,    $a                  ;V -  eax <- A      
  2194.             mov     $x,     eax                 ;U -  X <- eax
  2195.             and     eax,    0FFh                ;V -  
  2196.             add     ebp,    2                   ;U -  
  2197.             or      ebx,    dwot[zn_t+eax*4];V -  
  2198.             jmp     PollInt                     ;N -  
  2199.            
  2200.         OP8A: ; TXA
  2201.             and     ebx,    07Dh                ;U -  
  2202.             mov     eax,    $x                  ;V -  eax <- X  
  2203.             mov     $a,     eax                 ;U -  A <- eax
  2204.             and     eax,    0FFh                ;V -  
  2205.             add     ebp,    2                   ;U -  
  2206.             or      ebx,    dwot[zn_t+eax*4];V -  
  2207.             jmp     PollInt                     ;N -  
  2208.            
  2209.         OPA8: ; TAY
  2210.             and     ebx,    07Dh                ;U -  
  2211.             mov     eax,    $a                  ;V -  eax <- A      
  2212.             mov     $y,     eax                 ;U -  Y <- eax
  2213.             and     eax,    0FFh                ;V -  
  2214.             add     ebp,    2                   ;U -  
  2215.             or      ebx,    dwot[zn_t+eax*4];V -  
  2216.             jmp     PollInt                     ;N -  
  2217.        
  2218.         OP98: ; TYA
  2219.             and     ebx,    07Dh                ;U -  
  2220.             mov     eax,    $y                  ;V -  eax <- Y      
  2221.             mov     $a,     eax                 ;U -  A <- eax
  2222.             and     eax,    0FFh                ;V -  
  2223.             add     ebp,    2                   ;U -  
  2224.             or      ebx,    dwot[zn_t+eax*4];V -  
  2225.             jmp     PollInt                     ;N -  
  2226.            
  2227.         OPBA: ; TSX    
  2228.             and     ebx,    07Dh                ;U -  
  2229.             mov     eax,    $s                  ;V -  eax <- S      
  2230.             mov     $x,     eax                 ;U -  X <- eax
  2231.             and     eax,    0FFh                ;V -  
  2232.             add     ebp,    2                   ;U -  
  2233.             or      ebx,    dwot[zn_t+eax*4];V -  
  2234.             jmp     PollInt                     ;N -  
  2235.            
  2236.         OP9A: ; TXS (RTOR only this not set flag)
  2237.             mov     eax,    $x                  ;U -  eax <- X          
  2238.             add     ebp,    2                   ;V -  
  2239.             mov     $s,     eax                 ;U -  S <- eax
  2240.             jmp     PollInt                     ;N -  
  2241. ;***
  2242. ;   ASL
  2243. ;               0A: ACC             2 cycles
  2244. ;               06: ZERO PAGE       5 cycles
  2245. ;               16: ZERO PAGE X     6 cycles
  2246. ;               0E: ABS             6 cycles
  2247. ;               1E: ABS X           7 cycles
  2248. ;   Algorithm:
  2249. ;  
  2250. ;           SET_CARRY(src & 0x80);
  2251. ;           src <<= 1;
  2252. ;           src &= 0xff;
  2253. ;           SET_SIGN(src);
  2254. ;           SET_ZERO(src);
  2255. ;           STORE src in memory or accumulator depending on addressing mode.
  2256. ;
  2257. ;*************************************************      
  2258.  
  2259.             OP0A: ; ASL A - 2 cycles        
  2260.                 movzx   eax,    byt[edi]    ;N -  eax <- A  
  2261.                 and     ebx,    01111100b   ;U -  clr N-Z-C
  2262.                 lea     ebp,    [ebp+2]     ;V -  2 Cycles
  2263.                 shl     al,     1           ;U -  ASL A
  2264.                 mov     dl,     dl          ;V -  
  2265.                 adc     ebx,    0           ;U -  set C
  2266.                 mov     $a,     eax         ;V -  A <- eax  
  2267.                 or      ebx,    dwot[zn_t+eax*4] ;U -  set Z-N
  2268.                 jmp     PollInt             ;V - /N
  2269.                
  2270.             OP06: ; ASL ZERO PAGE 5 cycles
  2271.                 movzx   edx,    byt[edx]    ;N -  edx <- a8Real
  2272.                 movzx   eax,    byt[ram+edx];N -  eax <- MEM
  2273.                 and     ebx,    01111100b   ;U -  clr N-Z-C
  2274.                 lea     ebp,    [ebp+5]     ;V -  5 Cycles
  2275.                 shl     al,     1           ;U -  ASL
  2276.                 mov     dl,     dl          ;V -  
  2277.                 adc     ebx,    0           ;U -  set C
  2278.                 lea     esi,    [esi+1]     ;V -  ++ PC
  2279.                 mov     byt[ram+edx], al    ;U -  MEM <- eax
  2280.                 or      bl,     byt[zn_t+eax*4] ;V -  set Z-N
  2281.                 jmp     PollInt             ;N -  
  2282.                
  2283.             OP16: ; ASL ZERO PAGE X
  2284.                 movzx   edx,    byt[edx]    ;N -  edx <- a8Temp
  2285.                 add     dl,     byt[edi+4]  ;U -  edx <- a8Real
  2286.                 mov     al,     al          ;V -  
  2287.                 movzx   eax,    byt[ram+edx];N -  eax <- MEM  
  2288.                 and     ebx,    01111100b   ;U -  clr N-Z-C
  2289.                 lea     ebp,    [ebp+6]     ;V -  6 Cycles
  2290.                 shl     al,     1           ;U -  ASL
  2291.                 mov     dl,     dl          ;V -  
  2292.                 adc     ebx,    0           ;U -  set C
  2293.                 lea     esi,    [esi+1]     ;V -  ++ PC
  2294.                 mov     byt[ram+edx], al    ;U -  MEM <- eax
  2295.                 or      bl,     byt[zn_t+eax*4] ;V -  set Z-N
  2296.                 jmp     PollInt             ;N -
  2297.                
  2298.             OP0E: ; ASL ABS    
  2299.                 mov     ax,     wot[edx]    ;U -  eax <- a16Real
  2300.                 add     si,     2           ;V -  ++ PC                
  2301.                 mov     $t1,    eax         ;U -  t1 <- a16Real
  2302.                 push    eax                 ;V -  
  2303.                 call    CpuAMread@4         ;N -  
  2304.                 and     eax,    0FFh        ;U -  purify
  2305.                 and     ebx,    01111100b   ;V -  clr Z-N-C
  2306.                 shl     al,     1           ;U -  ASL
  2307.                 mov     dl,     dl          ;V -  
  2308.                 adc     ebx,    0           ;U -  set C
  2309.                 lea     ebp,    [ebp+6]     ;V -  6 Cycles
  2310.                 or      ebx,    dwot[zn_t+eax*4]    ;U -  set Z-N  
  2311.                 push    eax                 ;V -  push MEM
  2312.                 push    $t1                 ;U -  push a16Real
  2313.                 mov     eax,    eax         ;V -  
  2314.                 call    CpuAMwrite@8            ;N -  
  2315.                 jmp     PollInt             ;N -  
  2316.  
  2317.             OP1E: ; ASL ABS X
  2318.                 movzx   ecx,    byt[edi+4]  ;N -  ecx <- X
  2319.                 mov     ax,     wot[edx]    ;U -  eax <- a16Temp
  2320.                 mov     bx,     bx          ;V -  
  2321.                 add     ax,     cx          ;U -  eax <- a16Real
  2322.                 add     si,     2           ;V -  ++ PC                
  2323.                 mov     $t1,    eax         ;U -  t1 <- a16Real
  2324.                 push    eax                 ;V -  
  2325.                 call    CpuAMread@4         ;N -  
  2326.                 and     eax,    0FFh        ;U -  purify
  2327.                 and     ebx,    01111100b   ;V -  clr Z-N-C
  2328.                 shl     al,     1           ;U -  ASL
  2329.                 mov     dl,     dl          ;V -  
  2330.                 adc     ebx,    0           ;U -  set C
  2331.                 lea     ebp,    [ebp+7]     ;V -  7 Cycles
  2332.                 or      ebx,    dwot[zn_t+eax*4]    ;U -  set Z-N
  2333.                 push    eax                 ;V -  push MEM
  2334.                 push    $t1                 ;U -  push a16Real
  2335.                 mov     eax,    eax         ;V -  
  2336.                 call    CpuAMwrite@8            ;N -  
  2337.                 jmp     PollInt             ;N -  
  2338.  
  2339. ;***
  2340. ;   LSR
  2341. ;               4A: ACC             2 cycles
  2342. ;               46: ZERO PAGE       5 cycles
  2343. ;               56: ZERO PAGE X     6 cycles
  2344. ;               4E: ABS             6 cycles
  2345. ;               5E: ABS X           7 cycles
  2346. ;   Algorithm:
  2347. ;  
  2348. ;           SET_CARRY(src & 0x01);
  2349. ;           src >>= 1;
  2350. ;           SET_SIGN(src);
  2351. ;           SET_ZERO(src);
  2352. ;           STORE src in memory or accumulator depending on addressing mode.
  2353. ;
  2354. ;*************************************************
  2355.    
  2356.             OP4A: ; LSR A
  2357.                 movzx   eax,    byt[edi]    ;N -  eax <- A  
  2358.                 and     ebx,    01111100b   ;U -  clr N-Z-C
  2359.                 lea     ebp,    [ebp+2]     ;V -  2 Cycles
  2360.                 shr     al,     1           ;U -  LSR A
  2361.                 mov     dl,     dl          ;V -  
  2362.                 adc     ebx,    0           ;U -  set C
  2363.                 mov     $a,     eax         ;V -  A <- eax  
  2364.                 or      ebx,    dwot[zn_t+eax*4] ;U -  set Z-N
  2365.                 jmp     PollInt             ;V - /N
  2366.                
  2367.             OP46: ; LSR ZERO PAGE
  2368.                 movzx   edx,    byt[edx]    ;N -  edx <- a8Real
  2369.                 movzx   eax,    byt[ram+edx];N -  eax <- MEM
  2370.                 and     ebx,    01111100b   ;U -  clr N-Z-C
  2371.                 lea     ebp,    [ebp+5]     ;V -  5 Cycles
  2372.                 shr     al,     1           ;U -  LSR
  2373.                 mov     dl,     dl          ;V -  
  2374.                 adc     ebx,    0           ;U -  set C
  2375.                 lea     esi,    [esi+1]     ;V -  ++ PC
  2376.                 mov     byt[ram+edx], al    ;U -  MEM <- eax
  2377.                 or      bl,     byt[zn_t+eax*4] ;V -  set Z-N
  2378.                 jmp     PollInt             ;N -  
  2379.                
  2380.             OP56: ; LSR ZERO PAGE X
  2381.                 movzx   edx,    byt[edx]    ;N -  edx <- a8Temp
  2382.                 add     dl,     byt[edi+4]  ;U -  edx <- a8Real
  2383.                 mov     al,     al          ;V -  
  2384.                 movzx   eax,    byt[ram+edx];N -  eax <- MEM  
  2385.                 and     ebx,    01111100b   ;U -  clr N-Z-C
  2386.                 lea     ebp,    [ebp+6]     ;V -  6 Cycles
  2387.                 shr     al,     1           ;U -  LSR
  2388.                 mov     dl,     dl          ;V -  
  2389.                 adc     ebx,    0           ;U -  set C
  2390.                 lea     esi,    [esi+1]     ;V -  ++ PC
  2391.                 mov     byt[ram+edx], al    ;U -  MEM <- eax
  2392.                 or      bl,     byt[zn_t+eax*4] ;V -  set Z-N
  2393.                 jmp     PollInt             ;N -
  2394.                
  2395.             OP4E: ; LSR ABS
  2396.                 mov     ax,     wot[edx]    ;U -  eax <- a16Real
  2397.                 add     si,     2           ;V -  ++ PC                
  2398.                 mov     $t1,    eax         ;U -  t1 <- a16Real
  2399.                 push    eax                 ;V -  
  2400.                 call    CpuAMread@4         ;N -  
  2401.                 and     eax,    0FFh        ;U -  purify
  2402.                 and     ebx,    01111100b   ;V -  clr Z-N-C
  2403.                 shr     al,     1           ;U -  LSR
  2404.                 mov     dl,     dl          ;V -  
  2405.                 adc     ebx,    0           ;U -  set C
  2406.                 lea     ebp,    [ebp+6]     ;V -  6 Cycles
  2407.                 or      ebx,    dwot[zn_t+eax*4]    ;U -  set Z-N  
  2408.                 push    eax                 ;V -  push MEM
  2409.                 push    $t1                 ;U -  push a16Real
  2410.                 mov     eax,    eax         ;V -  
  2411.                 call    CpuAMwrite@8            ;N -  
  2412.                 jmp     PollInt             ;N -  
  2413.                
  2414.             OP5E: ; LSR ABS X
  2415.                 movzx   ecx,    byt[edi+4]  ;N -  ecx <- X
  2416.                 mov     ax,     wot[edx]    ;U -  eax <- a16Temp
  2417.                 mov     bx,     bx          ;V -  
  2418.                 add     ax,     cx          ;U -  eax <- a16Real
  2419.                 add     si,     2           ;V -  ++ PC                
  2420.                 mov     $t1,    eax         ;U -  t1 <- a16Real
  2421.                 push    eax                 ;V -  
  2422.                 call    CpuAMread@4         ;N -  
  2423.                 and     eax,    0FFh        ;U -  purify
  2424.                 and     ebx,    01111100b   ;V -  clr Z-N-C
  2425.                 shr     al,     1           ;U -  LSR
  2426.                 mov     dl,     dl          ;V -  
  2427.                 adc     ebx,    0           ;U -  set C
  2428.                 lea     ebp,    [ebp+7]     ;V -  7 Cycles
  2429.                 or      ebx,    dwot[zn_t+eax*4]    ;U -  set Z-N
  2430.                 push    eax                 ;V -  push MEM
  2431.                 push    $t1                 ;U -  push a16Real
  2432.                 mov     eax,    eax         ;V -  
  2433.                 call    CpuAMwrite@8            ;N -  
  2434.                 jmp     PollInt             ;N -  
  2435.  
  2436. ;***
  2437. ;   ROL
  2438. ;               2A: ACC             2 cycles
  2439. ;               26: ZERO PAGE       5 cycles
  2440. ;               36: ZERO PAGE X     6 cycles
  2441. ;               2E: ABS             6 cycles
  2442. ;               3E: ABS X           7 cycles
  2443. ;   Algorithm:
  2444. ;  
  2445. ;           src <<= 1;
  2446. ;           if (IF_CARRY()) {
  2447. ;               src |= 0x1;
  2448. ;           }
  2449. ;           SET_CARRY(src > 0xff);
  2450. ;           src &= 0xff;
  2451. ;           SET_SIGN(src);
  2452. ;           SET_ZERO(src);
  2453. ;           STORE src in memory or accumulator depending on addressing mode.
  2454. ;
  2455. ;*************************************************      
  2456.  
  2457.                
  2458.             OP2A: ; ROL A      
  2459.                 movzx   eax,    byt[edi]    ;N -  eax <- A
  2460.                 and     ebx,    01111101b   ;U -  set C    
  2461.                 lea     ebp,    [ebp+2]     ;V -  2 Cycles
  2462.                 shr     ebx,    1           ;U -  throw C
  2463.                 mov     eax,    eax         ;V -  
  2464.                 rcl     al,     1           ;N -  ROL A
  2465.                 rcl     bl,     1           ;N -  receive C
  2466.                 mov     $a,     eax         ;U -  A <- eax
  2467.                 or      ebx,    dwot[zn_t+eax*4]    ;V -  set Z-N
  2468.                 jmp     PollInt             ;N -
  2469.                
  2470.             OP26: ; ROL ZERO PAGE
  2471.                 movzx   edx,    byt[edx]    ;N -  edx <- a8Real
  2472.                 movzx   eax,    byt[ram+edx];N -  eax <- MEM
  2473.                 and     ebx,    01111101b   ;U -  set C    
  2474.                 lea     ebp,    [ebp+5]     ;V -  5 Cycles
  2475.                 shr     ebx,    1           ;U -  throw C
  2476.                 lea     esi,    [esi+1]     ;V -  ++ PC
  2477.                 rcl     al,     1           ;N -  ROL
  2478.                 rcl     bl,     1           ;N -  receive C
  2479.                 mov     byt[ram+edx], al    ;U -  MEM <- eax
  2480.                 or      bl,     byt[zn_t+eax*4] ;V -  set Z-N
  2481.                 jmp     PollInt             ;N -
  2482.                
  2483.                
  2484.             OP36: ; ROL ZERO PAGE X
  2485.                 movzx   edx,    byt[edx]    ;N -  edx <- a8Temp
  2486.                 add     dl,     byt[edi+4]  ;U -  edx <- a8Real
  2487.                 mov     bl,     bl          ;V -
  2488.                 movzx   eax,    byt[ram+edx];N -  eax <- MEM
  2489.                 and     ebx,    01111101b   ;U -  set C    
  2490.                 lea     ebp,    [ebp+6]     ;V -  6 Cycles
  2491.                 shr     ebx,    1           ;U -  throw C
  2492.                 lea     esi,    [esi+1]     ;V -  ++ PC
  2493.                 rcl     al,     1           ;N -  ROL
  2494.                 rcl     bl,     1           ;N -  receive C
  2495.                 mov     byt[ram+edx], al    ;U -  MEM <- eax
  2496.                 or      bl,     byt[zn_t+eax*4] ;V -  set Z-N
  2497.                 jmp     PollInt             ;N -
  2498.            
  2499.             OP2E: ; ROL ABS
  2500.                 mov     ax,     wot[edx]    ;U -  eax <- a16Real
  2501.                 add     si,     2           ;V -  ++ PC
  2502.                 mov     $t1,    eax         ;U -  t1 <- a16Real
  2503.                 push    eax                 ;V -  
  2504.                 call    CpuAMread@4         ;N -  
  2505.                 and     eax,    0FFh        ;U -  purify
  2506.                 and     ebx,    01111101b   ;V -  clr Z-N-C
  2507.                 shr     ebx,    1           ;U -  throw C
  2508.                 lea     ebp,    [ebp+6]     ;V -  6 Cycles
  2509.                 rcl     al,     1           ;N -  ROL
  2510.                 rcl     bl,     1           ;N -  receive C
  2511.                 push    eax                 ;U -  
  2512.                 push    $t1                 ;V -  
  2513.                 mov     edx,    edx         ;U -
  2514.                 or      ebx,    dwot[zn_t+eax*4]    ;V -  reset Z-N Flags
  2515.                 call    CpuAMwrite@8            ;N -  
  2516.                 jmp     PollInt             ;N -  
  2517.  
  2518.  
  2519.             OP3E: ; ROL ABS X  
  2520.                 movzx   ecx,    byt[edi+4]  ;N -  ecx <- X
  2521.                 mov     ax,     wot[edx]    ;U -  eax <- a16Temp
  2522.                 add     si,     2           ;V -  ++ PC
  2523.                 add     ax,     cx          ;U -  eax <- a16Real
  2524.                 mov     dx,     dx          ;V -
  2525.                 mov     $t1,    eax         ;U -  t1 <- a16Real
  2526.                 push    eax                 ;V -  
  2527.                 call    CpuAMread@4         ;N -  
  2528.                 and     eax,    0FFh        ;U -  purify
  2529.                 and     ebx,    01111101b   ;V -  clr Z-N-C
  2530.                 shr     ebx,    1           ;U -  throw C
  2531.                 lea     ebp,    [ebp+7]     ;V -  7 Cycles
  2532.                 rcl     al,     1           ;N -  ROL
  2533.                 rcl     bl,     1           ;N -  receive C
  2534.                 push    eax                 ;U -  
  2535.                 push    $t1                 ;V -  
  2536.                 mov     edx,    edx         ;U -
  2537.                 or      ebx,    dwot[zn_t+eax*4]    ;V -  reset Z-N Flags
  2538.                 call    CpuAMwrite@8            ;N -  
  2539.                 jmp     PollInt             ;N -  
  2540.                
  2541. ;***
  2542. ;   ROR
  2543. ;               6A: ACC             2 cycles
  2544. ;               66: ZERO PAGE       5 cycles
  2545. ;               76: ZERO PAGE X     6 cycles
  2546. ;               6E: ABS             6 cycles
  2547. ;               7E: ABS X           7 cycles
  2548. ;   Algorithm:
  2549. ;  
  2550. ;           if (IF_CARRY()) {
  2551. ;               src |= 0x100;
  2552. ;           }
  2553. ;           SET_CARRY(src & 0x01);
  2554. ;           src >>= 1;
  2555. ;           SET_SIGN(src);
  2556. ;           SET_ZERO(src);
  2557. ;           STORE src in memory or accumulator depending on addressing mode.
  2558. ;
  2559. ;*************************************************  
  2560.  
  2561.             OP6A: ; ROR A
  2562.                 movzx   eax,    byt[edi]    ;N -  eax <- A
  2563.                 and     ebx,    01111101b   ;U -  set C    
  2564.                 lea     ebp,    [ebp+2]     ;V -  2 Cycles
  2565.                 shr     ebx,    1           ;U -  throw C
  2566.                 mov     eax,    eax         ;V -  
  2567.                 rcr     al,     1           ;N -  ROR A
  2568.                 rcl     bl,     1           ;N -  receive C
  2569.                 mov     $a,     eax         ;U -  A <- eax
  2570.                 or      ebx,    dwot[zn_t+eax*4]    ;V -  set Z-N
  2571.                 jmp     PollInt             ;N -    
  2572.                
  2573.             OP66: ; ROR ZERO PAGE
  2574.                 movzx   edx,    byt[edx]    ;N -  edx <- a8Real
  2575.                 movzx   eax,    byt[ram+edx];N -  eax <- MEM
  2576.                 and     ebx,    01111101b   ;U -  set C    
  2577.                 lea     ebp,    [ebp+5]     ;V -  5 Cycles
  2578.                 shr     ebx,    1           ;U -  throw C
  2579.                 lea     esi,    [esi+1]     ;V -  ++ PC
  2580.                 rcr     al,     1           ;N -  ROR
  2581.                 rcl     bl,     1           ;N -  receive C
  2582.                 mov     byt[ram+edx], al    ;U -  MEM <- eax
  2583.                 or      bl,     byt[zn_t+eax*4] ;V -  set Z-N
  2584.                 jmp     PollInt             ;N -
  2585.                
  2586.                
  2587.             OP76: ; ROR ZERO PAGE X
  2588.                 movzx   edx,    byt[edx]    ;N -  edx <- a8Temp
  2589.                 add     dl,     byt[edi+4]  ;U -  edx <- a8Real
  2590.                 mov     bl,     bl          ;V -
  2591.                 movzx   eax,    byt[ram+edx];N -  eax <- MEM
  2592.                 and     ebx,    01111101b   ;U -  set C    
  2593.                 lea     ebp,    [ebp+6]     ;V -  6 Cycles
  2594.                 shr     ebx,    1           ;U -  throw C
  2595.                 lea     esi,    [esi+1]     ;V -  ++ PC
  2596.                 rcr     al,     1           ;N -  ROR
  2597.                 rcl     bl,     1           ;N -  receive C
  2598.                 mov     byt[ram+edx], al    ;U -  MEM <- eax
  2599.                 or      bl,     byt[zn_t+eax*4] ;V -  set Z-N
  2600.                 jmp     PollInt             ;N -
  2601.            
  2602.             OP6E: ; ROR ABS
  2603.                 mov     ax,     wot[edx]    ;U -  eax <- a16Real
  2604.                 add     si,     2           ;V -  ++ PC
  2605.                 mov     $t1,    eax         ;U -  t1 <- a16Real
  2606.                 push    eax                 ;V -  
  2607.                 call    CpuAMread@4         ;N -  
  2608.                 and     eax,    0FFh        ;U -  purify
  2609.                 and     ebx,    01111101b   ;V -  clr Z-N-C
  2610.                 shr     ebx,    1           ;U -  throw C
  2611.                 lea     ebp,    [ebp+6]     ;V -  6 Cycles
  2612.                 rcr     al,     1           ;N -  ROR
  2613.                 rcl     bl,     1           ;N -  receive C
  2614.                 push    eax                 ;U -  
  2615.                 push    $t1                 ;V -  
  2616.                 mov     edx,    edx         ;U -
  2617.                 or      ebx,    dwot[zn_t+eax*4]    ;V -  reset Z-N Flags
  2618.                 call    CpuAMwrite@8            ;N -  
  2619.                 jmp     PollInt             ;N -  
  2620.                        
  2621.             OP7E: ; ROR ABS X  
  2622.                 movzx   ecx,    byt[edi+4]  ;N -  ecx <- X
  2623.                 mov     ax,     wot[edx]    ;U -  eax <- a16Temp
  2624.                 add     si,     2           ;V -  ++ PC
  2625.                 add     ax,     cx          ;U -  eax <- a16Real
  2626.                 mov     dx,     dx          ;V -
  2627.                 mov     $t1,    eax         ;U -  t1 <- a16Real
  2628.                 push    eax                 ;V -  
  2629.                 call    CpuAMread@4         ;N -  
  2630.                 and     eax,    0FFh        ;U -  purify
  2631.                 and     ebx,    01111101b   ;V -  clr Z-N-C
  2632.                 shr     ebx,    1           ;U -  throw C
  2633.                 lea     ebp,    [ebp+7]     ;V -  7 Cycles
  2634.                 rcr     al,     1           ;N -  ROR
  2635.                 rcl     bl,     1           ;N -  receive C
  2636.                 push    eax                 ;U -  
  2637.                 push    $t1                 ;V -  
  2638.                 mov     edx,    edx         ;U -
  2639.                 or      ebx,    dwot[zn_t+eax*4]    ;V -  reset Z-N Flags
  2640.                 call    CpuAMwrite@8            ;N -  
  2641.                 jmp     PollInt             ;N -  
  2642.         OP00:
  2643.         OPEA:
  2644.         ; When the MOS 6502 processor was modified into the Ricoh 2A03 chip for the NES,\
  2645.         ; the BRK (Force Break) opcode was eliminated.
  2646.         ; Thus, the BRK command doesn't actually do anything on the NES and is effectively identical to NOP.
  2647.         ; Because of this, when you see a BRK in decompiled NES code,\
  2648.         ; you can be fairly certain that the #00 value is either game data or unused.
  2649.         ; Having a BRK execute on the NES won't harm anything, it will only eat up a clock cycle to process.
  2650.         ; You can take advantage of this feature when making game cheats.
  2651.         ; For example, if you want to change an opcode that takes a two-byte operand into an opcode that uses a one-byte operand,\
  2652.         ; you can ignore the second byte of the operand if it is a #00 because the NES will simply treat it as a BRK, which is ignored.
  2653.         ; On an original MOS 6502 processor,\
  2654.         ; BRK would set the Interrupt Flag to prevent further interrupts and then move the Program Counter Register to the new location.
  2655.         ; Addressing Modes
  2656.         ; ==================================================================
  2657.         ; Addressing Mode   Assembly Language Form  Opcode  # Bytes # Cycles
  2658.         ; ===============   ======================  ======   ======   =====
  2659.         ;   Implied                 BRK              00         1       2
  2660.         ; ========================================================================
  2661.         ; ref link: www.thealmightyguru.com/Games/Hacking/Wiki/index.php?title=BRK
  2662.         ; ========================================================================
  2663.             add     ebp,    2
  2664.             jmp     PollInt
  2665.             OP48: ; PHA            
  2666.                 mov     eax,    $a                      ;U -  eax <- A
  2667.                 mov     edx,    $s                      ;V -  edx <- S
  2668.                 and     edx,    0FFh                    ;U -  purify
  2669.                 add     ebp,    3                       ;V -  3 Cycles          
  2670.                 mov     byt[ram+0100h+edx], al          ;U -  STACK <- A
  2671.                 dec     dl                              ;V -  STACK --  
  2672.                 mov     $s,     edx                     ;U -  
  2673.                 jmp     PollInt                         ;V -
  2674.                
  2675.             OP08: ; PHP
  2676.                 mov     edx,    $s                      ;U -  edx <- S
  2677.                 add     ebp,    3                       ;V -  3 Cycles      
  2678.                 and     edx,    0FFh                    ;U -  purify
  2679.                 or      ebx,    B_FLAG                  ;V -  set B Flag            
  2680.                 mov     byt[ram+0100h+edx], bl          ;U -  STACK <- P
  2681.                 dec     dl                              ;V -  STACK --          
  2682.                 mov     $s,     edx                     ;U -  
  2683.                 jmp     PollInt                         ;V -
  2684.                
  2685.             OP68: ; PLA
  2686.                 mov     edx,    $s                      ;U -  edx <- S
  2687.                 and     ebx,    07Dh                    ;V -  clr Z-N
  2688.                 and     edx,    0FFh                    ;U -  purify
  2689.                 add     ebp,    4                       ;V -  4 Cycles          
  2690.                 mov     al,     byt[ram+0101h+edx]      ;U -  A <- STACK  
  2691.                 add     dl,     1                       ;V -  ++ STACK          
  2692.                 and     eax,    0FFh                    ;U -  purify
  2693.                 mov     $s,     edx                     ;V -            
  2694.                 mov     $a,     eax                     ;U -  
  2695.                 or      ebx,    dwot[zn_t+eax*4]    ;V -  set Z-N
  2696.                 jmp     PollInt                         ;N -  
  2697.                
  2698.             OP28: ; PLP
  2699.                 mov     edx,    $s                      ;U -  edx <- S          
  2700.                 add     ebp,    4                       ;V -  4 Cycles
  2701.                 and     edx,    0FFh                    ;U -  purify
  2702.                 mov     ecx,    ecx                     ;V -            
  2703.                 mov     bl,     byt[ram+0101h+edx]      ;U -  P <- STACK
  2704.                 add     dl,     1                       ;V -  ++ STACK          
  2705.                 mov     $s,     edx                     ;U -  
  2706.                 jmp     PollInt                         ;V -
  2707.                
  2708. ;***
  2709. ;   BIT
  2710. ;               24: ZERO PAGE       3 cycles
  2711. ;               2C: ABS             4 cycles
  2712. ;   Algorithm:
  2713. ;  
  2714. ;               SET_SIGN(src);
  2715. ;               SET_OVERFLOW(0x40 & src);  
  2716. ;               SET_ZERO(src & AC);
  2717. ;*************************************************  
  2718.  
  2719.         OP24: ; BIT ZERO PAGE 3 cycles
  2720.             movzx   eax,    byt[edx]    ;N -  eax <- a8Real    
  2721.             mov     al,     byt[ram+eax];U -  eax <- MEM    
  2722.             and     bl,     00111101b   ;V -  clr N-Z-V
  2723.             mov     ecx,    $a          ;U -  ecx <- A
  2724.             lea     esi,    [esi+1]     ;V -  ++ PC
  2725.             test    al,     cl          ;U -  
  2726.             mov     bl,     bl          ;V -
  2727.             setz    cl                  ;N -  set Z  
  2728.             and     eax,    0C0h        ;U -  get N-V
  2729.             and     ecx,    001h        ;V -  get Z
  2730.             lea     edx,    [eax+ecx*2] ;U -  mix N-V-Z
  2731.             lea     ebp,    [ebp+3]     ;V -  3 Cycles
  2732.             or      ebx,    edx         ;U -  set N-V-Z
  2733.             jmp     PollInt             ;V -
  2734.            
  2735.         OP2C: ; BIT ABS 4 cycles
  2736.             mov     ax,     wot[edx]    ;U -  eax <- a16Real
  2737.             and     bx,     00111101b   ;V -  clr N-Z-V
  2738.             push    eax                 ;U -
  2739.             lea     esi,    [esi+2]     ;V -  ++ PC
  2740.             call    CpuAMread@4             ;N -
  2741.             mov     ecx,    $a          ;U -  ecx <- A
  2742.             lea     ebx,    [ebx]       ;V -
  2743.             test    al,     cl          ;U -  
  2744.             mov     bl,     bl          ;V -
  2745.             setz    cl                  ;N -  set Z  
  2746.             and     eax,    0C0h        ;U -  get N-V
  2747.             and     ecx,    001h        ;V -  get Z
  2748.             lea     edx,    [eax+ecx*2] ;U -  mix N-V-Z
  2749.             lea     ebp,    [ebp+4]     ;V -  4 Cycles
  2750.             or      ebx,    edx         ;U -  set N-V-Z
  2751.             jmp     PollInt             ;V -
  2752. ;***
  2753. ;   STA  
  2754. ;               85: ZERO PAGE       3 cycles
  2755. ;               95: ZERO PAGE X     4 cycles
  2756. ;               80: ABS             4 cycles
  2757. ;               90: ABS X           5 cycles
  2758. ;               99: ABS Y           5 cycles
  2759. ;               81: X INDIRECT      6 cycles
  2760. ;               91: INDIRECT Y      6 cycles (no test cross page)  
  2761. ;           X   86: ZERO PAGE       3 cycles
  2762. ;           X   96: ZERO PAGE Y     4 cycles
  2763. ;           X   8E: ABS             4 cycles
  2764. ;           Y   84: ZERO PAGE       3 cycles
  2765. ;           Y   94: ZERO PAGE X     4 cycles
  2766. ;           Y   8C: ABS             4 cycles
  2767. ;
  2768. ;   Algorithm:
  2769. ;  
  2770. ;           STORE(address, A);
  2771. ;
  2772. ;*************************************************
  2773.  
  2774. ; =====
  2775.     ;   A
  2776.         ; =====    
  2777.  
  2778.         OP85: ; STA ZERO PAGE
  2779.             movzx   eax,    byt[edx]        ;N -  eax <- a8Real
  2780.             mov     ecx,    $a              ;U -  ecx <- A
  2781.             lea     ebp,    [ebp+3]         ;V -  3 Cycles
  2782.             mov     byt[ram+eax],   cl      ;U -  MEM <- ecx
  2783.             mov     bl,     bl              ;V -
  2784.             lea     esi,    [esi+1]         ;U -  ++ PC
  2785.             jmp     PollInt                 ;V -
  2786.            
  2787.         OP95: ; STA ZERO PAGE X
  2788.             movzx   eax,    byt[edx]        ;N -  eax <- a8Temp
  2789.             add     al,     byt[edi+4]      ;U -
  2790.             mov     dl,     dl              ;V -
  2791.             mov     ecx,    $a              ;U -  ecx <- A
  2792.             lea     ebp,    [ebp+4]         ;V -  4 Cycles
  2793.             mov     byt[ram+eax],   cl      ;U -  MEM <- ecx
  2794.             mov     bl,     bl              ;V -
  2795.             lea     esi,    [esi+1]         ;U -  ++ PC
  2796.             jmp     PollInt                 ;V -
  2797.            
  2798.         OP8D: ; STA ABS
  2799.             movzx   eax,    wot[edx]        ;N -  eax <- a16Real
  2800.             push    $a                      ;U -  
  2801.             push    eax                     ;V -  
  2802.             call    CpuAMwrite@8                ;N -  
  2803.             lea     esi,    [esi+2]         ;U -  ++ PC
  2804.             lea     ebp,    [ebp+4]         ;V -  4 Cycles
  2805.             jmp     PollInt                 ;V -
  2806.            
  2807.         OP9D: ; STA ABS X
  2808.             movzx   eax,    wot[edx]        ;N -  eax <- a16Temp
  2809.             movzx   ecx,    byt[edi+4]      ;N -  ecx <- X  
  2810.             push    $a                      ;U -  
  2811.             add     eax,    ecx             ;V -  eax <- a16Real
  2812.             push    eax                     ;U -  
  2813.             lea     ebp,    [ebp+5]         ;V -  5 Cycles
  2814.             call    CpuAMwrite@8                ;N -  
  2815.             lea     esi,    [esi+2]         ;U -  ++ PC
  2816.             jmp     PollInt                 ;V - /N ...
  2817.            
  2818.         OP99: ; STA ABS Y
  2819.             movzx   eax,    wot[edx]        ;N -  eax <- a16Temp
  2820.             movzx   ecx,    byt[edi+8]      ;N -  ecx <- Y
  2821.             push    $a                      ;U -  
  2822.             add     eax,    ecx             ;V -  eax <- a16Real
  2823.             push    eax                     ;U -  
  2824.             lea     ebp,    [ebp+5]         ;V -  5 Cycles
  2825.             call    CpuAMwrite@8                ;N -  
  2826.             lea     esi,    [esi+2]         ;U -  ++ PC
  2827.             jmp     PollInt                 ;V - /N ...
  2828.            
  2829.         OP81: ; STA X INDIRECT
  2830.             movzx   eax,    byt[edx]        ;N -  eax <- a8Temp
  2831.             add     al,     byt[edi+4]      ;U -  eax <- a8Real
  2832.             mov     cl,     cl              ;V -
  2833.             mov     dx,     wot[eax+ram]    ;U -  edx <- a16Real
  2834.             add     bp,     6               ;V -  6 Cycles
  2835.             push    $a                      ;U -  
  2836.             push    edx                     ;V -  
  2837.             call    CpuAMwrite@8                ;N -  call CpuAMwrite@8
  2838.             add     esi,    1               ;U -  ++ PC
  2839.             jmp     PollInt                 ;V -
  2840.                
  2841.         OP91: ; STA INDIRECT Y
  2842.             movzx   eax,    byt[edx]        ;N -  eax <- a8Real
  2843.             movzx   edx,    byt[edi+8]      ;N -  edx <- Y
  2844.             mov     cx,     wot[ram+eax]    ;U -  ecx <- a16Temp
  2845.             add     si,     1               ;V -  ++ PC
  2846.             add     cx,     dx              ;U -  ecx <- a16Real
  2847.             add     bp,     6               ;V -  6 Cycles
  2848.             push    $a                      ;U -  
  2849.             push    ecx                     ;V -  
  2850.             call    CpuAMwrite@8                ;N -
  2851.             jmp     PollInt                 ;V -
  2852.  
  2853.  
  2854. ; =====
  2855.     ;   X
  2856.         ; =====    
  2857.        
  2858.         OP86: ; STX ZERO PAGE
  2859.             movzx   eax,    byt[edx]        ;N -  eax <- a8Real
  2860.             mov     ecx,    $x              ;U -  ecx <- X
  2861.             lea     ebp,    [ebp+3]         ;V -  3 Cycles
  2862.             mov     byt[ram+eax],   cl      ;U -  MEM <- ecx
  2863.             mov     bl,     bl              ;V -
  2864.             lea     esi,    [esi+1]         ;U -  ++ PC
  2865.             jmp     PollInt                 ;V -
  2866.                
  2867.         OP96: ; STX ZERO PAGE Y
  2868.             movzx   eax,    byt[edx]        ;N -  eax <- a8Temp
  2869.             add     al,     byt[edi+8]      ;U -
  2870.             mov     dl,     dl              ;V -
  2871.             mov     ecx,    $x              ;U -  ecx <- X
  2872.             lea     ebp,    [ebp+4]         ;V -  4 Cycles
  2873.             mov     byt[ram+eax],   cl      ;U -  MEM <- ecx
  2874.             mov     bl,     bl              ;V -
  2875.             lea     esi,    [esi+1]         ;U -  ++ PC
  2876.             jmp     PollInt                 ;V -
  2877.                    
  2878.         OP8E: ; STX ABS
  2879.             movzx   eax,    wot[edx]        ;N -  eax <- a16Real
  2880.             push    $x                      ;U -  
  2881.             push    eax                     ;V -  
  2882.             call    CpuAMwrite@8                ;N -  
  2883.             lea     esi,    [esi+2]         ;U -  ++ PC
  2884.             lea     ebp,    [ebp+4]         ;V -  4 Cycles
  2885.             jmp     PollInt                 ;V -
  2886.  
  2887.  
  2888. ; =====
  2889.     ;   y
  2890.         ; =====    
  2891.        
  2892.         OP84: ; STY ZERO PAGE
  2893.             movzx   eax,    byt[edx]        ;N -  eax <- a8Real
  2894.             mov     ecx,    $y              ;U -  ecx <- Y
  2895.             lea     ebp,    [ebp+3]         ;V -  3 Cycles
  2896.             mov     byt[ram+eax],   cl      ;U -  MEM <- ecx
  2897.             mov     bl,     bl              ;V -
  2898.             lea     esi,    [esi+1]         ;U -  ++ PC
  2899.             jmp     PollInt                 ;V -
  2900.            
  2901.         OP94: ; STY ZERO PAGE X
  2902.             movzx   eax,    byt[edx]        ;N -  eax <- a8Temp
  2903.             add     al,     byt[edi+4]      ;U -
  2904.             mov     dl,     dl              ;V -
  2905.             mov     ecx,    $y              ;U -  ecx <- Y
  2906.             lea     ebp,    [ebp+4]         ;V -  4 Cycles
  2907.             mov     byt[ram+eax],   cl      ;U -  MEM <- ecx
  2908.             mov     bl,     bl              ;V -
  2909.             lea     esi,    [esi+1]         ;U -  ++ PC
  2910.             jmp     PollInt                 ;V -
  2911.            
  2912.         OP8C: ; STY ABS
  2913.             movzx   eax,    wot[edx]        ;N -  eax <- a16Real
  2914.             push    $y                      ;U -  
  2915.             push    eax                     ;V -  
  2916.             call    CpuAMwrite@8                ;N -  
  2917.             lea     esi,    [esi+2]         ;U -  ++ PC
  2918.             lea     ebp,    [ebp+4]         ;V -  4 Cycles
  2919.             jmp     PollInt                 ;V -
  2920.        
  2921.                 ALIGNXMM
  2922.                 PollInt:
  2923.                         mov     eax,    dwot[int_pending]   ;U -  load Pending signal
  2924.                         and     eax,    3                   ;V -  clr bits
  2925.                         lea     ecx,    [ecx]               ;U -  
  2926.                         jmp     dwot[INT_TAB+eax*4]         ;V -  decode interrupt
  2927.                         ALIGNXMM
  2928.                         IRQ_:                  
  2929.                             and     eax,    1               ;U -  clr NMI flag ...
  2930.                             mov     ecx,    $s              ;V -  load S stack
  2931.                             and     ecx,    0FFh            ;U -  clr bits
  2932.                             lea     edx,    [edx]           ;V -        
  2933.                             mov     dwot[int_pending],  eax ;U -  write back Pending_int            
  2934.                             mov     wot[ecx+ram+0100h-1], si;V -  push now PC
  2935.                             and     ebx,    0EFh            ;U -  clr B flag ...
  2936.                             add     ebp,    INT_C           ;V -  add INT Cycles
  2937.                             mov     byt[ecx+ram+0100h-2], bl;U -  push Flags
  2938.                             sub     cl,     3               ;V -  sub Stack
  2939.                             or      ebx,    I_FLAG          ;U -  set Interrupt Disable Flags
  2940.                             mov     eax,    dwot[cpuBanks+28];V -  get last Bank
  2941.                             mov     $s,     ecx             ;U -  write back Stack          
  2942.                             mov     si,     wot[eax+01FFEh] ;V - /N set IRQ addr
  2943.                             jmp     main_Loop               ;N -                            
  2944.                         ALIGNXMM
  2945.                         NMI_:
  2946.                             and     eax,    1               ;U -  clr NMI flag ...
  2947.                             mov     ecx,    $s              ;V -  load S stack
  2948.                             and     ecx,    0FFh            ;U -  clr bits
  2949.                             lea     edx,    [edx]           ;V -        
  2950.                             mov     dwot[int_pending],  eax ;U -  write back Pending_int            
  2951.                             mov     wot[ecx+ram+0100h-1], si;V -  push now PC
  2952.                             and     ebx,    0EFh            ;U -  clr B flag ...
  2953.                             add     ebp,    INT_C           ;V -  add INT Cycles
  2954.                             mov     byt[ecx+ram+0100h-2], bl;U -  push Flags
  2955.                             sub     cl,     3               ;V -  sub Stack
  2956.                             or      ebx,    I_FLAG          ;U -  set Interrupt Disable Flags
  2957.                             mov     eax,    dwot[cpuBanks+28];V -  get last Bank
  2958.                             mov     $s,     ecx             ;U -  write back Stack          
  2959.                             mov     si,     wot[eax+01FFAh] ;V - /N set NMI addr
  2960.                             jmp     main_Loop               ;N -  
  2961.                            
  2962.                         ALIGNXMM
  2963.                         NO_DEAL:
  2964.                             jmp main_Loop
  2965.                            
  2966.                         INT_TAB dd NO_DEAL, IRQ_, NMI_, NMI_        
  2967. FastCall2A03 endp
  2968.        
  2969. setNMI proc C
  2970.              option prologue:none, epilogue:none
  2971.              
  2972.        or dwot[int_pending], NMI_FLAG
  2973.        ret
  2974.      
  2975. setNMI endp
  2976.  
  2977. setIRQ proc C
  2978.              option prologue:none, epilogue:none
  2979.          
  2980.        or dwot[int_pending], IRQ_FLAG
  2981.        ret
  2982.        
  2983. setIRQ endp
  2984.  
  2985. fastNMI proc C
  2986.              option prologue:none, epilogue:none
  2987.          
  2988. fastNMI endp
  2989.  
  2990. fastIRQ proc C
  2991.              option prologue:none, epilogue:none
  2992.          
  2993. fastIRQ endp
  2994.  
  2995. cpuReset proc C
  2996.              option prologue:none, epilogue:none
  2997.          push ebx
  2998.          lea edi, regs
  2999.          
  3000.          xor ecx, ecx
  3001.          or $p, 022h
  3002.          
  3003.          mov $a, ecx
  3004.          mov $x, ecx
  3005.          
  3006.          mov $y, ecx
  3007.          mov $s, 0FFh
  3008.          
  3009.          mov eax, dwot[cpuBanks+28]
  3010.          mov ecx, dwot[eax+01FFCh] ; set RESET addr
  3011.          
  3012.          mov $pc, ecx
  3013.          pop ebx
  3014.          
  3015.          ret
  3016. cpuReset endp
  3017.  
  3018. set_DMA_Cycles proc C
  3019.              option prologue:none, epilogue:none
  3020.              
  3021.         test dword ptr[esp+4], -1
  3022.         je __No_Force
  3023.         mov dwot[dma_c], 514
  3024. __No_Force:
  3025.         add dwot[dma_c], 514
  3026.         ret
  3027.  
  3028. set_DMA_Cycles endp
  3029.  
  3030.     end
Add Comment
Please, Sign In to add comment