GophHub - zajo/appler/src/65C02.ASM


Raw File

    1	;  _____________________________________________
    2	; |                                             |
    3	; |  Project:   APPLER                          |
    4	; |  File:      65C02.ASM                       |
    5	; |  Compiler:  16-bit TASM (2.5)               |
    6	; |                                             |
    7	; |  Subject:   65C02 CPU Emulator              |
    8	; |                                             |
    9	; |  Author:    Alexander Patalenski            |
   10	; |_____________________________________________|
   11	
   12	                include GLOBALS.INC
   13	                include INTERFAC.INC
   14	
   15	UserMask        =       0FC02h
   16	
   17	Emulate         segment common
   18	                assume  CS:Emulate,DS:Apple,ES:Video,SS:Data
   19	
   20	Immediate       MACRO                           ; #$..
   21	                lodsb
   22	                ENDM
   23	
   24	Page0           MACRO                           ; $..
   25	                lodsb
   26	                mov     bh,bl
   27	                xlat
   28	                ENDM
   29	
   30	Page0X          MACRO                           ; $..,X
   31	                lodsb
   32	                add     al,cl
   33	                mov     bh,bl
   34	                xlat
   35	                ENDM
   36	
   37	Page0Y          MACRO                           ; $..,Y
   38	                lodsb
   39	                add     ax,bp
   40	                mov     bh,bl
   41	                xlat
   42	                ENDM
   43	
   44	Direct          MACRO                           ; $....
   45	                lodsw
   46	                mov     bh,ah
   47	                ENDM
   48	
   49	DirectX         MACRO                           ; $....,X
   50	                lodsw
   51	                add     ax,cx
   52	                mov     bh,ah
   53	                ENDM
   54	
   55	DirectY         MACRO                           ; $....,Y
   56	                lodsw
   57	                add     ax,bp
   58	                mov     bh,ah
   59	                ENDM
   60	
   61	IndirectPage0   MACRO                           ; ($..)
   62	                lodsb
   63	                mov     ah,bl
   64	                xchg    bx,ax
   65	                xlat
   66	                inc     bl
   67	                mov     bh,[bx]
   68	                mov     bl,ch
   69	                ENDM
   70	
   71	IndirectPage0X  MACRO                           ; ($..,X)
   72	                lodsb
   73	                mov     bx,cx
   74	                add     bl,al
   75	                mov     al,[bx]
   76	                inc     bl
   77	                mov     bh,[bx]
   78	                mov     bl,ch
   79	                ENDM
   80	
   81	IndirectPage0Y  MACRO                           ; ($..),Y
   82	                lodsb
   83	                mov     ah,bl
   84	                xchg    bx,ax
   85	                xlat
   86	                inc     bl
   87	                mov     ah,[bx]
   88	                add     ax,bp
   89	                mov     bh,ah
   90	                mov     bl,ch
   91	                ENDM
   92	
   93	;-------------------------------------------------------------------------------
   94	
   95	_LDA_           MACRO
   96	                mov     dl,al
   97	                or      dl,dl
   98	                ENDM
   99	
  100	_LDX_           MACRO
  101	                mov     cl,al
  102	                or      cl,cl
  103	                ENDM
  104	
  105	_LDY_           MACRO
  106	                mov     ah,bl
  107	                mov     bp,ax
  108	                or      al,al
  109	                ENDM
  110	
  111	_AND_           MACRO
  112	                and     dl,al
  113	                ENDM
  114	
  115	_ORA_           MACRO
  116	                or      dl,al
  117	                ENDM
  118	
  119	_EOR_           MACRO
  120	                xor     dl,al
  121	                ENDM
  122	
  123	ADCcounter      =       0
  124	_ADC_           MACRO
  125	                Local   _ADC_10
  126	ADCcounter      =       ADCcounter+1
  127	                rcr     dh,1
  128	                adc     al,dl
  129	                IRP     n,<%ADCcounter>
  130	ADC&&n          Label   byte
  131	                ENDM
  132	                cld                             ;; or <daa>
  133	                mov     dl,al
  134	                mov     dh,bl                   ;; 0
  135	                jno     _ADC_10
  136	                mov     dh,00100000b
  137	_ADC_10:        rcl     dh,1
  138	                ENDM
  139	
  140	SBCcounter      =       0
  141	_SBC_           MACRO
  142	                Local   _SBC_10
  143	SBCcounter      =       SBCcounter+1
  144	                rcr     dh,1
  145	                cmc
  146	                sbb     dl,al
  147	                mov     al,dl
  148	                IRP     n,<%SBCcounter>
  149	SBC&&n          Label   byte
  150	                ENDM
  151	                cld                             ;; or <das>
  152	                cmc
  153	                mov     dl,al
  154	                mov     dh,bl                   ;; 0
  155	                jno     _SBC_10
  156	                mov     dh,00100000b
  157	_SBC_10:        rcl     dh,1
  158	                ENDM
  159	
  160	_CMP_           MACRO
  161	                rcr     dh,1
  162	                cmp     dl,al
  163	                cmc
  164	                rcl     dh,1
  165	                ENDM
  166	
  167	_CPX_           MACRO
  168	                rcr     dh,1
  169	                cmp     cl,al
  170	                cmc
  171	                rcl     dh,1
  172	                ENDM
  173	
  174	_CPY_           MACRO
  175	                mov     bx,bp
  176	                rcr     dh,1
  177	                cmp     bl,al
  178	                cmc
  179	                rcl     dh,1
  180	                mov     bl,bh
  181	                ENDM
  182	
  183	_BIT_           MACRO
  184	                test    dl,al
  185	                lahf
  186	                shl     ax,1
  187	                ror     ah,1
  188	                shl     dh,2
  189	                shl     al,1
  190	                rcr     dh,1
  191	                shr     dh,1
  192	                sahf
  193	                ENDM
  194	
  195	
  196	DoInstr0        MACRO   Inst,Adr
  197	                Adr
  198	              _&Inst&_
  199	                DoNext
  200	                ENDM
  201	
  202	DoInstr         MACRO   Inst,Adr
  203	                Local   Inst_cont,Inst_C0XX
  204	                Adr
  205	                cmp     bh,0C0h
  206	                je      Inst_C0XX
  207	                xlat
  208	Inst_cont:    _&Inst&_
  209	                DoNext
  210	Inst_C0XX:      mov     bh,bl
  211	                mov     bl,al
  212	                shl     bx,1
  213	                mov     di,offset Inst_cont
  214	                jmp     SS:C0XXRead[bx]         ; AL - Address
  215	                ENDM
  216	
  217	
  218	
  219	MemPage         =       0
  220	                REPT    100h
  221	                org     MemPage*100h
  222	                jmp     BadOpcode
  223	MemPage         =       MemPage+1
  224			ENDM
  225	
  226	
  227	                Opcode  0A9h                    ; LDA #$..
  228	                AddTiming 2
  229	                DoInstr0 LDA,Immediate
  230	                CheckAddress
  231	
  232	                Opcode  0A5h                    ; LDA $..
  233	                AddTiming 3
  234	                DoInstr0 LDA,Page0
  235	                CheckAddress
  236	
  237	                Opcode  0B5h                    ; LDA $..,X
  238	                AddTiming 4
  239	                DoInstr0 LDA,Page0X
  240	                CheckAddress
  241	
  242	                Opcode  0ADh                    ; LDA $....
  243	                AddTiming 4
  244	                DoInstr LDA,Direct
  245	                CheckAddress
  246	
  247	                Opcode  0BDh                    ; LDA $....,X
  248	                AddTiming 4
  249	                DoInstr LDA,DirectX
  250	                CheckAddress
  251	
  252	                Opcode  0B9h                    ; LDA $....,Y
  253	                AddTiming 4
  254	                DoInstr LDA,DirectY
  255	                CheckAddress
  256	
  257	                Opcode  0B2h                    ; LDA ($..)     **65C02**
  258	                AddTiming 5
  259	                DoInstr LDA,IndirectPage0
  260	                CheckAddress
  261	
  262	                Opcode  0A1h                    ; LDA ($..,X)
  263	                AddTiming 6
  264	                DoInstr LDA,IndirectPage0X
  265	                CheckAddress
  266	
  267	                Opcode  0B1h                    ; LDA ($..),Y
  268	                AddTiming 5
  269	                DoInstr LDA,IndirectPage0Y
  270	                CheckAddress
  271	
  272	                Opcode  0A2h                    ; LDX #$..
  273	                AddTiming 2
  274	                DoInstr0 LDX,Immediate
  275	                CheckAddress
  276	
  277	                Opcode  0A6h                    ; LDX $..
  278	                AddTiming 3
  279	                DoInstr0 LDX,Page0
  280	                CheckAddress
  281	
  282	                Opcode  0B6h                    ; LDX $..,Y
  283	                AddTiming 4
  284	                DoInstr0 LDX,Page0Y
  285	                CheckAddress
  286	
  287	                Opcode  0AEh                    ; LDX $....
  288	                AddTiming 4
  289	                DoInstr LDX,Direct
  290	                CheckAddress
  291	
  292	                Opcode  0BEh                    ; LDX $....,Y
  293	                AddTiming 4
  294	                DoInstr LDX,DirectY
  295	                CheckAddress
  296	
  297	                Opcode  0A0h                    ; LDY #$..
  298	                AddTiming 2
  299	                DoInstr0 LDY,Immediate
  300	                CheckAddress
  301	
  302	                Opcode  0A4h                    ; LDY $..
  303	                AddTiming 3
  304	                DoInstr0 LDY,Page0
  305	                CheckAddress
  306	
  307	                Opcode  0B4h                    ; LDY $..,X
  308	                AddTiming 4
  309	                DoInstr0 LDY,Page0X
  310	                CheckAddress
  311	
  312	                Opcode  0ACh                    ; LDY $....
  313	                AddTiming 4
  314	                DoInstr LDY,Direct
  315	                CheckAddress
  316	
  317	                Opcode  0BCh                    ; LDY $....,X
  318	                AddTiming 4
  319	                DoInstr LDY,DirectX
  320	                CheckAddress
  321	
  322	                Opcode  69h                     ; ADC #$..
  323	                AddTiming 2
  324	                DoInstr0 ADC,Immediate
  325	                CheckAddress
  326	
  327	                Opcode  65h                     ; ADC $..
  328	                AddTiming 3
  329	                DoInstr0 ADC,Page0
  330	                CheckAddress
  331	
  332	                Opcode  75h                     ; ADC $..,X
  333	                AddTiming 4
  334	                DoInstr0 ADC,Page0X
  335	                CheckAddress
  336	
  337	                Opcode  6Dh                     ; ADC $....
  338	                AddTiming 4
  339	                DoInstr ADC,Direct
  340	                CheckAddress
  341	
  342	                Opcode  7Dh                     ; ADC $....,X
  343	                AddTiming 4
  344	                DoInstr ADC,DirectX
  345	                CheckAddress
  346	
  347	                Opcode  79h                     ; ADC $....,Y
  348	                AddTiming 4
  349	                DoInstr ADC,DirectY
  350	                CheckAddress
  351	
  352	                Opcode  72h                     ; ADC ($..)     **65C02**
  353	                AddTiming 5
  354	                DoInstr ADC,IndirectPage0
  355	                CheckAddress
  356	
  357	                Opcode  61h                     ; ADC ($..,X)
  358	                AddTiming 6
  359	                DoInstr ADC,IndirectPage0X
  360	                CheckAddress
  361	
  362	                Opcode  71h                     ; ADC ($..),Y
  363	                AddTiming 5
  364	                DoInstr ADC,IndirectPage0Y
  365	                CheckAddress
  366	
  367	                Opcode  0E9h                    ; SBC #$..
  368	                AddTiming 2
  369	                DoInstr0 SBC,Immediate
  370	                CheckAddress
  371	
  372	                Opcode  0E5h                    ; SBC $..
  373	                AddTiming 3
  374	                DoInstr0 SBC,Page0
  375	                CheckAddress
  376	
  377	                Opcode  0F5h                    ; SBC $..,X
  378	                AddTiming 4
  379	                DoInstr0 SBC,Page0X
  380	                CheckAddress
  381	
  382	                Opcode  0EDh                    ; SBC $....
  383	                AddTiming 4
  384	                DoInstr SBC,Direct
  385	                CheckAddress
  386	
  387	                Opcode  0FDh                    ; SBC $....,X
  388	                AddTiming 4
  389	                DoInstr SBC,DirectX
  390	                CheckAddress
  391	
  392	                Opcode  0F9h                    ; SBC $....,Y
  393	                AddTiming 4
  394	                DoInstr SBC,DirectY
  395	                CheckAddress
  396	
  397	                Opcode  0F2h                    ; SBC ($..)     **65C02**
  398	                AddTiming 5
  399	                DoInstr SBC,IndirectPage0
  400	                CheckAddress
  401	
  402	                Opcode  0E1h                    ; SBC ($..,X)
  403	                AddTiming 6
  404	                DoInstr SBC,IndirectPage0X
  405	                CheckAddress
  406	
  407	                Opcode  0F1h                    ; SBC ($..),Y
  408	                AddTiming 5
  409	                DoInstr SBC,IndirectPage0Y
  410	                CheckAddress
  411	
  412	                Opcode  29h                     ; AND #$..
  413	                AddTiming 2
  414	                DoInstr0 AND,Immediate
  415	                CheckAddress
  416	
  417	                Opcode  25h                     ; AND $..
  418	                AddTiming 3
  419	                DoInstr0 AND,Page0
  420	                CheckAddress
  421	
  422	                Opcode  35h                     ; AND $..,X
  423	                AddTiming 4
  424	                DoInstr0 AND,Page0X
  425	                CheckAddress
  426	
  427	                Opcode  2Dh                     ; AND $....
  428	                AddTiming 4
  429	                DoInstr AND,Direct
  430	                CheckAddress
  431	
  432	                Opcode  3Dh                     ; AND $....,X
  433	                AddTiming 4
  434	                DoInstr AND,DirectX
  435	                CheckAddress
  436	
  437	                Opcode  39h                     ; AND $....,Y
  438	                AddTiming 4
  439	                DoInstr AND,DirectY
  440	                CheckAddress
  441	
  442	                Opcode  32h                     ; AND ($..)     **65C02**
  443	                AddTiming 5
  444	                DoInstr AND,IndirectPage0
  445	                CheckAddress
  446	
  447	                Opcode  21h                     ; AND ($..,X)
  448	                AddTiming 6
  449	                DoInstr AND,IndirectPage0X
  450	                CheckAddress
  451	
  452	                Opcode  31h                     ; AND ($..),Y
  453	                AddTiming 5
  454	                DoInstr AND,IndirectPage0Y
  455	                CheckAddress
  456	
  457	                Opcode  09h                     ; ORA #$..
  458	                AddTiming 2
  459	                DoInstr0 ORA,Immediate
  460	                CheckAddress
  461	
  462	                Opcode  05h                     ; ORA $..
  463	                AddTiming 3
  464	                DoInstr0 ORA,Page0
  465	                CheckAddress
  466	
  467	                Opcode  15h                     ; ORA $..,X
  468	                AddTiming 4
  469	                DoInstr0 ORA,Page0X
  470	                CheckAddress
  471	
  472	                Opcode  0Dh                     ; ORA $....
  473	                AddTiming 4
  474	                DoInstr ORA,Direct
  475	                CheckAddress
  476	
  477	                Opcode  1Dh                     ; ORA $....,X
  478	                AddTiming 4
  479	                DoInstr ORA,DirectX
  480	                CheckAddress
  481	
  482	                Opcode  19h                     ; ORA $....,Y
  483	                AddTiming 4
  484	                DoInstr ORA,DirectY
  485	                CheckAddress
  486	
  487	                Opcode  12h                     ; ORA ($..)     **65C02**
  488	                AddTiming 5
  489	                DoInstr ORA,IndirectPage0
  490	                CheckAddress
  491	
  492	                Opcode  01h                     ; ORA ($..,X)
  493	                AddTiming 6
  494	                DoInstr ORA,IndirectPage0X
  495	                CheckAddress
  496	
  497	                Opcode  11h                     ; ORA ($..),Y
  498	                AddTiming 5
  499	                DoInstr ORA,IndirectPage0Y
  500	                CheckAddress
  501	
  502	                Opcode  49h                     ; EOR #$..
  503	                AddTiming 2
  504	                DoInstr0 EOR,Immediate
  505	                CheckAddress
  506	
  507	                Opcode  45h                     ; EOR $..
  508	                AddTiming 3
  509	                DoInstr0 EOR,Page0
  510	                CheckAddress
  511	
  512	                Opcode  55h                     ; EOR $..,X
  513	                AddTiming 4
  514	                DoInstr0 EOR,Page0X
  515	                CheckAddress
  516	
  517	                Opcode  4Dh                     ; EOR $....
  518	                AddTiming 4
  519	                DoInstr EOR,Direct
  520	                CheckAddress
  521	
  522	                Opcode  5Dh                     ; EOR $....,X
  523	                AddTiming 4
  524	                DoInstr EOR,DirectX
  525	                CheckAddress
  526	
  527	                Opcode  59h                     ; EOR $....,Y
  528	                AddTiming 4
  529	                DoInstr EOR,DirectY
  530	                CheckAddress
  531	
  532	                Opcode  52h                     ; EOR ($..)     **65C02**
  533	                AddTiming 5
  534	                DoInstr EOR,IndirectPage0
  535	                CheckAddress
  536	
  537	                Opcode  41h                     ; EOR ($..,X)
  538	                AddTiming 6
  539	                DoInstr EOR,IndirectPage0X
  540	                CheckAddress
  541	
  542	                Opcode  51h                     ; EOR ($..),Y
  543	                AddTiming 5
  544	                DoInstr EOR,IndirectPage0Y
  545	                CheckAddress
  546	
  547	                Opcode  0C9h                    ; CMP #$..
  548	                AddTiming 2
  549	                DoInstr0 CMP,Immediate
  550	                CheckAddress
  551	
  552	                Opcode  0C5h                    ; CMP $..
  553	                AddTiming 3
  554	                DoInstr0 CMP,Page0
  555	                CheckAddress
  556	
  557	                Opcode  0D5h                    ; CMP $..,X
  558	                AddTiming 4
  559	                DoInstr0 CMP,Page0X
  560	                CheckAddress
  561	
  562	                Opcode  0CDh                    ; CMP $....
  563	                AddTiming 4
  564	                DoInstr CMP,Direct
  565	                CheckAddress
  566	
  567	                Opcode  0DDh                    ; CMP $....,X
  568	                AddTiming 4
  569	                DoInstr CMP,DirectX
  570	                CheckAddress
  571	
  572	                Opcode  0D9h                    ; CMP $....,Y
  573	                AddTiming 4
  574	                DoInstr CMP,DirectY
  575	                CheckAddress
  576	
  577	                Opcode  0D2h                    ; CMP ($..)     **65C02**
  578	                AddTiming 5
  579	                DoInstr CMP,IndirectPage0
  580	                CheckAddress
  581	
  582	                Opcode  0C1h                    ; CMP ($..,X)
  583	                AddTiming 6
  584	                DoInstr CMP,IndirectPage0X
  585	                CheckAddress
  586	
  587	                Opcode  0D1h                    ; CMP ($..),Y
  588	                AddTiming 5
  589	                DoInstr CMP,IndirectPage0Y
  590	                CheckAddress
  591	
  592	                Opcode  0E0h                    ; CPX #$..
  593	                AddTiming 2
  594	                DoInstr0 CPX,Immediate
  595	                CheckAddress
  596	
  597	                Opcode  0E4h                    ; CPX $..
  598	                AddTiming 3
  599	                DoInstr0 CPX,Page0
  600	                CheckAddress
  601	
  602	                Opcode  0ECh                    ; CPX $....
  603	                AddTiming 4
  604	                DoInstr CPX,Direct
  605	                CheckAddress
  606	
  607	                Opcode  0C0h                    ; CPY #$..
  608	                AddTiming 2
  609	                DoInstr0 CPY,Immediate
  610	                CheckAddress
  611	
  612	                Opcode  0C4h                    ; CPY $..
  613	                AddTiming 3
  614	                DoInstr0 CPY,Page0
  615	                CheckAddress
  616	
  617	                Opcode  0CCh                    ; CPY $....
  618	                AddTiming 4
  619	                DoInstr CPY,Direct
  620	                CheckAddress
  621	
  622	                Opcode  89h                     ; BIT #$..      **65C02**
  623	                AddTiming 2
  624	                DoInstr0 BIT,Immediate
  625	                CheckAddress
  626	
  627	                Opcode  24h                     ; BIT $..
  628	                AddTiming 3
  629	                DoInstr0 BIT,Page0
  630	                CheckAddress
  631	
  632	                Opcode  34h                     ; BIT $..,X     **65C02**
  633	                AddTiming 4
  634	                DoInstr0 BIT,Page0X
  635	                CheckAddress
  636	
  637	                Opcode  2Ch                     ; BIT $....
  638	                AddTiming 4
  639	                DoInstr BIT,Direct
  640	                CheckAddress
  641	
  642	                Opcode  3Ch                     ; BIT $....,X   **65C02**
  643	                AddTiming 4
  644	                DoInstr BIT,DirectX
  645	                CheckAddress
  646	
  647	                Opcode  85h                     ; STA $..
  648	                AddTiming 3
  649	                lodsb
  650	                mov     ah,bl
  651	                mov     di,ax
  652	                mov     [di],dl
  653	                DoNext
  654	                CheckAddress
  655	
  656	                Opcode  95h                     ; STA $..,X
  657	                AddTiming 4
  658	                lodsb
  659	                lahf
  660	                add     al,cl
  661	                sahf
  662	                mov     ah,bl
  663	                mov     di,ax
  664	                mov     [di],dl
  665	                DoNext
  666	                CheckAddress
  667	
  668	                Opcode  8Dh                     ; STA $....
  669	                AddTiming 4
  670	                lodsw
  671	                mov     di,ax
  672	                mov     bh,dl
  673	                GoWrite
  674	                CheckAddress
  675	
  676	                Opcode  9Dh                     ; STA $....,X
  677	                AddTiming 5
  678	                lodsw
  679	                mov     di,ax
  680	                lahf
  681	                add     di,cx
  682	                sahf
  683	                mov     ax,di
  684	                mov     bh,dl
  685	                GoWrite
  686	                CheckAddress
  687	
  688	                Opcode  99h                     ; STA $....,Y
  689	                AddTiming 5
  690	                lodsw
  691	                mov     di,ax
  692	                lea     ax,[di+bp]
  693	                mov     di,ax
  694	                mov     bh,dl
  695	                GoWrite
  696	                CheckAddress
  697	
  698	                Opcode  92h                     ; STA ($..)     **65C02**
  699	                AddTiming 6
  700	                lodsb
  701	                mov     ah,bl
  702	                mov     di,ax
  703	                lahf
  704	                inc     al
  705	                jz      STA_10
  706	                sahf
  707	                mov     di,[di]
  708	                mov     ax,di
  709	                mov     bh,dl
  710	                GoWrite
  711	STA_10:         sahf
  712	                mov     al,[di]
  713	                mov     ah,DS:[0]
  714	                mov     di,ax
  715	                mov     bh,dl
  716	                GoWrite
  717	                CheckAddress
  718	
  719	                Opcode  81h                     ; STA ($..,X)
  720	                AddTiming 6
  721	                lodsb
  722	                lahf
  723	                add     al,cl
  724	                mov     di,ax
  725	                inc     al
  726	                jz      STA_20
  727	                and     di,0FFh
  728	                sahf
  729	                mov     di,[di]
  730	                mov     ax,di
  731	                mov     bh,dl
  732	                GoWrite
  733	STA_20:         sahf
  734	                mov     al,DS:[0FFh]
  735	                mov     ah,DS:[000h]
  736	                mov     di,ax
  737	                mov     bh,dl
  738	                GoWrite
  739	                CheckAddress
  740	
  741	                Opcode  91h                     ; STA ($..),Y
  742	                AddTiming 6
  743	                lodsb
  744	                mov     ah,bl
  745	                mov     di,ax
  746	                lahf
  747	                inc     al
  748	                jz      STA_30
  749	                mov     di,[di]
  750	                add     di,bp
  751	                sahf
  752	                mov     ax,di
  753	                mov     bh,dl
  754	                GoWrite
  755	STA_30:         mov     bl,[di]
  756	                mov     bh,DS:[0]
  757	                add     bx,bp
  758	                sahf
  759	                mov     ax,bx
  760	                mov     di,bx
  761	                mov     bl,ch
  762	                mov     bh,dl
  763	                GoWrite
  764	                CheckAddress
  765	
  766	                Opcode  86h                     ; STX $..
  767	                AddTiming 3
  768	                lodsb
  769	                mov     ah,bl
  770	                mov     di,ax
  771	                mov     [di],cl
  772	                DoNext
  773	                CheckAddress
  774	
  775	                Opcode  96h                     ; STX $..,Y
  776	                AddTiming 4
  777	                lodsb
  778	                mov     bx,bp
  779	                lahf
  780	                add     bl,al
  781	                sahf
  782	                mov     [bx],cl
  783	                mov     bl,bh
  784	                DoNext
  785	                CheckAddress
  786	
  787	                Opcode  8Eh                     ; STX $....
  788	                AddTiming 4
  789	                lodsw
  790	                mov     di,ax
  791	                mov     bh,cl
  792	                GoWrite
  793	                CheckAddress
  794	
  795	                Opcode  84h                     ; STY $..
  796	                AddTiming 3
  797	                lodsb
  798	                mov     ah,bl
  799	                mov     di,ax
  800	                mov     ax,bp
  801	                mov     [di],al
  802	                DoNext
  803	                CheckAddress
  804	
  805	                Opcode  94h                     ; STY $..,X
  806	                AddTiming 4
  807	                lodsb
  808	                lahf
  809	                add     al,cl
  810	                sahf
  811	                mov     ah,bl
  812	                mov     di,ax
  813	                mov     ax,bp
  814	                mov     [di],al
  815	                DoNext
  816	                CheckAddress
  817	
  818	                Opcode  8Ch                     ; STY $....
  819	                AddTiming 4
  820	                mov     ax,bp
  821	                mov     bh,al
  822	                lodsw
  823	                mov     di,ax
  824	                GoWrite
  825	                CheckAddress
  826	
  827	                Opcode  64h                     ; STZ $..       **65C02**
  828	                AddTiming 3
  829	                lodsb
  830	                mov     ah,bl
  831	                mov     di,ax
  832	                mov     [di],bl
  833	                DoNext
  834	                CheckAddress
  835	
  836	                Opcode  74h                     ; STZ $..,X     **65C02**
  837	                AddTiming 4
  838	                lodsb
  839	                lahf
  840	                add     al,cl
  841	                sahf
  842	                mov     ah,bl
  843	                mov     di,ax
  844	                mov     [di],bl
  845	                DoNext
  846	                CheckAddress
  847	
  848	                Opcode  9Ch                     ; STZ $....     **65C02**
  849	                AddTiming 4
  850	                lodsw
  851	                mov     di,ax
  852	                mov     bh,bl
  853	                GoWrite
  854	                CheckAddress
  855	
  856	                Opcode  9Eh                     ; STZ $....,X   **65C02**
  857	                AddTiming 5
  858	                lodsw
  859	                mov     di,ax
  860	                lahf
  861	                add     di,cx
  862	                sahf
  863	                mov     ax,di
  864	                mov     bh,bl
  865	                GoWrite
  866	                CheckAddress
  867	
  868	                Opcode  0Ah                     ; ASL
  869	                AddTiming 2
  870	                rcr     dh,1
  871	                shl     dl,1
  872	                rcl     dh,1
  873	                DoNext
  874	                CheckAddress
  875	
  876	                Opcode  06h                     ; ASL $..
  877	                AddTiming 5
  878	                lodsb
  879	                mov     ah,bl
  880	                mov     di,ax
  881	                rcr     dh,1
  882	                shl     byte ptr [di],1
  883	                rcl     dh,1
  884	                DoNext
  885	                CheckAddress
  886	
  887	                Opcode  16h                     ; ASL $..,X
  888	                AddTiming 6
  889	                lodsb
  890	                add     al,cl
  891	                mov     ah,bl
  892	                mov     di,ax
  893	                rcr     dh,1
  894	                shl     byte ptr [di],1
  895	                rcl     dh,1
  896	                DoNext
  897	                CheckAddress
  898	
  899	                Opcode  0Eh                     ; ASL $....
  900	                AddTiming 6
  901	                lodsw
  902	                mov     di,ax
  903	                mov     bh,[di]
  904	                rcr     dh,1
  905	                shl     bh,1
  906	                rcl     dh,1
  907	                GoWrite
  908	                CheckAddress
  909	
  910	                Opcode  1Eh                     ; ASL $....,X
  911	                AddTiming 7
  912	                lodsw
  913	                add     ax,cx
  914	                mov     di,ax
  915	                mov     bh,[di]
  916	                rcr     dh,1
  917	                shl     bh,1
  918	                rcl     dh,1
  919	                GoWrite
  920	                CheckAddress
  921	
  922	                Opcode  4Ah                     ; LSR
  923	                AddTiming 2
  924	                rcr     dh,1
  925	                shr     dl,1
  926	                rcl     dh,1
  927	                DoNext
  928	                CheckAddress
  929	
  930	                Opcode  46h                     ; LSR $..
  931	                AddTiming 5
  932	                lodsb
  933	                mov     ah,bl
  934	                mov     di,ax
  935	                rcr     dh,1
  936	                shr     byte ptr [di],1
  937	                rcl     dh,1
  938	                DoNext
  939	                CheckAddress
  940	
  941	                Opcode  56h                     ; LSR $..,X
  942	                AddTiming 6
  943	                lodsb
  944	                add     al,cl
  945	                mov     ah,bl
  946	                mov     di,ax
  947	                rcr     dh,1
  948	                shr     byte ptr [di],1
  949	                rcl     dh,1
  950	                DoNext
  951	                CheckAddress
  952	
  953	                Opcode  4Eh                     ; LSR $....
  954	                AddTiming 6
  955	                lodsw
  956	                mov     di,ax
  957	                mov     bh,[di]
  958	                rcr     dh,1
  959	                shr     bh,1
  960	                rcl     dh,1
  961	                GoWrite
  962	                CheckAddress
  963	
  964	                Opcode  5Eh                     ; LSR $....,X
  965	                AddTiming 7
  966	                lodsw
  967	                add     ax,cx
  968	                mov     di,ax
  969	                mov     bh,[di]
  970	                rcr     dh,1
  971	                shr     bh,1
  972	                rcl     dh,1
  973	                GoWrite
  974	                CheckAddress
  975	
  976	                Opcode  2Ah                     ; ROL
  977	                AddTiming 2
  978	                rcr     dh,1
  979	                rcl     dx,1
  980	                or      dl,dl
  981	                DoNext
  982	                CheckAddress
  983	
  984	                Opcode  26h                     ; ROL $..
  985	                AddTiming 5
  986	                lodsb
  987	                mov     ah,bl
  988	                mov     di,ax
  989	                mov     al,[di]
  990	                rcr     dh,1
  991	                rcl     al,1
  992	                rcl     dh,1
  993	                or      al,al
  994	                mov     [di],al
  995	                DoNext
  996	                CheckAddress
  997	
  998	                Opcode  36h                     ; ROL $..,X
  999	                AddTiming 6
 1000	                lodsb
 1001	                add     al,cl
 1002	                mov     ah,bl
 1003	                mov     di,ax
 1004	                mov     al,[di]
 1005	                rcr     dh,1
 1006	                rcl     al,1
 1007	                rcl     dh,1
 1008	                or      al,al
 1009	                mov     [di],al
 1010	                DoNext
 1011	                CheckAddress
 1012	
 1013	                Opcode  2Eh                     ; ROL $....
 1014	                AddTiming 6
 1015	                lodsw
 1016	                mov     di,ax
 1017	                mov     bh,[di]
 1018	                rcr     dh,1
 1019	                rcl     bh,1
 1020	                rcl     dh,1
 1021	                or      bh,bh
 1022	                GoWrite
 1023	                CheckAddress
 1024	
 1025	                Opcode  3Eh                     ; ROL $....,X
 1026	                AddTiming 7
 1027	                lodsw
 1028	                add     ax,cx
 1029	                mov     di,ax
 1030	                mov     bh,[di]
 1031	                rcr     dh,1
 1032	                rcl     bh,1
 1033	                rcl     dh,1
 1034	                or      bh,bh
 1035	                GoWrite
 1036	                CheckAddress
 1037	
 1038	                Opcode  6Ah                     ; ROR
 1039	                AddTiming 2
 1040	                rcr     dx,1
 1041	                rcl     dh,1
 1042	                or      dl,dl
 1043	                DoNext
 1044	                CheckAddress
 1045	
 1046	                Opcode  66h                     ; ROR $..
 1047	                AddTiming 5
 1048	                lodsb
 1049	                mov     ah,bl
 1050	                mov     di,ax
 1051	                mov     al,[di]
 1052	                rcr     dh,1
 1053	                rcr     al,1
 1054	                rcl     dh,1
 1055	                or      al,al
 1056	                mov     [di],al
 1057	                DoNext
 1058	                CheckAddress
 1059	
 1060	                Opcode  76h                     ; ROR $..,X
 1061	                AddTiming 6
 1062	                lodsb
 1063	                add     al,cl
 1064	                mov     ah,bl
 1065	                mov     di,ax
 1066	                mov     al,[di]
 1067	                rcr     dh,1
 1068	                rcr     al,1
 1069	                rcl     dh,1
 1070	                or      al,al
 1071	                mov     [di],al
 1072	                DoNext
 1073	                CheckAddress
 1074	
 1075	                Opcode  6Eh                     ; ROR $....
 1076	                AddTiming 6
 1077	                lodsw
 1078	                mov     di,ax
 1079	                mov     bh,[di]
 1080	                rcr     dh,1
 1081	                rcr     bh,1
 1082	                rcl     dh,1
 1083	                or      bh,bh
 1084	                GoWrite
 1085	                CheckAddress
 1086	
 1087	                Opcode  7Eh                     ; ROR $....,X
 1088	                AddTiming 7
 1089	                lodsw
 1090	                add     ax,cx
 1091	                mov     di,ax
 1092	                mov     bh,[di]
 1093	                rcr     dh,1
 1094	                rcr     bh,1
 1095	                rcl     dh,1
 1096	                or      bh,bh
 1097	                GoWrite
 1098	                CheckAddress
 1099	
 1100	                Opcode  1Ah                     ; INC           **65C02**
 1101	                AddTiming 2
 1102	                inc     dl
 1103	                DoNext
 1104	                CheckAddress
 1105	
 1106	                Opcode  0E6h                    ; INC $..
 1107	                AddTiming 5
 1108	                lodsb
 1109	                mov     ah,bl
 1110	                mov     di,ax
 1111	                inc     byte ptr [di]
 1112	                DoNext
 1113	                CheckAddress
 1114	
 1115	                Opcode  0F6h                    ; INC $..,X
 1116	                AddTiming 6
 1117	                lodsb
 1118	                add     al,cl
 1119	                mov     ah,bl
 1120	                mov     di,ax
 1121	                inc     byte ptr [di]
 1122	                DoNext
 1123	                CheckAddress
 1124	
 1125	                Opcode  0EEh                    ; INC $....
 1126	                AddTiming 6
 1127	                lodsw
 1128	                mov     di,ax
 1129	                mov     bh,[di]
 1130	                inc     bh
 1131	                GoWrite
 1132	                CheckAddress
 1133	
 1134	                Opcode  0FEh                    ; INC $....,X
 1135	                AddTiming 7
 1136	                lodsw
 1137	                add     ax,cx
 1138	                mov     di,ax
 1139	                mov     bh,[di]
 1140	                inc     bh
 1141	                GoWrite
 1142	                CheckAddress
 1143	
 1144	                Opcode  3Ah                     ; DEC           **65C02**
 1145	                AddTiming 2
 1146	                dec     dl
 1147	                DoNext
 1148	                CheckAddress
 1149	
 1150	                Opcode  0C6h                    ; DEC $..
 1151	                AddTiming 5
 1152	                lodsb
 1153	                mov     ah,bl
 1154	                mov     di,ax
 1155	                dec     byte ptr [di]
 1156	                DoNext
 1157	                CheckAddress
 1158	
 1159	                Opcode  0D6h                    ; DEC $..,X
 1160	                AddTiming 6
 1161	                lodsb
 1162	                add     al,cl
 1163	                mov     ah,bl
 1164	                mov     di,ax
 1165	                dec     byte ptr [di]
 1166	                DoNext
 1167	                CheckAddress
 1168	
 1169	                Opcode  0CEh                    ; DEC $....
 1170	                AddTiming 6
 1171	                lodsw
 1172	                mov     di,ax
 1173	                mov     bh,[di]
 1174	                dec     bh
 1175	                GoWrite
 1176	                CheckAddress
 1177	
 1178	                Opcode  0DEh                    ; DEC $....,X
 1179	                AddTiming 7
 1180	                lodsw
 1181	                add     ax,cx
 1182	                mov     di,ax
 1183	                mov     bh,[di]
 1184	                dec     bh
 1185	                GoWrite
 1186	                CheckAddress
 1187	
 1188	                Opcode  14h                     ; TRB $..       **65C02**
 1189	                AddTiming 5
 1190	                lodsb
 1191	                mov     ah,bl
 1192	                mov     di,ax
 1193	                lahf
 1194	                mov     al,[di]
 1195	                mov     bh,al
 1196	                and     bh,dl
 1197	                rcl     ah,1
 1198	                lahf
 1199	                rcl     ah,1
 1200	                ror     ah,1
 1201	                xor     al,bh
 1202	                mov     [di],al
 1203	                sahf
 1204	                DoNext
 1205	                CheckAddress
 1206	
 1207	                Opcode  1Ch                     ; TRB $....     **65C02**
 1208	                AddTiming 6
 1209	                lodsw
 1210	                mov     di,ax
 1211	                lahf
 1212	                mov     al,[di]
 1213	                mov     bh,al
 1214	                and     bh,dl
 1215	                rcl     ah,1
 1216	                lahf
 1217	                rcl     ah,1
 1218	                ror     ah,1
 1219	                xor     bh,al
 1220	                sahf
 1221	                mov     ax,di
 1222	                GoWrite
 1223	                CheckAddress
 1224	
 1225	                Opcode  04h                     ; TSB $..       **65C02**
 1226	                AddTiming 5
 1227	                lodsb
 1228	                mov     ah,bl
 1229	                mov     di,ax
 1230	                lahf
 1231	                or      [di],dl
 1232	                or      dl,dl
 1233	                mov     al,ah
 1234	                lahf
 1235	                shl     ax,1
 1236	                ror     ah,1
 1237	                sahf
 1238	                DoNext
 1239	                CheckAddress
 1240	
 1241	                Opcode  0Ch                     ; TSB $....     **65C02**
 1242	                AddTiming 6
 1243	                lodsw
 1244	                mov     di,ax
 1245	                mov     bh,dl
 1246	                lahf
 1247	                or      bh,[di]
 1248	                or      dl,dl
 1249	                mov     al,ah
 1250	                lahf
 1251	                shl     ax,1
 1252	                ror     ah,1
 1253	                sahf
 1254	                mov     ax,di
 1255	                GoWrite
 1256	                CheckAddress
 1257	
 1258	                Opcode  80h                     ; BRA $..       **65C02**
 1259	                AddTiming 3
 1260	                lodsb
 1261	                cbw
 1262	                mov     bx,ax
 1263	                lea     si,[si+bx]
 1264	                mov     bl,ch
 1265	                DoNext
 1266	                CheckAddress
 1267	
 1268	                Opcode  0D0h                    ; BNE $..
 1269	                AddTiming 2
 1270	                lodsb
 1271	                je      BNE_10
 1272	                cbw
 1273	                mov     bx,ax
 1274	                lea     si,[si+bx]
 1275	                mov     bl,ch
 1276	                AddTiming 1
 1277	BNE_10:         DoNext
 1278	                CheckAddress
 1279	
 1280	                Opcode  0F0h                    ; BEQ $..
 1281	                AddTiming 2
 1282	                lodsb
 1283	                jne     BEQ_10
 1284	                cbw
 1285	                mov     bx,ax
 1286	                lea     si,[si+bx]
 1287	                mov     bl,ch
 1288	                AddTiming 1
 1289	BEQ_10:         DoNext
 1290	                CheckAddress
 1291	
 1292	                Opcode  10h                     ; BPL $..
 1293	                AddTiming 2
 1294	                lodsb
 1295	                js      BPL_10
 1296	                cbw
 1297	                mov     bx,ax
 1298	                lea     si,[si+bx]
 1299	                mov     bl,ch
 1300	                AddTiming 1
 1301	BPL_10:         DoNext
 1302	                CheckAddress
 1303	
 1304	                Opcode  30h                     ; BMI $..
 1305	                AddTiming 2
 1306	                lodsb
 1307	                jns     BMI_10
 1308	                cbw
 1309	                mov     bx,ax
 1310	                lea     si,[si+bx]
 1311	                mov     bl,ch
 1312	                AddTiming 1
 1313	BMI_10:         DoNext
 1314	                CheckAddress
 1315	
 1316	                Opcode  90h                     ; BCC $..
 1317	                AddTiming 2
 1318	                lodsb
 1319	                ror     dh,1
 1320	                jc      BCC_10
 1321	                cbw
 1322	                mov     bx,ax
 1323	                lea     si,[si+bx]
 1324	                mov     bl,ch
 1325	                AddTiming 1
 1326	BCC_10:         rol     dh,1
 1327	                DoNext
 1328	                CheckAddress
 1329	
 1330	                Opcode  0B0h                    ; BCS $..
 1331	                AddTiming 2
 1332	                lodsb
 1333	                ror     dh,1
 1334	                jnc     BCS_10
 1335	                cbw
 1336	                mov     bx,ax
 1337	                lea     si,[si+bx]
 1338	                mov     bl,ch
 1339	                AddTiming 1
 1340	BCS_10:         rol     dh,1
 1341	                DoNext
 1342	                CheckAddress
 1343	
 1344	                Opcode  50h                     ; BVC $..
 1345	                AddTiming 2
 1346	                lodsb
 1347	                rol     dh,1
 1348	                jo      BVC_10
 1349	                cbw
 1350	                mov     bx,ax
 1351	                lea     si,[si+bx]
 1352	                mov     bl,ch
 1353	                AddTiming 1
 1354	BVC_10:         ror     dh,1
 1355	                DoNext
 1356	                CheckAddress
 1357	
 1358	                Opcode  70h                     ; BVS $..
 1359	                AddTiming 2
 1360	                lodsb
 1361	                rol     dh,1
 1362	                jno     BVS_10
 1363	                cbw
 1364	                mov     bx,ax
 1365	                lea     si,[si+bx]
 1366	                mov     bl,ch
 1367	                AddTiming 1
 1368	BVS_10:         ror     dh,1
 1369	                DoNext
 1370	                CheckAddress
 1371	
 1372	                Opcode  4Ch                     ; JMP $....
 1373	                AddTiming 3
 1374	                mov     si,[si]
 1375	                DoNext
 1376	                CheckAddress
 1377	
 1378	                Opcode  6Ch                     ; JMP ($....)
 1379	                AddTiming 5
 1380	                mov     bx,[si]
 1381	                mov     si,[bx]
 1382	                lahf
 1383	                inc     bl
 1384	                jz      JMP_10
 1385	                sahf
 1386	                mov     bl,ch
 1387	                DoNext
 1388	JMP_10:         sahf
 1389	                mov     ax,si
 1390	                mov     ah,[bx]
 1391	                mov     si,ax
 1392	                DoNext
 1393	                CheckAddress
 1394	
 1395	                Opcode  7Ch                     ; JMP ($....,X) **65C02**
 1396	                AddTiming 6
 1397	                mov     bx,[si]
 1398	                lahf
 1399	                add     bx,cx
 1400	                mov     si,[bx]
 1401	                inc     bl
 1402	                jz      JMP_20
 1403	                sahf
 1404	                mov     bl,ch
 1405	                DoNext
 1406	JMP_20:         sahf
 1407	                mov     ax,si
 1408	                mov     ah,[bx]
 1409	                mov     si,ax
 1410	                DoNext
 1411	                CheckAddress
 1412	
 1413	                Opcode  20h                     ; JSR $....
 1414	                AddTiming 6
 1415	                mov     di,si
 1416	                mov     si,[si]
 1417	                mov     bx,AppleSP
 1418	                lahf
 1419	                inc     di
 1420	                or      bl,bl
 1421	                jz      JSR_10
 1422	                dec     bx
 1423	                mov     [bx],di
 1424	                dec     bl
 1425	                sahf
 1426	                mov     AppleSP,bx
 1427	                mov     bl,ch
 1428	                DoNext
 1429	JSR_10:         sahf
 1430	                mov     ax,di
 1431	                mov     DS:[StackPage*100h],ah
 1432	                mov     DS:[StackPage*100h+0FFh],al
 1433	                mov     byte ptr AppleSP,0FEh
 1434	                mov     bl,ch
 1435	                DoNext
 1436	                CheckAddress
 1437	
 1438	                Opcode  60h                     ; RTS
 1439	                AddTiming 6
 1440	                call    synchronize
 1441	                mov     bx,AppleSP
 1442	                lahf
 1443	                inc     bl
 1444	                mov     si,[bx]
 1445	                inc     bl
 1446	                mov     AppleSP,bx
 1447	                jz      RTS_10
 1448	                inc     si
 1449	                sahf
 1450	                mov     bl,ch
 1451	                DoNext
 1452	RTS_10:         mov     bx,si
 1453	                mov     bh,DS:[StackPage*100h]
 1454	                mov     si,bx
 1455	                inc     si
 1456	                sahf
 1457	                mov     bl,ch
 1458	                DoNext
 1459	                CheckAddress
 1460	
 1461	                Opcode  00h                     ; BRK
 1462	                AddTiming 6
 1463	                lahf
 1464	                mov     al,AppleFlags
 1465	                mov     bl,al
 1466	                or      al,00000100b
 1467	                mov     AppleFlags,al
 1468	                mov     al,ah
 1469	                and     al,11000000b
 1470	                shl     ax,1
 1471	                rol     al,3
 1472	                ror     ah,1
 1473	                rcr     al,1
 1474	                or      al,dh
 1475	                or      al,bl
 1476	                mov     bx,AppleSP
 1477	                inc     si
 1478	                or      bl,bl
 1479	                jz      BRK_10
 1480	                dec     bx
 1481	                mov     [bx],si
 1482	                dec     bl
 1483	                mov     [bx],al
 1484	                dec     bl
 1485	                sahf
 1486	                mov     AppleSP,bx
 1487	                mov     si,DS:[BRKvector]
 1488	                mov     bl,ch
 1489	                DoNext
 1490	BRK_10:         sahf
 1491	                mov     bx,si
 1492	                mov     DS:[StackPage*100h],bh
 1493	                mov     ah,bl
 1494	                mov     DS:[StackPage*100h+0FEh],ax
 1495	                mov     byte ptr AppleSP,0FDh
 1496	                mov     si,DS:[BRKvector]
 1497	                mov     bl,ch
 1498	                DoNext
 1499	                CheckAddress
 1500	
 1501	                Opcode  40h                     ; RTI
 1502	                AddTiming 6
 1503	                mov     bx,AppleSP
 1504	                inc     bl
 1505	                mov     al,[bx]
 1506	                inc     bl
 1507	                mov     si,[bx]
 1508	                inc     bl
 1509	                mov     AppleSP,bx
 1510	                jz      RTI_30
 1511	RTI_05:         mov     dh,al
 1512	                and     dh,01000001b
 1513	                mov     bh,al
 1514	                cbw
 1515	                shr     al,1
 1516	                ror     ax,1
 1517	                ror     ah,1
 1518	                mov     al,AppleFlags
 1519	                mov     bl,al
 1520	                and     bx,0000110000110000b
 1521	                or      bl,bh
 1522	                mov     AppleFlags,bl
 1523	                xor     al,bl
 1524	                test    al,00001000b
 1525	                jnz     RTI_10
 1526	                sahf
 1527	                mov     bl,ch
 1528	                DoNext
 1529	RTI_10:         test    bl,00001000b
 1530	                mov     bl,ch
 1531	                jnz     RTI_20
 1532	                jmp     CLD_10
 1533	RTI_20:         jmp     SED_10
 1534	RTI_30:         mov     bx,si
 1535	                mov     bh,DS:[StackPage*100h]
 1536	                mov     si,bx
 1537	                jmp     RTI_05
 1538	                CheckAddress
 1539	
 1540	                Opcode  48h                     ; PHA
 1541	                AddTiming 3
 1542	                mov     bx,AppleSP
 1543	                mov     [bx],dl
 1544	                lahf
 1545	                dec     bl
 1546	                sahf
 1547	                mov     AppleSP,bx
 1548	                mov     bl,ch
 1549	                DoNext
 1550	                CheckAddress
 1551	
 1552	                Opcode  68h                     ; PLA
 1553	                AddTiming 6
 1554	                mov     bx,AppleSP
 1555	                inc     bl
 1556	                mov     dl,[bx]
 1557	                mov     AppleSP,bx
 1558	                or      dl,dl
 1559	                mov     bl,ch
 1560	                DoNext
 1561	                CheckAddress
 1562	
 1563	                Opcode  0DAh                    ; PHX           **65C02**
 1564	                AddTiming 3
 1565	                mov     bx,AppleSP
 1566	                mov     [bx],cl
 1567	                lahf
 1568	                dec     bl
 1569	                sahf
 1570	                mov     AppleSP,bx
 1571	                mov     bl,ch
 1572	                DoNext
 1573	                CheckAddress
 1574	
 1575	                Opcode  0FAh                    ; PLX           **65C02**
 1576	                AddTiming 4
 1577	                mov     bx,AppleSP
 1578	                inc     bl
 1579	                mov     cl,[bx]
 1580	                mov     AppleSP,bx
 1581	                or      cl,cl
 1582	                mov     bl,ch
 1583	                DoNext
 1584	                CheckAddress
 1585	
 1586	                Opcode  5Ah                     ; PHY           **65C02**
 1587	                AddTiming 3
 1588	                mov     ax,bp
 1589	                mov     bx,AppleSP
 1590	                mov     [bx],al
 1591	                lahf
 1592	                dec     bl
 1593	                sahf
 1594	                mov     AppleSP,bx
 1595	                mov     bl,ch
 1596	                DoNext
 1597	                CheckAddress
 1598	
 1599	                Opcode  7Ah                     ; PLY           **65C02**
 1600	                AddTiming 4
 1601	                mov     bx,AppleSP
 1602	                inc     bl
 1603	                mov     al,[bx]
 1604	                mov     AppleSP,bx
 1605	                mov     ah,ch
 1606	                mov     bp,ax
 1607	                or      al,al
 1608	                mov     bl,ch
 1609	                DoNext
 1610	                CheckAddress
 1611	
 1612	                Opcode  08h                     ; PHP
 1613	                AddTiming 3
 1614	                lahf
 1615	                mov     al,ah
 1616	                and     al,11000000b
 1617	                shl     ax,1
 1618	                rol     al,3
 1619	                ror     ah,1
 1620	                rcr     al,1
 1621	                or      al,dh
 1622	                or      al,AppleFlags
 1623	                mov     bx,AppleSP
 1624	                mov     [bx],al
 1625	                dec     bl
 1626	                sahf
 1627	                mov     AppleSP,bx
 1628	                mov     bl,ch
 1629	                DoNext
 1630	                CheckAddress
 1631	
 1632	                Opcode  28h                     ; PLP
 1633	                AddTiming 4
 1634	                mov     bx,AppleSP
 1635	                inc     bl
 1636	                mov     al,[bx]
 1637	                mov     AppleSP,bx
 1638	                mov     dh,al
 1639	                and     dh,01000001b
 1640	                mov     bh,al
 1641	                cbw
 1642	                shr     al,1
 1643	                ror     ax,1
 1644	                ror     ah,1
 1645	                mov     al,AppleFlags
 1646	                mov     bl,al
 1647	                and     bx,0000110000110000b
 1648	                or      bl,bh
 1649	                mov     AppleFlags,bl
 1650	                xor     al,bl
 1651	                test    al,00001000b
 1652	                jnz     PLP_10
 1653	                sahf
 1654	                mov     bl,ch
 1655	                DoNext
 1656	PLP_10:         test    bl,00001000b
 1657	                mov     bl,ch
 1658	                jnz     PLP_20
 1659	                jmp     CLD_10
 1660	PLP_20:         jmp     SED_10
 1661	                CheckAddress
 1662	
 1663	                Opcode  0E8h                    ; INX
 1664	                AddTiming 2
 1665	                inc     cl
 1666	                DoNext
 1667	                CheckAddress
 1668	
 1669	                Opcode  0CAh                    ; DEX
 1670	                AddTiming 2
 1671	                dec     cl
 1672	                DoNext
 1673	                CheckAddress
 1674	
 1675	                Opcode  0C8h                    ; INY
 1676	                AddTiming 2
 1677	                mov     ax,bp
 1678	                inc     al
 1679	                mov     bp,ax
 1680	                DoNext
 1681	                CheckAddress
 1682	
 1683	                Opcode  88h                     ; DEY
 1684	                AddTiming 2
 1685	                mov     ax,bp
 1686	                dec     al
 1687	                mov     bp,ax
 1688	                DoNext
 1689	                CheckAddress
 1690	
 1691	                Opcode  0AAh                    ; TAX
 1692	                AddTiming 2
 1693	                mov     cl,dl
 1694	                or      cl,cl
 1695	                DoNext
 1696	                CheckAddress
 1697	
 1698	                Opcode  0A8h                    ; TAY
 1699	                AddTiming 2
 1700	                mov     ah,bl
 1701	                mov     al,dl
 1702	                mov     bp,ax
 1703	                or      al,al
 1704	                DoNext
 1705	                CheckAddress
 1706	
 1707	                Opcode  8Ah                     ; TXA
 1708	                AddTiming 2
 1709	                mov     dl,cl
 1710	                or      dl,dl
 1711	                DoNext
 1712	                CheckAddress
 1713	
 1714	                Opcode  98h                     ; TYA
 1715	                AddTiming 2
 1716	                mov     ax,bp
 1717	                mov     dl,al
 1718	                or      dl,dl
 1719	                DoNext
 1720	                CheckAddress
 1721	
 1722	                Opcode  0BAh                    ; TSX
 1723	                AddTiming 2
 1724	                mov     cl,byte ptr AppleSP
 1725	                or      cl,cl
 1726	                DoNext
 1727	                CheckAddress
 1728	
 1729	                Opcode  9Ah                     ; TXS
 1730	                AddTiming 2
 1731	                mov     byte ptr AppleSP,cl
 1732	                DoNext
 1733	                CheckAddress
 1734	
 1735	                Opcode  18h                     ; CLC
 1736	                AddTiming 2
 1737	                rcr     dh,1
 1738	                clc
 1739	                rcl     dh,1
 1740	                DoNext
 1741	                CheckAddress
 1742	
 1743	                Opcode  38h                     ; SEC
 1744	                AddTiming 2
 1745	                rcr     dh,1
 1746	                stc
 1747	                rcl     dh,1
 1748	                DoNext
 1749	                CheckAddress
 1750	
 1751	                Opcode  0B8h                    ; CLV
 1752	                AddTiming 2
 1753	                rcr     dh,1
 1754	                mov     dh,bl
 1755	                rcl     dh,1
 1756	                DoNext
 1757	                CheckAddress
 1758	
 1759	                Opcode  58h                     ; CLI
 1760	                AddTiming 2
 1761	                lahf
 1762	                and     AppleFlags,11111011b
 1763	                sahf
 1764	                DoNext
 1765	                CheckAddress
 1766	
 1767	                Opcode  78h                     ; SEI
 1768	                AddTiming 2
 1769	                lahf
 1770	                or      AppleFlags,00000100b
 1771	                sahf
 1772	                DoNext
 1773	                CheckAddress
 1774	
 1775	                Opcode  0D8h                    ; CLD
 1776	                AddTiming 2
 1777	                lahf
 1778	                and     AppleFlags,11110111b
 1779	CLD_10:         sahf
 1780	                mov     di,ds
 1781	                mov     ax,cs
 1782	                mov     ds,ax
 1783	                assume  DS:Emulate
 1784	                mov     al,0FCh                 ; <cld>
 1785	Temp            =       0
 1786	                REPT    ADCcounter
 1787	Temp            =       Temp+1
 1788	                IRP     n,<%Temp>
 1789	                mov     ADC&&n,al
 1790	                ENDM
 1791	                ENDM
 1792	Temp            =       0
 1793	                REPT    SBCcounter
 1794	Temp            =       Temp+1
 1795	                IRP     n,<%Temp>
 1796	                mov     SBC&&n,al
 1797	                ENDM
 1798	                ENDM
 1799	                mov     ds,di
 1800	                assume  DS:Apple
 1801	                DoNext
 1802	                CheckAddress
 1803	
 1804	                Opcode  0F8h                    ; SED
 1805	                AddTiming 2
 1806	                lahf
 1807	                or      AppleFlags,00001000b
 1808	SED_10:         sahf
 1809	                mov     di,ds
 1810	                mov     ax,cs
 1811	                mov     ds,ax
 1812	                assume  DS:Emulate
 1813	                mov     al,27h                  ; <daa>
 1814	Temp            =       0
 1815	                REPT    ADCcounter
 1816	Temp            =       Temp+1
 1817	                IRP     n,<%Temp>
 1818	                mov     ADC&&n,al
 1819	                ENDM
 1820	                ENDM
 1821	                mov     al,2Fh                  ; <das>
 1822	Temp            =       0
 1823	                REPT    SBCcounter
 1824	Temp            =       Temp+1
 1825	                IRP     n,<%Temp>
 1826	                mov     SBC&&n,al
 1827	                ENDM
 1828	                ENDM
 1829	                mov     ds,di
 1830	                assume  DS:Apple
 1831	                DoNext
 1832	                CheckAddress
 1833	
 1834	                Opcode  0EAh                    ; NOP
 1835	                AddTiming 2
 1836	                DoNext
 1837	                CheckAddress
 1838	
 1839	;-------------------------------------------------------------------------------
 1840	
 1841	                Opcode  02h                     ; ???
 1842	                jmp     RETapple
 1843	BadOpcode:      xchg    bh,bl
 1844	                mov     bl,SS:NotInstr[bx]
 1845	                lahf
 1846	                or      bl,bl
 1847	                jns     InvalidInst
 1848	                cmp     word ptr [si],UserMask
 1849	                je      JumpToUser
 1850	                and     bl,7Fh
 1851	InvalidInst:    dec     si
 1852	                add     si,bx
 1853	                sahf
 1854	                mov     bl,bh
 1855	                DoNext
 1856	JumpToUser:     add     si,2
 1857	                lodsb
 1858	                mov     bl,al
 1859	                shl     bx,2
 1860	                sahf
 1861	                Save    ds es
 1862	                pushf
 1863	                call    SS:UserAdrs[bx]
 1864	                Restore ds es
 1865	                mov     bl,0
 1866	                DoNext
 1867	                CheckAddress
 1868	
 1869	Emulate         ends
 1870	
 1871	User            segment public
 1872	                assume  cs:User
 1873	
 1874	BlankU:         iret
 1875	
 1876	DebugU:         jmp     far ptr RETapple
 1877	
 1878	User            ends
 1879	
 1880	Data            segment stack 'stack'
 1881	
 1882	;                       0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
 1883	NotInstr        db      0,0,2,2,0,0,0,2,0,0,0,1,0,0,0,4 ; 00 00 - Debugger
 1884	                db      0,0,0,2,0,0,0,2,0,0,0,1,0,0,0,4 ; 10 8x - User
 1885	                db      0,0,4,2,0,0,0,2,0,0,0,1,0,0,0,4 ; 20
 1886	                db      0,0,0,2,0,0,0,2,0,0,0,1,0,0,0,4 ; 30
 1887	                db      0,0,2,2,2,0,0,2,0,0,0,1,0,0,0,4 ; 40
 1888	                db      0,0,0,2,3,0,0,2,0,0,0,1,4,0,0,4 ; 50
 1889	                db      0,0,3,2,0,0,0,2,0,0,0,1,0,0,0,4 ; 60
 1890	                db      0,0,0,2,0,0,0,2,0,0,0,1,0,0,0,4 ; 70
 1891	                db      0,0,3,2,0,0,0,2,0,0,0,1,0,0,0,4 ; 80
 1892	                db      0,0,0,2,0,0,0,2,0,0,0,1,0,0,0,4 ; 90
 1893	                db      0,0,0,2,0,0,0,2,0,0,0,1,0,0,0,4 ; A0
 1894	                db      0,0,0,2,0,0,0,2,0,0,0,1,0,0,0,4 ; B0
 1895	                db      0,0,2,2,0,0,0,2,0,0,0,1,0,0,0,4 ; C0
 1896	                db      0,0,0,2,2,0,0,2,0,0,0,1,3,0,0,4 ; D0
 1897	                db      0,0,2,2,0,0,0,2,0,0,0,1,0,0,0,4 ; E0
 1898	                db      0,0,0,2,3,0,0,2,0,0,0,1,3,0,0,84 ; F0
 1899	
 1900			even
 1901	UserAdrs        dd      DebugU,BlankU,BlankU,BlankU,BlankU,BlankU,BlankU,BlankU
 1902	                dd      BlankU,BlankU,BlankU,BlankU,BlankU,BlankU,BlankU,BlankU
 1903	                dd      0F0h dup (BlankU)
 1904	
 1905	Data            ends
 1906	
 1907	;-------------------------------------------------------------------------------
 1908	
 1909	                WriteAllFreeSpace
 1910	
 1911	                End
 1912	

Generated by GNU Enscript 1.6.6, and GophHub 1.3.