home *** CD-ROM | disk | FTP | other *** search
/ The Best of Select: Games 3 / cd.iso / games / c64 / c64-386 / 6510.asm next >
Assembly Source File  |  1993-01-20  |  106KB  |  2,827 lines

  1. ; ****************************************************************************
  2. ; *                                                                          *
  3. ; *                       6510.ASM - 386 6510 emulator                       *
  4. ; *                                                                          *
  5. ; *                            R.F. van Ee (1993)                            *
  6. ; *                                                                          *
  7. ; ****************************************************************************
  8.  
  9.                         .model  small
  10.                         .386c
  11.  
  12.  
  13. ; ****************************************************************************
  14. ; Includes
  15.  
  16.                         include 6510.INC
  17.  
  18.  
  19. ; ****************************************************************************
  20. ; Labels
  21.  
  22.                         .data
  23.                         public  Int_Flags
  24.                         public  OpCodes
  25.                         public  _A
  26.                         public  _X
  27.                         public  _Y
  28.                         public  _Flags
  29.                         public  _PC
  30.                         public  _SP
  31.  
  32.                         extrn   _WriteTable
  33.                         extrn   _ReadTable
  34.  
  35.                         .code
  36.                         public  _Emul6510
  37.                         public  _6510Quit
  38.                         public  Interrupt
  39.  
  40.                         extrn   Start
  41.  
  42.                         extrn   ZPWrite
  43.  
  44.  
  45. ; ****************************************************************************
  46. ; Opcode jump table
  47.  
  48.                         .data
  49. OpCodes                 dw      BRK             ; 00
  50.                         dw      ORA_IND_X       ; 01
  51.                         dw      KIL             ; 02
  52.                         dw      SLO_IND_X       ; 03
  53.  
  54.                         dw      DOP             ; 04
  55.                         dw      ORA_ZP          ; 05
  56.                         dw      ASL_ZP          ; 06
  57.                         dw      SLO_ZP          ; 07
  58.  
  59.                         dw      PHP             ; 08
  60.                         dw      ORA_IMM         ; 09
  61.                         dw      ASL_A           ; 0A
  62.                         dw      ANC_IMM         ; 0B
  63.  
  64.                         dw      TOP             ; 0C
  65.                         dw      ORA_ABS         ; 0D
  66.                         dw      ASL_ABS         ; 0E
  67.                         dw      SLO_ABS         ; 0F
  68.  
  69.                         dw      BPL             ; 10
  70.                         dw      ORA_IND_Y       ; 11
  71.                         dw      KIL             ; 12
  72.                         dw      SLO_IND_Y       ; 13
  73.  
  74.                         dw      DOP             ; 14
  75.                         dw      ORA_ZP_X        ; 15
  76.                         dw      ASL_ZP_X        ; 16
  77.                         dw      SLO_ZP_X        ; 17
  78.  
  79.                         dw      CLC_            ; 18
  80.                         dw      ORA_ABS_Y       ; 19
  81.                         dw      NOP_            ; 1A
  82.                         dw      SLO_ABS_Y       ; 1B
  83.  
  84.                         dw      TOP             ; 1C
  85.                         dw      ORA_ABS_X       ; 1D
  86.                         dw      ASL_ABS_X       ; 1E
  87.                         dw      SLO_ABS_X       ; 1F
  88.  
  89.                         dw      JSR             ; 20
  90.                         dw      AND_IND_X       ; 21
  91.                         dw      KIL             ; 22
  92.                         dw      RLA_IND_X       ; 23
  93.  
  94.                         dw      BIT_ZP          ; 24
  95.                         dw      AND_ZP          ; 25
  96.                         dw      ROL_ZP          ; 26
  97.                         dw      RLA_ZP          ; 27
  98.  
  99.                         dw      PLP             ; 28
  100.                         dw      AND_IMM         ; 29
  101.                         dw      ROL_A           ; 2A
  102.                         dw      ANC_IMM         ; 2B
  103.  
  104.                         dw      BIT_ABS         ; 2C
  105.                         dw      AND_ABS         ; 2D
  106.                         dw      ROL_ABS         ; 2E
  107.                         dw      RLA_ABS         ; 2F
  108.  
  109.                         dw      BMI             ; 30
  110.                         dw      AND_IND_Y       ; 31
  111.                         dw      KIL             ; 32
  112.                         dw      RLA_IND_Y       ; 33
  113.  
  114.                         dw      DOP             ; 34
  115.                         dw      AND_ZP_X        ; 35
  116.                         dw      ROL_ZP_X        ; 36
  117.                         dw      RLA_ZP_X        ; 37
  118.  
  119.                         dw      SEC             ; 38
  120.                         dw      AND_ABS_Y       ; 39
  121.                         dw      NOP_            ; 3A
  122.                         dw      RLA_ABS_Y       ; 3B
  123.  
  124.                         dw      TOP             ; 3C
  125.                         dw      AND_ABS_X       ; 3D
  126.                         dw      ROL_ABS_X       ; 3E
  127.                         dw      RLA_ABS_X       ; 3F
  128.  
  129.                         dw      RTI             ; 40
  130.                         dw      EOR_IND_X       ; 41
  131.                         dw      KIL             ; 42
  132.                         dw      SRE_IND_X       ; 43
  133.  
  134.                         dw      DOP             ; 44
  135.                         dw      EOR_ZP          ; 45
  136.                         dw      LSR_ZP          ; 46
  137.                         dw      SRE_ZP          ; 47
  138.  
  139.                         dw      PHA             ; 48
  140.                         dw      EOR_IMM         ; 49
  141.                         dw      LSR_A           ; 4A
  142.                         dw      ASR_IMM         ; 4B
  143.  
  144.                         dw      JMP_ABS         ; 4C
  145.                         dw      EOR_ABS         ; 4D
  146.                         dw      LSR_ABS         ; 4E
  147.                         dw      SRE_ABS         ; 4F
  148.  
  149.                         dw      BVC             ; 50
  150.                         dw      EOR_IND_Y       ; 51
  151.                         dw      KIL             ; 52
  152.                         dw      SRE_IND_Y       ; 53
  153.  
  154.                         dw      DOP             ; 54
  155.                         dw      EOR_ZP_X        ; 55
  156.                         dw      LSR_ZP_X        ; 56
  157.                         dw      SRE_ZP_X        ; 57
  158.  
  159.                         dw      CLI_            ; 58
  160.                         dw      EOR_ABS_Y       ; 59
  161.                         dw      NOP_            ; 5A
  162.                         dw      SRE_ABS_Y       ; 5B
  163.  
  164.                         dw      TOP             ; 5C
  165.                         dw      EOR_ABS_X       ; 5D
  166.                         dw      LSR_ABS_X       ; 5E
  167.                         dw      SRE_ABS_X       ; 5F
  168.  
  169.                         dw      RTS             ; 60
  170.                         dw      ADC_IND_X       ; 61
  171.                         dw      KIL             ; 62
  172.                         dw      RRA_IND_X       ; 63
  173.  
  174.                         dw      DOP             ; 64
  175.                         dw      ADC_ZP          ; 65
  176.                         dw      ROR_ZP          ; 66
  177.                         dw      RRA_ZP          ; 67
  178.  
  179.                         dw      PLA             ; 68
  180.                         dw      ADC_IMM         ; 69
  181.                         dw      ROR_A           ; 6A
  182.                         dw      ARR_IMM         ; 6B
  183.  
  184.                         dw      JMP_IND         ; 6C
  185.                         dw      ADC_ABS         ; 6D
  186.                         dw      ROR_ABS         ; 6E
  187.                         dw      RRA_ABS         ; 6F
  188.  
  189.                         dw      BVS             ; 70
  190.                         dw      ADC_IND_Y       ; 71
  191.                         dw      KIL             ; 72
  192.                         dw      RRA_IND_Y       ; 73
  193.  
  194.                         dw      DOP             ; 74
  195.                         dw      ADC_ZP_X        ; 75
  196.                         dw      ROR_ZP_X        ; 76
  197.                         dw      RRA_ZP_X        ; 77
  198.  
  199.                         dw      SEI             ; 78
  200.                         dw      ADC_ABS_Y       ; 79
  201.                         dw      NOP_            ; 7A
  202.                         dw      RRA_ABS_Y       ; 7B
  203.  
  204.                         dw      TOP             ; 7C
  205.                         dw      ADC_ABS_X       ; 7D
  206.                         dw      ROR_ABS_X       ; 7E
  207.                         dw      RRA_ABS_X       ; 7F
  208.  
  209.                         dw      DOP             ; 80
  210.                         dw      STA_IND_X       ; 81
  211.                         dw      DOP             ; 82
  212.                         dw      SAX_IND_X       ; 83
  213.  
  214.                         dw      STY_ZP          ; 84
  215.                         dw      STA_ZP          ; 85
  216.                         dw      STX_ZP          ; 86
  217.                         dw      SAX_ZP          ; 87
  218.  
  219.                         dw      DEY             ; 88
  220.                         dw      DOP             ; 89
  221.                         dw      TXA             ; 8A
  222.                         dw      AXA_IMM         ; 8B
  223.  
  224.                         dw      STY_ABS         ; 8C
  225.                         dw      STA_ABS         ; 8D
  226.                         dw      STX_ABS         ; 8E
  227.                         dw      SAX_ABS         ; 8F
  228.  
  229.                         dw      BCC             ; 90
  230.                         dw      STA_IND_Y       ; 91
  231.                         dw      KIL             ; 92
  232.                         dw      SAH_IND_Y       ; 93
  233.  
  234.                         dw      STY_ZP_X        ; 94
  235.                         dw      STA_ZP_X        ; 95
  236.                         dw      STX_ZP_Y        ; 96
  237.                         dw      SAX_ZP_Y        ; 97
  238.  
  239.                         dw      TYA             ; 98
  240.                         dw      STA_ABS_Y       ; 99
  241.                         dw      TXS             ; 9A
  242.                         dw      SSH_ABS_Y       ; 9B
  243.  
  244.                         dw      SYH_ABS_X       ; 9C
  245.                         dw      STA_ABS_X       ; 9D
  246.                         dw      SXH_ABS_Y       ; 9E
  247.                         dw      SAH_ABS_Y       ; 9F
  248.  
  249.                         dw      LDY_IMM         ; A0
  250.                         dw      LDA_IND_X       ; A1
  251.                         dw      LDX_IMM         ; A2
  252.                         dw      LAX_IND_X       ; A3
  253.  
  254.                         dw      LDY_ZP          ; A4
  255.                         dw      LDA_ZP          ; A5
  256.                         dw      LDX_ZP          ; A6
  257.                         dw      LAX_ZP          ; A7
  258.  
  259.                         dw      TAY             ; A8
  260.                         dw      LDA_IMM         ; A9
  261.                         dw      TAX             ; AA
  262.                         dw      LAX_IMM         ; AB
  263.  
  264.                         dw      LDY_ABS         ; AC
  265.                         dw      LDA_ABS         ; AD
  266.                         dw      LDX_ABS         ; AE
  267.                         dw      LAX_ABS         ; AF
  268.  
  269.                         dw      BCS             ; B0
  270.                         dw      LDA_IND_Y       ; B1
  271.                         dw      KIL             ; B2
  272.                         dw      LAX_IND_Y       ; B3
  273.  
  274.                         dw      LDY_ZP_X        ; B4
  275.                         dw      LDA_ZP_X        ; B5
  276.                         dw      LDX_ZP_Y        ; B6
  277.                         dw      LAX_ZP_Y        ; B7
  278.  
  279.                         dw      CLV_            ; B8
  280.                         dw      LDA_ABS_Y       ; B9
  281.                         dw      TSX             ; BA
  282.                         dw      AST_ABS_Y       ; BB
  283.  
  284.                         dw      LDY_ABS_X       ; BC
  285.                         dw      LDA_ABS_X       ; BD
  286.                         dw      LDX_ABS_Y       ; BE
  287.                         dw      LAX_ABS_Y       ; BF
  288.  
  289.                         dw      CPY_IMM         ; C0
  290.                         dw      CMP_IND_X       ; C1
  291.                         dw      DOP             ; C2
  292.                         dw      DCP_IND_X       ; C3
  293.  
  294.                         dw      CPY_ZP          ; C4
  295.                         dw      CMP_ZP          ; C5
  296.                         dw      DEC_ZP          ; C6
  297.                         dw      DCP_ZP          ; C7
  298.  
  299.                         dw      INY             ; C8
  300.                         dw      CMP_IMM         ; C9
  301.                         dw      DEX             ; CA
  302.                         dw      ASX_IMM         ; CB
  303.  
  304.                         dw      CPY_ABS         ; CC
  305.                         dw      CMP_ABS         ; CD
  306.                         dw      DEC_ABS         ; CE
  307.                         dw      DCP_ABS         ; CF
  308.  
  309.                         dw      BNE             ; D0
  310.                         dw      CMP_IND_Y       ; D1
  311.                         dw      KIL             ; D2
  312.                         dw      DCP_IND_Y       ; D3
  313.  
  314.                         dw      DOP             ; D4
  315.                         dw      CMP_ZP_X        ; D5
  316.                         dw      DEC_ZP_X        ; D6
  317.                         dw      DCP_ZP_X        ; D7
  318.  
  319.                         dw      CLD_            ; D8
  320.                         dw      CMP_ABS_Y       ; D9
  321.                         dw      NOP_            ; DA
  322.                         dw      DCP_ABS_Y       ; DB
  323.  
  324.                         dw      TOP             ; DC
  325.                         dw      CMP_ABS_X       ; DD
  326.                         dw      DEC_ABS_X       ; DE
  327.                         dw      DCP_ABS_X       ; DF
  328.  
  329.                         dw      CPX_IMM         ; E0
  330.                         dw      SBC_IND_X       ; E1
  331.                         dw      DOP             ; E2
  332.                         dw      ISC_IND_X       ; E3
  333.  
  334.                         dw      CPX_ZP          ; E4
  335.                         dw      SBC_ZP          ; E5
  336.                         dw      INC_ZP          ; E6
  337.                         dw      ISC_ZP          ; E7
  338.  
  339.                         dw      INX             ; E8
  340.                         dw      SBC_IMM         ; E9
  341.                         dw      NOP_            ; EA
  342.                         dw      SBC_IMM         ; EB
  343.  
  344.                         dw      CPX_ABS         ; EC
  345.                         dw      SBC_ABS         ; ED
  346.                         dw      INC_ABS         ; EE
  347.                         dw      ISC_ABS         ; EF
  348.  
  349.                         dw      BEQ             ; F0
  350.                         dw      SBC_IND_Y       ; F1
  351.                         dw      KIL             ; F2
  352.                         dw      ISC_IND_Y       ; F3
  353.  
  354.                         dw      DOP             ; F4
  355.                         dw      SBC_ZP_X        ; F5
  356.                         dw      INC_ZP_X        ; F6
  357.                         dw      ISC_ZP_X        ; F7
  358.  
  359.                         dw      SED             ; F8
  360.                         dw      SBC_ABS_Y       ; F9
  361.                         dw      NOP_            ; FA
  362.                         dw      ISC_ABS_Y       ; FB
  363.  
  364.                         dw      TOP             ; FC
  365.                         dw      SBC_ABS_X       ; FD
  366.                         dw      INC_ABS_X       ; FE
  367.                         dw      ISC_ABS_X       ; FF
  368.  
  369.  
  370. ; ****************************************************************************
  371. ; _Emul6510: the 6510 emulator
  372.  
  373.                         .data
  374. Int_Flags               db      000h            ; b0 = IRQ; b1 = NMI
  375. _A                      db      000h
  376. _X                      db      000h
  377. _Y                      db      000h
  378. _Flags                  db      024h            ; Interrupts disabled
  379. _SP                     dw      001ffh
  380. _PC                     dw      BOOTOFFSET
  381.  
  382.                         .code
  383. _Emul6510               proc    near
  384.                         sub     ebx,ebx         ; Clear ebx
  385.  
  386.                         mov     ch,byte ptr _A  ; Load accumulator
  387.                         mov     cl,byte ptr _X  ; Load X register
  388.                         mov     dl,byte ptr _Y  ; Load Y register
  389.                         mov     si,word ptr _PC ; Load PC
  390.                         mov     bp,word ptr _SP ; Load SP
  391.                         cld
  392.  
  393.                         Encode_Flags _Flags
  394.                                                 ; Load flags: 6510 -> emulator
  395.                         Fetch                   ; Fetch first instruction
  396.  
  397. _6510Quit:              Decode_Flags al         ; Emulator -> 6510
  398.                         mov     byte ptr _A,ch
  399.                         mov     byte ptr _X,cl
  400.                         mov     byte ptr _Y,dl
  401.                         mov     byte ptr _Flags,al
  402.                         mov     word ptr _PC,si
  403.                         mov     word ptr _SP,bp
  404.                         ret
  405. _Emul6510               endp
  406.  
  407.  
  408. ; ****************************************************************************
  409. ; 6510 interrupt handler
  410.  
  411.                         align 4
  412. Interrupt               proc    near
  413.                         cmp     byte ptr Int_Flags,NMI_Flag
  414.                         jae     NMI
  415. Interrupt               endp
  416.  
  417.  
  418. ; ****************************************************************************
  419. ; 6510 IRQ handler
  420.  
  421. IRQ                     proc    near
  422.                         test    dh,CPU_I        ; IRQ enabled?
  423.                         jz      IRQ_enabled     ; Yes
  424.                         mov     bl,es:[si]      ; Get opcode (bh = 0 already)
  425.                         inc     si              ; PC++
  426.                         jmp     word ptr [ebx][ebx]
  427.                                                 ; Jump to opcode routine
  428.                         align   4
  429. IRQ_enabled:            Push_Int                ; Push PC and P
  430.                         mov     si,es:[IRQ_VECTOR]
  431.                         or      dh,CPU_I        ; Disable interrupts
  432.                         and     byte ptr Int_Flags,Not (IRQ_Flag)
  433.                                                 ; Clear IRQ flag
  434.                         mov     bl,es:[si]      ; Get opcode
  435.                         inc     si              ; PC++
  436.                         jmp     word ptr [ebx][ebx]
  437.                                                 ; Jump to opcode routine
  438. IRQ                     endp
  439.  
  440.  
  441. ; ****************************************************************************
  442. ; 6510 NMI handler
  443.  
  444.                         align   4
  445. NMI                     proc    near
  446.                         Push_Int                ; Push PC and P
  447.                         mov     si,es:[NMI_VECTOR]
  448.                         or      dh,CPU_I        ; Disable interrupts
  449.                         and     byte ptr Int_Flags,Not (NMI_Flag)
  450.                                                 ; Clear NMI flag
  451.                         Fetch                   ; Fetch next instruction
  452. NMI                     endp
  453.  
  454.  
  455. ; ****************************************************************************
  456. ; Opcode routines
  457.  
  458.                         align   4
  459. ANC_IMM                 proc    near
  460.                         and     ch,es:[si]
  461.                         lahf
  462.                         and     dh,Not (CPU_N + CPU_Z + CPU_C)
  463.                     and     ah,CPU_N + CPU_Z
  464.                         or      dh,ah
  465.                         rol     ah,1
  466.                         inc     si
  467.                         and     ah,CPU_C
  468.                         or      dh,ah
  469.                         Fetch
  470. ANC_IMM                 endp
  471.  
  472.                         align   4
  473. ADC_ABS                 proc    near
  474.                         Read_ABS
  475.                         OpADC
  476. ADC_ABS                 endp
  477.  
  478.                         align   4
  479. ADC_ZP                  proc    near
  480.                         Read_ZP al
  481.                         OpADC
  482. ADC_ZP                  endp
  483.  
  484.                         align   4
  485. ADC_IMM                 proc    near
  486.                         Read_IMM al
  487.                         OpADC
  488. ADC_IMM                 endp
  489.  
  490.                         align   4
  491. ADC_ABS_X               proc    near
  492.                         Read_ABS_X
  493.                         OpADC
  494. ADC_ABS_X               endp
  495.  
  496.                         align   4
  497. ADC_ABS_Y               proc    near
  498.                         Read_ABS_Y
  499.                         OpADC
  500. ADC_ABS_Y               endp
  501.  
  502.                         align   4
  503. ADC_IND_X               proc    near
  504.                         Read_IND_X
  505.                         OpADC
  506. ADC_IND_X               endp
  507.  
  508.                         align   4
  509. ADC_IND_Y               proc    near
  510.                         Read_IND_Y
  511.                         OpADC
  512. ADC_IND_Y               endp
  513.  
  514.                         align   4
  515. ADC_ZP_X                proc    near
  516.                         Read_ZP_X al
  517.                         OpADC
  518. ADC_ZP_X                endp
  519.  
  520.                         align   4
  521. AND_ABS                 proc    near
  522.                         Read_ABS
  523.                         and     ch,al
  524.                         Flgnz
  525.                         Fetch
  526. AND_ABS                 endp
  527.  
  528.                         align   4
  529. AND_ZP                  proc    near
  530.                         mov     bl,es:[si]
  531.                         inc     si
  532.                         and     ch,es:[bx]
  533.                         Flgnz
  534.                         Fetch
  535. AND_ZP                  endp
  536.  
  537.                         align   4
  538. AND_IMM                 proc    near
  539.                         and     ch,es:[si]
  540.                         Flgnz
  541.                         inc     si
  542.                         Fetch
  543. AND_IMM                 endp
  544.  
  545.                         align   4
  546. AND_ABS_X               proc    near
  547.                         Read_ABS_X
  548.                         and     ch,al
  549.                         Flgnz
  550.                         Fetch
  551. AND_ABS_X               endp
  552.  
  553.                         align   4
  554. AND_ABS_Y               proc    near
  555.                         Read_ABS_Y
  556.                         and     ch,al
  557.                         Flgnz
  558.                         Fetch
  559. AND_ABS_Y               endp
  560.  
  561.                         align   4
  562. AND_IND_X               proc    near
  563.                         Read_IND_X
  564.                         and     ch,al
  565.                         Flgnz
  566.                         Fetch
  567. AND_IND_X               endp
  568.  
  569.                         align   4
  570. AND_IND_Y               proc    near
  571.                         Read_IND_Y
  572.                         and     ch,al
  573.                         Flgnz
  574.                         Fetch
  575. AND_IND_Y               endp
  576.  
  577.                         align   4
  578. AND_ZP_X                proc    near
  579.                         mov     bl,es:[si]
  580.                         add     bl,cl
  581.                         inc     si
  582.                         and     ch,es:[bx]
  583.                         Flgnz
  584.                         Fetch
  585. AND_ZP_X                endp
  586.  
  587.                         align   4
  588. ARR_IMM                 proc    near
  589.                         mov     ah,dh
  590.                         and     ch,es:[si]              ; AND #
  591.                         and     dh,Not (CPU_N + CPU_V + CPU_Z + CPU_C)
  592.                         sahf
  593.                         rcr     ch,1                    ; ROR
  594.                         inc     ch                      ; RCR doesn't affect
  595.                         inc     si
  596.                         dec     ch                      ; the N and Z flags
  597.                         jnz     ARR_IMM1
  598.                         or      dh,CPU_Z                ; Set Z flag
  599.                         Fetch
  600.                         align   4
  601. ARR_IMM1:               mov     al,ch
  602.                         shr     al,1
  603.                         xor     al,ch
  604.                         shr     al,2                    ; Shift to V position
  605.                         and     al,CPU_V
  606.                         or      dh,al                   ; Set V flag
  607.                         mov     al,ch
  608.                         shl     al,2
  609.                         adc     dh,0                    ; Set C flag
  610.                         mov     al,ch
  611.                         and     al,CPU_N
  612.                         or      dh,al                   ; Set N flag
  613.                         Fetch
  614. ARR_IMM                 endp
  615.  
  616.                         align   4
  617. ASL_A                   proc    near
  618.                         add     ch,ch
  619.                         Flgnzc
  620.                         Fetch
  621. ASL_A                   endp
  622.  
  623.                         align   4
  624. ASL_ABS                 proc    near
  625.                         Read_ABS
  626.                         add     al,al
  627.                         Flgnzc
  628.                         RMW_write
  629. ASL_ABS                 endp
  630.  
  631.                         align   4
  632. ASL_ZP                  proc    near
  633.                         mov     bl,es:[si]
  634.                         inc     si
  635.                         mov     al,es:[bx]
  636.                         add     es:[bx],al
  637.                         Flgnzc
  638.                         Fetch
  639. ASL_ZP                  endp
  640.  
  641.                         align   4
  642. ASL_ABS_X               proc    near
  643.                         Read_ABS_X
  644.                         add     al,al
  645.                         Flgnzc
  646.                         RMW_write
  647. ASL_ABS_X               endp
  648.  
  649.                         align   4
  650. ASL_ZP_X                proc    near
  651.                         mov     bl,es:[si]
  652.                         add     bl,cl
  653.                         mov     al,es:[bx]
  654.                         inc     si
  655.                         add     es:[bx],al
  656.                         Flgnzc
  657.                         Fetch
  658. ASL_ZP_X                endp
  659.  
  660.                         align   4
  661. ASR_IMM                 proc    near
  662.                         and     ch,es:[si]              ; AND #
  663.                         shr     ch,1                    ; LSR
  664.                         Flgnzc
  665.                         inc     si
  666.                         Fetch
  667. ASR_IMM                 endp
  668.  
  669.                         align   4
  670. AST_ABS_Y               proc    near
  671.                         Read_ABS_Y
  672.                         and     ax,bp                   ; And with stack register
  673.                         mov     ah,01h
  674.                         mov     bp,ax                   ; Store in stack reg,
  675.                         mov     ch,al                   ; accu and
  676.                         mov     cl,al                   ; x reg
  677.                         or      ch,ch                   ; Set flags
  678.                         Flgnz
  679.                         Fetch
  680. AST_ABS_Y               endp
  681.  
  682.                         align   4
  683. ASX_IMM                 proc    near
  684.                         and     cl,ch                   ; AND X,A
  685.                         sub     cl,es:[si]
  686.                         cmc
  687.                         Flgnzc                          ; V unaffected!
  688.                         inc     si
  689.                         Fetch
  690. ASX_IMM                 endp
  691.  
  692.                         align   4
  693. AXA_IMM                 proc    near
  694.                         mov     ch,cl                   ; TXA
  695.                         and     ch,es:[si]              ; AND #
  696.                         Flgnz
  697.                         inc     si
  698.                         Fetch
  699. AXA_IMM                 endp
  700.  
  701.                         align   4
  702. BCC                     proc    near
  703.                         test    dh,CPU_C
  704.                         jnz     BCC_DontJump
  705.                         movsx   ax,byte ptr es:[si]
  706.                         add     si,ax
  707. BCC_DontJump:           inc     si
  708.                         Fetch
  709. BCC                     endp
  710.  
  711.                         align   4
  712. BCS                     proc    near
  713.                         test    dh,CPU_C
  714.                         jz      BCS_DontJump
  715.                         movsx   ax,byte ptr es:[si]
  716.                         add     si,ax
  717. BCS_DontJump:           inc     si
  718.                         Fetch
  719. BCS                     endp
  720.  
  721.                         align   4
  722. BEQ                     proc    near
  723.                         test    dh,CPU_Z
  724.                         jz      BEQ_DontJump
  725.                         movsx   ax,byte ptr es:[si]
  726.                         add     si,ax
  727. BEQ_DontJump:           inc     si
  728.                         Fetch
  729. BEQ                     endp
  730.  
  731.                         align   4
  732. BIT_ABS                 proc    near
  733.                         Read_ABS
  734.                         and     dh,Not (CPU_N + CPU_V + CPU_Z)
  735.                                               ; Reset N, V and Z flags
  736.                         test    al,ch
  737.                         jnz     BIT_ABS_nz
  738.                         or      dh,CPU_Z      ; Set Z flag
  739. BIT_ABS_nz:             mov     ah,al
  740.                         and     ah,CPU_N      ; Keep nothing but bit 7
  741.                         or      dh,ah         ; Set N flag if necessary
  742.                         shr     al,3          ; Shift bit 6 to V position
  743.                         and     al,CPU_V      ; Keep nothing but bit 3
  744.                         or      dh,al         ; Set V flag if necessary
  745.                         Fetch
  746. BIT_ABS                 endp
  747.  
  748.                         align   4
  749. BIT_ZP                  proc    near
  750.                         Read_ZP al
  751.                         and     dh,Not (CPU_N + CPU_V + CPU_Z)
  752.                                               ; Reset N, V and Z flags
  753.                         test    al,ch
  754.                         jnz     BIT_ZP_nz
  755.                         or      dh,CPU_Z      ; Set Z flag
  756. BIT_ZP_nz:              mov     ah,al
  757.                         and     ah,CPU_N      ; Keep nothing but bit 7
  758.                         or      dh,ah         ; Set N flag if necessary
  759.                         shr     al,3          ; Shift bit 6 to V position
  760.                         and     al,CPU_V      ; Keep nothing but bit 3
  761.                         or      dh,al         ; Set V flag if necessary
  762.                         Fetch
  763. BIT_ZP                  endp
  764.  
  765.                         align   4
  766. BMI                     proc    near
  767.                         test    dh,CPU_N
  768.                         jz      BMI_DontJump
  769.                         movsx   ax,byte ptr es:[si]
  770.                         add     si,ax
  771. BMI_DontJump:           inc     si
  772.                         Fetch
  773. BMI                     endp
  774.  
  775.                         align   4
  776. BNE                     proc    near
  777.                         test    dh,CPU_Z
  778.                         jnz     BNE_DontJump
  779.                         movsx   ax,byte ptr es:[si]
  780.                         add     si,ax
  781. BNE_DontJump:           inc     si
  782.                         Fetch
  783. BNE                     endp
  784.  
  785.                         align   4
  786. BPL                     proc    near
  787.                         test    dh,CPU_N
  788.                         jnz     BPL_DontJump
  789.                         movsx   ax,byte ptr es:[si]
  790.                         add     si,ax
  791. BPL_DontJump:           inc     si
  792.                         Fetch
  793. BPL                     endp
  794.  
  795.                         align   4
  796. BRK                     proc    near
  797.                         inc     si                      ; Advance PC one more address
  798.                         or      dh,CPU_B                ; Set B flag
  799.                         Push_Int                        ; Push PC and flags
  800.                         and     dh,Not (CPU_B)          ; Reset B flag again
  801.                         mov     si,es:[IRQ_VECTOR]
  802.                         or      dh,CPU_I                ; Disable interrupts
  803.                         mov     bl,es:[si]              ; Get opcode
  804.                         inc     si                      ; PC++
  805.                         jmp     word ptr [ebx][ebx]
  806.                                                         ; Jump to opcode routine
  807. BRK                     endp
  808.  
  809.                         align   4
  810. BVC                     proc    near
  811.                         test    dh,CPU_V
  812.                         jnz     BVC_DontJump
  813.                         movsx   ax,byte ptr es:[si]
  814.                         add     si,ax
  815. BVC_DontJump:           inc     si
  816.                         Fetch
  817. BVC                     endp
  818.  
  819.                         align   4
  820. BVS                     proc    near
  821.                         test    dh,CPU_V
  822.                         jz      BVS_DontJump
  823.                         movsx   ax,byte ptr es:[si]
  824.                         add     si,ax
  825. BVS_DontJump:           inc     si
  826.                         Fetch
  827. BVS                     endp
  828.  
  829.                         align   4
  830. CLC_                    proc    near
  831.                         and     dh,Not (CPU_C)
  832.                         Fetch
  833. CLC_                    endp
  834.  
  835.                         align   4
  836. CLD_                    proc    near
  837.                         and     dh,Not (CPU_M)
  838.                         Fetch
  839. CLD_                    endp
  840.  
  841.                         align   4
  842. CLI_                    proc    near
  843.                         and     dh,Not (CPU_I)
  844.                         Fetch
  845. CLI_                    endp
  846.  
  847.                         align   4
  848. CLV_                    proc    near
  849.                         and     dh,Not (CPU_V)
  850.                         Fetch
  851. CLV_                    endp
  852.  
  853.                         align   4
  854. CMP_ABS                 proc    near
  855.                         Read_ABS
  856.                         cmp     ch,al
  857.                         cmc
  858.                         Flgnzc
  859.                         Fetch
  860. CMP_ABS                 endp
  861.  
  862.                         align   4
  863. CMP_ZP                  proc    near
  864.                         mov     bl,es:[si]
  865.                         inc     si
  866.                         cmp     ch,es:[bx]
  867.                         cmc
  868.                         Flgnzc
  869.                         Fetch
  870. CMP_ZP                  endp
  871.  
  872.                         align   4
  873. CMP_IMM                 proc    near
  874.                         cmp     ch,es:[si]
  875.                         cmc
  876.                         Flgnzc
  877.                         inc     si
  878.                         Fetch
  879. CMP_IMM                 endp
  880.  
  881.                         align   4
  882. CMP_ABS_X               proc    near
  883.                         Read_ABS_X
  884.                         cmp     ch,al
  885.                         cmc
  886.                         Flgnzc
  887.                         Fetch
  888. CMP_ABS_X               endp
  889.  
  890.                         align   4
  891. CMP_ABS_Y               proc    near
  892.                         Read_ABS_Y
  893.                         cmp     ch,al
  894.                         cmc
  895.                         Flgnzc
  896.                         Fetch
  897. CMP_ABS_Y               endp
  898.  
  899.                         align   4
  900. CMP_IND_X               proc    near
  901.                         Read_IND_X
  902.                         cmp     ch,al
  903.                         cmc
  904.                         Flgnzc
  905.                         Fetch
  906. CMP_IND_X               endp
  907.  
  908.                         align   4
  909. CMP_IND_Y               proc    near
  910.                         Read_IND_Y
  911.                         cmp     ch,al
  912.                         cmc
  913.                         Flgnzc
  914.                         Fetch
  915. CMP_IND_Y               endp
  916.  
  917.                         align   4
  918. CMP_ZP_X                proc    near
  919.                         mov     bl,es:[si]
  920.                         add     bl,cl
  921.                         inc     si
  922.                         cmp     ch,es:[bx]
  923.                         cmc
  924.                         Flgnzc
  925.                         Fetch
  926. CMP_ZP_X                endp
  927.  
  928.                         align   4
  929. CPX_ABS                 proc    near
  930.                         Read_ABS
  931.                         cmp     cl,al
  932.                         cmc
  933.                         Flgnzc
  934.                         Fetch
  935. CPX_ABS                 endp
  936.  
  937.                         align   4
  938. CPX_ZP                  proc    near
  939.                         mov     bl,es:[si]
  940.                         inc     si
  941.                         cmp     cl,es:[bx]
  942.                         cmc
  943.                         Flgnzc
  944.                         Fetch
  945. CPX_ZP                  endp
  946.  
  947.                         align   4
  948. CPX_IMM                 proc    near
  949.                         cmp     cl,es:[si]
  950.                         cmc
  951.                         Flgnzc
  952.                         inc     si
  953.                         Fetch
  954. CPX_IMM                 endp
  955.  
  956.                         align   4
  957. CPY_ABS                 proc    near
  958.                         Read_ABS
  959.                         cmp     dl,al
  960.                         cmc
  961.                         Flgnzc
  962.                         Fetch
  963. CPY_ABS                 endp
  964.  
  965.                         align   4
  966. CPY_ZP                  proc    near
  967.                         mov     bl,es:[si]
  968.                         inc     si
  969.                         cmp     dl,es:[bx]
  970.                         cmc
  971.                         Flgnzc
  972.                         Fetch
  973. CPY_ZP                  endp
  974.  
  975.                         align   4
  976. CPY_IMM                 proc    near
  977.                         cmp     dl,es:[si]
  978.                         cmc
  979.                         Flgnzc
  980.                         inc     si
  981.                         Fetch
  982. CPY_IMM                 endp
  983.  
  984.                         align   4
  985. DCP_ABS                 proc    near
  986.                         Read_ABS
  987.                         dec     al
  988.                         cmp     ch,al
  989.                         cmc
  990.                         Flgnzc
  991.                         RMW_write
  992. DCP_ABS                 endp
  993.  
  994.                         align   4
  995. DCP_ZP                  proc    near
  996.                         mov     bl,es:[si]
  997.                         inc     si
  998.                         mov     al,es:[bx]
  999.                         dec     al
  1000.                         cmp     ch,al
  1001.                         mov     es:[bx],al
  1002.                         cmc
  1003.                         Flgnzc
  1004.                         Fetch
  1005. DCP_ZP                  endp
  1006.  
  1007.                         align   4
  1008. DCP_ABS_X               proc    near
  1009.                         Read_ABS_X
  1010.                         dec     al
  1011.                         cmp     ch,al
  1012.                         cmc
  1013.                         Flgnzc
  1014.                         RMW_write
  1015. DCP_ABS_X               endp
  1016.  
  1017.                         align   4
  1018. DCP_ABS_Y               proc    near
  1019.                         Read_ABS_Y
  1020.                         dec     al
  1021.                         cmp     ch,al
  1022.                         cmc
  1023.                         Flgnzc
  1024.                         RMW_write
  1025. DCP_ABS_Y               endp
  1026.  
  1027.                         align   4
  1028. DCP_IND_X               proc    near
  1029.                         Read_IND_X
  1030.                         dec     al
  1031.                         cmp     ch,al
  1032.                         cmc
  1033.                         Flgnzc
  1034.                         RMW_write
  1035. DCP_IND_X               endp
  1036.  
  1037.                         align   4
  1038. DCP_IND_Y               proc    near
  1039.                         Read_IND_Y
  1040.                         dec     al
  1041.                         cmp     ch,al
  1042.                         cmc
  1043.                         Flgnzc
  1044.                         RMW_write
  1045. DCP_IND_Y               endp
  1046.  
  1047.                         align   4
  1048. DCP_ZP_X                proc    near
  1049.                         mov     bl,es:[si]
  1050.                         add     bl,cl
  1051.                         inc     si
  1052.                         mov     al,es:[bx]
  1053.                         dec     al
  1054.                         cmp     ch,al
  1055.                         mov     es:[bx],al
  1056.                         cmc
  1057.                         Flgnzc
  1058.                         Fetch
  1059. DCP_ZP_X                endp
  1060.  
  1061.                         align   4
  1062. DEC_ABS                 proc    near
  1063.                         Read_ABS
  1064.                         dec     al
  1065.                         Flgnz
  1066.                         RMW_write
  1067. DEC_ABS                 endp
  1068.  
  1069.                         align   4
  1070. DEC_ZP                  proc    near
  1071.                         mov     bl,es:[si]
  1072.                         inc     si
  1073.                         dec     byte ptr es:[bx]
  1074.                         Flgnz
  1075.                         Fetch
  1076. DEC_ZP                  endp
  1077.  
  1078.                         align   4
  1079. DEC_ABS_X               proc    near
  1080.                         Read_ABS_X
  1081.                         dec     al
  1082.                         Flgnz
  1083.                         RMW_write
  1084. DEC_ABS_X               endp
  1085.  
  1086.                         align   4
  1087. DEC_ZP_X                proc    near
  1088.                         mov     bl,es:[si]
  1089.                         add     bl,cl
  1090.                         inc     si
  1091.                         dec     byte ptr es:[bx]
  1092.                         Flgnz
  1093.                         Fetch
  1094. DEC_ZP_X                endp
  1095.  
  1096.                         align   4
  1097. DEX                     proc    near
  1098.                         dec     cl
  1099.                         Flgnz
  1100.                         Fetch
  1101. DEX                     endp
  1102.  
  1103.                         align   4
  1104. DEY                     proc    near
  1105.                         dec     dl
  1106.                         Flgnz
  1107.                         Fetch
  1108. DEY                     endp
  1109.  
  1110.                         align   4
  1111. DOP                     proc    near
  1112.                         inc     si                      ; Advance one byte!
  1113.                         Fetch
  1114. DOP                     endp
  1115.  
  1116.                         align   4
  1117. EOR_ABS                 proc    near
  1118.                         Read_ABS
  1119.                         xor     ch,al
  1120.                         Flgnz
  1121.                         Fetch
  1122. EOR_ABS                 endp
  1123.  
  1124.                         align   4
  1125. EOR_ZP                  proc    near
  1126.                         mov     bl,es:[si]
  1127.                         inc     si
  1128.                         xor     ch,es:[bx]
  1129.                         Flgnz
  1130.                         Fetch
  1131. EOR_ZP                  endp
  1132.  
  1133.                         align   4
  1134. EOR_IMM                 proc    near
  1135.                         xor     ch,es:[si]
  1136.                         Flgnz
  1137.                         inc     si
  1138.                         Fetch
  1139. EOR_IMM                 endp
  1140.  
  1141.                         align   4
  1142. EOR_ABS_X               proc    near
  1143.                         Read_ABS_X
  1144.                         xor     ch,al
  1145.                         Flgnz
  1146.                         Fetch
  1147. EOR_ABS_X               endp
  1148.  
  1149.                         align   4
  1150. EOR_ABS_Y               proc    near
  1151.                         Read_ABS_Y
  1152.                         xor     ch,al
  1153.                         Flgnz
  1154.                         Fetch
  1155. EOR_ABS_Y               endp
  1156.  
  1157.                         align   4
  1158. EOR_IND_X               proc    near
  1159.                         Read_IND_X
  1160.                         xor     ch,al
  1161.                         Flgnz
  1162.                         Fetch
  1163. EOR_IND_X               endp
  1164.  
  1165.                         align   4
  1166. EOR_IND_Y               proc    near
  1167.                         Read_IND_Y
  1168.                         xor     ch,al
  1169.                         Flgnz
  1170.                         Fetch
  1171. EOR_IND_Y               endp
  1172.  
  1173.                         align   4
  1174. EOR_ZP_X                proc    near
  1175.                         mov     bl,es:[si]
  1176.                         add     bl,cl
  1177.                         inc     si
  1178.                         xor     ch,es:[bx]
  1179.                         Flgnz
  1180.                         Fetch
  1181. EOR_ZP_X                endp
  1182.  
  1183.                         align   4
  1184. INC_ABS                 proc    near
  1185.                         Read_ABS
  1186.                         inc     al
  1187.                         Flgnz
  1188.                         RMW_write
  1189. INC_ABS                 endp
  1190.  
  1191.                         align   4
  1192. INC_ZP                  proc    near
  1193.                         mov     bl,es:[si]
  1194.                         inc     si
  1195.                         inc     byte ptr es:[bx]
  1196.                         Flgnz
  1197.                         Fetch
  1198. INC_ZP                  endp
  1199.  
  1200.                         align   4
  1201. INC_ABS_X               proc    near
  1202.                         Read_ABS_X
  1203.                         inc     al
  1204.                         Flgnz
  1205.                         RMW_write
  1206. INC_ABS_X               endp
  1207.  
  1208.                         align   4
  1209. INC_ZP_X                proc    near
  1210.                         mov     bl,es:[si]
  1211.                         add     bl,cl
  1212.                         inc     si
  1213.                         inc     byte ptr es:[bx]
  1214.                         Flgnz
  1215.                         Fetch
  1216. INC_ZP_X                endp
  1217.  
  1218.                         align   4
  1219. INX                     proc    near
  1220.                         inc     cl
  1221.                         Flgnz
  1222.                         Fetch
  1223. INX                     endp
  1224.  
  1225.                         align   4
  1226. INY                     proc    near
  1227.                         inc     dl
  1228.                         Flgnz
  1229.                         Fetch
  1230. INY                     endp
  1231.  
  1232.                         align   4
  1233. ISC_ABS                 proc    near
  1234.                         Read_ABS
  1235.                         mov     ah,dh
  1236.                         test    dh,CPU_M                ; Decimal mode?
  1237.                         jnz     ISC_ABS1
  1238.                         inc     al
  1239.                         mov     bh,al                   ; Save al
  1240.                         sahf
  1241.                         cmc
  1242.                         sbb     ch,al
  1243.                         cmc
  1244.                         Flgnvzc
  1245.                         mov     al,bh                   ; Restore al
  1246.                         mov     bh,0
  1247.                         RMW_write                       ; Store al
  1248.                         align   4
  1249. ISC_ABS1:               inc     al
  1250.                         mov     bh,al                   ; Store al
  1251.                         xchg    al,ch
  1252.                         sahf
  1253.                         cmc
  1254.                         sbb     al,ch
  1255.                         das                             ; Adjust al for packed BCD sub
  1256.                         cmc
  1257.                         mov     ch,al
  1258.                         Flgnvzc
  1259.                         mov     al,bh                   ; Restore al
  1260.                         mov     bh,0
  1261.                         RMW_write                       ; Store al
  1262. ISC_ABS                 endp
  1263.  
  1264.                         align   4
  1265. ISC_ZP                  proc    near
  1266.                         mov     bl,es:[si]
  1267.                         mov     ah,dh
  1268.                         inc     si
  1269.                         mov     al,es:[bx]
  1270.                         test    dh,CPU_M                ; Decimal mode?
  1271.                         jnz     ISC_ZP1
  1272.                         inc     al
  1273.                         mov     bh,al                   ; Store al
  1274.                         sahf
  1275.                         cmc
  1276.                         sbb     ch,al
  1277.                         cmc
  1278.                         Flgnvzc
  1279.                         mov     al,bh                   ; Restore al
  1280.                         mov     bh,0
  1281.                         mov     es:[bx],al              ; Store al
  1282.                         Fetch
  1283.                         align   4
  1284. ISC_ZP1:                inc     al
  1285.                         mov     bh,al                   ; Store al
  1286.                         xchg    al,ch
  1287.                         sahf
  1288.                         cmc
  1289.                         sbb     al,ch
  1290.                         das                             ; Adjust al for packed BCD sub
  1291.                         cmc
  1292.                         mov     ch,al
  1293.                         Flgnvzc
  1294.                         mov     al,bh                   ; Restore al
  1295.                         mov     bh,0
  1296.                         mov     es:[bx],al              ; Store al
  1297.                         Fetch
  1298. ISC_ZP                  endp
  1299.  
  1300.                         align   4
  1301. ISC_ABS_X               proc    near
  1302.                         Read_ABS_X
  1303.                         mov     ah,dh
  1304.                         test    dh,CPU_M                ; Decimal mode?
  1305.                         jnz     ISC_ABS_X1
  1306.                         inc     al
  1307.                         mov     bh,al                   ; Save al
  1308.                         sahf
  1309.                         cmc
  1310.                         sbb     ch,al
  1311.                         cmc
  1312.                         Flgnvzc
  1313.                         mov     al,bh                   ; Restore al
  1314.                         mov     bh,0
  1315.                         RMW_write                       ; Store al
  1316.                         align   4
  1317. ISC_ABS_X1:             inc     al
  1318.                         mov     bh,al                   ; Store al
  1319.                         xchg    al,ch
  1320.                         sahf
  1321.                         cmc
  1322.                         sbb     al,ch
  1323.                         das                             ; Adjust al for packed BCD sub
  1324.                         cmc
  1325.                         mov     ch,al
  1326.                         Flgnvzc
  1327.                         mov     al,bh                   ; Restore al
  1328.                         mov     bh,0
  1329.                         RMW_write                       ; Store al
  1330. ISC_ABS_X               endp
  1331.  
  1332.                         align   4
  1333. ISC_ABS_Y               proc    near
  1334.                         Read_ABS_Y
  1335.                         mov     ah,dh
  1336.                         test    dh,CPU_M                ; Decimal mode?
  1337.                         jnz     ISC_ABS_Y1
  1338.                         inc     al
  1339.                         mov     bh,al                   ; Save al
  1340.                         sahf
  1341.                         cmc
  1342.                         sbb     ch,al
  1343.                         cmc
  1344.                         Flgnvzc
  1345.                         mov     al,bh                   ; Restore al
  1346.                         mov     bh,0
  1347.                         RMW_write                       ; Store al
  1348.                         align   4
  1349. ISC_ABS_Y1:             inc     al
  1350.                         mov     bh,al                   ; Store al
  1351.                         xchg    al,ch
  1352.                         sahf
  1353.                         cmc
  1354.                         sbb     al,ch
  1355.                         das                             ; Adjust al for packed BCD sub
  1356.                         cmc
  1357.                         mov     ch,al
  1358.                         Flgnvzc
  1359.                         mov     al,bh                   ; Restore al
  1360.                         mov     bh,0
  1361.                         RMW_write                       ; Store al
  1362. ISC_ABS_Y               endp
  1363.  
  1364.                         align   4
  1365. ISC_IND_X               proc    near
  1366.                         Read_IND_X
  1367.                         mov     ah,dh
  1368.                         test    dh,CPU_M                ; Decimal mode?
  1369.                         jnz     ISC_IND_X1
  1370.                         inc     al
  1371.                         mov     bh,al                   ; Save al
  1372.                         sahf
  1373.                         cmc
  1374.                         sbb     ch,al
  1375.                         cmc
  1376.                         Flgnvzc
  1377.                         mov     al,bh                   ; Restore al
  1378.                         mov     bh,0
  1379.                         RMW_write                       ; Store al
  1380.                         align   4
  1381. ISC_IND_X1:             inc     al
  1382.                         mov     bh,al                   ; Store al
  1383.                         xchg    al,ch
  1384.                         sahf
  1385.                         cmc
  1386.                         sbb     al,ch
  1387.                         das                             ; Adjust al for packed BCD sub
  1388.                         cmc
  1389.                         mov     ch,al
  1390.                         Flgnvzc
  1391.                         mov     al,bh                   ; Restore al
  1392.                         mov     bh,0
  1393.                         RMW_write                       ; Store al
  1394. ISC_IND_X               endp
  1395.  
  1396.                         align   4
  1397. ISC_IND_Y               proc    near
  1398.                         Read_IND_Y
  1399.                         mov     ah,dh
  1400.                         test    dh,CPU_M                ; Decimal mode?
  1401.                         jnz     ISC_IND_Y1
  1402.                         inc     al
  1403.                         mov     bh,al                   ; Save al
  1404.                         sahf
  1405.                         cmc
  1406.                         sbb     ch,al
  1407.                         cmc
  1408.                         Flgnvzc
  1409.                         mov     al,bh                   ; Restore al
  1410.                         mov     bh,0
  1411.                         RMW_write                       ; Store al
  1412.                         align   4
  1413. ISC_IND_Y1:             inc     al
  1414.                         mov     bh,al                   ; Store al
  1415.                         xchg    al,ch
  1416.                         sahf
  1417.                         cmc
  1418.                         sbb     al,ch
  1419.                         das                             ; Adjust al for packed BCD sub
  1420.                         cmc
  1421.                         mov     ch,al
  1422.                         Flgnvzc
  1423.                         mov     al,bh                   ; Restore al
  1424.                         mov     bh,0
  1425.                         RMW_write                       ; Store al
  1426. ISC_IND_Y               endp
  1427.  
  1428.                         align   4
  1429. ISC_ZP_X                proc    near
  1430.                         mov     bl,es:[si]
  1431.                         mov     ah,dh
  1432.                         add     bl,cl
  1433.                         inc     si
  1434.                         mov     al,es:[bx]
  1435.                         test    dh,CPU_M                ; Decimal mode?
  1436.                         jnz     ISC_ZP_X1
  1437.                         inc     al
  1438.                         mov     bh,al                   ; Store al
  1439.                         sahf
  1440.                         cmc
  1441.                         sbb     ch,al
  1442.                         cmc
  1443.                         Flgnvzc
  1444.                         mov     al,bh                   ; Restore al
  1445.                         mov     bh,0
  1446.                         mov     es:[bx],al              ; Store al
  1447.                         Fetch
  1448.                         align   4
  1449. ISC_ZP_X1:              inc     al
  1450.                         mov     bh,al                   ; Store al
  1451.                         xchg    al,ch
  1452.                         sahf
  1453.                         cmc
  1454.                         sbb     al,ch
  1455.                         das                             ; Adjust al for packed BCD sub
  1456.                         cmc
  1457.                         mov     ch,al
  1458.                         Flgnvzc
  1459.                         mov     al,bh                   ; Restore al
  1460.                         mov     bh,0
  1461.                         mov     es:[bx],al              ; Store al
  1462.                         Fetch
  1463. ISC_ZP_X                endp
  1464.  
  1465.                         align   4
  1466. JMP_ABS                 proc    near
  1467.                         mov     si,es:[si]
  1468.                         Fetch
  1469. JMP_ABS                 endp
  1470.  
  1471.                         align   4
  1472. JMP_IND                 proc    near
  1473.                         mov     bx,es:[si]
  1474.                         mov     al,es:[bx]
  1475.                         inc     bl
  1476.                         mov     ah,es:[bx]
  1477.                         mov     bh,0
  1478.                         mov     si,ax
  1479.                         Fetch
  1480. JMP_IND                 endp
  1481.  
  1482.                         align   4
  1483. JSR                     proc    near
  1484.                         mov     ax,es:[si]
  1485.                         inc     si              ; 1 instead of 2 bytes!
  1486.                         xchg    ax,si
  1487.                         Push_16
  1488.                         Fetch
  1489. JSR                     endp
  1490.  
  1491.                         align   4
  1492. KIL                     proc    near
  1493.                         jmp     _6510Quit
  1494. KIL                     endp
  1495.  
  1496.                         align   4
  1497. LAX_ABS                 proc    near
  1498.                         Read_ABS
  1499.                         mov     ch,al           ; Load to accu
  1500.                         mov     cl,al           ; and to x reg
  1501.                         or      al,al
  1502.                         Flgnz
  1503.                         Fetch
  1504. LAX_ABS                 endp
  1505.  
  1506.                         align   4
  1507. LAX_ZP                  proc    near
  1508.                         mov     bl,es:[si]
  1509.                         inc     si
  1510.                         mov     ch,es:[bx]
  1511.                         mov     cl,ch
  1512.                         or      ch,ch
  1513.                         Flgnz
  1514.                         Fetch
  1515. LAX_ZP                  endp
  1516.  
  1517.                         align   4
  1518. LAX_IMM                 proc    near
  1519.                         mov     ch,es:[si]      ; Load to accu
  1520.                         mov     cl,ch           ; and to x reg
  1521.                         or      ch,ch
  1522.                         Flgnz
  1523.                         inc     si
  1524.                         Fetch
  1525. LAX_IMM                 endp
  1526.  
  1527.                         align   4
  1528. LAX_ABS_Y               proc    near
  1529.                         Read_ABS_Y
  1530.                         mov     ch,al
  1531.                         mov     cl,al
  1532.                         or      al,al
  1533.                         Flgnz
  1534.                         Fetch
  1535. LAX_ABS_Y               endp
  1536.  
  1537.                         align   4
  1538. LAX_IND_X               proc    near
  1539.                         Read_IND_X
  1540.                         mov     ch,al
  1541.                         mov     cl,al
  1542.                         or      al,al
  1543.                         Flgnz
  1544.                         Fetch
  1545. LAX_IND_X               endp
  1546.  
  1547.                         align   4
  1548. LAX_IND_Y               proc    near
  1549.                         Read_IND_Y
  1550.                         mov     ch,al
  1551.                         mov     cl,al
  1552.                         or      al,al
  1553.                         Flgnz
  1554.                         Fetch
  1555. LAX_IND_Y               endp
  1556.  
  1557.                         align   4
  1558. LAX_ZP_Y                proc    near
  1559.                         mov     bl,es:[si]
  1560.                         add     bl,dl
  1561.                         inc     si
  1562.                         mov     ch,es:[bx]
  1563.                         mov     cl,ch
  1564.                         or      ch,ch
  1565.                         Flgnz
  1566.                         Fetch
  1567. LAX_ZP_Y                endp
  1568.  
  1569.                         align   4
  1570. LDA_ABS                 proc    near
  1571.                         Read_ABS
  1572.                         mov     ch,al
  1573.                         or      al,al
  1574.                         Flgnz
  1575.                         Fetch
  1576. LDA_ABS                 endp
  1577.  
  1578.                         align   4
  1579. LDA_ZP                  proc    near
  1580.                         mov     bl,es:[si]
  1581.                         inc     si
  1582.                         mov     ch,es:[bx]
  1583.                         or      ch,ch
  1584.                         Flgnz
  1585.                         Fetch
  1586. LDA_ZP                  endp
  1587.  
  1588.                         align   4
  1589. LDA_IMM                 proc    near
  1590.                         mov     ch,es:[si]
  1591.                         inc     si
  1592.                         or      ch,ch
  1593.                         Flgnz
  1594.                         Fetch
  1595. LDA_IMM                 endp
  1596.  
  1597.                         align   4
  1598. LDA_ABS_X               proc    near
  1599.                         Read_ABS_X
  1600.                         mov     ch,al
  1601.                         or      al,al
  1602.                         Flgnz
  1603.                         Fetch
  1604. LDA_ABS_X               endp
  1605.  
  1606.                         align   4
  1607. LDA_ABS_Y               proc    near
  1608.                         Read_ABS_Y
  1609.                         mov     ch,al
  1610.                         or      al,al
  1611.                         Flgnz
  1612.                         Fetch
  1613. LDA_ABS_Y               endp
  1614.  
  1615.                         align   4
  1616. LDA_IND_X               proc    near
  1617.                         Read_IND_X
  1618.                         mov     ch,al
  1619.                         or      al,al
  1620.                         Flgnz
  1621.                         Fetch
  1622. LDA_IND_X               endp
  1623.  
  1624.                         align   4
  1625. LDA_IND_Y               proc    near
  1626.                         Read_IND_Y
  1627.                         mov     ch,al
  1628.                         or      al,al
  1629.                         Flgnz
  1630.                         Fetch
  1631. LDA_IND_Y               endp
  1632.  
  1633.                         align   4
  1634. LDA_ZP_X                proc    near
  1635.                         mov     bl,es:[si]
  1636.                         add     bl,cl
  1637.                         inc     si
  1638.                         mov     ch,es:[bx]
  1639.                         or      ch,ch
  1640.                         Flgnz
  1641.                         Fetch
  1642. LDA_ZP_X                endp
  1643.  
  1644.                         align   4
  1645. LDX_ABS                 proc    near
  1646.                         Read_ABS
  1647.                         mov     cl,al
  1648.                         or      al,al
  1649.                         Flgnz
  1650.                         Fetch
  1651. LDX_ABS                 endp
  1652.  
  1653.                         align   4
  1654. LDX_ZP                  proc    near
  1655.                         mov     bl,es:[si]
  1656.                         inc     si
  1657.                         mov     cl,es:[bx]
  1658.                         or      cl,cl
  1659.                         Flgnz
  1660.                         Fetch
  1661. LDX_ZP                  endp
  1662.  
  1663.                         align   4
  1664. LDX_IMM                 proc    near
  1665.                         mov     cl,es:[si]
  1666.                         inc     si
  1667.                         or      cl,cl
  1668.                         Flgnz
  1669.                         Fetch
  1670. LDX_IMM                 endp
  1671.  
  1672.                         align   4
  1673. LDX_ABS_Y               proc    near
  1674.                         Read_ABS_Y
  1675.                         mov     cl,al
  1676.                         or      al,al
  1677.                         Flgnz
  1678.                         Fetch
  1679. LDX_ABS_Y               endp
  1680.  
  1681.                         align   4
  1682. LDX_ZP_Y                proc    near
  1683.                         mov     bl,es:[si]
  1684.                         add     bl,dl
  1685.                         inc     si
  1686.                         mov     cl,es:[bx]
  1687.                         or      cl,cl
  1688.                         Flgnz
  1689.                         Fetch
  1690. LDX_ZP_Y                endp
  1691.  
  1692.                         align   4
  1693. LDY_ABS                 proc    near
  1694.                         Read_ABS
  1695.                         mov     dl,al
  1696.                         or      al,al
  1697.                         Flgnz
  1698.                         Fetch
  1699. LDY_ABS                 endp
  1700.  
  1701.                         align   4
  1702. LDY_ZP                  proc    near
  1703.                         mov     bl,es:[si]
  1704.                         inc     si
  1705.                         mov     dl,es:[bx]
  1706.                         or      dl,dl
  1707.                         Flgnz
  1708.                         Fetch
  1709. LDY_ZP                  endp
  1710.  
  1711.                         align   4
  1712. LDY_IMM                 proc    near
  1713.                         mov     dl,es:[si]
  1714.                         inc     si
  1715.                         or      dl,dl
  1716.                         Flgnz
  1717.                         Fetch
  1718. LDY_IMM                 endp
  1719.  
  1720.                         align   4
  1721. LDY_ABS_X               proc    near
  1722.                         Read_ABS_X
  1723.                         mov     dl,al
  1724.                         or      al,al
  1725.                         Flgnz
  1726.                         Fetch
  1727. LDY_ABS_X               endp
  1728.  
  1729.                         align   4
  1730. LDY_ZP_X                proc    near
  1731.                         mov     bl,es:[si]
  1732.                         add     bl,cl
  1733.                         inc     si
  1734.                         mov     dl,es:[bx]
  1735.                         or      dl,dl
  1736.                         Flgnz
  1737.                         Fetch
  1738. LDY_ZP_X                endp
  1739.  
  1740.                         align   4
  1741. LSR_A                   proc    near
  1742.                         shr     ch,1
  1743.                         Flgnzc
  1744.                         Fetch
  1745. LSR_A                   endp
  1746.  
  1747.                         align   4
  1748. LSR_ABS                 proc    near
  1749.                         Read_ABS
  1750.                         shr     al,1
  1751.                         Flgnzc
  1752.                         RMW_write
  1753. LSR_ABS                 endp
  1754.  
  1755.                         align   4
  1756. LSR_ZP                  proc    near
  1757.                         mov     bl,es:[si]
  1758.                         inc     si
  1759.                         shr     byte ptr es:[bx],1
  1760.                         Flgnzc
  1761.                         Fetch
  1762. LSR_ZP                  endp
  1763.  
  1764.                         align   4
  1765. LSR_ABS_X               proc    near
  1766.                         Read_ABS_X
  1767.                         shr     al,1
  1768.                         Flgnzc
  1769.                         RMW_write
  1770. LSR_ABS_X               endp
  1771.  
  1772.                         align   4
  1773. LSR_ZP_X                proc    near
  1774.                         mov     bl,es:[si]
  1775.                         add     bl,cl
  1776.                         inc     si
  1777.                         shr     byte ptr es:[bx],1
  1778.                         Flgnzc
  1779.                         Fetch
  1780. LSR_ZP_X                endp
  1781.  
  1782.                         align   4
  1783. NOP_                    proc    near
  1784.                         Fetch
  1785. NOP_                    endp
  1786.  
  1787.                         align   4
  1788. ORA_ABS                 proc    near
  1789.                         Read_ABS
  1790.                         or      ch,al
  1791.                         Flgnz
  1792.                         Fetch
  1793. ORA_ABS                 endp
  1794.  
  1795.                         align   4
  1796. ORA_ZP                  proc    near
  1797.                         mov     bl,es:[si]
  1798.                         inc     si
  1799.                         or      ch,es:[bx]
  1800.                         Flgnz
  1801.                         Fetch
  1802. ORA_ZP                  endp
  1803.  
  1804.                         align   4
  1805. ORA_IMM                 proc    near
  1806.                         or      ch,es:[si]
  1807.                         Flgnz
  1808.                         inc     si
  1809.                         Fetch
  1810. ORA_IMM                 endp
  1811.  
  1812.                         align   4
  1813. ORA_ABS_X               proc    near
  1814.                         Read_ABS_X
  1815.                         or      ch,al
  1816.                         Flgnz
  1817.                         Fetch
  1818. ORA_ABS_X               endp
  1819.  
  1820.                         align   4
  1821. ORA_ABS_Y               proc    near
  1822.                         Read_ABS_Y
  1823.                         or      ch,al
  1824.                         Flgnz
  1825.                         Fetch
  1826. ORA_ABS_Y               endp
  1827.  
  1828.                         align   4
  1829. ORA_IND_X               proc    near
  1830.                         Read_IND_X
  1831.                         or      ch,al
  1832.                         Flgnz
  1833.                         Fetch
  1834. ORA_IND_X               endp
  1835.  
  1836.                         align   4
  1837. ORA_IND_Y               proc    near
  1838.                         Read_IND_Y
  1839.                         or      ch,al
  1840.                         Flgnz
  1841.                         Fetch
  1842. ORA_IND_Y               endp
  1843.  
  1844.                         align   4
  1845. ORA_ZP_X                proc    near
  1846.                         mov     bl,es:[si]
  1847.                         add     bl,cl
  1848.                         inc     si
  1849.                         or      ch,es:[bx]
  1850.                         Flgnz
  1851.                         Fetch
  1852. ORA_ZP_X                endp
  1853.  
  1854.                         align   4
  1855. PHA                     proc    near
  1856.                         Push_8  ch
  1857.                         Fetch
  1858. PHA                     endp
  1859.  
  1860.                         align   4
  1861. PHP                     proc    near
  1862.                         mov     bl,dh
  1863.                         mov     al,FlgDecodeTable[bx]
  1864.                         Push_8  al
  1865.                         Fetch
  1866. PHP                     endp
  1867.  
  1868.                         align   4
  1869. PLA                     proc    near
  1870.                         Pop_8   ch
  1871.                         or      ch,ch
  1872.                         Flgnz
  1873.                         Fetch
  1874. PLA                     endp
  1875.  
  1876.                         align   4
  1877. PLP                     proc    near
  1878.                         mov     bx,bp
  1879.                         inc     bl
  1880.                         mov     bp,bx
  1881.                         movzx   bx,byte ptr es:[bx]
  1882.                         mov     dh,FlgEncodeTable[bx]
  1883.                         Fetch
  1884. PLP                     endp
  1885.  
  1886.                         align   4
  1887. RLA_ABS                 proc    near
  1888.                         Read_ABS
  1889.                         mov     ah,dh
  1890.                     and     dh,Not (CPU_N + CPU_Z + CPU_C)
  1891.                         sahf
  1892.                         adc     al,al                   ; Shift data left
  1893.                         adc     dh,0                    ; Update Carry
  1894.                         and     ch,al                   ; AND with accu
  1895.                         lahf
  1896.                     and     ah,CPU_N + CPU_Z
  1897.                         or      dh,ah
  1898.                         RMW_write
  1899. RLA_ABS                 endp
  1900.  
  1901.                         align   4
  1902. RLA_ZP                  proc    near
  1903.                         mov     bl,es:[si]
  1904.                         mov     ah,dh
  1905.                         inc     si
  1906.                         mov     al,es:[bx]
  1907.                     and     dh,Not (CPU_N + CPU_Z + CPU_C)
  1908.                         sahf
  1909.                         adc     al,al                   ; Shift data left
  1910.                         adc     dh,0                    ; Update carry
  1911.                         and     ch,al                   ; AND with accu
  1912.                         lahf
  1913.                         mov     es:[bx],al              ; Store result
  1914.                     and     ah,CPU_N + CPU_Z
  1915.                         or      dh,ah
  1916.                         Fetch
  1917. RLA_ZP                  endp
  1918.  
  1919.                         align   4
  1920. RLA_ABS_X               proc    near
  1921.                         Read_ABS_X
  1922.                         mov     ah,dh
  1923.                     and     dh,Not (CPU_N + CPU_Z + CPU_C)
  1924.                         sahf
  1925.                         adc     al,al                   ; Shift data left
  1926.                         adc     dh,0
  1927.                         and     ch,al                   ; AND with accu
  1928.                         lahf
  1929.                     and     ah,CPU_N + CPU_Z
  1930.                         or      dh,ah
  1931.                         RMW_write
  1932. RLA_ABS_X               endp
  1933.  
  1934.                         align   4
  1935. RLA_ABS_Y               proc    near
  1936.                         Read_ABS_Y
  1937.                         mov     ah,dh
  1938.                     and     dh,Not (CPU_N + CPU_Z + CPU_C)
  1939.                         sahf
  1940.                         adc     al,al                   ; Shift data left
  1941.                         adc     dh,0
  1942.                         and     ch,al                   ; AND with accu
  1943.                         lahf
  1944.                     and     ah,CPU_N + CPU_Z
  1945.                         or      dh,ah
  1946.                         RMW_write
  1947. RLA_ABS_Y               endp
  1948.  
  1949.                         align   4
  1950. RLA_IND_X               proc    near
  1951.                         Read_IND_X
  1952.                         mov     ah,dh
  1953.                     and     dh,Not (CPU_N + CPU_Z + CPU_C)
  1954.                         sahf
  1955.                         adc     al,al                   ; Shift data left
  1956.                     adc     dh,0
  1957.                         and     ch,al                   ; AND with accu
  1958.                         lahf
  1959.                     and     ah,CPU_N + CPU_Z
  1960.                         or      dh,ah
  1961.                         RMW_write
  1962. RLA_IND_X               endp
  1963.  
  1964.                         align   4
  1965. RLA_IND_Y               proc    near
  1966.                         Read_IND_Y
  1967.                         mov     ah,dh
  1968.                     and     dh,Not (CPU_N + CPU_Z + CPU_C)
  1969.                         sahf
  1970.                         adc     al,al                   ; Shift data left
  1971.                         adc     dh,0
  1972.                         and     ch,al                   ; AND with accu
  1973.                         lahf
  1974.                     and     ah,CPU_N + CPU_Z
  1975.                         or      dh,ah
  1976.                         RMW_write
  1977. RLA_IND_Y               endp
  1978.  
  1979.                         align   4
  1980. RLA_ZP_X                proc    near
  1981.                         mov     bl,es:[si]
  1982.                         mov     ah,dh
  1983.                         add     bl,cl
  1984.                         inc     si
  1985.                         mov     al,es:[bx]
  1986.                     and     dh,Not (CPU_N + CPU_Z + CPU_C)
  1987.                         sahf
  1988.                         adc     al,al                   ; Shift data left
  1989.                         adc     dh,0
  1990.                         and     ch,al                   ; AND with accu
  1991.                         lahf
  1992.                         mov     es:[bx],al
  1993.                     and     ah,CPU_N + CPU_Z
  1994.                         or      dh,ah
  1995.                         Fetch
  1996. RLA_ZP_X                endp
  1997.  
  1998.                         align   4
  1999. ROL_A                   proc    near
  2000.                         mov     ah,dh
  2001.                         sahf
  2002.                         adc     ch,ch
  2003.                         Flgnzc
  2004.                         Fetch
  2005. ROL_A                   endp
  2006.  
  2007.                         align   4
  2008. ROL_ABS                 proc    near
  2009.                         Read_ABS
  2010.                         mov     ah,dh
  2011.                         sahf
  2012.                         adc     al,al
  2013.                         Flgnzc
  2014.                         RMW_write
  2015. ROL_ABS                 endp
  2016.  
  2017.                         align   4
  2018. ROL_ZP                  proc    near
  2019.                         mov     bl,es:[si]
  2020.                         mov     ah,dh
  2021.                         inc     si
  2022.                         mov     al,es:[bx]
  2023.                         sahf
  2024.                         adc     es:[bx],al
  2025.                         Flgnzc
  2026.                         Fetch
  2027. ROL_ZP                  endp
  2028.  
  2029.                         align   4
  2030. ROL_ABS_X               proc    near
  2031.                         Read_ABS_X
  2032.                         mov     ah,dh
  2033.                         sahf
  2034.                         adc     al,al
  2035.                         Flgnzc
  2036.                         RMW_write
  2037. ROL_ABS_X               endp
  2038.  
  2039.                         align   4
  2040. ROL_ZP_X                proc    near
  2041.                         mov     bl,es:[si]
  2042.                         mov     ah,dh
  2043.                         add     bl,cl
  2044.                         inc     si
  2045.                         mov     al,es:[bx]
  2046.                         sahf
  2047.                         adc     es:[bx],al
  2048.                         Flgnzc
  2049.                         Fetch
  2050. ROL_ZP_X                endp
  2051.  
  2052.                         align   4
  2053. ROR_A                   proc    near
  2054.                         mov     ah,dh
  2055.                         sahf
  2056.                         rcr     ch,1
  2057.                         inc     ch
  2058.                         dec     ch
  2059.                         Flgnzc
  2060.                         Fetch
  2061. ROR_A                   endp
  2062.  
  2063.                         align   4
  2064. ROR_ABS                 proc    near
  2065.                         Read_ABS
  2066.                         mov     ah,dh
  2067.                         sahf
  2068.                         rcr     al,1
  2069.                         inc     al
  2070.                         dec     al
  2071.                         Flgnzc
  2072.                         RMW_write
  2073. ROR_ABS                 endp
  2074.  
  2075.                         align   4
  2076. ROR_ZP                  proc    near
  2077.                         mov     bl,es:[si]
  2078.                         mov     ah,dh
  2079.                         inc     si
  2080.                         sahf
  2081.                         mov     al,es:[bx]
  2082.                         rcr     al,1
  2083.                         mov     es:[bx],al
  2084.                         inc     al
  2085.                         dec     al
  2086.                         Flgnzc
  2087.                         Fetch
  2088. ROR_ZP                  endp
  2089.  
  2090.                         align   4
  2091. ROR_ABS_X               proc    near
  2092.                         Read_ABS_X
  2093.                         mov     ah,dh
  2094.                         sahf
  2095.                         rcr     al,1
  2096.                         inc     al
  2097.                         dec     al
  2098.                         Flgnzc
  2099.                         RMW_write
  2100. ROR_ABS_X               endp
  2101.  
  2102.                         align   4
  2103. ROR_ZP_X                proc    near
  2104.                         mov     bl,es:[si]
  2105.                         mov     ah,dh
  2106.                         add     bl,cl
  2107.                         inc     si
  2108.                         sahf
  2109.                         mov     al,es:[bx]
  2110.                         rcr     al,1
  2111.                         mov     es:[bx],al
  2112.                         inc     al
  2113.                         dec     al
  2114.                         Flgnzc
  2115.                         Fetch
  2116. ROR_ZP_X                endp
  2117.  
  2118.                         align   4
  2119. RRA_ABS                 proc    near
  2120.                         Read_ABS
  2121.                         mov     ah,dh
  2122.                         test    dh,CPU_M                ; Decimal mode?
  2123.                         jnz     RRA_ABS1
  2124.                         sahf
  2125.                         rcr     al,1                    ; Rotate data right
  2126.                         mov     bh,al                   ; Save al
  2127.                         adc     ch,al
  2128.                         Flgnvzc
  2129.                         mov     al,bh                   ; Restore al
  2130.                         mov     bh,0
  2131.                         RMW_write                       ; Store al
  2132.                         align   4
  2133. RRA_ABS1:               sahf
  2134.                         rcr     al,1                    ; Rotate data right
  2135.                         mov     bh,al                   ; Store al
  2136.                         adc     al,ch
  2137.                         daa                             ; Adjust al for packed BCD add
  2138.                         mov     ch,al
  2139.                         Flgnvzc
  2140.                         mov     al,bh                   ; Restore al
  2141.                         mov     bh,0
  2142.                         RMW_write                       ; Store al
  2143. RRA_ABS                 endp
  2144.  
  2145.                         align   4
  2146. RRA_ZP                  proc    near
  2147.                         mov     bl,es:[si]
  2148.                         mov     ah,dh
  2149.                         inc     si
  2150.                         mov     al,es:[bx]
  2151.                         test    dh,CPU_M                ; Decimal mode?
  2152.                         jnz     RRA_ZP1
  2153.                         sahf                            ; Set/reset real carry
  2154.                         rcr     al,1                    ; Rotate data right
  2155.                         mov     bh,al                   ; Store al
  2156.                         adc     ch,al
  2157.                         Flgnvzc
  2158.                         mov     al,bh                   ; Restore al
  2159.                         mov     bh,0
  2160.                         mov     es:[bx],al              ; Store al
  2161.                         Fetch
  2162.                         align   4
  2163. RRA_ZP1:                sahf                            ; Set/reset real carry
  2164.                         rcr     al,1                    ; Rotate data right
  2165.                         mov     bh,al                   ; Store al
  2166.                         adc     al,ch
  2167.                         daa                             ; Adjust al for packed BCD add
  2168.                         mov     ch,al
  2169.                         Flgnvzc
  2170.                         mov     al,bh                   ; Restore al
  2171.                         mov     bh,0
  2172.                         mov     es:[bx],al              ; Store al
  2173.                         Fetch
  2174. RRA_ZP                  endp
  2175.  
  2176.                         align   4
  2177. RRA_ABS_X               proc    near
  2178.                         Read_ABS_X
  2179.                         mov     ah,dh
  2180.                         test    dh,CPU_M                ; Decimal mode?
  2181.                         jnz     RRA_ABS_X1
  2182.                         sahf                            ; Set/reset real carry
  2183.                         rcr     al,1
  2184.                         mov     bh,al                   ; Store al
  2185.                         adc     ch,al
  2186.                         Flgnvzc
  2187.                         mov     al,bh                   ; Restore al
  2188.                         mov     bh,0
  2189.                         RMW_write                       ; Store al
  2190.                         align   4
  2191. RRA_ABS_X1:             sahf                            ; Set/reset real carry
  2192.                         rcr     al,1
  2193.                         mov     bh,al                   ; Store al
  2194.                         adc     al,ch
  2195.                         daa                             ; Adjust al for packed BCD add
  2196.                         mov     ch,al
  2197.                         Flgnvzc
  2198.                         mov     al,bh                   ; Restore al
  2199.                         mov     bh,0
  2200.                         RMW_write                       ; Store al
  2201. RRA_ABS_X               endp
  2202.  
  2203.                         align   4
  2204. RRA_ABS_Y               proc    near
  2205.                         Read_ABS_Y
  2206.                         mov     ah,dh
  2207.                         test    dh,CPU_M                ; Decimal mode?
  2208.                         jnz     RRA_ABS_Y1
  2209.                         sahf                            ; Set/reset real carry
  2210.                         rcr     al,1
  2211.                         mov     bh,al                   ; Store al
  2212.                         adc     ch,al
  2213.                         Flgnvzc
  2214.                         mov     al,bh                   ; Restore al
  2215.                         mov     bh,0
  2216.                         RMW_write                       ; Store al
  2217.                         align   4
  2218. RRA_ABS_Y1:             sahf                            ; Set/reset real carry
  2219.                         rcr     al,1
  2220.                         mov     bh,al                   ; Store al
  2221.                         adc     al,ch
  2222.                         daa                             ; Adjust al for packed BCD add
  2223.                         mov     ch,al
  2224.                         Flgnvzc
  2225.                         mov     al,bh                   ; Restore al
  2226.                         mov     bh,0
  2227.                         RMW_write                       ; Store al
  2228. RRA_ABS_Y               endp
  2229.  
  2230.                         align   4
  2231. RRA_IND_X               proc    near
  2232.                         Read_IND_X
  2233.                         mov     ah,dh
  2234.                         test    dh,CPU_M                ; Decimal mode?
  2235.                         jnz     RRA_IND_X1
  2236.                         sahf                            ; Set/reset real carry
  2237.                         rcr     al,1
  2238.                         mov     bh,al                   ; Store al
  2239.                         adc     ch,al
  2240.                         Flgnvzc
  2241.                         mov     al,bh                   ; Restore al
  2242.                         mov     bh,0
  2243.                         RMW_write                       ; Store al
  2244.                         align   4
  2245. RRA_IND_X1:             sahf                            ; Set/reset real carry
  2246.                         rcr     al,1
  2247.                         mov     bh,al                   ; Store al
  2248.                         adc     al,ch
  2249.                         daa                             ; Adjust al for packed BCD add
  2250.                         mov     ch,al
  2251.                         Flgnvzc
  2252.                         mov     al,bh                   ; Restore al
  2253.                         mov     bh,0
  2254.                         RMW_write                       ; Store al
  2255. RRA_IND_X               endp
  2256.  
  2257.                         align   4
  2258. RRA_IND_Y               proc    near
  2259.                         Read_IND_Y
  2260.                         mov     ah,dh
  2261.                         test    dh,CPU_M                ; Decimal mode?
  2262.                         jnz     RRA_IND_Y1
  2263.                         sahf                            ; Set/reset real carry
  2264.                         rcr     al,1
  2265.                         mov     bh,al                   ; Store al
  2266.                         adc     ch,al
  2267.                         Flgnvzc
  2268.                         mov     al,bh                   ; Restore al
  2269.                         mov     bh,0
  2270.                         RMW_write                       ; Store al
  2271.                         align   4
  2272. RRA_IND_Y1:             sahf                            ; Set/reset real carry
  2273.                         rcr     al,1
  2274.                         mov     bh,al                   ; Store al
  2275.                         adc     al,ch
  2276.                         daa                             ; Adjust al for packed BCD add
  2277.                         mov     ch,al
  2278.                         Flgnvzc
  2279.                         mov     al,bh                   ; Restore al
  2280.                         mov     bh,0
  2281.                         RMW_write                       ; Store al
  2282. RRA_IND_Y               endp
  2283.  
  2284.                         align   4
  2285. RRA_ZP_X                proc    near
  2286.                         mov     bl,es:[si]
  2287.                         mov     ah,dh
  2288.                         add     bl,cl
  2289.                         inc     si
  2290.                         mov     al,es:[bx]
  2291.                         test    dh,CPU_M                ; Decimal mode?
  2292.                         jnz     RRA_ZP_X1
  2293.                         sahf                            ; Set/reset real carry
  2294.                         rcr     al,1
  2295.                         mov     bh,al                   ; Store al
  2296.                         adc     ch,al
  2297.                         Flgnvzc
  2298.                         mov     al,bh                   ; Restore al
  2299.                         mov     bh,0
  2300.                         mov     es:[bx],al              ; Store al
  2301.                         Fetch
  2302.                         align   4
  2303. RRA_ZP_X1:              sahf                            ; Set/reset real carry
  2304.                         rcr     al,1
  2305.                         mov     bh,al                   ; Store al
  2306.                         adc     al,ch
  2307.                         daa                             ; Adjust al for packed BCD add
  2308.                         mov     ch,al
  2309.                         Flgnvzc
  2310.                         mov     al,bh                   ; Restore al
  2311.                         mov     bh,0
  2312.                         mov     es:[bx],al              ; Store al
  2313.                         Fetch
  2314. RRA_ZP_X                endp
  2315.  
  2316.                         align   4
  2317. RTI                     proc    near
  2318.                         Pop_Int
  2319.                         Fetch
  2320. RTI                     endp
  2321.  
  2322.                         align   4
  2323. RTS                     proc    near
  2324.                         Pop_16
  2325.                         inc     ax                      ; Advance one byte!
  2326.                         mov     si,ax
  2327.                         Fetch
  2328. RTS                     endp
  2329.  
  2330.                         align   4
  2331. SAH_ABS_Y               proc    near
  2332.                         mov     al,ch
  2333.                         mov     ah,es:[si+1]            ; Hi-byte
  2334.                         and     al,cl                   ; AND A,X
  2335.                         inc     ah
  2336.                         and     al,ah
  2337.                         Flgnz
  2338.                         Write_ABS_Y
  2339. SAH_ABS_Y               endp
  2340.  
  2341.                         align   4
  2342. SAH_IND_Y               proc    near
  2343.                         mov     al,ch
  2344.                         mov     ah,es:[si+1]            ; Hi-byte
  2345.                         and     al,cl                   ; AND A,X
  2346.                         inc     ah
  2347.                         and     al,ah
  2348.                         Flgnz
  2349.                         Write_IND_Y
  2350. SAH_IND_Y               endp
  2351.  
  2352.                         align   4
  2353. SAX_ABS                 proc    near
  2354.                         mov     al,ch
  2355.                         and     al,cl
  2356.                         Flgnz
  2357.                         Write_ABS
  2358. SAX_ABS                 endp
  2359.  
  2360.                         align   4
  2361. SAX_ZP                  proc    near
  2362.                         mov     al,ch
  2363.                         and     al,cl
  2364.                         Flgnz
  2365.                         Write_ZP al
  2366. SAX_ZP                  endp
  2367.  
  2368.                         align   4
  2369. SAX_ZP_Y                proc    near
  2370.                         mov     al,ch
  2371.                         and     al,cl
  2372.                         Flgnz
  2373.                         Write_ZP_Y al
  2374. SAX_ZP_Y                endp
  2375.  
  2376.                         align   4
  2377. SAX_IND_X               proc    near
  2378.                         mov     al,ch
  2379.                         and     al,cl
  2380.                         Flgnz
  2381.                         Write_IND_X
  2382. SAX_IND_X               endp
  2383.  
  2384.                         align   4
  2385. SBC_ABS                 proc    near
  2386.                         Read_ABS
  2387.                         OpSBC
  2388. SBC_ABS                 endp
  2389.  
  2390.                         align   4
  2391. SBC_ZP                  proc    near
  2392.                         Read_ZP al
  2393.                         OpSBC
  2394. SBC_ZP                  endp
  2395.  
  2396.                         align   4
  2397. SBC_IMM                 proc    near
  2398.                         Read_IMM al
  2399.                         OpSBC
  2400. SBC_IMM                 endp
  2401.  
  2402.                         align   4
  2403. SBC_ABS_X               proc    near
  2404.                         Read_ABS_X
  2405.                         OpSBC
  2406. SBC_ABS_X               endp
  2407.  
  2408.                         align   4
  2409. SBC_ABS_Y               proc    near
  2410.                         Read_ABS_Y
  2411.                         OpSBC
  2412. SBC_ABS_Y               endp
  2413.  
  2414.                         align   4
  2415. SBC_IND_X               proc    near
  2416.                         Read_IND_X
  2417.                         OpSBC
  2418. SBC_IND_X               endp
  2419.  
  2420.                         align   4
  2421. SBC_IND_Y               proc    near
  2422.                         Read_IND_Y
  2423.                         OpSBC
  2424. SBC_IND_Y               endp
  2425.  
  2426.                         align   4
  2427. SBC_ZP_X                proc    near
  2428.                         Read_ZP_X al
  2429.                         OpSBC
  2430. SBC_ZP_X                endp
  2431.  
  2432.                         align   4
  2433. SEC                     proc    near
  2434.                         or      dh,CPU_C
  2435.                         Fetch
  2436. SEC                     endp
  2437.  
  2438.                         align   4
  2439. SEI                     proc    near
  2440.                         or      dh,CPU_I
  2441.                         Fetch
  2442. SEI                     endp
  2443.  
  2444.                         align   4
  2445. SED                     proc    near
  2446.                         or      dh,CPU_M
  2447.                         Fetch
  2448. SED                     endp
  2449.  
  2450.                         align   4
  2451. SLO_ABS                 proc    near
  2452.                         Read_ABS
  2453.                     and     dh,Not (CPU_N + CPU_Z + CPU_C)
  2454.                         add     al,al                   ; Shift data left
  2455.                         adc     dh,0                    ; Update Carry
  2456.                         or      ch,al                   ; OR with accu
  2457.                         lahf
  2458.                     and     ah,CPU_N + CPU_Z
  2459.                         or      dh,ah
  2460.                         RMW_write
  2461. SLO_ABS                 endp
  2462.  
  2463.                         align   4
  2464. SLO_ZP                  proc    near
  2465.                         mov     bl,es:[si]
  2466.                         inc     si
  2467.                         mov     al,es:[bx]
  2468.                     and     dh,Not (CPU_N + CPU_Z + CPU_C)
  2469.                         add     al,al                   ; Shift data left
  2470.                         adc     dh,0                    ; Update carry
  2471.                         or      ch,al                   ; OR with accu
  2472.                         lahf
  2473.                         mov     es:[bx],al              ; Store result
  2474.                     and     ah,CPU_N + CPU_Z
  2475.                         or      dh,ah
  2476.                         Fetch
  2477. SLO_ZP                  endp
  2478.  
  2479.                         align   4
  2480. SLO_ABS_X               proc    near
  2481.                         Read_ABS_X
  2482.                     and     dh,Not (CPU_N + CPU_Z + CPU_C)
  2483.                         add     al,al                   ; Shift data left
  2484.                         adc     dh,0
  2485.                         or      ch,al                   ; OR with accu
  2486.                         lahf
  2487.                     and     ah,CPU_N + CPU_Z
  2488.                         or      dh,ah
  2489.                         RMW_write
  2490. SLO_ABS_X               endp
  2491.  
  2492.                         align   4
  2493. SLO_ABS_Y               proc    near
  2494.                         Read_ABS_Y
  2495.                     and     dh,Not (CPU_N + CPU_Z + CPU_C)
  2496.                         add     al,al                   ; Shift data left
  2497.                         adc     dh,0
  2498.                         or      ch,al                   ; OR with accu
  2499.                         lahf
  2500.                     and     ah,CPU_N + CPU_Z
  2501.                         or      dh,ah
  2502.                         RMW_write
  2503. SLO_ABS_Y               endp
  2504.  
  2505.                         align   4
  2506. SLO_IND_X               proc    near
  2507.                         Read_IND_X
  2508.                     and     dh,Not (CPU_N + CPU_Z + CPU_C)
  2509.                         add     al,al                   ; Shift data left
  2510.                     adc     dh,0
  2511.                         or      ch,al                   ; OR with accu
  2512.                         lahf
  2513.                     and     ah,CPU_N + CPU_Z
  2514.                         or      dh,ah
  2515.                         RMW_write
  2516. SLO_IND_X               endp
  2517.  
  2518.                         align   4
  2519. SLO_IND_Y               proc    near
  2520.                         Read_IND_Y
  2521.                     and     dh,Not (CPU_N + CPU_Z + CPU_C)
  2522.                         add     al,al                   ; Shift data left
  2523.                         adc     dh,0
  2524.                         or      ch,al                   ; OR with accu
  2525.                         lahf
  2526.                     and     ah,CPU_N + CPU_Z
  2527.                         or      dh,ah
  2528.                         RMW_write
  2529. SLO_IND_Y               endp
  2530.  
  2531.                         align   4
  2532. SLO_ZP_X                proc    near
  2533.                         mov     bl,es:[si]
  2534.                         add     bl,cl
  2535.                         inc     si
  2536.                         mov     al,es:[bx]
  2537.                     and     dh,Not (CPU_N + CPU_Z + CPU_C)
  2538.                         add     al,al                   ; Shift data left
  2539.                         adc     dh,0
  2540.                         or      ch,al                   ; OR with accu
  2541.                         lahf
  2542.                         mov     es:[bx],al
  2543.                     and     ah,CPU_N + CPU_Z
  2544.                         or      dh,ah
  2545.                         Fetch
  2546. SLO_ZP_X                endp
  2547.  
  2548.                         align   4
  2549. SRE_ABS                 proc    near
  2550.                         Read_ABS
  2551.                     and     dh,Not (CPU_N + CPU_Z + CPU_C)
  2552.                         shr     al,1                    ; Shift data right
  2553.                         adc     dh,0                    ; Update Carry
  2554.                         xor     ch,al                   ; XOR with accu
  2555.                         lahf
  2556.                     and     ah,CPU_N + CPU_Z
  2557.                         or      dh,ah
  2558.                         RMW_write
  2559. SRE_ABS                 endp
  2560.  
  2561.                         align   4
  2562. SRE_ZP                  proc    near
  2563.                         mov     bl,es:[si]
  2564.                         inc     si
  2565.                         mov     al,es:[bx]
  2566.                     and     dh,Not (CPU_N + CPU_Z + CPU_C)
  2567.                         shr     al,1                    ; Shift data right
  2568.                         adc     dh,0                    ; Update carry
  2569.                         xor     ch,al                   ; XOR with accu
  2570.                         lahf
  2571.                         mov     es:[bx],al              ; Store result
  2572.                     and     ah,CPU_N + CPU_Z
  2573.                         or      dh,ah
  2574.                         Fetch
  2575. SRE_ZP                  endp
  2576.  
  2577.                         align   4
  2578. SRE_ABS_X               proc    near
  2579.                         Read_ABS_X
  2580.                     and     dh,Not (CPU_N + CPU_Z + CPU_C)
  2581.                         shr     al,1                    ; Shift data right
  2582.                         adc     dh,0
  2583.                         xor     ch,al                   ; XOR with accu
  2584.                         lahf
  2585.                     and     ah,CPU_N + CPU_Z
  2586.                         or      dh,ah
  2587.                         RMW_write
  2588. SRE_ABS_X               endp
  2589.  
  2590.                         align   4
  2591. SRE_ABS_Y               proc    near
  2592.                         Read_ABS_Y
  2593.                     and     dh,Not (CPU_N + CPU_Z + CPU_C)
  2594.                         shr     al,1                    ; Shift data right
  2595.                         adc     dh,0
  2596.                         xor     ch,al                   ; XOR with accu
  2597.                         lahf
  2598.                     and     ah,CPU_N + CPU_Z
  2599.                         or      dh,ah
  2600.                         RMW_write
  2601. SRE_ABS_Y               endp
  2602.  
  2603.                         align   4
  2604. SRE_IND_X               proc    near
  2605.                         Read_IND_X
  2606.                     and     dh,Not (CPU_N + CPU_Z + CPU_C)
  2607.                         shr     al,1                    ; Shift data right
  2608.                     adc     dh,0
  2609.                         xor     ch,al                   ; XOR with accu
  2610.                         lahf
  2611.                     and     ah,CPU_N + CPU_Z
  2612.                         or      dh,ah
  2613.                         RMW_write
  2614. SRE_IND_X               endp
  2615.  
  2616.                         align   4
  2617. SRE_IND_Y               proc    near
  2618.                         Read_IND_Y
  2619.                     and     dh,Not (CPU_N + CPU_Z + CPU_C)
  2620.                         shr     al,1                    ; Shift data right
  2621.                         adc     dh,0
  2622.                         xor     ch,al                   ; XOR with accu
  2623.                         lahf
  2624.                     and     ah,CPU_N + CPU_Z
  2625.                         or      dh,ah
  2626.                         RMW_write
  2627. SRE_IND_Y               endp
  2628.  
  2629.                         align   4
  2630. SRE_ZP_X                proc    near
  2631.                         mov     bl,es:[si]
  2632.                         add     bl,cl
  2633.                         inc     si
  2634.                         mov     al,es:[bx]
  2635.                     and     dh,Not (CPU_N + CPU_Z + CPU_C)
  2636.                         shr     al,1                    ; Shift data right
  2637.                         adc     dh,0
  2638.                         xor     ch,al                   ; XOR with accu
  2639.                         lahf
  2640.                         mov     es:[bx],al
  2641.                     and     ah,CPU_N + CPU_Z
  2642.                         or      dh,ah
  2643.                         Fetch
  2644. SRE_ZP_X                endp
  2645.  
  2646.                         align   4
  2647. SSH_ABS_Y               proc    near
  2648.                         mov     al,ch
  2649.                         and     al,cl                   ; AND A,X
  2650.                         mov     ah,001h
  2651.                         mov     bp,ax                   ; Store in SP
  2652.                         mov     ah,es:[si+1]            ; High-byte
  2653.                         inc     ah
  2654.                         and     al,ah
  2655.                         Write_ABS_Y
  2656.                         Fetch
  2657. SSH_ABS_Y               endp
  2658.  
  2659.                         align   4
  2660. SXH_ABS_Y               proc    near
  2661.                         mov     al,es:[si+1]            ; High-byte
  2662.                         inc     al
  2663.                         and     al,cl                   ; AND HI+1,X
  2664.                         Write_ABS_Y
  2665. SXH_ABS_Y               endp
  2666.  
  2667.                         align   4
  2668. SYH_ABS_X               proc    near
  2669.                         mov     al,es:[si+1]            ; High-byte
  2670.                         inc     al
  2671.                         and     al,dl                   ; AND HI+1,Y
  2672.                         Write_ABS_X
  2673. SYH_ABS_X               endp
  2674.  
  2675.                         align   4
  2676. STA_ABS                 proc    near
  2677.                         mov     al,ch
  2678.                         Write_ABS
  2679. STA_ABS                 endp
  2680.  
  2681.                         align   4
  2682. STA_ZP                  proc    near
  2683.                         Write_ZP ch
  2684. STA_ZP                  endp
  2685.  
  2686.                         align   4
  2687. STA_ABS_X               proc    near
  2688.                         mov     al,ch
  2689.                         Write_ABS_X
  2690. STA_ABS_X               endp
  2691.  
  2692.                         align   4
  2693. STA_ABS_Y               proc    near
  2694.                         mov     al,ch
  2695.                         Write_ABS_Y
  2696. STA_ABS_Y               endp
  2697.  
  2698.                         align   4
  2699. STA_IND_X               proc    near
  2700.                         mov     al,ch
  2701.                         Write_IND_X
  2702. STA_IND_X               endp
  2703.  
  2704.                         align   4
  2705. STA_IND_Y               proc    near
  2706.                         mov     al,ch
  2707.                         Write_IND_Y
  2708. STA_IND_Y               endp
  2709.  
  2710.                         align   4
  2711. STA_ZP_X                proc    near
  2712.                         Write_ZP_X ch
  2713. STA_ZP_X                endp
  2714.  
  2715.                         align   4
  2716. STX_ABS                 proc    near
  2717.                         mov     al,cl
  2718.                         Write_ABS
  2719. STX_ABS                 endp
  2720.  
  2721.                         align   4
  2722. STX_ZP                  proc    near
  2723.                         Write_ZP cl
  2724. STX_ZP                  endp
  2725.  
  2726.                         align   4
  2727. STX_ZP_Y                proc    near
  2728.                         Write_ZP_Y cl
  2729. STX_ZP_Y                endp
  2730.  
  2731.                         align   4
  2732. STY_ABS                 proc    near
  2733.                         mov     al,dl
  2734.                         Write_ABS
  2735. STY_ABS                 endp
  2736.  
  2737.                         align   4
  2738. STY_ZP                  proc    near
  2739.                         Write_ZP dl
  2740. STY_ZP                  endp
  2741.  
  2742.                         align   4
  2743. STY_ZP_X                proc    near
  2744.                         Write_ZP_X dl
  2745. STY_ZP_X                endp
  2746.  
  2747.                         align   4
  2748. TAX                     proc    near
  2749.                         mov     cl,ch
  2750.                         or      ch,ch
  2751.                         Flgnz
  2752.                         Fetch
  2753. TAX                     endp
  2754.  
  2755.                         align   4
  2756. TAY                     proc    near
  2757.                         mov     dl,ch
  2758.                         or      ch,ch
  2759.                         Flgnz
  2760.                         Fetch
  2761. TAY                     endp
  2762.  
  2763.                         align   4
  2764. TOP                     proc    near
  2765.                         add     si,2                    ; Advance two bytes!
  2766.                         Fetch
  2767. TOP                     endp
  2768.  
  2769.                         align   4
  2770. TSX                     proc    near
  2771.                         mov     ax,bp
  2772.                         mov     cl,al
  2773.                         or      al,al
  2774.                         Flgnz
  2775.                         Fetch
  2776. TSX                     endp
  2777.  
  2778.                         align   4
  2779. TXA                     proc    near
  2780.                         mov     ch,cl
  2781.                         or      cl,cl
  2782.                         Flgnz
  2783.                         Fetch
  2784. TXA                     endp
  2785.  
  2786.                         align   4
  2787. TXS                     proc    near
  2788.                         mov     al,cl
  2789.                         mov     ah,01h
  2790.                         mov     bp,ax
  2791.                         Fetch
  2792. TXS                     endp
  2793.  
  2794.                         align   4
  2795. TYA                     proc    near
  2796.                         mov     ch,dl
  2797.                         or      dl,dl
  2798.                         Flgnz
  2799.                         Fetch
  2800. TYA                     endp
  2801.  
  2802.  
  2803. ; ****************************************************************************
  2804. ; Flag decode table
  2805.  
  2806.                         .data
  2807. FlgDecodeTable          db      00100000b
  2808.  
  2809.                         BitPattern = 00000001b
  2810.                         rept    255
  2811.                                 Decode BitPattern
  2812.                                 BitPattern = BitPattern + 1
  2813.                         endm
  2814.  
  2815.  
  2816. ; ****************************************************************************
  2817. ; Flag encode table
  2818.  
  2819. FlgEncodeTable          db      00000000b
  2820.  
  2821.                         BitPattern = 00000001b
  2822.                         rept    255
  2823.                                 Encode BitPattern
  2824.                                 BitPattern = BitPattern + 1
  2825.                         endm
  2826.  
  2827.                         end     Start