\\ Assembler for Z80                            ( 27.06.91/KK )                                                                 Source:          23.03.88 ( Heinz Schnitter : Z280 , Z80 )                       04.06.91 ( Klaus Kohl : Structure & HD64180 )                                                                                  Information:                                                                                                     - Includes local labels ( n$: and n$ )                          - Use volksFORTH-Heap:    | , HIDE and REVEAL                                                                                     For other FORTH-Versions use redefinition : | ; and exchange    HIDE ( hide last word ) and REVEAL ( allowing last word ) .                                                                                                                                                                                                                                                                  ( Loadscreen )                  DECIMAL         ( 10.08.91/KK )  sflag @  dup 2 or  sflag !                       \ Warning off  here                           ( Begin )                        Vocabulary Assembler                                            Assembler definitions                                           decimal 02    load     ( Variable, RESET )                      decimal 03 05 thru     ( local labels, READY, CHECK )           decimal 06 11 thru     ( Flags )                                decimal 12 19 thru     ( interpreter )                          decimal 20 64 thru     ( opcode-tables )                        decimal 65 66 thru     ( structures )                           decimal 67 68 thru     ( leave/enter assembler )                decimal here  swap -                                            cr indent .( Length of Assembler: ) u. .( bytes )               sflag !                                          \ Warning on                                                                  ( VARIABLE's and RESET )                HEX     ( 17.08.89/KK )                                                                       | VARIABLE <$>    \ local labels                                | VARIABLE <SEA>  \ last address found in search                | VARIABLE <ARG>  \ type of arguments on parameter stack        | VARIABLE <ESC>  \ type of escape code                         | VARIABLE <OPC>  \ OPCode                                      | VARIABLE <AM>   \ address modes                               | VARIABLE <RM>   \ register modes                              | VARIABLE  SSP   \ save of SP                            | : RESET       ( clears all variables )                                <$>     OFF     <SEA>   OFF     <ARG>   OFF                     <ESC>   OFF     <OPC>   OFF     <AM>    OFF                     <RM>    OFF     SP@  SSP ! ;                            | : -RESET?     ( ... f -- -1 | ... 0 )                            DUP IF  SSP @ SP!  RESET  TRUE  THEN ;                       ( local labels )                        DECIMAL ( 01.07.91/KK )                                                                 | VCREATE $TAB 40 VALLOT                                                                                                        | : CLR$TAB $TAB 40 ERASE ;                                                                                                     | : $: CREATE C,                                                     DOES> C@  $TAB 2+  +   HERE SWAP ! ;                                                                                       | : $  CREATE C,                                                     DOES> C@ $TAB + <$> ON ;                                                                                                                                                                                                                                                                                                                                                                   ( local labels )                        DECIMAL ( 30.08.88/KK )                                                                         00 $:  1$:      00 $  1$                                        04 $:  2$:      04 $  2$                                        08 $:  3$:      08 $  3$                                        12 $:  4$:      12 $  4$                                        16 $:  5$:      16 $  5$                                        20 $:  6$:      20 $  6$                                        24 $:  7$:      24 $  7$                                        28 $:  8$:      28 $  8$                                        32 $:  9$:      32 $  9$                                        36 $: 10$:      36 $ 10$                                                                                                                                                                                                                                                                                                ( READY  CHECK )                        DECIMAL ( 01.07.91/KK )                                                                 | : READY RESET CLR$TAB ;                                                                                                       | : CHECK       ( -- ) ( test $tab )                               $tab &40 +  $tab                                                DO I @ IF I BEGIN  DUP @                                                    WHILE  DUP DUP @                                                       DUP  @ ROT !                                                    OVER 2+ @ DUP 0=                                                -RESET? ERROR" Unresolved Local Label"                          SWAP !                                                   REPEAT DROP                                                THEN                                                     4 +LOOP CLR$TAB ;                                                                                                            ( CONSTANT's: mask )                    HEX     ( 31.08.88/KK )                                                                 \ F E D C | B A 9 8 | 7 6 5 4 | 3 2 1 0                         \   SOURCE   |    DEST.  |  ARG  | ESC                                                                                          | 0F800 CONSTANT SMSK   \ source mask                           \ 007C0 CONSTANT DMSK   \ destination mask                      | 0FFC0 CONSTANT RMSK   \ register mask                         | 00038 CONSTANT AMSK   \ argument mask                         | 00007 CONSTANT EMSK   \ escape code mask                                                                                                                                                                                                                                                                                                                                                                                                                      ( CONSTANT's: data )                    HEX     ( 31.08.88/KK )                                                                 \ F E D C | B A 9 8 | 7 6 5 4 | 3 2 1 0                         \   SOURCE   |    DEST.  |  ARG  | ESC                                                                                          |    00 CONSTANT --     \ no data                               |    01 CONSTANT 3B     \ 3-Bit number                          |    02 CONSTANT 3B.X   \ 3-Bit number and X indeX Format 3     |    03 CONSTANT .X     \ indeX Format 3                        |    04 CONSTANT 8B     \ 8-Bit number or X indeX Format 1+2    |    05 CONSTANT X.8B   \ indeX and 8-Bit number                |    06 CONSTANT DSP    \ DiSPlacement 8-bit relative           |    07 CONSTANT 16B    \ 16-Bit number or address                                                                                                                                                                                                              ( CONSTANT's: escape code )             HEX     ( 31.08.88/KK )                                                                 \ F E D C | B A 9 8 | 7 6 5 4 | 3 2 1 0                         \   SOURCE   |    DEST.  |  ARG  | ESC                                                                                          |    00 CONSTANT ----   \ no escape code                        |    01 CONSTANT E_CB   \ CB   escape code                      |    02 CONSTANT E_DD   \ DD   escape code                      |    03 CONSTANT E_DDCB \ DDCB escape code                      |    04 CONSTANT E_ED   \ ED   escape code                      |    05 CONSTANT E_FD   \ FD   escape code                      |    06 CONSTANT E_FDCB \ FDCB escape code                                                                                                                                                                                                                                                                                      ( registers )                           HEX     ( 06.09.88/KK )                                                                 \ F E D C | B A 9 8 | 7 6 5 4 | 3 2 1 0                         \   SOURCE   |    DEST.  |  ARG  | ESC                                                                                          | : RM: CREATE DUP C, 1+    ( n -- n+1 )                              DOES> C@                                                              <AM> @  IF    6                                                         ELSE 0B THEN  SHIFT  <RM> +! ;                                                                                                                                                                                                                                                                                                                                                                                                                                                                              ( registers )                           HEX     ( 06.09.88/KK )                                                                    1    RM: A                                                           RM: B           RM: C                                           RM: D           RM: E                                           RM: H           RM: L                                           RM: I           RM: R                                           RM: BC          RM: DE                                          RM: HL          RM: SP                                          RM: IX          RM: IY                                          RM: IX+         RM: IY+                                         RM: AF          RM: AF'                                         RM: NZ          RM: Z                                           RM: NC        ( RM: C ) 1 +                                     RM: PO          RM: PE                                          RM: P           RM: M                   DROP            ( addressmodes )                        HEX     ( 01.09.88/KK )                                                                 \ F E D C | B A 9 8 | 7 6 5 4 | 3 2 1 0                         \   SOURCE   |    DEST.  |  ARG  | ESC                                                                                          | : AM: CREATE DUP 2* C, 1+    ( N -- N+1 )                           DOES> C@  <AM> ! ;                                                                                                           1    AM: )           AM: ),                                          AM: ,(          AM: ,           DROP                                                                                                                                                                                                                                                                                                                                                                                                                    ( definings and dispatcher )            HEX     ( 06.09.88/KK )                                                                 | : +OPC <OPC> +! ;                                             | : RM@  <RM> @ ;                                                                                                               | : ?PERFORM @ ?DUP IF EXECUTE THEN ;                           | : (DISPATCH  2*  R@  DUP C@ R> + >R  + 1+ ?PERFORM ;          | : DISPATCH                                                      COMPILE (DISPATCH  DUP 2* 1+ C,                                 0 ?DO [ FORTH ] , [ ASSEMBLER ] LOOP ;      IMMEDIATE                                                                                                                                                                                                                                                                                                                                                                                                         ( escape codes OPcodes )                HEX     ( 17.08.89/KK )                                                                 | : ESC>T: CREATE C, DOES> C@ C, ;                              |     0CB ESC>T: CB>T                                           |     0DD ESC>T: DD>T                                           |     0ED ESC>T: ED>T                                           |     0FD ESC>T: FD>T                                           |              : DDCB>T DD>T CB>T ;                             |              : FDCB>T FD>T CB>T ;                             \ compile codes                                                 | : ESC>T   <ESC> @  DUP 6 U>                                      -RESET? ERROR" Wrong Escape Opcode"                             [ ' FDCB>T ' FD>T ' ED>T ' DDCB>T ' DD>T ' CB>T  0  7 ]         DISPATCH ;                                                   | : OPC>T <OPC> @  C, ;                                         | : >T    ESC>T OPC>T ;                                         ( definings )                           HEX     ( 04.06.91/KK )                                                                 | : ARG  3 SHIFT OR ;                                           | : ESC  OR [ FORTH ] , [ ASSEMBLER ] ;                                                                                         | : 8B?         ( n -- n f ) ( within -128 .. 255 ? )                   DUP -80 100 WITHIN ;                                    | : DSP?        ( n -- n f ) ( within -128 .. 127 ? )                   DUP -80 80 WITHIN ;                                                                                                     | : S?          ( -- N )                                          SSP @ SP@ - 2- 2/ ;                                                                                                           | : ?$  <$> @                                                           IF   HERE OVER @ [ FORTH ] , [ ASSEMBLER ] SWAP !               ELSE [ FORTH ] , [ ASSEMBLER ] THEN ;                   ( tests )                               DECIMAL ( 04.06.91/KK )                                                                 | : B#>OPC      ( bit -- )                                         DUP 7 U>                                                        -RESET? ERROR" Wrong Bitnumber"                                 3 SHIFT +OPC ;                                                                                                               | : ?ARG        ( n -- )                                           S? 1-  -  -RESET? ERROR" Wrong # Of Arguments" ;                                                                             | : ?8B         ( n -- )                                           8B? NOT   -RESET? ERROR" Out of 8-Bit-Range" ;                                                                               | : ?DSP        ( local value ? )                                  <$> @ IF 2+ @ THEN                                              HERE 1+ - DSP? NOT -RESET? ERROR" Offset Out Of Range" ;     ( search )                              HEX     ( 17.08.89/KK )                                                                 | : REG@ DUP @ RMSK AND ;               \ addr -- addr reg      | : ARG@ DUP @ AMSK AND -3 SHIFT ;      \ addr -- addr arg      | : ESC@ DUP @ EMSK AND ;               \ addr -- addr e.esc    | : OPC@ DUP 2+ C@ ;                    \ addr -- addr opc                                                                      | : SEARCH.OPC          ( groupaddr -- )                          DUP C@ +OPC           ( correction opcode )                     1+ <AM> @ + @ ?DUP 0= -RESET? ERROR" Wrong Mode" ( tableaddr )  DUP @ SWAP 2+         ( tableaddr -- end+2 begin )              ?DO [ FORTH ] I [ ASSEMBLER ]   REG@ RM@  =                        IF   ARG@ <ARG> !  ESC@ <ESC> !  OPC@ +OPC  <SEA> !  LEAVE      ELSE DROP THEN                                               3 +LOOP <SEA> @ 0= -RESET? ERROR" Wrong Register" ;                                                                           ( GROUP0 )                              HEX     ( 17.08.89/KK )                                                                 | : M0  ( 0       ) 0 ?ARG                        >T ;          | : M1  ( 3B      ) 1 ?ARG          B#>OPC        >T ;          | : M2  ( 3B.X    ) 2 ?ARG ?8B SWAP B#>OPC ESC>T C, OPC>T ;     | : M3  ( .X      ) 1 ?ARG ?8B             ESC>T C, OPC>T ;     | : M4  ( 8B      ) 1 ?ARG ?8B                    >T C, ;       | : M5  ( X.8B    ) 2 ?ARG ?8B SWAP ?8B           >T C, C, ;    | : M6  ( DSP     ) 1 ?ARG                        >T ?DSP C, ;  | : M7  ( 16B     ) 1 ?ARG                        >T ?$ ;       | : GROUP0:                                                        CREATE  C, [ FORTH ] , , , , , [ ASSEMBLER ]                    DOES>   SEARCH.OPC <ARG> @                                              DUP 7 U> -RESET? ERROR" Wrong Addressmode"                      [ ' M7 ' M6 ' M5 ' M4 ' M3 ' M2 ' M1 ' M0 8 ]                   DISPATCH  RESET ;                                    ( GROUP1  GROUP2  GROUP3 )              HEX     ( 17.08.89/KK )                                                                 | : GROUP1:     ( escape.code object.code -- )                     CREATE  C, C,                                                   DOES>   DUP  C@ +OPC  1+ C@  <ESC> !   >T  RESET ;           | : GROUP2:     ( codes esc # -- )  \ n = 0 .. #-1                 CREATE  DUP C, SWAP C,  0 DO C, LOOP                            DOES>   2 ?ARG  OVER OVER C@ U< NOT                                     -RESET? ERROR" Wrong Value"                                     1+  DUP C@ <ESC> !  1+  +  C@ +OPC  >T  RESET ;      | : GROUP3:     ( codes esc # -- )  \ n = 0, 8, 16 .. (#-1)*8      CREATE  DUP C, SWAP C,  0 DO C, LOOP                            DOES>   2 ?ARG  SWAP DUP 3 AND IF DROP -1 ELSE 8 / THEN SWAP            OVER OVER C@ U< NOT                                             -RESET? ERROR" Wrong Value"                                     1+  DUP C@ <ESC> !  1+  +  C@ +OPC  >T  RESET ;      ( TABLE:  ;TABLE  OPC, )                        ( 01.09.88/KK )                                                                 \ generate new table                                            | : TABLE:        ( -- addr )                                      RESET  | CREATE  HERE                                           HERE 2+ [ FORTH ] , [ ASSEMBLER ] ;                                                                                          \ change endpoint                                               | : ;TABLE        ( addr -- )                                      HERE SWAP ! ;                                                                                                                \ compiling opcodes for registermode                            | : OPC,          ( arg esc opcode -- )                            >R  >R  RM@ SWAP ARG  R> ESC  R> C,  RESET ;                                                                                                                                                 ( ADC )                                 HEX     ( 31.08.88/KK )                                                                 TABLE: ADC3                                                             A ,( HL    --      ----    08E  OPC,                            A ,( IX+   8B      E_DD    08E  OPC,                            A ,( IY+   8B      E_FD    08E  OPC,    ;TABLE          TABLE: ADC4                                                             A , A      --      ----    08F  OPC,                            A , B      --      ----    088  OPC,                            A , C      --      ----    089  OPC,                            A , D      --      ----    08A  OPC,                            A , E      --      ----    08B  OPC,                            A , H      --      ----    08C  OPC,                            A , L      --      ----    08D  OPC,                    ( continue )                                                                                                                    ( ADC )                                         ( 31.05.91/KK )                                                                         A ,        8B      ----    0CE  OPC,                            HL , BC    --      E_ED    04A  OPC,                            HL , DE    --      E_ED    05A  OPC,                            HL , HL    --      E_ED    06A  OPC,                            HL , SP    --      E_ED    07A  OPC,    ;TABLE                                                                             ADC4  ADC3  ----  ----  ----         000 GROUP0: ADC,                                                                                                                                                                                                                                                                                                                                                                                                                                                                        ( ADD )                                 HEX     ( 31.08.88/KK )                                                                 TABLE: ADD3                                                             A ,( HL    --      ----    086  OPC,                            A ,( IX+   8B      E_DD    086  OPC,                            A ,( IY+   8B      E_FD    086  OPC,    ;TABLE          TABLE: ADD4                                                             A , A      --      ----    087  OPC,                            A , B      --      ----    080  OPC,                            A , C      --      ----    081  OPC,                            A , D      --      ----    082  OPC,                            A , E      --      ----    083  OPC,                            A , H      --      ----    084  OPC,                            A , L      --      ----    085  OPC,                            A ,        8B      ----    0C6  OPC,                    ( continue )                                                    ( ADD )                                         ( 31.05.91/KK )                                                                         HL , BC    --      ----    009  OPC,                            HL , DE    --      ----    019  OPC,                            HL , HL    --      ----    029  OPC,                            HL , SP    --      ----    039  OPC,                            IX , BC    --      E_DD    009  OPC,                            IX , DE    --      E_DD    019  OPC,                            IX , HL    --      E_DD    029  OPC,                            IX , SP    --      E_DD    039  OPC,                            IY , BC    --      E_FD    009  OPC,                            IY , DE    --      E_FD    019  OPC,                            IY , HL    --      E_FD    029  OPC,                            IY , SP    --      E_FD    039  OPC,    ;TABLE                                                                             ADD4  ADD3  ----  ----  ----         000 GROUP0: ADD,        ( AND )                                 HEX     ( 31.05.91/KK )                                                                 TABLE: AND0                                                             A          --      ----    0A7  OPC,                            B          --      ----    0A0  OPC,                            C          --      ----    0A1  OPC,                            D          --      ----    0A2  OPC,                            E          --      ----    0A3  OPC,                            H          --      ----    0A4  OPC,                            L          --      ----    0A5  OPC,                                       8B      ----    0E6  OPC,    ;TABLE          TABLE: AND1                                                             HL  )      --      ----    0A6  OPC,                            IX+ )      8B      E_DD    0A6  OPC,                            IY+ )      8B      E_FD    0A6  OPC,    ;TABLE             ----  ----  ----  AND1  AND0         000 GROUP0: AND,        ( BIT )                                 HEX     ( 31.05.91/KK )                                                                 TABLE: BIT3                                                             ,( HL      3B      E_CB    046  OPC,                            ,( IX+     3B.X    E_DDCB  046  OPC,                            ,( IY+     3B.X    E_FDCB  046  OPC,    ;TABLE          TABLE: BIT4                                                             , A        3B      E_CB    047  OPC,                            , B        3B      E_CB    040  OPC,                            , C        3B      E_CB    041  OPC,                            , D        3B      E_CB    042  OPC,                            , E        3B      E_CB    043  OPC,                            , H        3B      E_CB    044  OPC,                            , L        3B      E_CB    045  OPC,    ;TABLE                                                                             BIT4  BIT3  ----  ----  ----         000 GROUP0: BIT,        ( CALL )                                HEX     ( 31.05.91/KK )                                                                 TABLE: CALL0                                                                       16B     ----    009  OPC,    ;TABLE          TABLE: CALL4                                                            NZ  ,      16B     ----    000  OPC,                            Z   ,      16B     ----    008  OPC,                            NC  ,      16B     ----    010  OPC,                            C   ,      16B     ----    018  OPC,                            PO  ,      16B     ----    020  OPC,                            PE  ,      16B     ----    028  OPC,                            P   ,      16B     ----    030  OPC,                            M   ,      16B     ----    038  OPC,    ;TABLE                                                                             CALL4 ----  ----  ----  CALL0        0C4 GROUP0: CALL,                                                                       ( CCF CP CPD CPDR CPI CPIR CPL DAA )    HEX     ( 31.05.91/KK )                                                                                            ----         03F GROUP1: CCF,                                                                           ----  ----  ----  AND1  AND0         018 GROUP0: CP,                                                                                                    E_ED         0A9 GROUP1: CPD,                                   E_ED         0B9 GROUP1: CPDR,                                                                                                  E_ED         0A1 GROUP1: CPI,                                   E_ED         0B1 GROUP1: CPIR,                                                                                                  ----         02F GROUP1: CPL,                                                                                                   ----         027 GROUP1: DAA,                                                                        ( DEC )                                 HEX     ( 31.08.88/KK )                                                                 TABLE: DEC0                                                             A          --      ----    03D  OPC,                            B          --      ----    005  OPC,                            BC         --      ----    00B  OPC,                            C          --      ----    00D  OPC,                            D          --      ----    015  OPC,                            DE         --      ----    01B  OPC,                            E          --      ----    01D  OPC,                            H          --      ----    025  OPC,                            HL         --      ----    02B  OPC,                            IX         --      E_DD    02B  OPC,                            IY         --      E_FD    02B  OPC,                            L          --      ----    02D  OPC,                            SP         --      ----    03B  OPC,    ;TABLE          ( DEC  DI  DJNZ  EI )                   HEX     ( 31.05.91/KK )                                                                 TABLE: DEC1                                                             HL  )      --      ----    035  OPC,                            IX+ )      8B      E_DD    035  OPC,                            IY+ )      8B      E_FD    035  OPC,    ;TABLE                                                                             ----  ----  ----  DEC1  DEC0         000 GROUP0: DEC,                                                                                                   ----         0F3 GROUP1: DI,                                                                         TABLE: DJNZ0                                                                       DSP     ----    010  OPC,    ;TABLE             ----  ----  ----  ----  DJNZ0        000 GROUP0: DJNZ,                                                                                                  ----         0FB GROUP1: EI,         ( EX  EXX  HALT )                       HEX     ( 31.05.91/KK )                                                                 TABLE: EX2                                                              SP ), HL   --      ----    0E3  OPC,                            SP ), IX   --      E_DD    0E3  OPC,                            SP ), IY   --      E_FD    0E3  OPC,    ;TABLE          TABLE: EX4                                                              AF , AF'   --      ----    008  OPC,                            DE , HL    --      ----    0EB  OPC,    ;TABLE                                                                             EX4   ----  EX2   ----  ----         000 GROUP0: EX,                                                                                                    ----         0D9 GROUP1: EXX,                                                                                                   ----         076 GROUP1: HALT,                                                                       ( IM  IN )                              HEX     ( 31.05.91/KK )                                                                    05E   056   046         E_ED           3  GROUP2: IM,                                                                        TABLE: IN3                                                              A ,( C     --      E_ED    078  OPC,                            A ,(       8B      ----    0DB  OPC,                            B ,( C     --      E_ED    040  OPC,                            C ,( C     --      E_ED    048  OPC,                            D ,( C     --      E_ED    050  OPC,                            E ,( C     --      E_ED    058  OPC,                            H ,( C     --      E_ED    060  OPC,                            L ,( C     --      E_ED    068  OPC,    ;TABLE                                                                             ----  IN3   ----  ----  ----         000 GROUP0: IN,                                                                         ( IN0 )                                 HEX     ( 04.06.91/KK )                                                                 TABLE: IN03                                                             B ,(       8B      E_ED    000  OPC,                            C ,(       8B      E_ED    008  OPC,                            D ,(       8B      E_ED    010  OPC,                            E ,(       8B      E_ED    018  OPC,                            H ,(       8B      E_ED    020  OPC,                            L ,(       8B      E_ED    028  OPC,                            A ,(       8B      E_ED    038  OPC,    ;TABLE                                                                             ----  IN03  ----  ----  ----         000 GROUP0: IN0,                                                                                                                                                                                                                                                                        ( INC )                                 HEX     ( 31.08.88/KK )                                                                 TABLE: INC0                                                             A          --      ----    03C  OPC,                            B          --      ----    004  OPC,                            BC         --      ----    003  OPC,                            C          --      ----    00C  OPC,                            D          --      ----    014  OPC,                            DE         --      ----    013  OPC,                            E          --      ----    01C  OPC,                            H          --      ----    024  OPC,                            HL         --      ----    023  OPC,                            IX         --      E_DD    023  OPC,                            IY         --      E_FD    023  OPC,                            L          --      ----    02C  OPC,                            SP         --      ----    033  OPC,    ;TABLE          ( INC  IND  INDR  INI  INIR )           HEX     ( 31.05.91/KK )                                                                 TABLE: INC1                                                             HL  )      --      ----    034  OPC,                            IX+ )      8B      E_DD    034  OPC,                            IY+ )      8B      E_FD    034  OPC,    ;TABLE                                                                             ----  ----  ----  INC1  INC0         000 GROUP0: INC,                                                                                                                                                                   E_ED         0AA GROUP1: IND,                                   E_ED         0BA GROUP1: INDR,                                                                                                  E_ED         0A2 GROUP1: INI,                                   E_ED         0B2 GROUP1: INIR,                                                                       ( JP )                                  HEX     ( 31.05.91/KK )                                                                 TABLE: JP0                                                                         16B     ----    001  OPC,    ;TABLE          TABLE: JP1                                                              HL )       --      ----    027  OPC,                            IX )       --      E_DD    027  OPC,                            IY )       --      E_FD    027  OPC,    ;TABLE                                                                             CALL4 ----  ----  JP1   JP0          0C2 GROUP0: JP,                                                                                                                                                                                                                                                                                                                                                                                                         ( JP )                                  HEX     ( 31.05.91/KK )                                                                 TABLE: JR0                                                                         DSP     ----    018  OPC,    ;TABLE          TABLE: JR4                                                              NZ  ,      DSP     ----    020  OPC,                            Z   ,      DSP     ----    028  OPC,                            NC  ,      DSP     ----    030  OPC,                            C   ,      DSP     ----    038  OPC,    ;TABLE                                                                             JR4   ----  ----  ----  JR0          000 GROUP0: JR,                                                                                                                                                                                                                                                                                                                                         ( LD )                                  HEX     ( 31.08.88/KK )                                                                 TABLE: LD2                                                              BC ), A    --      ----    002  OPC,                            DE ), A    --      ----    012  OPC,                            HL ), A    --      ----    077  OPC,                            HL ), B    --      ----    070  OPC,                            HL ), C    --      ----    071  OPC,                            HL ), D    --      ----    072  OPC,                            HL ), E    --      ----    073  OPC,                            HL ), H    --      ----    074  OPC,                            HL ), L    --      ----    075  OPC,                            HL ),      8B      ----    036  OPC,                                                                                    ( continue )                                                                                                                    ( LD )                                  HEX     ( 31.08.88/KK )                                                                         IX+ ), A   8B      E_DD    077  OPC,                            IX+ ), B   8B      E_DD    070  OPC,                            IX+ ), C   8B      E_DD    071  OPC,                            IX+ ), D   8B      E_DD    072  OPC,                            IX+ ), E   8B      E_DD    073  OPC,                            IX+ ), H   8B      E_DD    074  OPC,                            IX+ ), L   8B      E_DD    075  OPC,                            IX+ ),     X.8B    E_DD    036  OPC,                                                                                    ( continue )                                                                                                                                                                                                                                                                                                                    ( LD )                                  HEX     ( 31.08.88/KK )                                                                         IY+ ), A   8B      E_FD    077  OPC,                            IY+ ), B   8B      E_FD    070  OPC,                            IY+ ), C   8B      E_FD    071  OPC,                            IY+ ), D   8B      E_FD    072  OPC,                            IY+ ), E   8B      E_FD    073  OPC,                            IY+ ), H   8B      E_FD    074  OPC,                            IY+ ), L   8B      E_FD    075  OPC,                            IY+ ),     X.8B    E_FD    036  OPC,                                                                                    ( continue )                                                                                                                                                                                                                                                                                                                    ( LD )                                  HEX     ( 31.08.88/KK )                                                                         ), A       16B     ----    032  OPC,                            ), BC      16B     E_ED    043  OPC,                            ), DE      16B     E_ED    053  OPC,                            ), HL      16B     ----    022  OPC,                            ), IX      16B     E_DD    022  OPC,                            ), IY      16B     E_FD    022  OPC,                            ), SP      16B     E_ED    073  OPC,    ;TABLE                                                                                                                                                                                                                                                                                                                                                                                                                                                                          ( LD )                                  HEX     ( 31.08.88/KK )                                                                 TABLE: LD3                                                              A ,( BC    --      ----    00A  OPC,                            A ,( DE    --      ----    01A  OPC,                            A ,( HL    --      ----    07E  OPC,                            A ,( IX+   8B      E_DD    07E  OPC,                            A ,( IY+   8B      E_FD    07E  OPC,                            A ,(       16B     ----    03A  OPC,                                                                                    ( continue )                                                                                                                                                                                                                                                                                                                                                                                    ( LD )                                  HEX     ( 31.08.88/KK )                                                                         B ,( HL    --      ----    046  OPC,                            B ,( IX+   8B      E_DD    046  OPC,                            B ,( IY+   8B      E_FD    046  OPC,                            BC ,(      16B     E_ED    04B  OPC,                            C ,( HL    --      ----    04E  OPC,                            C ,( IX+   8B      E_DD    04E  OPC,                            C ,( IY+   8B      E_FD    04E  OPC,                                                                                    ( continue )                                                                                                                                                                                                                                                                                                                                                                                    ( LD )                                  HEX     ( 31.08.88/KK )                                                                         D ,( HL    --      ----    056  OPC,                            D ,( IX+   8B      E_DD    056  OPC,                            D ,( IY+   8B      E_FD    056  OPC,                            DE ,(      16B     E_ED    05B  OPC,                            E ,( HL    --      ----    05E  OPC,                            E ,( IX+   8B      E_DD    05E  OPC,                            E ,( IY+   8B      E_FD    05E  OPC,                                                                                    ( continue )                                                                                                                                                                                                                                                                                                                                                                                    ( LD )                                  HEX     ( 31.08.88/KK )                                                                         H ,( HL    --      ----    066  OPC,                            H ,( IX+   8B      E_DD    066  OPC,                            H ,( IY+   8B      E_FD    066  OPC,                            HL ,(      16B     ----    02A  OPC,                            IX ,(      16B     E_DD    02A  OPC,                            IY ,(      16B     E_FD    02A  OPC,                            L ,( HL    --      ----    06E  OPC,                            L ,( IX+   8B      E_DD    06E  OPC,                            L ,( IY+   8B      E_FD    06E  OPC,                                                                                            SP ,(      16B     E_ED    07B  OPC,    ;TABLE                                                                                                                                                                                                          ( LD )                                  HEX     ( 31.08.88/KK )                                                                 TABLE: LD4                                                              A , A      --      ----    07F  OPC,                            A , B      --      ----    078  OPC,                            A , C      --      ----    079  OPC,                            A , D      --      ----    07A  OPC,                            A , E      --      ----    07B  OPC,                            A , H      --      ----    07C  OPC,                            A , I      --      E_ED    057  OPC,                            A , L      --      ----    07D  OPC,                            A , R      --      E_ED    05F  OPC,                            A ,        8B      ----    03E  OPC,                                                                                    ( continue )                                                                                                                    ( LD )                                  HEX     ( 31.08.88/KK )                                                                         B , A      --      ----    047  OPC,                            B , B      --      ----    040  OPC,                            B , C      --      ----    041  OPC,                            B , D      --      ----    042  OPC,                            B , E      --      ----    043  OPC,                            B , H      --      ----    044  OPC,                            B , L      --      ----    045  OPC,                            B ,        8B      ----    006  OPC,                            BC ,       16B     ----    001  OPC,                                                                                    ( continue )                                                                                                                                                                                                                                                    ( LD )                                  HEX     ( 31.08.88/KK )                                                                         C , A      --      ----    04F  OPC,                            C , B      --      ----    048  OPC,                            C , C      --      ----    049  OPC,                            C , D      --      ----    04A  OPC,                            C , E      --      ----    04B  OPC,                            C , H      --      ----    04C  OPC,                            C , L      --      ----    04D  OPC,                            C ,        8B      ----    00E  OPC,                                                                                    ( continue )                                                                                                                                                                                                                                                                                                                    ( LD )                                  HEX     ( 31.08.88/KK )                                                                         D , A      --      ----    057  OPC,                            D , B      --      ----    050  OPC,                            D , C      --      ----    051  OPC,                            D , D      --      ----    052  OPC,                            D , E      --      ----    053  OPC,                            D , H      --      ----    054  OPC,                            D , L      --      ----    055  OPC,                            D ,        8B      ----    016  OPC,                            DE ,       16B     ----    011  OPC,                                                                                    ( continue )                                                                                                                                                                                                                                                    ( LD )                                  HEX     ( 31.08.88/KK )                                                                         E , A      --      ----    05F  OPC,                            E , B      --      ----    058  OPC,                            E , C      --      ----    059  OPC,                            E , D      --      ----    05A  OPC,                            E , E      --      ----    05B  OPC,                            E , H      --      ----    05C  OPC,                            E , L      --      ----    05D  OPC,                            E ,        8B      ----    01E  OPC,                                                                                    ( continue )                                                                                                                                                                                                                                                                                                                    ( LD )                                  HEX     ( 31.08.88/KK )                                                                         H , A      --      ----    067  OPC,                            H , B      --      ----    060  OPC,                            H , C      --      ----    061  OPC,                            H , D      --      ----    062  OPC,                            H , E      --      ----    063  OPC,                            H , H      --      ----    064  OPC,                            H , L      --      ----    065  OPC,                            H ,        8B      ----    026  OPC,                            HL ,       16B     ----    021  OPC,                            I , A      --      E_ED    047  OPC,                            IX ,       16B     E_DD    021  OPC,                            IY ,       16B     E_FD    021  OPC,                                                                                    ( continue )                                                    ( LD )                                  HEX     ( 31.08.88/KK )                                                                         L , A      --      ----    06F  OPC,                            L , B      --      ----    068  OPC,                            L , C      --      ----    069  OPC,                            L , D      --      ----    06A  OPC,                            L , E      --      ----    06B  OPC,                            L , H      --      ----    06C  OPC,                            L , L      --      ----    06D  OPC,                            L ,        8B      ----    02E  OPC,                                                                                    ( continue )                                                                                                                                                                                                                                                                                                                    ( LD  LDD  LDDR  LDI  LDIR )            HEX     ( 31.05.91/KK )                                                                         R , A      --      E_ED    04F  OPC,                            SP , HL    --      ----    0F9  OPC,                            SP , IX    --      E_DD    0F9  OPC,                            SP , IY    --      E_FD    0F9  OPC,                            SP ,       16B     ----    031  OPC,    ;TABLE                                                                             LD4   LD3   LD2   ----  ----         000 GROUP0: LD,                                                                                                    E_ED         0A8 GROUP1: LDD,                                   E_ED         0B8 GROUP1: LDDR,                                                                                                  E_ED         0A0 GROUP1: LDI,                                   E_ED         0B0 GROUP1: LDIR,                                                                       ( MLT  NEG  NOP  OR )                       HEX ( 04.06.91/KK )                                                                 TABLE: MLT0                                                             BC         --      E_ED    000  OPC,                            DE         --      E_ED    010  OPC,                            HL         --      E_ED    020  OPC,                            SP         --      E_ED    030  OPC, ;TABLE                                                                                ----  ----  ----  ----  MLT0         04C GROUP0: MLT,                                                                                                   E_ED         044 GROUP1: NEG,                                                                                                   ----         000 GROUP1: NOP,                                                                           ----  ----  ----  AND1  AND0         010 GROUP0: OR,                                                                         ( OTDM  OTDMR  OTDR  OTIM  OTIMR  OTIR )    HEX ( 04.06.91/KK )                                                                                            E_ED         08B GROUP1: OTDM,                                  E_ED         09B GROUP1: OTDMR,                                 E_ED         0BB GROUP1: OTDR,                                                                                                  E_ED         083 GROUP1: OTIM,                                  E_ED         093 GROUP1: OTIMR,                                 E_ED         0B3 GROUP1: OTIR,                                                                                                                                                                                                                                                                                                                                                                                                                                                                       ( OUT )                                 HEX     ( 04.06.91/KK )                                                                 TABLE: OUT2                                                             C ), A     --      E_ED    079  OPC,                            C ), B     --      E_ED    041  OPC,                            C ), C     --      E_ED    049  OPC,                            C ), D     --      E_ED    051  OPC,                            C ), E     --      E_ED    059  OPC,                            C ), H     --      E_ED    061  OPC,                            C ), L     --      E_ED    069  OPC,                              ), A     8B      ----    0D3  OPC,    ;TABLE                                                                             ----  ----  OUT2  ----  ----         000 GROUP0: OUT,                                                                                                                                                                                                        ( OUT0  OUTD  OUTI )                    HEX     ( 04.06.91/KK )                                                                 TABLE: OUT02                                                              ), B     8B      E_ED    001  OPC,                              ), C     8B      E_ED    009  OPC,                              ), D     8B      E_ED    011  OPC,                              ), E     8B      E_ED    019  OPC,                              ), H     8B      E_ED    021  OPC,                              ), L     8B      E_ED    029  OPC,                              ), A     8B      E_ED    039  OPC,    ;TABLE                                                                             ----  ----  OUT02 ----  ----         000 GROUP0: OUT0,                                                                                                  E_ED         0AB GROUP1: OUTD,                                  E_ED         0A3 GROUP1: OUTI,                                                                       ( POP  PUSH  RES )                      HEX     ( 31.05.91/KK )                                                                 TABLE: POP0                                                             AF         --      ----    0F1  OPC,                            BC         --      ----    0C1  OPC,                            DE         --      ----    0D1  OPC,                            HL         --      ----    0E1  OPC,                            IX         --      E_DD    0E1  OPC,                            IY         --      E_FD    0E1  OPC,    ;TABLE                                                                             ----  ----  ----  ----  POP0         000 GROUP0: POP,           ----  ----  ----  ----  POP0         004 GROUP0: PUSH,                                                                          BIT4  BIT3  ----  ----  ----         040 GROUP0: RES,                                                                                                                                        ( RET  RETI  RETN )                     HEX     ( 31.05.91/KK )                                                                 TABLE: RET0                                                                        --      ----    0C9  OPC,                            NZ         --      ----    0C0  OPC,                            Z          --      ----    0C8  OPC,                            NC         --      ----    0D0  OPC,                            C          --      ----    0D8  OPC,                            PO         --      ----    0E0  OPC,                            PE         --      ----    0E8  OPC,                            M          --      ----    0F0  OPC,                            P          --      ----    0F8  OPC,    ;TABLE             ----  ----  ----  ----  RET0         000 GROUP0: RET,                                                                                                   E_ED         04D GROUP1: RETI,                                  E_ED         045 GROUP1: RETN,       ( RL )                                  HEX     ( 31.08.88/KK )                                                                 ( RLC0 used from most shift-commands )                          TABLE: RLC0                                                             A          --      E_CB    007  OPC,                            B          --      E_CB    000  OPC,                            C          --      E_CB    001  OPC,                            D          --      E_CB    002  OPC,                            E          --      E_CB    003  OPC,                            H          --      E_CB    004  OPC,                            L          --      E_CB    005  OPC,    ;TABLE          TABLE: RLC1                                                             HL  )      --      E_CB    006  OPC,                            IX+ )      .X      E_DDCB  006  OPC,                            IY+ )      .X      E_FDCB  006  OPC,    ;TABLE                                                                          ( RL .. RLD  RR .. RRD  RST )           HEX     ( 31.05.91/KK )                                                                    ----  ----  ----  RLC1  RLC0         010 GROUP0: RL,                                    ----         017 GROUP1: RLA,           ----  ----  ----  RLC1  RLC0         000 GROUP0: RLC,                                   ----         007 GROUP1: RLCA,                                  E_ED         06F GROUP1: RLD,                                                                           ----  ----  ----  RLC1  RLC0         018 GROUP0: RR,                                    ----         01F GROUP1: RRA,           ----  ----  ----  RLC1  RLC0         008 GROUP0: RRC,                                   ----         00F GROUP1: RRCA,                                  E_ED         067 GROUP1: RRD,                                                                           0FF   0F7   0EF   0E7                                           0DF   0D7   0CF   0C7   ----           8 GROUP3: RST,        ( SBC )                                 HEX     ( 02.09.88/KK )                                                                 TABLE: SBC3                                                             A ,( HL    --      ----    09E  OPC,                            A ,( IX+   8B      E_DD    09E  OPC,                            A ,( IY+   8B      E_FD    09E  OPC,    ;TABLE          TABLE: SBC4                                                             A , A      --      ----    09F  OPC,                            A , B      --      ----    098  OPC,                            A , C      --      ----    099  OPC,                            A , D      --      ----    09A  OPC,                            A , E      --      ----    09B  OPC,                            A , H      --      ----    09C  OPC,                            A , L      --      ----    09D  OPC,                    ( continue )                                                                                                                    ( SBC  SCF )                                    ( 31.05.91/KK )                                                                         A ,        8B      ----    0DE  OPC,                            HL , BC    --      E_ED    042  OPC,                            HL , DE    --      E_ED    052  OPC,                            HL , HL    --      E_ED    062  OPC,                            HL , SP    --      E_ED    072  OPC,    ;TABLE                                                                             SBC4  SBC3  ----  ----  ----         000 GROUP0: SBC,                                                                                                   ----         037 GROUP1: SCF,                                                                                                                                                                                                                                                                                                                                        ( SET  SLA  SRA  SRL  SUB )             HEX     ( 04.06.91/KK )                                                                    BIT4  BIT3  ----  ----  ----         080 GROUP0: SET,                                                                           ----  ----  ----  RLC1  RLC0         020 GROUP0: SLA,                                                                                                   E_ED         076 GROUP1: SLP                                                                            ----  ----  ----  RLC1  RLC0         028 GROUP0: SRA,           ----  ----  ----  RLC1  RLC0         038 GROUP0: SRL,                                                                           ----  ----  ----  AND1  AND0        -010 GROUP0: SUB,                                                                                                                                                                                                                                                                        ( TST  XOR )                            HEX     ( 04.06.91/KK )                                                                 TABLE: TST0                                                             B          --      E_ED    004  OPC,                            C          --      E_ED    00C  OPC,                            D          --      E_ED    014  OPC,                            E          --      E_ED    01C  OPC,                            H          --      E_ED    024  OPC,                            L          --      E_ED    02C  OPC,                                       8B      E_ED    064  OPC,                            A          --      E_ED    03C  OPC,    ;TABLE          TABLE: TST1                                                             HL         --      E_ED    034  OPC,    ;TABLE             ----  ----  ----  TST1  TST0         000 GROUP0: TST,                                                                           ----  ----  ----  AND1  AND0         008 GROUP0: XOR,        ( -JP for conditions )                  HEX     ( 01.07.91/KK )                                                                 TABLE: -JR0                                                                        DSP     ----    018  OPC,    ;TABLE          TABLE: -JR4                                                              Z  ,      DSP     ----    020  OPC,                            NZ  ,      DSP     ----    028  OPC,                             C  ,      DSP     ----    030  OPC,                            NC  ,      DSP     ----    038  OPC,    ;TABLE          | -JR4   ----  ----  ---- -JR0          000 GROUP0: -JR,                                                                        | : >JRCC       <RM> @  IF , THEN  HERE 2+  -JR, ;              | : <JRCC       <RM> @  IF , THEN  -JR, ;                       | : >JRRES      HERE OVER - ?8B SWAP 1- C! ;                    | : >JRRESUME   BEGIN  -2 =  WHILE  >JRRES  REPEAT  RESET ;                                                                     ( Controll Structure )                  HEX     ( 01.07.91/KK )                                                                 : IF,           >JRCC  HERE  1  RESET ;                         : ELSE,         1 ?PAIRS  HERE 2+ DUP JR, -1 ROT >JRRES RESET ; : THEN,         ABS 1 ?PAIRS  >JRRES  RESET ;                                                                                   : BEGIN,        2 HERE 2  RESET ;                               : WHILE,        DUP 2 ?PAIRS   >JRCC  HERE -2  2SWAP  RESET ;   : REPEAT,       2 ?PAIRS  SP@ 2+ SSP !  JR,    >JRRESUME ;      : UNTIL,        2 ?PAIRS  SP@ 2+ SSP !  <JRCC  >JRRESUME ;                                                                      : DO,           HERE 3  RESET ;                                 : LOOP,         3 ?PAIRS  DJNZ, ;                                                                                                                                                                                                                               ( BPOP  DPUSH  HPUSH  END-CODE )                ( 04.06.91/KK )                                                                 \ NOOP-CFA points to NEXT                                         : next,   ['] noop @     jp, ;                                  : hpush,  ['] noop @ 1-  jp, ;                                  : dpush,  ['] noop @ 2-  jp, ;                                  : bpop,   ['] noop @ 3 - jp, ;                                                                                                : END-PROC      CHECK  RESET  REVEAL  FORTH ;                                                                                   : END-CODE      [COMPILE] END-PROC ;                                                                                                                                                                                                                                                                                                                                                            \ ;CODE  PROC  CODE                             ( 31.05.91/KK ) FORTH DEFINITIONS       \ begin machine primitive definitions   : ;CODE         dup 0 ?pairs drop                                               COMPILE (;CODE  [compile] [                                     [ ASSEMBLER ] READY [ FORTH ]                                   ASSEMBLER ;                           IMMEDIATE : PROC          CREATE  HIDE                                                    [ ASSEMBLER ] READY [ FORTH ]                                   ASSEMBLER ;                                     : CODE          [COMPILE] PROC  HERE DUP 2- !  ;                                                                                                                                                                                                                                                                                                                                                                                                                