File:  [gforth] / gforth / arch / r8c / asm.fs
Revision 1.14: download - view: text, annotated - select for diffs
Mon Dec 31 19:02:25 2007 UTC (14 years, 11 months ago) by anton
Branches: MAIN
CVS tags: v0-7-0, HEAD
updated copyright year after changing license notice

    1: \ FORTH Assembler for R8C                    hfs 23:54 25.12.05
    2: \
    3: \ Copyright (C) 2006,2007 Free Software Foundation, Inc.
    4: 
    5: \ This file is part of Gforth.
    6: 
    7: \ Gforth is free software; you can redistribute it and/or
    8: \ modify it under the terms of the GNU General Public License
    9: \ as published by the Free Software Foundation, either version 3
   10: \ of the License, or (at your option) any later version.
   11: 
   12: \ This program is distributed in the hope that it will be useful,
   13: \ but WITHOUT ANY WARRANTY; without even the implied warranty of
   14: \ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   15: \ GNU General Public License for more details.
   16: 
   17: \ You should have received a copy of the GNU General Public License
   18: \ along with this program. If not, see http://www.gnu.org/licenses/.
   19: \
   20: \ Autor:          Heinz Schnitter (hfs)
   21: \
   22: \ Information:
   23: \
   24: \ - R8C.ASM is a table driven assembler.
   25: \ - R8C.ASM supports OPCodes of Renesas R8C Microcomputer in
   26: \   postfix notation.
   27: 
   28: \ only forth definitions
   29: 
   30: require asm/basic.fs
   31: 
   32:  also ASSEMBLER definitions
   33: 
   34: require asm/target.fs
   35: 
   36: \ for tests only                hfs 07:47 04/24/92
   37: 
   38: \ : TC, base @ >r hex 0 <# # # #>       type r> base ! ;
   39: \ : T,  base @ >r hex 0 <# # # # # #>   type r> base ! ;
   40: \ : ta, base @ >r hex 0 <# # # # # # #> type r> base ! ;
   41: : ta, true abort" This stupid 20 bit addressing mode doesn't work!" ;
   42: 
   43:  HERE                   ( Begin )
   44: 
   45: \ VARIABLEs and RESET                        hfs 10:03 04/23/92
   46: 
   47:       VARIABLE SSP                 \ save of SP
   48:       VARIABLE <,>                 \ two addrs
   49:       VARIABLE <M>                 \ mode searched for in table
   50:       VARIABLE <OPC>               \ OPCode
   51:       VARIABLE <.B>
   52:       VARIABLE <S-OPND>
   53:       VARIABLE <D-OPND>
   54: 
   55:  : ssave SP@ SSP ! ;
   56: 
   57:  : RESET       ( clears all variables )
   58:    0 <M>   C!    $0FF <M>   1+ C!
   59:    0 <OPC> C!    $0FF <OPC> 1+ C!
   60:    <S-OPND> OFF  <D-OPND> OFF
   61:    <,> OFF       <.B> OFF  ssave ;
   62: 
   63:  : opnd?  ( -- N ) SSP @ SP@ - 1 cells - 1 cells / ;
   64:  : ,? <,> @ ;
   65:  : S-OPND? <S-OPND> @ ;
   66:  : D-OPND? <D-OPND> @ ;
   67: 
   68:  : WITHIN >R OVER > SWAP R> <= 0= OR 0= ;
   69: 
   70:  : 4B?  ( n -- n f ) ( within -8 .. 7 ? )
   71:    DUP -$8   $7   WITHIN ;
   72:  : >4B?  ( n -- n f ) 4B? 0= ;
   73: 
   74:  : 8B?  ( n -- n f ) ( within -128 .. 127 ? )
   75:    DUP -$80   $7F   WITHIN ;
   76:  : >8B?  ( n -- n f ) 8B? 0= ;
   77: 
   78:    $0ff   CONSTANT abs8
   79:  : abs8?  ( n -- n f ) DUP abs8 u< ;
   80:  : >abs8? ( n -- n f ) abs8? 0= ;
   81: 
   82:  : >opc <M> 1+ C@ <OPC> 1+ C! ;
   83: 
   84:  : M: CREATE  C, C,
   85:        DOES> ,?
   86:        IF    dup C@          <M>    c@ $F0 AND OR <M>    c!
   87:               1+ C@          <M> 1+ c@ $F0 AND OR <M> 1+ c!
   88:        ELSE  dup C@ 4 lshift <M>    c@ $0F AND OR <M>    c!
   89:               1+ C@ 4 lshift <M> 1+ c@ $0F AND OR <M> 1+ c!
   90:        THEN ;
   91: 
   92: \ address-modes hfs
   93: 
   94:  %0000 0 M: R0    ' R0 alias R0L  ' R0 alias R2R0  ' R0  alias C
   95:  %0001 0 M: R1    ' R1 alias R0H  ' R1 alias R3R1  ' R1  alias D
   96:  %0010 0 M: R2    ' R2 alias R1L                   ' R2  alias Z
   97:  %0011 0 M: R3    ' R3 alias R1H                   ' R3  alias S
   98:  %0100 0 M: A0                    ' A0 alias A1A0  ' A0  alias B
   99:  %0101 0 M: A1                                     ' A1  alias O
  100:  %0110 0 M: [A0]                                  ' [A0] alias I
  101:  %0111 0 M: [A1]                                  ' [A1] alias U
  102:  %1010 0 M: [SB]
  103:  %1011 0 M: [FB]
  104:  %1111 0 M: abs:16
  105:  %0000 1 M: #
  106:  %0001 1 M: INTBL
  107:  %0010 1 M: INTBH
  108:  %0011 1 M: FLG
  109:  %0100 1 M: ISP
  110:  %0101 1 M: SP
  111:  %0110 1 M: SB
  112:  %0111 1 M: FB
  113:  
  114: \ %0000 2 M: [SP]
  115: 
  116: \ two cells are used for each adress mode in the table:
  117: \
  118: \ cell 1 contains the src and dst MODE# searched for.
  119: \
  120: \ Cell 2 contains the xt of the action word for this address mode.
  121: \
  122: \ |     #src#dst|src  dst|                     |
  123: \ |.....76543210 76543210 .....7654321076543210|
  124: \ |          MODE        |            xt       |
  125: 
  126:  : TABLE:        ( -- addr ) \ generate new table
  127:    CREATE HERE DUP 1 cells + , RESET ;
  128: 
  129:  : ;TABLE        ( addr -- ) \ change endpoint
  130:    HERE SWAP ! ;
  131: 
  132:  : TAB,          ( xt opcode -- )
  133:    <M> @ , , RESET ;
  134: 
  135:  : SEARCH.MODE.2 ( addr -- xt )
  136:    TRUE SWAP
  137:    DUP     C@ <OPC>     C!    ( opc from GROUP2: )
  138:    DUP 1+  C@ <OPC> 1+  C!    ( opc from GROUP2: )
  139:    2 + @ DUP @                ( tableaddr )
  140:    SWAP 1 cells +             ( end+2 begin )
  141:    ?DO [ forth ] I [ assembler ] @ <M> @ =
  142:        IF [ forth ] I [ assembler ] 1 cells + @ swap 0= LEAVE THEN
  143:    2 cells +LOOP ABORT" Addressmode failed" ;
  144: 
  145:  : SEARCH.MODE.4 ( addr -- xt )
  146:    TRUE SWAP
  147:    DUP     C@ <OPC>     C!    ( opc from GROUP4: )
  148:    DUP 1+  C@ <OPC> 1+  C!    ( opc from GROUP4: )
  149:    DUP 2 + C@ <OPC> 2 + C!    ( opc from GROUP4: )
  150:    DUP 3 + C@ <OPC> 3 + C!    ( opc from GROUP4: )
  151:    4 + @ DUP @                ( tableaddr )
  152:    SWAP 1 cells +             ( end+2 begin )
  153:    ?DO [ forth ] I [ assembler ] @ <M> @ =
  154:        IF [ forth ] I [ assembler ] 1 cells + @ swap 0= LEAVE THEN
  155:    2 cells +LOOP ABORT" Addressmode failed" ;
  156: 
  157: \ GROUPS                                     hfs 07:18 04/24/92
  158: 
  159:  : GROUP2:   CREATE C, C,  ,        ( xt opc opc  -- )
  160:              DOES> SEARCH.MODE.2 EXECUTE RESET ;
  161: 
  162:  : GROUP4:   CREATE C, C,  C, C,  , ( xt opc opc  opc opc  -- )
  163:              DOES> SEARCH.MODE.4 EXECUTE RESET ;
  164: 
  165: \ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  166:  : , opnd? <s-opnd> ! ssave <,> ON ;
  167: \ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  168: 
  169:  : OPC, <OPC> C@ X C, <OPC> 1+ C@ X C, ;
  170: 
  171:  : [An],     <M> 1+ C@ $F0 AND
  172:              CASE
  173:                 %01100000 of s-opnd?  \ [A0]
  174:                              IF abs8? IF %10000000 ELSE %11000000 THEN
  175:                              <M> 1+ C@ $0F AND OR <M> 1+ C! THEN
  176:                           endof
  177:                 %01110000 of s-opnd?  \ [A1]
  178:                              IF abs8? IF %10010000 ELSE %11010000 THEN
  179:                              <M> 1+ C@ $0F AND OR <M> 1+ C! THEN
  180:                           endof
  181:              ENDCASE ;
  182: 
  183:  : ,[An]     <M> 1+ C@ $0F AND
  184:              CASE
  185:                 %0110 of d-opnd?  \ [A0]
  186:                          IF abs8? IF %1000 ELSE %1100 THEN
  187:                          <M> 1+ C@ $F0 AND OR <M> 1+ C! THEN
  188:                       endof
  189:                 %0111 of d-opnd?  \ [A1]
  190:                          IF abs8? IF %1001 ELSE %1101 THEN
  191:                          <M> 1+ C@ $F0 AND OR <M> 1+ C! THEN
  192:                       endof
  193:              ENDCASE ;
  194: 
  195:  : [SB],     s-opnd?
  196:              IF >abs8? IF %11100000 <M> 1+ C@ $0F AND OR <M> 1+ C! THEN
  197:              ELSE true abort" displacement expected" THEN ;
  198: 
  199:  : ,[SB]     d-opnd?
  200:              IF >abs8? IF %1110 <M> 1+ C@ $F0 AND OR <M> 1+ C! THEN
  201:              ELSE true abort" displacement expected" THEN ;
  202: 
  203:  : [FB],     s-opnd? 0= ABORT" displacement expected" ;
  204: 
  205:  : ,[FB]     d-opnd? 0= ABORT" displacement expected" ;
  206: 
  207:  : abs:16,   s-opnd? 0= ABORT" absolute Adr expected" ;
  208: 
  209:  : ,abs:16   d-opnd? 0= ABORT" absolute Adr expected" ;
  210: 
  211:  : #,        s-opnd? 0= ABORT" operand expected"
  212:              <OPC> 2 + c@ %00000001 and 0= IF <.b> on THEN
  213:              <OPC> 2 + c@ <OPC> c!
  214:              <OPC> 3 + c@ <M> 1+ c@ $0F and or <M> 1+ c! ;
  215: 
  216:  : q#,       s-opnd? 0= ABORT" operand expected"
  217:              s-opnd? d-opnd? and IF swap THEN
  218:              >4B? ABORT" immediate > 4 Bit"
  219:              4 lshift <M> 1+ c@ $0F and or <M> 1+ c! ;
  220: 
  221:  : ctrl,     <M> 1+ C@ %10000000 OR <M> 1+ C! ;
  222: 
  223:  : ,ctrl     <M> 1+ C@ $0F and 4 lshift
  224:              <M> 1+ C@ $F0 and 4 rshift OR %10000000 or <M> 1+ C! ;
  225: \ ----------------------------------------------------------------------------------------------
  226: \ ----------------------------------------------------------------------------------------------
  227:  : GROUP.1B: CREATE C,                 ( opc  -- )
  228:              DOES> c@ X C,
  229:              RESET ;
  230:  %00000100 GROUP.1B: nop
  231:  %11111011 GROUP.1B: reit
  232:  %11110011 GROUP.1B: rts
  233: \ ----------------------------------------------------------------------------------------------
  234:  : GROUP.1B.l8: CREATE C,              ( opc  -- )
  235:              DOES> c@ X C,
  236:              opnd? 0= ABORT" label expected"
  237:              >8B?  ABORT" label > 8 Bit" X C,
  238:              RESET ;
  239:  %01101000 GROUP.1B.l8: JGEU ' JGEU alias JC
  240:  %01101001 GROUP.1B.l8: JGTU
  241:  %01101010 GROUP.1B.l8: JEQ  ' JEQ  alias JZ
  242:  %01101011 GROUP.1B.l8: JN
  243:  %01101100 GROUP.1B.l8: JLTU ' JLTU alias JNC
  244:  %01101101 GROUP.1B.l8: JLEU
  245:  %01101110 GROUP.1B.l8: JNE  ' JNE  alias JNZ
  246:  %01101111 GROUP.1B.l8: JPZ
  247:  %11111110 GROUP.1B.l8: JMP.B
  248: \ ----------------------------------------------------------------------------------------------
  249:  : GROUP.1B.l16: CREATE C,              ( opc  -- )
  250:              DOES> c@ X C,
  251:              opnd? 0= ABORT" label expected"
  252:              X ,
  253:              RESET ;
  254:  %11110100 GROUP.1B.l16: JMP.W
  255: \ ----------------------------------------------------------------------------------------------
  256:  : GROUP.2B: CREATE C, C,           ( opc opc  -- )
  257:              DOES>  dup c@ X C, 1+ c@ X C,
  258:              RESET ;
  259:  %11101001 %01111100 GROUP.2B: smovb.b
  260:  %11101000 %01111100 GROUP.2B: smovf.b
  261:  %11101010 %01111100 GROUP.2B: sstr.b
  262: 
  263:  %11101001 %01111101 GROUP.2B: smovb.w
  264:  %11101000 %01111101 GROUP.2B: smovf.w
  265:  %11101010 %01111101 GROUP.2B: sstr.w
  266: \ ----------------------------------------------------------------------------------------------
  267:  : GROUP.2B.l8: CREATE C, C,         ( opc opc  -- )
  268:              DOES>  dup c@ X C, 1+ c@ X C,
  269:              opnd? 0= ABORT" label expected"
  270:              >8B?  ABORT" label > 8 Bit" X C,
  271:              RESET ;
  272:  %11001000 %01111101 GROUP.2B.l8: JLE
  273:  %11001001 %01111101 GROUP.2B.l8: JO
  274:  %11001010 %01111101 GROUP.2B.l8: JGE
  275:  %11001100 %01111101 GROUP.2B.l8: JGT
  276:  %11001101 %01111101 GROUP.2B.l8: JNO
  277:  %11001110 %01111101 GROUP.2B.l8: JLT
  278: \ ----------------------------------------------------------------------------------------------
  279:  : GROUP.2B.F: CREATE C, C,           ( opc opc  -- )
  280:              DOES>   dup c@ X C, 1+ c@ <M> 1+ C@ $70 and or X C,
  281:              RESET ;
  282:  %00000101 %11101011 GROUP.2B.F: FCLR
  283:  %00000100 %11101011 GROUP.2B.F: FSET
  284: \ ----------------------------------------------------------------------------------------------
  285:  : ctrl,R    opnd? <d-opnd> !
  286:              ctrl,
  287:              >opc OPC, ;
  288: 
  289:  : ctrl,[An] opnd? <d-opnd> !
  290:              ctrl, ,[An]
  291:              >opc OPC,
  292:              d-opnd?
  293:              IF abs8? IF X C, ELSE X , THEN THEN ;
  294: 
  295:  : ctrl,[SB] opnd? <d-opnd> !
  296:              ctrl, ,[SB]
  297:              >opc OPC,
  298:              abs8? IF X C, ELSE X , THEN ;
  299: 
  300:  : ctrl,[FB] opnd? <d-opnd> !
  301:              ctrl, ,[FB]
  302:              >opc OPC,
  303:              >8B? ABORT" displacement > 8 Bit"
  304:              X C, ;
  305: 
  306:  : ctrl,abs:16 opnd? <d-opnd> !
  307:              ctrl, ,abs:16
  308:              >opc OPC,
  309:              X , ;
  310: 
  311:  Table: st-control-reg
  312:         INTBL , R0     ' ctrl,R TAB,        INTBL , R1     ' ctrl,R TAB,
  313:         INTBL , R2     ' ctrl,R TAB,        INTBL , R3     ' ctrl,R TAB,
  314:         INTBL , A0     ' ctrl,R TAB,        INTBL , A1     ' ctrl,R TAB,
  315:         INTBL , [A0]   ' ctrl,[An] TAB,     INTBL , [A1]   ' ctrl,[An] TAB,
  316:         INTBL , [SB]   ' ctrl,[SB] TAB,     INTBL , [FB]   ' ctrl,[FB] TAB,
  317:         INTBL , abs:16 ' ctrl,abs:16 TAB,
  318:         INTBH , R0     ' ctrl,R TAB,        INTBH , R1     ' ctrl,R TAB,
  319:         INTBH , R2     ' ctrl,R TAB,        INTBH , R3     ' ctrl,R TAB,
  320:         INTBH , A0     ' ctrl,R TAB,        INTBH , A1     ' ctrl,R TAB,
  321:         INTBH , [A0]   ' ctrl,[An] TAB,     INTBH , [A1]   ' ctrl,[An] TAB,
  322:         INTBH , [SB]   ' ctrl,[SB] TAB,     INTBH , [FB]   ' ctrl,[FB] TAB,
  323:         INTBL , abs:16 ' ctrl,abs:16 TAB,
  324:         FLG   , R0     ' ctrl,R TAB,        FLG   , R1     ' ctrl,R TAB,
  325:         FLG   , R2     ' ctrl,R TAB,        FLG   , R3     ' ctrl,R TAB,
  326:         FLG   , A0     ' ctrl,R TAB,        FLG   , A1     ' ctrl,R TAB,
  327:         FLG   , [A0]   ' ctrl,[An] TAB,     FLG   , [A1]   ' ctrl,[An] TAB,
  328:         FLG   , [SB]   ' ctrl,[SB] TAB,     FLG   , [FB]   ' ctrl,[FB] TAB,
  329:         FLG   , abs:16 ' ctrl,abs:16 TAB,
  330:         ISP   , R0     ' ctrl,R TAB,        ISP   , R1     ' ctrl,R TAB,
  331:         ISP   , R2     ' ctrl,R TAB,        ISP   , R3     ' ctrl,R TAB,
  332:         ISP   , A0     ' ctrl,R TAB,        ISP   , A1     ' ctrl,R TAB,
  333:         ISP   , [A0]   ' ctrl,[An] TAB,     ISP   , [A1]   ' ctrl,[An] TAB,
  334:         ISP   , [SB]   ' ctrl,[SB] TAB,     ISP   , [FB]   ' ctrl,[FB] TAB,
  335:         ISP   , abs:16 ' ctrl,abs:16 TAB,
  336:         SP    , R0     ' ctrl,R TAB,        SP    , R1     ' ctrl,R TAB,
  337:         SP    , R2     ' ctrl,R TAB,        SP    , R3     ' ctrl,R TAB,
  338:         SP    , A0     ' ctrl,R TAB,        SP    , A1     ' ctrl,R TAB,
  339:         SP    , [A0]   ' ctrl,[An] TAB,     SP    , [A1]   ' ctrl,[An] TAB,
  340:         SP    , [SB]   ' ctrl,[SB] TAB,     SP    , [FB]   ' ctrl,[FB] TAB,
  341:         SP    , abs:16 ' ctrl,abs:16 TAB,
  342:         SB    , R0     ' ctrl,R TAB,        SB    , R1     ' ctrl,R TAB,
  343:         SB    , R2     ' ctrl,R TAB,        SB    , R3     ' ctrl,R TAB,
  344:         SB    , A0     ' ctrl,R TAB,        SB    , A1     ' ctrl,R TAB,
  345:         SB    , [A0]   ' ctrl,[An] TAB,     SB    , [A1]   ' ctrl,[An] TAB,
  346:         SB    , [SB]   ' ctrl,[SB] TAB,     SB    , [FB]   ' ctrl,[FB] TAB,
  347:         SB    , abs:16 ' ctrl,abs:16 TAB,
  348:         FB    , R0     ' ctrl,R TAB,        FB    , R1     ' ctrl,R TAB,
  349:         FB    , R2     ' ctrl,R TAB,        FB    , R3     ' ctrl,R TAB,
  350:         FB    , A0     ' ctrl,R TAB,        FB    , A1     ' ctrl,R TAB,
  351:         FB    , [A0]   ' ctrl,[An] TAB,     FB    , [A1]   ' ctrl,[An] TAB,
  352:         FB    , [SB]   ' ctrl,[SB] TAB,     FB    , [FB]   ' ctrl,[FB] TAB,
  353:         FB    , abs:16 ' ctrl,abs:16 TAB,
  354: 
  355:  ;TABLE
  356: 
  357:  st-control-reg %11111111 %01111011 GROUP2: stc
  358: 
  359: \ ----------------------------------------------------------------------------------------------
  360:  : R,ctrl    ,ctrl
  361:              >opc OPC, ;
  362: 
  363:  : [An],ctrl opnd? <d-opnd> !
  364:              [An], ,ctrl
  365:              >opc OPC,
  366:              s-opnd?
  367:              IF abs8? IF X C, ELSE X , THEN THEN ;
  368: 
  369:  : [SB],ctrl opnd? <d-opnd> !
  370:              [SB], ,ctrl
  371:              >opc OPC,
  372:              abs8? IF X C, ELSE X , THEN ;
  373: 
  374:  : [FB],ctrl opnd? <d-opnd> !
  375:              [FB], ,ctrl
  376:              >opc OPC,
  377:              >8B? ABORT" displacement > 8 Bit"
  378:              X C, ;
  379: 
  380:  : #,ctrl    #, ,ctrl
  381:              <M> 1+ C@ %01110000 and <M> 1+ C!
  382:              >opc OPC,
  383:              X , ;
  384: 
  385:  Table: ld-control-reg
  386:         R0   , INTBL ' R,ctrl TAB,        R0   , INTBH  ' R,ctrl TAB,
  387:         R0   , FLG   ' R,ctrl TAB,        R0   , ISP    ' R,ctrl TAB,
  388:         R0   , SP    ' R,ctrl TAB,        R0   , SB     ' R,ctrl TAB,
  389:         R0   , FB    ' R,ctrl TAB,
  390:         R1   , INTBL ' R,ctrl TAB,        R1   , INTBH  ' R,ctrl TAB,
  391:         R1   , FLG   ' R,ctrl TAB,        R1   , ISP    ' R,ctrl TAB,
  392:         R1   , SP    ' R,ctrl TAB,        R1   , SB     ' R,ctrl TAB,
  393:         R1   , FB    ' R,ctrl TAB,
  394:         R2   , INTBL ' R,ctrl TAB,        R2   , INTBH  ' R,ctrl TAB,
  395:         R2   , FLG   ' R,ctrl TAB,        R2   , ISP    ' R,ctrl TAB,
  396:         R2   , SP    ' R,ctrl TAB,        R2   , SB     ' R,ctrl TAB,
  397:         R2   , FB    ' R,ctrl TAB,
  398:         R3   , INTBL ' R,ctrl TAB,        R3   , INTBH  ' R,ctrl TAB,
  399:         R3   , FLG   ' R,ctrl TAB,        R3   , ISP    ' R,ctrl TAB,
  400:         R3   , SP    ' R,ctrl TAB,        R3   , SB     ' R,ctrl TAB,
  401:         R3   , FB    ' R,ctrl TAB,
  402:         A0   , INTBL ' R,ctrl TAB,        A0   , INTBH  ' R,ctrl TAB,
  403:         A0   , FLG   ' R,ctrl TAB,        A0   , ISP    ' R,ctrl TAB,
  404:         A0   , SP    ' R,ctrl TAB,        A0   , SB     ' R,ctrl TAB,
  405:         A0   , FB    ' R,ctrl TAB,
  406:         A1   , INTBL ' R,ctrl TAB,        A1   , INTBH  ' R,ctrl TAB,
  407:         A1   , FLG   ' R,ctrl TAB,        A1   , ISP    ' R,ctrl TAB,
  408:         A1   , SP    ' R,ctrl TAB,        A1   , SB     ' R,ctrl TAB,
  409:         A1   , FB    ' R,ctrl TAB,
  410:         [A0] , INTBL ' [An],ctrl TAB,   [A0]   , INTBH  ' [An],ctrl TAB,
  411:         [A0] , FLG   ' [An],ctrl TAB,   [A0]   , ISP    ' [An],ctrl TAB,
  412:         [A0] , SP    ' [An],ctrl TAB,   [A0]   , SB     ' [An],ctrl TAB,
  413:         [A0] , FB    ' [An],ctrl TAB,
  414:         [A1] , INTBL ' [An],ctrl TAB,   [A1]   , INTBH  ' [An],ctrl TAB,
  415:         [A1] , FLG   ' [An],ctrl TAB,   [A1]   , ISP    ' [An],ctrl TAB,
  416:         [A1] , SP    ' [An],ctrl TAB,   [A1]   , SB     ' [An],ctrl TAB,
  417:         [A1] , FB    ' [An],ctrl TAB,
  418:         [SB] , INTBL ' [SB],ctrl TAB,   [SB]   , INTBH  ' [SB],ctrl TAB,
  419:         [SB] , FLG   ' [SB],ctrl TAB,   [SB]   , ISP    ' [SB],ctrl TAB,
  420:         [SB] , SP    ' [SB],ctrl TAB,   [SB]   , SB     ' [SB],ctrl TAB,
  421:         [SB] , FB    ' [FB],ctrl TAB,
  422:         [FB] , INTBL ' [FB],ctrl TAB,   [FB]   , INTBH  ' [FB],ctrl TAB,
  423:         [FB] , FLG   ' [FB],ctrl TAB,   [FB]   , ISP    ' [FB],ctrl TAB,
  424:         [FB] , SP    ' [FB],ctrl TAB,   [FB]   , SB     ' [FB],ctrl TAB,
  425:         [FB] , FB    ' [FB],ctrl TAB,
  426:          #   , INTBL ' #,ctrl TAB,        #    , INTBH  ' #,ctrl TAB,
  427:          #   , FLG   ' #,ctrl TAB,        #    , ISP    ' #,ctrl TAB,
  428:          #   , SP    ' #,ctrl TAB,        #    , SB     ' #,ctrl TAB,
  429:          #   , FB    ' #,ctrl TAB,
  430:  ;TABLE
  431: 
  432:  ld-control-reg %00000000 %11101011  %11111111 %01111010 GROUP4: ldc
  433: 
  434: \ ----------------------------------------------------------------------------------------------
  435:  : (R)    <OPC> 1+ c@ <M> 1+ c@ 4 rshift or <M> 1+ c!
  436:           >opc OPC, ;
  437: 
  438: 
  439:  : ([An]) <OPC> 1+ c@ <M> 1+ c@ 4 rshift or <M> 1+ c!
  440:           <M> 1+ C@ $0F AND
  441:           CASE
  442:               %0110 of opnd?  \ [A0]
  443:                        IF abs8? IF %1000 ELSE %1100 THEN
  444:                        <M> 1+ C@ $F0 AND OR <M> 1+ C! THEN
  445:                     endof
  446:               %0111 of opnd?  \ [A1]
  447:                        IF abs8? IF %1001 ELSE %1101 THEN
  448:                        <M> 1+ C@ $F0 AND OR <M> 1+ C! THEN
  449:                     endof
  450:            ENDCASE
  451:            >opc OPC,
  452:            <opc> c@ %01111101 = <opc> 1+ c@ %00101100 = and   \ $12345 [ao] jmpi.w
  453:            <opc> c@ %01111101 = <opc> 1+ c@ %00101101 = and   \ $12345 [a1] jmpi.w
  454:            or
  455:            IF   opnd? IF 8B? IF X C, ELSE ta, THEN THEN
  456:            ELSE opnd? IF 8B? IF X C, ELSE X , THEN THEN THEN ;
  457: 
  458:  : ([SB])  <OPC> 1+ c@ <M> 1+ c@ 4 rshift or <M> 1+ c!
  459:            opnd? <d-opnd> !
  460:            ,[SB]
  461:            >opc OPC,
  462:            8B? IF X C, ELSE X , THEN ;
  463: 
  464:  : ([FB])  <OPC> 1+ c@ <M> 1+ c@ 4 rshift or <M> 1+ c!
  465:            opnd? <d-opnd> !
  466:            ,[FB]
  467:            >opc OPC,
  468:            X C, ;
  469: 
  470:  : (abs:16) <OPC> 1+ c@ <M> 1+ c@ 4 rshift or <M> 1+ c!
  471:            opnd? <d-opnd> !
  472:            ,abs:16
  473:            >opc OPC,
  474:            X , ;
  475: 
  476:  : (#)     opnd? 0= ABORT" operand expected"
  477:            <OPC> 1+ c@ %01000000 =
  478:            IF   <OPC> c@
  479:                 CASE
  480:                     %01110100 OF %01111100 <OPC> c! ENDOF
  481:                     %01110101 OF %01111101 <OPC> c! ENDOF
  482:                 ENDCASE
  483:            ELSE
  484:                 true abort" push.?:g only"
  485:            THEN %11100010 <M> 1+ c!
  486:            >opc OPC,
  487:            8B? IF X C, ELSE X , THEN ;
  488: 
  489:  Table: 2ByteOPC(dsp8/dsp16)          \ 2ByteOPC(dsp8/dsp16)
  490:         R0          ' (R) TAB,        R1     ' (R) TAB,
  491:         R2          ' (R) TAB,        R3     ' (R) TAB,
  492:         A0          ' (R) TAB,        A1     ' (R) TAB,
  493:         [A0]        ' ([An]) TAB,     [A1]   ' ([An]) TAB,
  494:         [SB]        ' ([SB]) TAB,     [FB]   ' ([FB]) TAB,
  495:         abs:16      ' (abs:16) TAB,    #     ' (#) TAB,
  496:  ;TABLE
  497: 
  498:  2ByteOPC(dsp8/dsp16) %11110000 %01110110 GROUP2: abs.b
  499:  2ByteOPC(dsp8/dsp16) %11100000 %01110110 GROUP2: adcf.b
  500:  2ByteOPC(dsp8/dsp16) %11010000 %01110110 GROUP2: div.b
  501:  2ByteOPC(dsp8/dsp16) %11000000 %01110110 GROUP2: divu.b
  502:  2ByteOPC(dsp8/dsp16) %10010000 %01110110 GROUP2: divx.b
  503:  2ByteOPC(dsp8/dsp16) %01010000 %01110100 GROUP2: neg.b
  504:  2ByteOPC(dsp8/dsp16) %01110000 %01110100 GROUP2: not.b:g
  505:  2ByteOPC(dsp8/dsp16) %11010000 %01110100 GROUP2: pop.b:g
  506:  2ByteOPC(dsp8/dsp16) %01000000 %01110100 GROUP2: push.b:g
  507:  2ByteOPC(dsp8/dsp16) %10100000 %01110110 GROUP2: rolc.b
  508:  2ByteOPC(dsp8/dsp16) %10110000 %01110110 GROUP2: rorc.b
  509: 
  510:  2ByteOPC(dsp8/dsp16) %11110000 %01110111 GROUP2: abs.w
  511:  2ByteOPC(dsp8/dsp16) %11100000 %01110111 GROUP2: adcf.w
  512:  2ByteOPC(dsp8/dsp16) %11010000 %01110111 GROUP2: div.w
  513:  2ByteOPC(dsp8/dsp16) %11000000 %01110111 GROUP2: divu.w
  514:  2ByteOPC(dsp8/dsp16) %10010000 %01110111 GROUP2: divx.w
  515:  2ByteOPC(dsp8/dsp16) %01010000 %01110101 GROUP2: neg.w
  516:  2ByteOPC(dsp8/dsp16) %01110000 %01110101 GROUP2: not.w:g
  517:  2ByteOPC(dsp8/dsp16) %11010000 %01110101 GROUP2: pop.w:g
  518:  2ByteOPC(dsp8/dsp16) %01000000 %01110101 GROUP2: push.w:g
  519:  2ByteOPC(dsp8/dsp16) %10100000 %01110111 GROUP2: rolc.w
  520:  2ByteOPC(dsp8/dsp16) %10110000 %01110111 GROUP2: rorc.w
  521: 
  522:  2ByteOPC(dsp8/dsp16) %00100000 %01111101 GROUP2: jmpi.w
  523:  2ByteOPC(dsp8/dsp16) %00000000 %01111101 GROUP2: jmpi.a
  524: 
  525: \ ----------------------------------------------------------------------------------------------
  526:  : q#,R      opnd? <d-opnd> !
  527:              q#,
  528:              >opc OPC, ;
  529: 
  530:  : q#,[an]   opnd? <d-opnd> !
  531:              q#, ,[an]
  532:              >opc OPC,
  533:              d-opnd?
  534:              IF abs8? IF X C, ELSE X , THEN THEN ;
  535: 
  536:  : q#,[sb]   opnd? <d-opnd> !
  537:              q#, ,[sb]
  538:              >opc OPC,
  539:              abs8? IF X C, ELSE X , THEN ;
  540: 
  541:  : q#,[fb]   opnd? <d-opnd> !
  542:              q#, ,[fb]
  543:              >opc OPC,
  544:              X C, ;
  545: 
  546:  : q#,abs:16 opnd? <d-opnd> !
  547:              q#, ,abs:16
  548:              >opc OPC,
  549:              X , ;
  550:  Table: quick
  551:         #   , R0     ' q#,R TAB,        #   , R1     ' q#,R TAB,
  552:         #   , R2     ' q#,R TAB,        #   , R3     ' q#,R TAB,
  553:         #   , A0     ' q#,R TAB,        #   , A1     ' q#,R TAB,
  554:         #   , [A0]   ' q#,[An] TAB,     #   , [A1]   ' q#,[An] TAB,
  555:         #   , [SB]   ' q#,[SB] TAB,     #   , [FB]   ' q#,[FB] TAB,
  556:         #   , abs:16 ' q#,abs:16 TAB,
  557:  ;TABLE
  558: 
  559:  quick %00000000 %11001000 GROUP2: add.b:q
  560:  quick %00000000 %11010000 GROUP2: cmp.b:q
  561:  quick %00000000 %11011000 GROUP2: mov.b:q
  562: 
  563:  quick %00000000 %11001001 GROUP2: add.w:q
  564:  quick %00000000 %11010001 GROUP2: cmp.w:q
  565:  quick %00000000 %11011001 GROUP2: mov.w:q
  566: 
  567: \ ----------------------------------------------------------------------------------------------
  568:  : R,R      >opc OPC, ;
  569: 
  570:  : R,[An]    opnd? <d-opnd> !
  571:              ,[An]
  572:              >opc OPC,
  573:              d-opnd?
  574:              IF abs8? IF X C, ELSE X , THEN THEN ;
  575: 
  576:  : R,[SB]    opnd? <d-opnd> !
  577:              ,[SB]
  578:              >opc OPC,
  579:              abs8? IF X C, ELSE X , THEN ;
  580: 
  581:  : R,[FB]    opnd? <d-opnd> !
  582:              ,[FB]
  583:              >opc OPC,
  584:              >8B? ABORT" displacement > 8 Bit"
  585:              X C, ;
  586: 
  587:  : R,abs:16  opnd? <d-opnd> !
  588:              ,abs:16
  589:              >opc OPC,
  590:              X , ;
  591: \ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  592:  : [An],R    opnd? <d-opnd> !
  593:              [An],
  594:              >opc OPC,
  595:              s-opnd?
  596:              IF abs8? IF X C, ELSE X , THEN THEN ;
  597: 
  598:  : [An],[An] opnd? <d-opnd> !
  599:              [An], ,[An]
  600:              >opc OPC,
  601:              s-opnd? d-opnd? and IF swap THEN
  602:              s-opnd?
  603:              IF abs8? IF X C, ELSE X , THEN THEN
  604:              d-opnd?
  605:              IF abs8? IF X C, ELSE X , THEN THEN ;
  606: 
  607:  : [An],[SB] opnd? <d-opnd> !
  608:              [An], ,[SB]
  609:              >opc OPC,
  610:              s-opnd? d-opnd? and IF swap THEN
  611:              s-opnd?
  612:              IF abs8? IF X C, ELSE X , THEN THEN
  613:              abs8? IF X C, ELSE X , THEN ;
  614: 
  615:  : [An],[FB] opnd? <d-opnd> !
  616:              [An], ,[FB]
  617:              >opc OPC,
  618:              s-opnd? d-opnd? and IF swap THEN
  619:              s-opnd?
  620:              IF abs8? IF X C, ELSE X , THEN THEN
  621:              >8B? ABORT" displacement > 8 Bit"
  622:              X C, ;
  623: 
  624:  : [An],abs:16 opnd? <d-opnd> !
  625:              [An], ,abs:16
  626:              >opc OPC,
  627:              s-opnd? d-opnd? and IF swap THEN
  628:              s-opnd?
  629:              IF abs8? IF X C, ELSE X , THEN THEN
  630:              X , ;
  631: \ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  632:  : [SB],R    opnd? <d-opnd> !
  633:              [SB],
  634:              >opc OPC,
  635:              abs8? IF X C, ELSE X , THEN ;
  636: 
  637:  : [SB],[An] opnd? <d-opnd> !
  638:              [SB], ,[An]
  639:              >opc OPC,
  640:              s-opnd? d-opnd? and IF swap THEN
  641:              abs8? IF X C, ELSE X , THEN
  642:              d-opnd?
  643:              IF abs8? IF X C, ELSE X , THEN THEN ;
  644: 
  645:  : [SB],[SB] opnd? <d-opnd> !
  646:              [SB], ,[SB]
  647:              >opc OPC,
  648:              swap
  649:              abs8? IF X C, ELSE X , THEN
  650:              abs8? IF X C, ELSE X , THEN ;
  651: 
  652:  : [SB],[FB] opnd? <d-opnd> !
  653:              [SB], ,[FB]
  654:              >opc OPC,
  655:              swap
  656:              abs8? IF X C, ELSE X , THEN
  657:              >8B? ABORT" displacement > 8 Bit"
  658:              X C, ;
  659: 
  660:  : [SB],abs:16 opnd? <d-opnd> !
  661:              [SB], ,abs:16
  662:              >opc OPC,
  663:              swap
  664:              abs8? IF X C, ELSE X , THEN
  665:              X , ;
  666: \ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  667:  : [FB],R    opnd? <d-opnd> !
  668:              [FB],
  669:              >opc OPC,
  670:              >8B? ABORT" displacement > 8 Bit"
  671:              X C, ;
  672: 
  673:  : [FB],[An] opnd? <d-opnd> !
  674:              [FB], ,[An]
  675:              >opc OPC,
  676:              s-opnd? d-opnd? and IF swap THEN
  677:              >8B? ABORT" displacement > 8 Bit"
  678:              X C, 
  679:              d-opnd?
  680:              IF abs8? IF X C, ELSE X , THEN THEN ;
  681: 
  682:  : [FB],[SB] opnd? <d-opnd> !
  683:              [FB], ,[SB]
  684:              >opc OPC,
  685:              swap
  686:              >8B? ABORT" displacement > 8 Bit"
  687:              X C, 
  688:              abs8? IF X C, ELSE X , THEN ;
  689: 
  690:  : [FB],[FB] opnd? <d-opnd> !
  691:              [FB], ,[FB]
  692:              >opc OPC,
  693:              swap
  694:              >8B? ABORT" displacement > 8 Bit"
  695:              X C, 
  696:              d-opnd?
  697:              IF 8B?   IF X C, ELSE X , THEN THEN ;
  698: 
  699:  : [FB],abs:16 opnd? <d-opnd> !
  700:              [FB], ,abs:16
  701:              >opc OPC,
  702:              swap
  703:              >8B? ABORT" displacement > 8 Bit"
  704:              X C,
  705:              X , ;
  706: \ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  707:  : abs:16,R  opnd? <d-opnd> !
  708:              abs:16,
  709:              >opc OPC,
  710:              X , ;
  711: 
  712:  : abs:16,[An] opnd? <d-opnd> !
  713:              abs:16, ,[An]
  714:              >opc OPC,
  715:              s-opnd? d-opnd? and IF swap THEN
  716:              X ,
  717:              d-opnd?
  718:              IF abs8? IF X C, ELSE X , THEN THEN ;
  719: 
  720:  : abs:16,[SB] opnd? <d-opnd> !
  721:              abs:16, ,[SB]
  722:              >opc OPC,
  723:              swap
  724:              X ,
  725:              abs8? IF X C, ELSE X , THEN ;
  726: 
  727:  : abs:16,[FB] opnd? <d-opnd> !
  728:              abs:16, ,[FB]
  729:              >opc OPC,
  730:              swap
  731:              X ,
  732:              >8B? ABORT" displacement > 8 Bit"
  733:              X C, ;
  734: 
  735:  : abs:16,abs:16 opnd? <d-opnd> !
  736:              abs:16, ,abs:16
  737:              >opc OPC,
  738:              swap
  739:              X ,
  740:              X , ;
  741: \ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  742:  : #,R       opnd? <d-opnd> !
  743:              #,
  744:              >opc OPC,
  745:              <.b> @ IF X C, ELSE X , THEN ;
  746: 
  747:  : #,[An]    opnd? <d-opnd> !
  748:              #, ,[An]
  749:              >opc OPC,
  750:              d-opnd?
  751:              IF abs8? IF X C, ELSE X , THEN THEN
  752:              <.b> @ IF X C, ELSE X , THEN ;
  753: 
  754:  : #,[SB]    opnd? <d-opnd> !
  755:              #, ,[SB]
  756:              >opc OPC,
  757:              abs8? IF X C, ELSE X , THEN
  758:              <.b> @ IF X C, ELSE X , THEN ;
  759: 
  760:  : #,[FB]    opnd? <d-opnd> !
  761:              #, ,[FB]
  762:              >opc OPC,
  763:              >8B? ABORT" displacement > 8 Bit"
  764:              X C, 
  765:              <.b> @ IF X C, ELSE X , THEN ;
  766: 
  767:  : #,abs:16  opnd? <d-opnd> !
  768:              #, ,abs:16
  769:              >opc OPC,
  770:              X ,
  771:              <.b> @ IF X C, ELSE X , THEN ;
  772: \ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  773:  Table: generic
  774:         R0   , R0     ' R,R TAB,        R0   , R1     ' R,R TAB,
  775:         R0   , R2     ' R,R TAB,        R0   , R3     ' R,R TAB,
  776:         R0   , A0     ' R,R TAB,        R0   , A1     ' R,R TAB,
  777:         R0   , [A0]   ' R,[An] TAB,     R0   , [A1]   ' R,[An] TAB,
  778:         R0   , [SB]   ' R,[SB] TAB,     R0   , [FB]   ' R,[FB] TAB,
  779:         R0   , abs:16 ' R,abs:16 TAB,
  780: 
  781:         R1   , R0     ' R,R TAB,        R1   , R1     ' R,R TAB,
  782:         R1   , R2     ' R,R TAB,        R1   , R3     ' R,R TAB,
  783:         R1   , A0     ' R,R TAB,        R1   , A1     ' R,R TAB,
  784:         R1   , [A0]   ' R,[An] TAB,     R1   , [A1]   ' R,[An] TAB,
  785:         R1   , [SB]   ' R,[SB] TAB,     R1   , [FB]   ' R,[FB] TAB,
  786:         R1   , abs:16 ' R,abs:16 TAB,
  787: 
  788:         R2   , R0     ' R,R TAB,        R2   , R1     ' R,R TAB,
  789:         R2   , R2     ' R,R TAB,        R2   , R3     ' R,R TAB,
  790:         R2   , A0     ' R,R TAB,        R2   , A1     ' R,R TAB,
  791:         R2   , [A0]   ' R,[An] TAB,     R2   , [A1]   ' R,[An] TAB,
  792:         R2   , [SB]   ' R,[SB] TAB,     R2   , [FB]   ' R,[FB] TAB,
  793:         R2   , abs:16 ' R,abs:16 TAB,
  794: 
  795:         R3   , R0     ' R,R TAB,        R3   , R1     ' R,R TAB,
  796:         R3   , R2     ' R,R TAB,        R3   , R3     ' R,R TAB,
  797:         R3   , A0     ' R,R TAB,        R3   , A1     ' R,R TAB,
  798:         R3   , [A0]   ' R,[An] TAB,     R3   , [A1]   ' R,[An] TAB,
  799:         R3   , [SB]   ' R,[SB] TAB,     R3   , [FB]   ' R,[FB] TAB,
  800:         R3   , abs:16 ' R,abs:16 TAB,
  801: 
  802:         A0   , R0     ' R,R TAB,        A0   , R1     ' R,R TAB,
  803:         A0   , R2     ' R,R TAB,        A0   , R3     ' R,R TAB,
  804:         A0   , A0     ' R,R TAB,        A0   , A1     ' R,R TAB,
  805:         A0   , [A0]   ' R,[An] TAB,     A0   , [A1]   ' R,[An] TAB,
  806:         A0   , [SB]   ' R,[SB] TAB,     A0   , [FB]   ' R,[FB] TAB,
  807:         A0   , abs:16 ' R,abs:16 TAB,
  808: 
  809:         A1   , R0     ' R,R TAB,        A1   , R1     ' R,R TAB,
  810:         A1   , R2     ' R,R TAB,        A1   , R3     ' R,R TAB,
  811:         A1   , A0     ' R,R TAB,        A1   , A1     ' R,R TAB,
  812:         A1   , [A0]   ' R,[An] TAB,     A1   , [A1]   ' R,[An] TAB,
  813:         A1   , [SB]   ' R,[SB] TAB,     A1   , [FB]   ' R,[FB] TAB,
  814:         A1   , abs:16 ' R,abs:16 TAB,
  815: 
  816:         [A0] , R0     ' [An],R  TAB,      [A0] , R1     ' [An],R  TAB,
  817:         [A0] , R2     ' [An],R  TAB,      [A0] , R3     ' [An],R  TAB,
  818:         [A0] , A0     ' [An],R  TAB,      [A0] , A1     ' [An],R  TAB,
  819:         [A0] , [A0]   ' [An],[An] TAB,    [A0] , [A1]   ' [An],[An] TAB,
  820:         [A0] , [SB]   ' [An],[SB] TAB,    [A0] , [FB]   ' [An],[FB] TAB,
  821:         [A0] , abs:16 ' [An],abs:16 TAB,
  822: 
  823:         [A1] , R0     ' [An],R  TAB,      [A1] , R1     ' [An],R  TAB,
  824:         [A1] , R2     ' [An],R  TAB,      [A1] , R3     ' [An],R  TAB,
  825:         [A1] , A0     ' [An],R  TAB,      [A1] , A1     ' [An],R  TAB,
  826:         [A1] , [A0]   ' [An],[An] TAB,    [A1] , [A1]   ' [An],[An] TAB,
  827:         [A1] , [SB]   ' [An],[SB] TAB,    [A1] , [FB]   ' [An],[FB] TAB,
  828:         [A1] , abs:16 ' [An],abs:16 TAB,
  829: 
  830:         [SB] , R0     ' [SB],R TAB,       [SB] , R1     ' [SB],R TAB,
  831:         [SB] , R2     ' [SB],R TAB,       [SB] , R3     ' [SB],R TAB,
  832:         [SB] , A0     ' [SB],R TAB,       [SB] , A1     ' [SB],R TAB,
  833:         [SB] , [A0]   ' [SB],[An] TAB,    [SB] , [A1]   ' [SB],[An] TAB,
  834:         [SB] , [SB]   ' [SB],[SB] TAB,    [SB] , [FB]   ' [SB],[FB] TAB,
  835:         [SB] , abs:16 ' [SB],abs:16 TAB,
  836: 
  837:         [FB] , R0     ' [FB],R TAB,       [FB] , R1     ' [FB],R TAB,
  838:         [FB] , R2     ' [FB],R TAB,       [FB] , R3     ' [FB],R TAB,
  839:         [FB] , A0     ' [FB],R TAB,       [FB] , A1     ' [FB],R TAB,
  840:         [FB] , [A0]   ' [FB],[An] TAB,    [FB] , [A1]   ' [FB],[An] TAB,
  841:         [FB] , [SB]   ' [FB],[SB] TAB,    [FB] , [FB]   ' [FB],[FB] TAB,
  842:         [FB] , abs:16 ' [FB],abs:16 TAB,
  843: 
  844:          #   , R0     '  #,R TAB,          #   , R1     ' #,R TAB,
  845:          #   , R2     '  #,R TAB,          #   , R3     ' #,R TAB,
  846:          #   , A0     '  #,R TAB,          #   , A1     ' #,R TAB,
  847:          #   , [A0]   '  #,[An] TAB,       #   , [A1]   ' #,[An] TAB,
  848:          #   , [SB]   '  #,[SB] TAB,       #   , [FB]   ' #,[FB] TAB,
  849:          #   , abs:16 '  #,abs:16 TAB,
  850: 
  851:       abs:16 , R0     ' abs:16,R TAB,      abs:16 , R1   ' abs:16,R TAB,
  852:       abs:16 , R2     ' abs:16,R TAB,      abs:16 , R3   ' abs:16,R TAB,
  853:       abs:16 , A0     ' abs:16,R TAB,      abs:16 , A1   ' abs:16,R TAB,
  854:       abs:16 , [A0]   ' abs:16,[An] TAB,   abs:16 , [A1] ' abs:16,[An] TAB,
  855:       abs:16 , [SB]   ' abs:16,[SB] TAB,   abs:16 , [FB] ' abs:16,[FB] TAB,
  856:       abs:16 , abs:16 ' abs:16,abs:16 TAB,
  857:  ;TABLE
  858: 
  859:  generic %01100000 %01110110  %11111111 %10110000 GROUP4: adc.b
  860:  generic %01000000 %01110110  %11111111 %10100000 GROUP4: add.b:g
  861:  generic %00100000 %01110110  %11111111 %10010000 GROUP4: and.b:g
  862:  generic %10000000 %01110110  %11111111 %11000000 GROUP4: cmp.b:g
  863:  generic %11000000 %01110100  %11111111 %01110010 GROUP4: mov.b:g
  864:  generic %01010000 %01111100  %11111111 %01111000 GROUP4: mul.b:g
  865:  generic %01000000 %01111100  %11111111 %01110000 GROUP4: mulu.b:g
  866:  generic %00110000 %01110110  %11111111 %10011000 GROUP4: or.b:g
  867:  generic %01110000 %01110110  %11111111 %10111000 GROUP4: sbb.b
  868:  generic %01010000 %01110110  %11111111 %10101000 GROUP4: sub.b:g
  869:  generic %00000000 %01110110  %11111111 %10000000 GROUP4: tst.b
  870:  generic %00010000 %01110110  %11111111 %10001000 GROUP4: xor.b
  871: 
  872:  generic %01100000 %01110111  %11111111 %10110001 GROUP4: adc.w
  873:  generic %01000000 %01110111  %11111111 %10100001 GROUP4: add.w:g
  874:  generic %00100000 %01110111  %11111111 %10010001 GROUP4: and.w:g
  875:  generic %10000000 %01110111  %11111111 %11000001 GROUP4: cmp.w:g
  876:  generic %11000000 %01110101  %11111111 %01110011 GROUP4: mov.w:g
  877:  generic %01010000 %01111101  %11111111 %01111001 GROUP4: mul.w:g
  878:  generic %01000000 %01111101  %11111111 %01110001 GROUP4: mulu.w:g
  879:  generic %00110000 %01110111  %11111111 %10011001 GROUP4: or.w:g
  880:  generic %01110000 %01110111  %11111111 %10111001 GROUP4: sbb.w
  881:  generic %01010000 %01110111  %11111111 %10101001 GROUP4: sub.w:g
  882:  generic %00000000 %01110111  %11111111 %10000001 GROUP4: tst.w
  883:  generic %00010000 %01110111  %11111111 %10001001 GROUP4: xor.w
  884: 
  885: \ ----------------------------------------------------------------------------------------------
  886:  : r1h,      <OPC> 1 + c@ $F0 and <M> 1+ c@ $0F and or <M> 1+ c! ;
  887: 
  888:  : R1H,R      r1h, r,r ;
  889: 
  890:  : R1H,[An]   r1h, r,[An] ;
  891: 
  892:  : R1H,[SB]   r1h, r,[SB] ;
  893: 
  894:  : R1H,[FB]   r1h, r,[FB] ;
  895: 
  896:  : R1H,abs:16 r1h, r,abs:16 ;
  897: 
  898: \ ----------------------------------------------------------------------------------------------
  899:  : rot#        CASE
  900:                  1 of $00 endof
  901:                  2 of $10 endof
  902:                  3 of $20 endof
  903:                  4 of $30 endof
  904:                  5 of $40 endof
  905:                  6 of $50 endof
  906:                  7 of $60 endof
  907:                  8 of $70 endof
  908:                 -1 of $80 endof
  909:                 -2 of $90 endof
  910:                 -3 of $A0 endof
  911:                 -4 of $B0 endof
  912:                 -5 of $C0 endof
  913:                 -6 of $D0 endof
  914:                 -7 of $E0 endof
  915:                 -8 of $F0 endof
  916:                 abort
  917:                ENDCASE ;
  918: 
  919:  : rot#,       s-opnd? 0= ABORT" operand expected"
  920:                <OPC> 2 + c@ <OPC> c!
  921:                s-opnd? d-opnd? and IF swap THEN
  922:                rot# <M> 1+ c@ $0F and or <M> 1+ c! ;
  923: 
  924:  : rot#,R      rot#,
  925:                >opc OPC, ;
  926: 
  927:  : rot#,[An]   opnd? <d-opnd> !
  928:                rot#, ,[An]
  929:                >opc OPC,
  930:                d-opnd?
  931:                IF abs8? IF X C, ELSE X , THEN THEN ;
  932: 
  933:  : rot#,[SB]   opnd? <d-opnd> !
  934:                rot#, ,[SB]
  935:                >opc OPC,
  936:                abs8? IF X C, ELSE X , THEN ;
  937: 
  938:  : rot#,[FB]   opnd? <d-opnd> !
  939:                rot#, ,[FB]
  940:                >opc OPC,
  941:                >8B? ABORT" displacement > 8 Bit"
  942:                X C, ;
  943: 
  944:  : rot#,abs:16 opnd? <d-opnd> !
  945:                rot#, ,abs:16
  946:                >opc OPC,
  947:                X , ;
  948: 
  949:  Table: rot-group
  950:          R1H , R0L    '  R1H,R TAB,          R1H , R0H    ' R1H,R TAB,
  951:          R1H , R1L    '  R1H,R TAB,          R1H , R3     ' R1H,R TAB,
  952:          R1H , A0     '  R1H,R TAB,          R1H , A1     ' R1H,R TAB,
  953:          R1H , [A0]   '  R1H,[An] TAB,       R1H , [A1]   ' R1H,[An] TAB,
  954:          R1H , [SB]   '  R1H,[SB] TAB,       R1H , [FB]   ' R1H,[FB] TAB,
  955:          R1H , abs:16 '  R1H,abs:16 TAB,
  956:            # , R0L    ' rot#,R TAB,            # , R0H    ' rot#,R TAB,
  957:            # , R1L    ' rot#,R TAB,            # , R3     ' rot#,R TAB,
  958:            # , A0     ' rot#,R TAB,            # , A1     ' rot#,R TAB,
  959:            # , [A0]   ' rot#,[An] TAB,         # , [A1]   ' rot#,[An] TAB,
  960:            # , [SB]   ' rot#,[SB] TAB,         # , [FB]   ' rot#,[FB] TAB,
  961:            # , abs:16 ' rot#,abs:16 TAB,
  962:  ;TABLE
  963: 
  964:  rot-group %00001111 %11100001 %01101111 %01110101 GROUP4: rot.w
  965:  rot-group %00001111 %11101001 %11101111 %01110101 GROUP4: shl.w
  966:  rot-group %00001111 %11110001 %11111111 %01110101 GROUP4: sha.w
  967: 
  968:  rot-group %00001111 %11100000 %01101111 %01110100 GROUP4: rot.b
  969:  rot-group %00001111 %11101000 %11101111 %01110100 GROUP4: shl.b
  970:  rot-group %00001111 %11110000 %11111111 %01110100 GROUP4: sha.b
  971: 
  972: \ ----------------------------------------------------------------------------------------------
  973:  ' noop alias bit
  974: 
  975:  : bit,      s-opnd? 0= ABORT" operand expected"
  976:              <OPC> 1+ C@ $F0 AND <M> 1+ c@ $0F AND OR <M> 1+ c! ;
  977: 
  978:  : bit,R      bit,
  979:               >opc OPC,
  980:               %00000111 and
  981:               X c, ;
  982: 
  983:  : bit[An]    <OPC> 1+ c@ $F0 AND <M> 1+ c@ 4 rshift or <M> 1+ c!
  984:               <M> 1+ C@ $0F AND
  985:               CASE
  986:               %0110 of opnd?  \ [A0]
  987:                        IF abs8? IF %1000 ELSE %1100 THEN
  988:                        <M> 1+ C@ $F0 AND OR <M> 1+ C! THEN
  989:                     endof
  990:               %0111 of opnd?  \ [A1]
  991:                        IF abs8? IF %1001 ELSE %1101 THEN
  992:                        <M> 1+ C@ $F0 AND OR <M> 1+ C! THEN
  993:                     endof
  994:               ENDCASE
  995:               >opc OPC,
  996:               opnd?
  997:               IF abs8? IF X C, ELSE X , THEN THEN ;
  998: 
  999:  : bit,[SB]   opnd? <d-opnd> !
 1000:               bit, ,[SB]
 1001:               3 lshift swap %00000111 and or
 1002:               >abs8? IF %1110 <M> 1+ C@ $F0 AND OR <M> 1+ C! THEN
 1003:               >opc OPC,
 1004:               abs8? IF X C, ELSE X , THEN ;
 1005: 
 1006:  : bit,[FB]   opnd? <d-opnd> !
 1007:               bit, ,[FB]
 1008:               >opc OPC,
 1009:               3 lshift swap %00000111 and or
 1010:               >8B? ABORT" displacement > 8 Bit"
 1011:               X C, ;
 1012: 
 1013:  : bit,abs:16 opnd? <d-opnd> !
 1014:               bit, ,abs:16
 1015:               >opc OPC,
 1016:               3 lshift swap %00000111 and or
 1017:               X , ;
 1018: 
 1019:  Table: bit-group
 1020:          bit , R0     '  bit,R TAB,          bit , R1     ' bit,R TAB,
 1021:          bit , R2     '  bit,R TAB,          bit , R3     ' bit,R TAB,
 1022:          bit , A0     '  bit,R TAB,          bit , A1     ' bit,R TAB,
 1023:                [A0]   '   bit[An] TAB,             [A1]   '  bit[An] TAB,
 1024:          bit , [SB]   '  bit,[SB] TAB,       bit , [FB]   ' bit,[FB] TAB,
 1025:          bit , abs:16 '  bit,abs:16 TAB,
 1026:  ;TABLE
 1027: 
 1028:  bit-group %01001111 %01111110 GROUP2: band
 1029:  bit-group %10001111 %01111110 GROUP2: bclr:g
 1030:  bit-group %01011111 %01111110 GROUP2: bnand
 1031:  bit-group %01111111 %01111110 GROUP2: bnor
 1032:  bit-group %10101111 %01111110 GROUP2: bnot:g
 1033:  bit-group %00111111 %01111110 GROUP2: bntst
 1034:  bit-group %11011111 %01111110 GROUP2: bnxor
 1035:  bit-group %01101111 %01111110 GROUP2: bor
 1036:  bit-group %10011111 %01111110 GROUP2: bset:g
 1037:  bit-group %10111111 %01111110 GROUP2: btst:g
 1038:  bit-group %00001111 %01111110 GROUP2: btstc
 1039:  bit-group %00011111 %01111110 GROUP2: btsts
 1040:  bit-group %11001111 %01111110 GROUP2: bxor
 1041: \ ----------------------------------------------------------------------------------------------
 1042: \ register definition
 1043:   ' R2 Alias rp
 1044:   ' R0 Alias tos
 1045:   ' A1 Alias ip
 1046:   ' A0 Alias w
 1047:   ' [A1] Alias [ip]
 1048:   ' [A0] Alias [w]
 1049: \ ----------------------------------------------------------------------------------------------
 1050: 
 1051: : IF,     dup $FF u> IF  dup 8 rshift X c,  THEN  X c, ;
 1052: 	  
 1053: 	  $68 Constant u<
 1054: 	  $69 Constant u<=
 1055: 	  $6A Constant 0<>
 1056: 	  $6B Constant 0>=
 1057: 	  $6C Constant u>=
 1058: 	  $6D Constant u>
 1059: 	  $6E Constant 0=
 1060: 	  $6F Constant 0<
 1061: 	  $7DC8 Constant >
 1062: 	  $7DC9 Constant no
 1063: 	  $7DCA Constant <
 1064: 	  $7DCC Constant <=
 1065: 	  $7DCD Constant o
 1066: 	  $7DCE Constant >=
 1067: 
 1068: : IF          IF, X here  0 X c, reset ;
 1069: : THEN        X here  over - swap X c! reset  ;
 1070: : AHEAD       $FE IF ;
 1071: : ELSE        AHEAD swap THEN reset ;
 1072: : WHILE       IF swap reset ;
 1073: : BEGIN       X here reset ;
 1074: : UNTIL       IF, X here -  X c, reset ;
 1075: : AGAIN       $FE UNTIL reset ;
 1076: : REPEAT      AGAIN THEN reset ;
 1077: 
 1078: 	 
 1079: \ include asm-test.fs
 1080: 
 1081:  HERE  SWAP -
 1082:  CR .( Length of Assembler: ) . .( Bytes ) CR
 1083: 
 1084: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>