Subversion Repositories pentevo

Rev

Blame | Last modification | View Log | Download | RSS feed | ?url?

  1. /* tipseudo.c */
  2. /*****************************************************************************/
  3. /* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only                     */
  4. /*                                                                           */
  5. /* AS                                                                        */
  6. /*                                                                           */
  7. /* Commonly Used TI-Style Pseudo Instructions-Befehle                        */
  8. /*                                                                           */
  9. /*****************************************************************************/
  10.  
  11. /*****************************************************************************
  12.  * Includes
  13.  *****************************************************************************/
  14.  
  15. #include "stdinc.h"
  16. #include <ctype.h>
  17. #include <string.h>
  18. #include <math.h>
  19.  
  20. #include "strutil.h"
  21. #include "be_le.h"
  22. #include "tifloat.h"
  23. #include "as_float.h"
  24. #include "ieeefloat.h"
  25. #include "asmdef.h"
  26. #include "asmsub.h"
  27. #include "asmpars.h"
  28. #include "asmitree.h"
  29. #include "onoff_common.h"
  30. #include "errmsg.h"
  31. #include "chartrans.h"
  32.  
  33. #include "codepseudo.h"
  34. #include "fourpseudo.h"
  35. #include "tipseudo.h"
  36.  
  37. #define LEAVE goto func_exit
  38.  
  39. /*****************************************************************************
  40.  * Local Functions
  41.  *****************************************************************************/
  42.  
  43. static void define_untyped_label(void)
  44. {
  45.   if (LabPart.str.p_str[0])
  46.   {
  47.     PushLocHandle(-1);
  48.     EnterIntSymbol(&LabPart, EProgCounter(), SegNone, False);
  49.     PopLocHandle();
  50.   }
  51. }
  52.  
  53. static void pseudo_qxx(Integer num)
  54. {
  55.   tStrComp *pArg;
  56.   Boolean ok = True;
  57.   as_float_t res;
  58.  
  59.   if (!ChkArgCnt(1, ArgCntMax))
  60.     return;
  61.  
  62.   forallargs (pArg, True)
  63.   {
  64.     if (!*pArg->str.p_str)
  65.     {
  66.       ok = False;
  67.       break;
  68.     }
  69.  
  70.     res = as_ldexp(EvalStrFloatExpression(pArg, &ok), num);
  71.     if (!ok)
  72.       break;
  73.  
  74.     if ((res > 32767.49) || (res < -32768.49))
  75.     {
  76.       ok = False;
  77.       WrError(ErrNum_OverRange);
  78.       break;
  79.     }
  80.     WAsmCode[CodeLen++] = res;
  81.   }
  82.  
  83.   if (!ok)
  84.     CodeLen = 0;
  85. }
  86.  
  87. static void pseudo_lqxx(Integer num)
  88. {
  89.   tStrComp *pArg;
  90.   Boolean ok = True;
  91.   as_float_t res;
  92.   LongInt resli;
  93.  
  94.   if (!ChkArgCnt(1, ArgCntMax))
  95.     return;
  96.  
  97.   forallargs (pArg, True)
  98.   {
  99.     if (!*pArg->str.p_str)
  100.     {
  101.       ok = False;
  102.       break;
  103.     }
  104.  
  105.     res = as_ldexp(EvalStrFloatExpression(pArg, &ok), num);
  106.     if (!ok)
  107.       break;
  108.  
  109.     if ((res > 2147483647.49) || (res < -2147483647.49))
  110.     {
  111.       ok = False;
  112.       WrError(ErrNum_OverRange);
  113.       break;
  114.     }
  115.     resli = res;
  116.     WAsmCode[CodeLen++] = resli & 0xffff;
  117.     WAsmCode[CodeLen++] = resli >> 16;
  118.   }
  119.  
  120.   if (!ok)
  121.     CodeLen = 0;
  122. }
  123.  
  124. typedef void (*tcallback)(
  125. #ifdef __PROTOS__
  126. Boolean *, int *, LargeInt, tSymbolFlags
  127. #endif
  128. );
  129.  
  130. static void pseudo_store(tcallback callback, Word MaxMultCharLen)
  131. {
  132.   Boolean ok = True;
  133.   int adr = 0;
  134.   tStrComp *pArg;
  135.   TempResult t;
  136.  
  137.   as_tempres_ini(&t);
  138.  
  139.   if (!ChkArgCnt(1, ArgCntMax))
  140.     LEAVE;
  141.  
  142.   define_untyped_label();
  143.  
  144.   forallargs (pArg, ok)
  145.   {
  146.     if (!*pArg->str.p_str)
  147.     {
  148.       ok = False;
  149.       break;
  150.     }
  151.  
  152.     EvalStrExpression(pArg, &t);
  153.     switch (t.Typ)
  154.     {
  155.       case TempFloat:
  156.         WrStrErrorPos(ErrNum_StringOrIntButFloat, pArg);
  157.         LEAVE;
  158.       case TempString:
  159.       {
  160.         unsigned char *cp, *cend;
  161.  
  162.         if (MultiCharToInt(&t, MaxMultCharLen))
  163.           goto ToInt;
  164.  
  165.         if (as_chartrans_xlate_nonz_dynstr(CurrTransTable->p_table, &t.Contents.str, pArg))
  166.           ok = False;
  167.         else
  168.         {
  169.           cp = (unsigned char *)t.Contents.str.p_str;
  170.           cend = cp + t.Contents.str.len;
  171.           while (cp < cend)
  172.             callback(&ok, &adr, *cp++ & 0xff, t.Flags);
  173.         }
  174.         break;
  175.       }
  176.       case TempInt:
  177.       ToInt:
  178.         callback(&ok, &adr, t.Contents.Int, t.Flags);
  179.         break;
  180.       default:
  181.         ok = False;
  182.         break;
  183.     }
  184.     if (!ok)
  185.       break;
  186.   }
  187.  
  188.   if (!ok)
  189.     CodeLen = 0;
  190.  
  191. func_exit:
  192.   as_tempres_free(&t);
  193. }
  194.  
  195. static void wr_code_byte(Boolean *ok, int *adr, LargeInt val, tSymbolFlags Flags)
  196. {
  197.   if (!mFirstPassUnknownOrQuestionable(Flags) && !RangeCheck(val, Int8))
  198.   {
  199.     WrError(ErrNum_OverRange);
  200.     *ok = False;
  201.     return;
  202.   }
  203.   WAsmCode[(*adr)++] = val & 0xff;
  204.   CodeLen = *adr;
  205. }
  206.  
  207. static void wr_code_word(Boolean *ok, int *adr, LargeInt val, tSymbolFlags Flags)
  208. {
  209.   if (!mFirstPassUnknownOrQuestionable(Flags) && !RangeCheck(val, Int16))
  210.   {
  211.     WrError(ErrNum_OverRange);
  212.     *ok = False;
  213.     return;
  214.   }
  215.   WAsmCode[(*adr)++] = val;
  216.   CodeLen = *adr;
  217. }
  218.  
  219. static void wr_code_long(Boolean *ok, int *adr, LargeInt val, tSymbolFlags Flags)
  220. {
  221.   if (!mFirstPassUnknownOrQuestionable(Flags) && !RangeCheck(val, Int32))
  222.   {
  223.     WrError(ErrNum_OverRange);
  224.     *ok = False;
  225.     return;
  226.   }
  227.   WAsmCode[(*adr)++] = val & 0xffff;
  228.   WAsmCode[(*adr)++] = val >> 16;
  229.   CodeLen = *adr;
  230. }
  231.  
  232. static void wr_code_byte_hilo(Boolean *ok, int *adr, LargeInt val, tSymbolFlags Flags)
  233. {
  234.   if (!mFirstPassUnknownOrQuestionable(Flags) && !RangeCheck(val, Int8))
  235.   {
  236.     WrError(ErrNum_OverRange);
  237.     *ok = False;
  238.     return;
  239.   }
  240.   if ((*adr) & 1)
  241.     WAsmCode[((*adr)++) / 2] |= val & 0xff;
  242.   else
  243.     WAsmCode[((*adr)++) / 2] = val << 8;
  244.   CodeLen = ((*adr) + 1) / 2;
  245. }
  246.  
  247. static void wr_code_byte_lohi(Boolean *ok, int *adr, LargeInt val, tSymbolFlags Flags)
  248. {
  249.   if (!mFirstPassUnknownOrQuestionable(Flags) && !RangeCheck(val, Int8))
  250.   {
  251.     WrError(ErrNum_OverRange);
  252.     *ok = False;
  253.     return;
  254.   }
  255.   if ((*adr) & 1)
  256.     WAsmCode[((*adr)++) / 2] |= val << 8;
  257.   else
  258.     WAsmCode[((*adr)++) / 2] = val & 0xff;
  259.   CodeLen = ((*adr) + 1) / 2;
  260. }
  261.  
  262. /*!------------------------------------------------------------------------
  263.  * \fn     DecodeFLOAT(Word Code)
  264.  * \brief  decode FLOAT instruction
  265.  * ------------------------------------------------------------------------ */
  266.  
  267. static void DecodeFLOAT(Word Code)
  268. {
  269.   Boolean ok;
  270.   int ret;
  271.   as_float_t fval;
  272.   tStrComp *pArg;
  273.   Byte Dest[4];
  274.  
  275.   UNUSED(Code);
  276.  
  277.   if (!ChkArgCnt(1, ArgCntMax))
  278.     return;
  279.   define_untyped_label();
  280.   ok = True;
  281.   if (SetMaxCodeLen(ArgCnt * 4))
  282.     return;
  283.   forallargs (pArg, ok)
  284.   {
  285.     if (!*pArg->str.p_str)
  286.     {
  287.       ok = False;
  288.       break;
  289.     }
  290.     fval = EvalStrFloatExpression(pArg, &ok);
  291.     if (!ok)
  292.       break;
  293.     if ((ret = as_float_2_ieee4(fval, Dest, False)) < 0)
  294.     {
  295.       asmerr_check_fp_dispose_result(ret, pArg);
  296.       ok = False;
  297.       break;
  298.     }
  299.     WAsmCode[CodeLen++] = (Word)Dest[0] | ((Word)Dest[1]) << 8;
  300.     WAsmCode[CodeLen++] = (Word)Dest[2] | ((Word)Dest[3]) << 8;
  301.   }
  302.   if (!ok)
  303.     CodeLen = 0;
  304. }
  305.  
  306. /*!------------------------------------------------------------------------
  307.  * \fn     DecodeDOUBLE(Word Code)
  308.  * \brief  decode DOUBLE instruction
  309.  * ------------------------------------------------------------------------ */
  310.  
  311. static void DecodeDOUBLE(Word Code)
  312. {
  313.   Boolean ok;
  314.   int ret;
  315.   as_float_t fval;
  316.   tStrComp *pArg;
  317.   Byte Dest[8];
  318.  
  319.   UNUSED(Code);
  320.  
  321.   if (!ChkArgCnt(1, ArgCntMax))
  322.     return;
  323.   define_untyped_label();
  324.   ok = True;
  325.   if (SetMaxCodeLen(ArgCnt * 8))
  326.     return;
  327.   forallargs (pArg, ok)
  328.   {
  329.     if (!*pArg->str.p_str)
  330.     {
  331.       ok = False;
  332.       break;
  333.     }
  334.     fval = EvalStrFloatExpression(pArg, &ok);
  335.     if (!ok)
  336.       break;
  337.     if ((ret = as_float_2_ieee8(fval, Dest, False)) < 0)
  338.     {
  339.       asmerr_check_fp_dispose_result(ret, pArg);;
  340.       ok = False;
  341.       break;
  342.     }
  343.     WAsmCode[CodeLen++] = (Word)Dest[0] | ((Word)Dest[1]) << 8;
  344.     WAsmCode[CodeLen++] = (Word)Dest[2] | ((Word)Dest[3]) << 8;
  345.     WAsmCode[CodeLen++] = (Word)Dest[4] | ((Word)Dest[5]) << 8;
  346.     WAsmCode[CodeLen++] = (Word)Dest[6] | ((Word)Dest[7]) << 8;
  347.   }
  348.   if (!ok)
  349.     CodeLen = 0;
  350. }
  351.  
  352. /*!------------------------------------------------------------------------
  353.  * \fn     DecodeEFLOAT(Word Code)
  354.  * \brief  decode EFLOAT instruction
  355.  * ------------------------------------------------------------------------ */
  356.  
  357. static void DecodeEFLOAT(Word Code)
  358. {
  359.   Boolean ok;
  360.   tStrComp *pArg;
  361.   as_float_t dbl, mant;
  362.   int exp;
  363.  
  364.   UNUSED(Code);
  365.  
  366.   if (!ChkArgCnt(1, ArgCntMax))
  367.     return;
  368.   define_untyped_label();
  369.   ok = True;
  370.   if (SetMaxCodeLen(ArgCnt * 4))
  371.     return;
  372.   forallargs (pArg, ok)
  373.   {
  374.     if (!*pArg->str.p_str)
  375.     {
  376.       ok = False;
  377.       break;
  378.     }
  379.     dbl = EvalStrFloatExpression(pArg, &ok);
  380.     mant = as_frexp(dbl, &exp);
  381.     WAsmCode[CodeLen++] = as_ldexp(mant, 15);
  382.     WAsmCode[CodeLen++] = exp - 1;
  383.   }
  384.   if (!ok)
  385.     CodeLen = 0;
  386. }
  387.  
  388. /*!------------------------------------------------------------------------
  389.  * \fn     DecodeBFLOAT(Word Code)
  390.  * \brief  decode BFLOAT instruction
  391.  * ------------------------------------------------------------------------ */
  392.  
  393. static void DecodeBFLOAT(Word Code)
  394. {
  395.   Boolean ok;
  396.   tStrComp *pArg;
  397.   as_float_t dbl, mant;
  398.   long lmant;
  399.   int exp;
  400.  
  401.   UNUSED(Code);
  402.  
  403.   if (!ChkArgCnt(1, ArgCntMax))
  404.     return;
  405.   define_untyped_label();
  406.   ok = True;
  407.   if (SetMaxCodeLen(ArgCnt * 6))
  408.     return;
  409.   forallargs (pArg, ok)
  410.   {
  411.     if (!*pArg->str.p_str)
  412.     {
  413.       ok = False;
  414.       break;
  415.     }
  416.     dbl = EvalStrFloatExpression(pArg, &ok);
  417.     mant = as_frexp(dbl, &exp);
  418.     lmant = as_ldexp(mant, 31);
  419.     WAsmCode[CodeLen++] = (lmant & 0xffff);
  420.     WAsmCode[CodeLen++] = (lmant >> 16);
  421.     WAsmCode[CodeLen++] = exp - 1;
  422.   }
  423.   if (!ok)
  424.     CodeLen = 0;
  425. }
  426.  
  427. /*!------------------------------------------------------------------------
  428.  * \fn     DecodeTFLOAT(Word Code)
  429.  * \brief  decode TFLOAT instruction
  430.  * ------------------------------------------------------------------------ */
  431.  
  432. static void DecodeTFLOAT(Word Code)
  433. {
  434.   Boolean ok;
  435.   tStrComp *pArg;
  436.   as_float_t dbl, mant;
  437.   int exp;
  438.  
  439.   UNUSED(Code);
  440.  
  441.   if (!ChkArgCnt(1, ArgCntMax))
  442.     return;
  443.   define_untyped_label();
  444.   ok = True;
  445.   if (SetMaxCodeLen(ArgCnt * 12))
  446.     return;
  447.   forallargs (pArg, ok)
  448.   {
  449.     if (!*pArg->str.p_str)
  450.     {
  451.       ok = False;
  452.       break;
  453.     }
  454.     dbl = EvalStrFloatExpression(pArg, &ok);
  455.     mant = as_frexp(dbl, &exp);
  456.     mant = as_modf(as_ldexp(mant, 15), &dbl);
  457.     WAsmCode[CodeLen + 3] = dbl;
  458.     mant = as_modf(as_ldexp(mant, 16), &dbl);
  459.     WAsmCode[CodeLen + 2] = dbl;
  460.     mant = as_modf(as_ldexp(mant, 16), &dbl);
  461.     WAsmCode[CodeLen + 1] = dbl;
  462.     mant = as_modf(as_ldexp(mant, 16), &dbl);
  463.     WAsmCode[CodeLen] = dbl;
  464.     CodeLen += 4;
  465.     WAsmCode[CodeLen++] = ((exp - 1) & 0xffff);
  466.     WAsmCode[CodeLen++] = ((exp - 1) >> 16);
  467.   }
  468.   if (!ok)
  469.     CodeLen = 0;
  470. }
  471.  
  472. /*!------------------------------------------------------------------------
  473.  * \fn     DecodeSTRING(Word Code)
  474.  * \brief  decode STRING instruction
  475.  * ------------------------------------------------------------------------ */
  476.  
  477. static void DecodeSTRING(Word Code)
  478. {
  479.   UNUSED(Code);
  480.  
  481.   pseudo_store(wr_code_byte_hilo, 1);
  482. }
  483.  
  484. /*!------------------------------------------------------------------------
  485.  * \fn     DecodeRSTRING(Word Code)
  486.  * \brief  decode RSTRING instruction
  487.  * ------------------------------------------------------------------------ */
  488.  
  489. static void DecodeRSTRING(Word Code)
  490. {
  491.   UNUSED(Code);
  492.  
  493.   pseudo_store(wr_code_byte_lohi, 1);
  494. }
  495.  
  496. /*!------------------------------------------------------------------------
  497.  * \fn     DecodeBYTE(Word Code)
  498.  * \brief  decode BYTE instruction
  499.  * ------------------------------------------------------------------------ */
  500.  
  501. static void DecodeBYTE(Word Code)
  502. {
  503.   UNUSED(Code);
  504.  
  505.   pseudo_store(wr_code_byte, 1);
  506. }
  507.  
  508. /*!------------------------------------------------------------------------
  509.  * \fn     DecodeWORD(Word Code)
  510.  * \brief  decode WORD instruction
  511.  * ------------------------------------------------------------------------ */
  512.  
  513. static void DecodeWORD(Word Code)
  514. {
  515.   UNUSED(Code);
  516.  
  517.   pseudo_store(wr_code_word, 2);
  518. }
  519.  
  520. /*!------------------------------------------------------------------------
  521.  * \fn     DecodeLONG(Word Code)
  522.  * \brief  decode LONG instruction
  523.  * ------------------------------------------------------------------------ */
  524.  
  525. static void DecodeLONG(Word Code)
  526. {
  527.   UNUSED(Code);
  528.  
  529.   pseudo_store(wr_code_long, 4);
  530. }
  531.  
  532. /*!------------------------------------------------------------------------
  533.  * \fn     DecodeBSS(Word Code)
  534.  * \brief  decode BSS instruction
  535.  * ------------------------------------------------------------------------ */
  536.  
  537. static void DecodeBSS_TI(Word Code)
  538. {
  539.   UNUSED(Code);
  540.  
  541.   define_untyped_label();
  542.   DecodeRES(Code);
  543. }
  544.  
  545. /*!------------------------------------------------------------------------
  546.  * \fn     DecodeDATA_TI(Word Code)
  547.  * \brief  decode TI-specific DATA instruction
  548.  * ------------------------------------------------------------------------ */
  549.  
  550. static void DecodeDATA_TI(Word Code)
  551. {
  552.   UNUSED(Code);
  553.   DecodeDATA(Int16, Int16);
  554. }
  555.  
  556. /*!------------------------------------------------------------------------
  557.  * \fn     Boolean Is99(const char *pStr, Integer *pNum)
  558.  * \brief  does string end with number 00...99?
  559.  * \param  pStr string to check
  560.  * \param  pNum appended number if yes
  561.  * \return True if yes
  562.  * ------------------------------------------------------------------------ */
  563.  
  564. static Boolean Is99(const char *pStr, Integer *pNum)
  565. {
  566.   int l = strlen(pStr);
  567.  
  568.   if ((l >= 3)
  569.    && as_isdigit(pStr[l - 2])
  570.    && as_isdigit(pStr[l - 1]))
  571.   {
  572.     *pNum = 10 * (pStr[l - 2] - '0') + (pStr[l - 1] - '0');
  573.     return True;
  574.   }
  575.   return False;
  576. }
  577.  
  578. /*****************************************************************************
  579.  * Global Functions
  580.  *****************************************************************************/
  581.  
  582. Boolean decode_ti_qxx(void)
  583. {
  584.   Integer Num;
  585.  
  586.   /* Qxx */
  587.  
  588.   if (!as_strncasecmp(OpPart.str.p_str, "Q", 1)
  589.    && Is99(OpPart.str.p_str, &Num))
  590.   {
  591.     pseudo_qxx(Num);
  592.     return True;
  593.   }
  594.  
  595.   /* LQxx */
  596.  
  597.   if (!as_strncasecmp(OpPart.str.p_str, "LQ", 2)
  598.    && Is99(OpPart.str.p_str, &Num))
  599.   {
  600.     pseudo_lqxx(Num);
  601.     return True;
  602.   }
  603.  
  604.   return False;
  605. }
  606.  
  607. void add_ti_pseudo(PInstTable p_inst_table)
  608. {
  609.   AddInstTable(p_inst_table, "RES"    , 0, DecodeRES);
  610.   AddInstTable(p_inst_table, "BSS"    , 0, DecodeBSS_TI);
  611.   AddInstTable(p_inst_table, "DATA"   , 0, DecodeDATA_TI);
  612.   AddInstTable(p_inst_table, "STRING" , 0, DecodeSTRING);
  613.   AddInstTable(p_inst_table, "RSTRING", 0, DecodeRSTRING);
  614.   AddInstTable(p_inst_table, "BYTE"   , 0, DecodeBYTE);
  615.   AddInstTable(p_inst_table, "WORD"   , 0, DecodeWORD);
  616.   AddInstTable(p_inst_table, "LONG"   , 0, DecodeLONG);
  617.   AddInstTable(p_inst_table, "FLOAT"  , 0, DecodeFLOAT);
  618.   AddInstTable(p_inst_table, "DOUBLE" , 0, DecodeDOUBLE);
  619.   AddInstTable(p_inst_table, "EFLOAT" , 0, DecodeEFLOAT);
  620.   AddInstTable(p_inst_table, "BFLOAT" , 0, DecodeBFLOAT);
  621.   AddInstTable(p_inst_table, "TFLOAT" , 0, DecodeTFLOAT);
  622. }
  623.  
  624. Boolean DecodeTIPseudo(void)
  625. {
  626.   static PInstTable InstTable;
  627.  
  628.   if (decode_ti_qxx())
  629.     return True;
  630.  
  631.   if (!InstTable)
  632.   {
  633.     InstTable = CreateInstTable(23);
  634.     add_ti_pseudo(InstTable);
  635.   }
  636.  
  637.   return LookupInstTable(InstTable, OpPart.str.p_str);
  638. }
  639.  
  640. Boolean IsTIDef(void)
  641. {
  642.   static const char *defs[] =
  643.   {
  644.     "BSS", "STRING", "RSTRING",
  645.     "BYTE", "WORD", "LONG", "FLOAT",
  646.     "DOUBLE", "EFLOAT", "BFLOAT",
  647.     "TFLOAT", NULL
  648.   };
  649.   const char **cp = defs;
  650.  
  651.   while (*cp)
  652.   {
  653.     if (Memo(*cp))
  654.       return True;
  655.     cp++;
  656.   }
  657.   return False;
  658. }
  659.  
  660. /*-------------------------------------------------------------------------*/
  661. /* Pseudo Instructions common to C3x/C4x */
  662.  
  663. static void DecodeSINGLE(Word Code)
  664. {
  665.   as_float_t f;
  666.   tStrComp *pArg;
  667.   Boolean OK;
  668.  
  669.   UNUSED(Code);
  670.  
  671.   if (ChkArgCnt(1, ArgCntMax))
  672.   {
  673.     OK = True;
  674.     forallargs (pArg, True)
  675.       if (OK)
  676.       {
  677.         f = EvalStrFloatExpression(pArg, &OK);
  678.         if (OK)
  679.         {
  680.           int ret = as_float_2_ti4(f, DAsmCode + CodeLen);
  681.           if (ret < 0)
  682.           {
  683.             asmerr_check_fp_dispose_result(ret, pArg);
  684.             OK = False;
  685.           }
  686.         }
  687.         if (OK)
  688.           CodeLen++;
  689.       }
  690.     if (!OK)
  691.       CodeLen = 0;
  692.   }
  693. }
  694.  
  695. static void DecodeEXTENDED(Word Code)
  696. {
  697.   as_float_t f;
  698.   tStrComp *pArg;
  699.   Boolean OK;
  700.  
  701.   UNUSED(Code);
  702.  
  703.   if (ChkArgCnt(1, ArgCntMax))
  704.   {
  705.     OK = True;
  706.     forallargs (pArg, True)
  707.       if (OK)
  708.       {
  709.         f = EvalStrFloatExpression(pArg, &OK);
  710.         if (OK)
  711.         {
  712.           int ret = as_float_2_ti5(f, DAsmCode + CodeLen + 1, DAsmCode + CodeLen);
  713.           if (ret < 0)
  714.           {
  715.             asmerr_check_fp_dispose_result(ret, pArg);
  716.             OK = False;
  717.           }
  718.         }
  719.         if (OK)
  720.           CodeLen += 2;
  721.       }
  722.     if (!OK)
  723.       CodeLen = 0;
  724.   }
  725. }
  726.  
  727. static void DecodeWORD_TI34x(Word Code)
  728. {
  729.   Boolean OK;
  730.   tStrComp *pArg;
  731.  
  732.   UNUSED(Code);
  733.  
  734.   if (ChkArgCnt(1, ArgCntMax))
  735.   {
  736.     OK = True;
  737.     forallargs (pArg, True)
  738.       if (OK) DAsmCode[CodeLen++] = EvalStrIntExpression(pArg, Int32, &OK);
  739.     if (!OK)
  740.       CodeLen = 0;
  741.   }
  742. }
  743.  
  744. static void DecodeDATA_TI34x(Word Code)
  745. {
  746.   Boolean OK;
  747.   TempResult t;
  748.   tStrComp *pArg;
  749.  
  750.   UNUSED(Code);
  751.   as_tempres_ini(&t);
  752.  
  753.   if (ChkArgCnt(1, ArgCntMax))
  754.   {
  755.     OK = True;
  756.     forallargs (pArg, OK)
  757.       if (OK)
  758.       {
  759.         EvalStrExpression(pArg, &t);
  760.         switch (t.Typ)
  761.         {
  762.           case TempInt:
  763.           ToInt:
  764. #ifdef HAS64
  765.             if (!RangeCheck(t.Contents.Int, Int32))
  766.             {
  767.               OK = False;
  768.               WrError(ErrNum_OverRange);
  769.             }
  770.             else
  771. #endif
  772.               DAsmCode[CodeLen++] = t.Contents.Int;
  773.             break;
  774.           case TempFloat:
  775.           {
  776.             int ret;
  777.  
  778.             if ((ret = as_float_2_ti4(t.Contents.Float, DAsmCode + CodeLen)) < 0)
  779.             {
  780.               asmerr_check_fp_dispose_result(ret, pArg);
  781.               OK = False;
  782.             }
  783.             else
  784.              CodeLen++;
  785.             break;
  786.           }
  787.           case TempString:
  788.           {
  789.             if (MultiCharToInt(&t, 4))
  790.               goto ToInt;
  791.  
  792.             if (as_chartrans_xlate_nonz_dynstr(CurrTransTable->p_table, &t.Contents.str, pArg))
  793.               OK = False;
  794.             else
  795.               string_2_dasm_code(&t.Contents.str, Packing ? 4 : 1, True);
  796.             break;
  797.           }
  798.           default:
  799.             OK = False;
  800.         }
  801.       }
  802.     if (!OK)
  803.       CodeLen = 0;
  804.   }
  805.   as_tempres_free(&t);
  806. }
  807.  
  808. static void DecodeBSS_TI34x(Word Code)
  809. {
  810.   Boolean OK;
  811.   tSymbolFlags Flags;
  812.   LongInt Size;
  813.  
  814.   UNUSED(Code);
  815.  
  816.   if (ChkArgCnt(1, 1))
  817.   {
  818.     Size = EvalStrIntExpressionWithFlags(&ArgStr[1], UInt24, &OK, &Flags);
  819.     if (mFirstPassUnknown(Flags)) WrError(ErrNum_FirstPassCalc);
  820.     if (OK && !mFirstPassUnknown(Flags))
  821.     {
  822.       DontPrint = True;
  823.       if (!Size)
  824.         WrError(ErrNum_NullResMem);
  825.       CodeLen = Size;
  826.       BookKeeping();
  827.     }
  828.   }
  829. }
  830.  
  831. void AddTI34xPseudo(TInstTable *pInstTable)
  832. {
  833.   AddInstTable(pInstTable, "SINGLE", 0, DecodeSINGLE);
  834.   AddInstTable(pInstTable, "EXTENDED", 0, DecodeEXTENDED);
  835.   AddInstTable(pInstTable, "WORD", 0, DecodeWORD_TI34x);
  836.   AddInstTable(pInstTable, "DATA", 0, DecodeDATA_TI34x);
  837.   AddInstTable(pInstTable, "BSS", 0, DecodeBSS_TI34x);
  838. }
  839.