/*乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗//
    bolcom.c
//乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗*/

#include <windows.h>

#define  _USE_MATH_DEFINES
#include <math.h>
#include <setjmp.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <bolalg.h>
#include <bolbas.h>
#define  OWN_USE
#include "bolcom.h"

#define  MODNAM  "BOLCOM"
#define  MODVER  OCTVAL(2,6,0,0)

//乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗//

  // 僄儔乕儊僢僙乕僕
static CODI eeCOM[] = {
  { E_STK, "僗僞僢僋僆乕僶乕僼儘乕" },
  { E_SEG, "僙僌儊儞僥乕僔儑儞堘斀" },
  { E_OPC, "晄惓側僆儁僐乕僪" },
  { E_DIV, "僛儘彍嶼僄儔乕" },
  { E_NUL, "僰儖嶲徠僄儔乕" },
  { E_ORD, "娭悢偺彉悢偑晄惓" },
  { E_EXE, "晄柧側僶僀僩僐乕僪幚峴帪僄儔乕" },
  { E_BCD, "僶僀僩僐乕僪僼傽僀儖偑晄惓" },
  { E_VER, "僶僀僩僐乕僪僼傽僀儖偑晄惓(屳姺惈偺側偄僶乕僕儑儞)" },
  { E_PRO, "僶僀僩僐乕僪僼傽僀儖偑晄惓(堎側傞僾儘僔乕僕儍庬暿)" },
  { E_NAC, "晄柧側僐儞僷僀儖僄儔乕" },
  { E_TKN, "晄惓側帤嬪" },
  { E_END, "梊婜偟側偄擖椡偺廔傢傝" },
  { E_DLM, "昁梫側嬫愗傝偺帤嬪偑側偄" },
  { E_UNX, "梊婜偟側偄帤嬪" },
  { E_IDN, "幆暿巕偑昁梫" },
  { E_UNK, "枹掕媊偺幆暿巕" },
  { E_DUP, "幆暿巕偺廳暋" },
  { E_VOI, "宆忣曬偑側偄" },
  { E_SCA, "僗僇儔宆埲奜偼抣搉偟偱偒側偄" },
  { E_CST, "晄惓側宆曄姺" },
  { E_OPR, "墘嶼巕偺晄惓側巊梡(宆偺晄堦抳)" },
  { E_ASN, "晄惓側戙擖(宆偺晄堦抳)" },
  { E_OBJ, "晄惓側戙擖(嵍曈抣偱側偄)" },
  { E_IMM, "晄惓側戙擖(嵍曈抣偑壜曄偱側偄)" },
  { E_PTR, "晄惓側媡嶲徠(嶲徠偱側偄)" },
  { E_STU, "峔憿懱偱側偄" },
  { E_NME, "儊儞僶柤偱側偄" },
  { E_MUL, "懡廳娫愙嶲徠偺夞悢惂尷傪挻偊偨" },
  { E_TYP, "宆柤偱側偄" },
  { E_ARY, "攝楍偱側偄" },
  { E_FNC, "娭悢偺愰尵偲掕媊(傑偨偼嵞愰尵)偺晄堦抳" },
  { E_JMP, "峴偒愭偺儔儀儖偑側偄" },
  { E_INT, "掕悢幃偼係僶僀僩惍悢宆偱側偗傟偽側傜側偄" },
  { E_SWI, "惂屼幃偼係僶僀僩惍悢宆偱側偗傟偽側傜側偄" },
  { E_ARI, "掕悢愰尵偼嶼弍宆偱側偗傟偽側傜側偄" },
  { E_INI, "掕悢幃偱側偗傟偽側傜側偄" },
  { E_AUT, "僗僇儔宆埲奜偺帺摦曄悢偼弶婜壔巕偱弶婜壔偱偒側偄" },
  { E_LIT, "暥帤攝楍埲奜偼暥帤楍儕僥儔儖偱弶婜壔偱偒側偄" },
  { E_LEN, "攝楍偺弶婜壔巕偑挿偡偓傞" },
  { E_ASZ, "攝楍偺梫慺悢偑惓偺惍悢偱側偄" },
  { E_CPL, "僐儞僷僀儖拞抐" },
  { E_ENT, "儊僀儞娭悢掕媊偑側偄" },
};
static CODS emCOM = { eeCOM, _countof(eeCOM) };

I4B  LOCALF fmtasz(rSTR fmt)
{ // printf彂幃暥帤楍偐傜壜曄堷悢慡懱偺僒僀僘傪媮傔傞
  I4B sz = 0;
  rSTR pt = fmt;

  while (!!*pt) {
    if (*pt == '%') {
      pt++;
      if (*pt == '%') continue;
      pt += strspn(pt, " #+-0");
      if (*pt == '*') { pt++; sz += 4;} else { pt += strspn(pt, "0123456789");}
      if (*pt == '.') {
        pt++;
        if (*pt == '*') { pt++; sz += 4;} else { pt += strspn(pt, "0123456789");}
      }
      if (*pt == 'l') {
        pt++;
        if (*pt == 'l') { pt++; sz += 4;}
      } else if (*pt == 'h' || *pt == 'L') {
        pt++;
      }
      switch (*pt++) {
      case 'c': case 'd': case 'i': case 'n': case 'o':
      case 'p': case 's': case 'u': case 'x': case 'X':
        sz += 4; break;
      case 'e': case 'E': case 'f': case 'g': case 'G':
        sz += 8; break;
      }
    } else if (iszen(pt)) {
      ((pU2B)pt)++;
    } else {
      pt++;
    }
  }
  return sz;
}

void WINAPI fi_0(pBIN sp)
{ // 僟儈乕
}

void LOCALF fi_sqrt(pBIN sp)
{ // sqrt
  *(pF8B)sp = sqrt(*(rF8B)sp);
}

void LOCALF fi_sin(pBIN sp)
{ // sin
  *(pF8B)sp = sin(*(rF8B)sp);
}

void LOCALF fi_cos(pBIN sp)
{ // cos
  *(pF8B)sp = cos(*(rF8B)sp);
}

void LOCALF fi_tan(pBIN sp)
{ // tan
  *(pF8B)sp = tan(*(rF8B)sp);
}

void LOCALF fi_asin(pBIN sp)
{ // asin
  *(pF8B)sp = asin(*(rF8B)sp);
}

void LOCALF fi_acos(pBIN sp)
{ // acos
  *(pF8B)sp = acos(*(rF8B)sp);
}

void LOCALF fi_atan(pBIN sp)
{ // atan
  *(pF8B)sp = atan(*(rF8B)sp);
}

void LOCALF fi_atan2(pBIN sp)
{ // atan2
  *(pF8B)(sp + 8) = atan2(*(rF8B)sp, *(rF8B)(sp + 8));
}

void LOCALF fi_exp(pBIN sp)
{ // exp
  *(pF8B)sp = exp(*(rF8B)sp);
}

void LOCALF fi_pow(pBIN sp)
{ // pow
  *(pF8B)(sp + 8) = pow(*(rF8B)sp, *(rF8B)(sp + 8));
}

void LOCALF fi_log(pBIN sp)
{ // log
  *(pF8B)sp = log(*(rF8B)sp);
}

void LOCALF fi_log10(pBIN sp)
{ // log10
  *(pF8B)sp = log10(*(rF8B)sp);
}

void LOCALF fi_ceil(pBIN sp)
{ // ceil
  *(pF8B)sp = ceil(*(rF8B)sp);
}

void LOCALF fi_floor(pBIN sp)
{ // floor
  *(pF8B)sp = floor(*(rF8B)sp);
}

void LOCALF fi_fabs(pBIN sp)
{ // fabs
  *(pF8B)sp = fabs(*(rF8B)sp);
}

void LOCALF fi_abs(pBIN sp)
{ // abs
  *(pI4B)sp = abs(*(rI4B)sp);
}

void LOCALF fi_atoi(pBIN sp)
{ // atoi
  *(pI4B)sp = strtol(*(rP4B)sp, NULL, 10);
}

void LOCALF fi_atof(pBIN sp)
{ // atof
  *(pF8B)(sp - 4) = strtod(*(rP4B)sp, NULL);
}

void LOCALF fi_rand(pBIN sp)
{ // rand
  *(pI4B)(sp - 4) = rand();
}

void LOCALF fi_srand(pBIN sp)
{ // srand
  srand(*(rU4B)sp);
}

void LOCALF fi_calloc(pBIN sp)
{ // calloc
  *(pP4B)(sp + 4) = calloc(*(rU4B)sp, *(rU4B)(sp + 4));
}

void LOCALF fi_malloc(pBIN sp)
{ // malloc
  *(pP4B)sp = malloc(*(rU4B)sp);
}

void LOCALF fi_realloc(pBIN sp)
{ // realloc
  *(pP4B)(sp + 4) = realloc(*(rP4B)sp, *(rU4B)(sp + 4));
}

void LOCALF fi_free(pBIN sp)
{ // free
  free(*(pP4B)sp);
}

void LOCALF fi_memchr(pBIN sp)
{ // memchr
  *(pP4B)(sp + 8) = memchr(*(rP4B)sp, *(rI4B)(sp + 4), *(rU4B)(sp + 8));
}

void LOCALF fi_memcmp(pBIN sp)
{ // memcmp
  *(pI4B)(sp + 8) = memcmp(*(rP4B)sp, *(rP4B)(sp + 4), *(rU4B)(sp + 8));
}

void LOCALF fi_memcpy(pBIN sp)
{ // memcpy
  *(pP4B)(sp + 8) = memcpy(*(pP4B)sp, *(rP4B)(sp + 4), *(rU4B)(sp + 8));
}

void LOCALF fi_memmove(pBIN sp)
{ // memmove
  *(pP4B)(sp + 8) = memmove(*(pP4B)sp, *(pP4B)(sp + 4), *(rU4B)(sp + 8));
}

void LOCALF fi_memset(pBIN sp)
{ // memset
  *(pP4B)(sp + 8) = memset(*(pP4B)sp, *(rI4B)(sp + 4), *(rU4B)(sp + 8));
}

void LOCALF fi_strchr(pBIN sp)
{ // strchr
  *(pP4B)(sp + 4) = strchr(*(rP4B)sp, *(rI4B)(sp + 4));
}

void LOCALF fi_strcmp(pBIN sp)
{ // strcmp
  *(pI4B)(sp + 4) = strcmp(*(rP4B)sp, *(rP4B)(sp + 4));
}

void LOCALF fi_stricmp(pBIN sp)
{ // stricmp
  *(pI4B)(sp + 4) = _stricmp(*(rP4B)sp, *(rP4B)(sp + 4));
}

void LOCALF fi_strncmp(pBIN sp)
{ // strncmp
  *(pI4B)(sp + 8) = strncmp(*(rP4B)sp, *(rP4B)(sp + 4), *(rU4B)(sp + 8));
}

void LOCALF fi_strnicmp(pBIN sp)
{ // strnicmp
  *(pI4B)(sp + 8) = _strnicmp(*(rP4B)sp, *(rP4B)(sp + 4), *(rU4B)(sp + 8));
}

void LOCALF fi_strcpy(pBIN sp)
{ // strcpy(strcpys)
  *(pP4B)(sp + 4) = strcpys(*(pP4B)sp, *(rP4B)(sp + 4));
}

void LOCALF fi_strcat(pBIN sp)
{ // strcat(strcats)
  *(pP4B)(sp + 4) = strcats(*(pP4B)sp, *(rP4B)(sp + 4));
}

void LOCALF fi_strlen(pBIN sp)
{ // strlen
  *(pU4B)sp = strlen(*(rP4B)sp);
}

void LOCALF fi_strspn(pBIN sp)
{ // strspn
  *(pU4B)(sp + 4) = strspn(*(rP4B)sp, *(rP4B)(sp + 4));
}

void LOCALF fi_strtol(pBIN sp)
{ // strtol
  *(pI4B)(sp + 8) = strtol(*(rP4B)sp, *(pP4B)(sp + 4), *(rI4B)(sp + 8));
}

void LOCALF fi_strtoul(pBIN sp)
{ // strtoul
  *(pU4B)(sp + 8) = strtoul(*(rP4B)sp, *(pP4B)(sp + 4), *(rI4B)(sp + 8));
}

void LOCALF fi_strtod(pBIN sp)
{ // strtod
  *(pF8B)sp = strtod(*(rP4B)sp, *(pP4B)(sp + 4));
}

void LOCALF fi_sprintf(pBIN sp)
{ // sprintf(sprintfs)
  I4B sz = fmtasz(*(rP4B)(sp + 4)), re;

  re = vsprintf_s(*(pP4B)sp, LBUF - 1, *(rP4B)(sp + 4), sp + 8);
  *(pI4B)(sp + 4 + sz) = re;
}

void LOCALF fi_atoi64(pBIN sp)
{ // _atoi64
  *(pI8B)(sp - 4) = _atoi64(*(rP4B)sp);
}

void LOCALF fi_strtoi64(pBIN sp)
{ // _strtoi64
  *(pI8B)(sp + 4) = _strtoi64(*(rP4B)sp, *(pP4B)(sp + 4), *(rI4B)(sp + 8));
}

void LOCALF fi_strtoui64(pBIN sp)
{ // _strtoui64
  *(pU8B)(sp + 4) = _strtoui64(*(rP4B)sp, *(pP4B)(sp + 4), *(rI4B)(sp + 8));
}

void LOCALF fi_fopen(pBIN sp)
{ // fopen(hfopen)
  *(pP4B)(sp + 4) = hfopen(*(rP4B)sp, *(rP4B)(sp + 4));
}

void LOCALF fi_fclose(pBIN sp)
{ // fclose(hfclose)
  *(pI4B)sp = hfclose(*(rP4B)sp);
}

void LOCALF fi_fprintf(pBIN sp)
{ // fprintf(hfprintf)
  I4B ln, sz = fmtasz(*(rP4B)(sp + 4));
  I1B bf[LBUF], wk[LBUF*2];

  vsprintf_s(bf, LBUF - 1, *(rP4B)(sp + 4), sp + 8);
  strreplb(wk, bf, "\n", "\r\n");
  ln = strlen(wk);
  write_file(*(pP4B)sp, wk, ln);
  *(pI4B)(sp + 4 + sz) = ln;
}

void LOCALF fi_memswap(pBIN sp)
{ // memswap
  memswap(*(pP4B)sp, *(pP4B)(sp + 4), *(rI4B)(sp + 8));
}

void LOCALF fi_memrotl(pBIN sp)
{ // memrotl
  memrotl(*(pP4B)sp, *(rI4B)(sp + 4), *(rI4B)(sp + 8));
}

void LOCALF fi_memrotr(pBIN sp)
{ // memrotr
  memrotr(*(pP4B)sp, *(rI4B)(sp + 4), *(rI4B)(sp + 8));
}

void LOCALF fi_sign(pBIN sp)
{ // sign
  *(pI4B)(sp + 4) = sign(*(rF8B)sp);
}

void LOCALF fi_iround(pBIN sp)
{ // iround
  *(pI4B)(sp + 4) = iround(*(rF8B)sp);
}

void LOCALF fi_hash(pBIN sp)
{ // hash
  *(pU4B)(sp + 4) = hash(*(rP4B)sp, *(rU4B)(sp + 4));
}

void LOCALF fi_nbound(pBIN sp)
{ // nbound
  *(pU4B)(sp + 4) = nbound(*(rU4B)sp, *(rU4B)(sp + 4));
}

void LOCALF fi_halloc(pBIN sp)
{ // halloc
  *(pP4B)(sp + 4) = halloc(*(rU4B)sp, *(rI4B)(sp + 4));
}

void LOCALF fi_hrealloc(pBIN sp)
{ // hrealloc
  *(pP4B)(sp + 4) = hrealloc(*(pP4B)sp, *(rU4B)(sp + 4));
}

void LOCALF fi_hfree(pBIN sp)
{ // hfree
  hfree(*(pP4B)sp);
}

void LOCALF fi_talloc(pBIN sp)
{ // talloc
  *(pP4B)sp = talloc(*(rU4B)sp);
}

void LOCALF fi_ualloc(pBIN sp)
{ // ualloc
  *(pP4B)sp = ualloc(*(rU4B)sp);
}

void LOCALF fi_valloc(pBIN sp)
{ // valloc
  *(pP4B)sp = valloc(*(rU4B)sp);
}

void LOCALF fi_idxval(pBIN sp)
{ // idxval
  *(pI4B)(sp + 4) = idxval(*(rP4B)sp, *(rI4B)(sp + 4));
}

void LOCALF fi_srchidx(pBIN sp)
{ // srchidx
  *(pI4B)(sp + 4) = srchidx(*(rP4B)sp, *(rI4B)(sp + 4));
}

void LOCALF fi_mapval(pBIN sp)
{ // mapval
  *(pI4B)(sp + 4) = mapval(*(rP4B)sp, *(rI4B)(sp + 4));
}

void LOCALF fi_srchmap(pBIN sp)
{ // srchmap
  *(pI4B)(sp + 4) = srchmap(*(rP4B)sp, *(rI4B)(sp + 4));
}

void LOCALF fi_enmstr(pBIN sp)
{ // enmstr
  *(pP4B)(sp + 4) = (P4B)enmstr(*(rP4B)sp, *(rI4B)(sp + 4));
}

void LOCALF fi_srchenm0(pBIN sp)
{ // srchenm0
  *(pI4B)(sp + 4) = srchenm0(*(rP4B)sp, *(rP4B)(sp + 4));
}

void LOCALF fi_codstr(pBIN sp)
{ // codstr
  *(pP4B)(sp + 4) = (P4B)codstr(*(rP4B)sp, *(rI4B)(sp + 4));
}

void LOCALF fi_srchcod0(pBIN sp)
{ // srchcod0
  *(pI4B)(sp + 4) = srchcod0(*(rP4B)sp, *(rP4B)(sp + 4));
}

void LOCALF fi_register_error_dsc(pBIN sp)
{ // register_error_descriptions
  *(pI4B)sp = register_error_descriptions(*(rP4B)sp);
}

void LOCALF fi_error_dsc(pBIN sp)
{ // error_description
  *(pP4B)sp = (P4B)error_description(*(rU4B)sp);
}

void LOCALF fi_first_error(pBIN sp)
{ // first_error
  *(pI4B)(sp - 4) = first_error();
}

void LOCALF fi_last_error(pBIN sp)
{ // last_error
  *(pI4B)(sp - 4) = last_error();
}

void LOCALF fi_reset_error(pBIN sp)
{ // reset_error
  reset_error();
}

void LOCALF fi_enable_error_reporting(pBIN sp)
{ // enable_error_reporting
  *(pI4B)(sp - 4) = enable_error_reporting();
}

void LOCALF fi_disable_error_reporting(pBIN sp)
{ // disable_error_reporting
  *(pI4B)(sp - 4) = disable_error_reporting();
}

void LOCALF fi_enable_error_logging(pBIN sp)
{ // enable_error_logging
  *(pI4B)(sp - 4) = enable_error_logging();
}

void LOCALF fi_disable_error_logging(pBIN sp)
{ // disable_error_logging
  *(pI4B)(sp - 4) = disable_error_logging();
}

void LOCALF fi_ierr(pBIN sp)
{ // ierr
  *(pP4B)sp = throw_error(NULL, *(rI4B)sp, NULL, -1);
}

void LOCALF fi_ferr(pBIN sp)
{ // ferr
  *(pP4B)(sp + 4) = throw_error(NULL, *(rI4B)sp, *(rP4B)(sp + 4), -1);
}

void LOCALF fi_serr(pBIN sp)
{ // serr
  *(pP4B)(sp +12) = throw_error(NULL, *(rI4B)sp, *(rP4B)(sp + 4), MKU4B(*(rI4B)(sp + 8), *(rI4B)(sp +12)));
}

void LOCALF fi_CreateIMG(pBIN sp)
{ // CreateIMG
  *(pP4B)(sp + 8) = CreateIMG(*(rI4B)sp, *(rI4B)(sp + 4), *(rU4B)(sp + 8));
}

void LOCALF fi_DuplicateIMG(pBIN sp)
{ // DuplicateIMG
  *(pP4B)sp = DuplicateIMG(*(rP4B)sp);
}

void LOCALF fi_DeleteIMG(pBIN sp)
{ // DeleteIMG
  DeleteIMG(*(rP4B)sp);
}

void LOCALF fi_MoveIMG(pBIN sp)
{ // MoveIMG
  *(pP4B)(sp + 4) = MoveIMG(*(pP4B)sp, *(pP4B)(sp + 4));
}

void LOCALF fi_PasteIMG(pBIN sp)
{ // PasteIMG
  PasteIMG(*(pP4B)sp, *(pP4B)(sp + 4), *(rI4B)(sp + 8), *(rI4B)(sp +12));
}

void LOCALF fi_TrimIMG(pBIN sp)
{ // TrimIMG
  TrimIMG(*(pP4B)sp, *(rI4B)(sp + 4), *(rI4B)(sp + 8), *(rI4B)(sp +12), *(rI4B)(sp +16), *(rU4B)(sp +20));
}

void LOCALF fi_SetXFMQ(pBIN sp)
{ // SetXFMQ
  SetXFMQ(*(pP4B)sp, *(rI4B)(sp + 4), *(rI4B)(sp + 8), *(rI4B)(sp +12), *(rI4B)(sp +16),
                     *(rI4B)(sp +20), *(rI4B)(sp +24), *(rI4B)(sp +28), *(rI4B)(sp +32));
}

void LOCALF fi_TransformIMG(pBIN sp)
{ // TransformIMG
  TransformIMG(*(pP4B)sp, *(rP4B)(sp + 4), *(rU4B)(sp + 8));
}

void LOCALF fi_InvertIMG(pBIN sp)
{ // InvertIMG
  InvertIMG(*(pP4B)sp, *(rI4B)(sp + 4));
}

void LOCALF fi_RotateIMG(pBIN sp)
{ // RotateIMG
  RotateIMG(*(pP4B)sp, *(rF8B)(sp + 4), *(rU4B)(sp +12));
}

void LOCALF fi_ResizeIMGX(pBIN sp)
{ // ResizeIMGX
  ResizeIMGX(*(pP4B)sp, *(rI4B)(sp + 4), *(rI4B)(sp + 8), *(rI4B)(sp +12));
}

void LOCALF fi_ResizeIMG(pBIN sp)
{ // ResizeIMG
  ResizeIMG(*(pP4B)sp, *(rI4B)(sp + 4), *(rI4B)(sp + 8));
}

void LOCALF fi_isspc(pBIN sp)
{ // isspc
  *(pI4B)sp = isspc(*(rP4B)sp);
}

void LOCALF fi_isctl(pBIN sp)
{ // isctl
  *(pI4B)sp = isctl(*(rP4B)sp);
}

void LOCALF fi_issym(pBIN sp)
{ // issym
  *(pI4B)sp = issym(*(rP4B)sp);
}

void LOCALF fi_isdig(pBIN sp)
{ // isdig
  *(pI4B)sp = isdig(*(rP4B)sp);
}

void LOCALF fi_isodig(pBIN sp)
{ // isodig
  *(pI4B)sp = isodig(*(rP4B)sp);
}

void LOCALF fi_isxdig(pBIN sp)
{ // isxdig
  *(pI4B)sp = isxdig(*(rP4B)sp);
}

void LOCALF fi_isupr(pBIN sp)
{ // isupr
  *(pI4B)sp = isupr(*(rP4B)sp);
}

void LOCALF fi_islwr(pBIN sp)
{ // islwr
  *(pI4B)sp = islwr(*(rP4B)sp);
}

void LOCALF fi_isalp(pBIN sp)
{ // isalp
  *(pI4B)sp = isalp(*(rP4B)sp);
}

void LOCALF fi_isalpx(pBIN sp)
{ // isalpx
  *(pI4B)sp = isalpx(*(rP4B)sp);
}

void LOCALF fi_isaln(pBIN sp)
{ // isaln
  *(pI4B)sp = isaln(*(rP4B)sp);
}

void LOCALF fi_isalnx(pBIN sp)
{ // isalnx
  *(pI4B)sp = isalnx(*(rP4B)sp);
}

void LOCALF fi_isasc(pBIN sp)
{ // isasc
  *(pI4B)sp = isasc(*(rP4B)sp);
}

void LOCALF fi_ishan(pBIN sp)
{ // ishan
  *(pI4B)sp = ishan(*(rP4B)sp);
}

void LOCALF fi_isprn(pBIN sp)
{ // isprn
  *(pI4B)sp = isprn(*(rP4B)sp);
}

void LOCALF fi_iszen1(pBIN sp)
{ // iszen1
  *(pI4B)sp = iszen1(*(rP4B)sp);
}

void LOCALF fi_iszen2(pBIN sp)
{ // iszen2
  *(pI4B)sp = iszen2(*(rP4B)sp);
}

void LOCALF fi_iszen(pBIN sp)
{ // iszen
  *(pI4B)sp = iszen(*(rP4B)sp);
}

void LOCALF fi_isret(pBIN sp)
{ // isret
  *(pI4B)sp = isret(*(rP4B)sp);
}

void LOCALF fi_iszspc(pBIN sp)
{ // iszspc
  *(pI4B)sp = iszspc(*(rP4B)sp);
}

void LOCALF fi_spncpy(pBIN sp)
{ // spncpy
  *(pP4B)(sp + 8) = spncpy(*(pP4B)sp, *(rP4B)(sp + 4), *(rP4B)(sp + 8));
}

void LOCALF fi_strcpyn(pBIN sp)
{ // strcpyn
  *(pP4B)(sp + 8) = strcpyn(*(pP4B)sp, *(rP4B)(sp + 4), *(rI4B)(sp + 8));
}

void LOCALF fi_strcpyx(pBIN sp)
{ // strcpyx
  *(pP4B)(sp + 8) = strcpyx(*(pP4B)sp, *(rP4B)(sp + 4), *(rI4B)(sp + 8));
}

void LOCALF fi_nthzen1(pBIN sp)
{ // nthzen1
  *(pI4B)(sp + 4) = nthzen1(*(rP4B)sp, *(rI4B)(sp + 4));
}

void LOCALF fi_nthyen(pBIN sp)
{ // nthyen
  *(pI4B)(sp + 4) = nthyen(*(rP4B)sp, *(rI4B)(sp + 4));
}

void LOCALF fi_mbschr(pBIN sp)
{ // mbschr
  *(pP4B)(sp + 4) = mbschr(*(rP4B)sp, *(rI4B)(sp + 4));
}

void LOCALF fi_mbsrchr(pBIN sp)
{ // mbsrchr
  *(pP4B)(sp + 4) = mbsrchr(*(rP4B)sp, *(rI4B)(sp + 4));
}

void LOCALF fi_mbslen(pBIN sp)
{ // mbslen
  *(pU4B)sp = mbslen(*(rP4B)sp);
}

void LOCALF fi_strmatchx(pBIN sp)
{ // strmatchx
  *(pI4B)(sp + 8) = strmatchx(*(rP4B)sp, *(rP4B)(sp + 4), *(rI4B)(sp + 8));
}

void LOCALF fi_strmatch(pBIN sp)
{ // strmatch
  *(pI4B)(sp + 4) = strmatch(*(rP4B)sp, *(rP4B)(sp + 4));
}

void LOCALF fi_strfindx(pBIN sp)
{ // strfindx
  *(pP4B)(sp + 8) = (P4B)strfindx(*(rP4B)sp, *(rP4B)(sp + 4), *(rI4B)(sp + 8));
}

void LOCALF fi_strfind(pBIN sp)
{ // strfind
  *(pP4B)(sp + 4) = (P4B)strfind(*(rP4B)sp, *(rP4B)(sp + 4));
}

void LOCALF fi_strlfind(pBIN sp)
{ // strlfind
  *(pI4B)(sp + 4) = strlfind(*(rP4B)sp, *(rP4B)(sp + 4));
}

void LOCALF fi_strrfind(pBIN sp)
{ // strrfind
  *(pI4B)(sp + 4) = strrfind(*(rP4B)sp, *(rP4B)(sp + 4));
}

void LOCALF fi_strifind(pBIN sp)
{ // strifind
  *(pP4B)(sp + 4) = (P4B)strifind(*(rP4B)sp, *(rP4B)(sp + 4));
}

void LOCALF fi_strilfind(pBIN sp)
{ // strilfind
  *(pI4B)(sp + 4) = strilfind(*(rP4B)sp, *(rP4B)(sp + 4));
}

void LOCALF fi_strirfind(pBIN sp)
{ // strirfind
  *(pI4B)(sp + 4) = strirfind(*(rP4B)sp, *(rP4B)(sp + 4));
}

void LOCALF fi_strlike(pBIN sp)
{ // strlike
  *(pI4B)(sp + 4) = strlike(*(rP4B)sp, *(rP4B)(sp + 4));
}

void LOCALF fi_strmlike(pBIN sp)
{ // strmlike
  *(pI4B)(sp + 4) = strmlike(*(rP4B)sp, *(rP4B)(sp + 4));
}

void LOCALF fi_strllike(pBIN sp)
{ // strllike
  *(pI4B)(sp + 4) = strllike(*(rP4B)sp, *(rP4B)(sp + 4));
}

void LOCALF fi_strrlike(pBIN sp)
{ // strrlike
  *(pI4B)(sp + 4) = strrlike(*(rP4B)sp, *(rP4B)(sp + 4));
}

void LOCALF fi_strcount(pBIN sp)
{ // strcount
  *(pI4B)(sp + 4) = strcount(*(rP4B)sp, *(rP4B)(sp + 4));
}

void LOCALF fi_tozenb(pBIN sp)
{ // tozenb
  *(pP4B)(sp + 4) = (P4B)tozenb(*(pP4B)sp, *(rP4B)(sp + 4));
}

void LOCALF fi_tohanb(pBIN sp)
{ // tohanb
  *(pP4B)(sp + 4) = (P4B)tohanb(*(pP4B)sp, *(rP4B)(sp + 4));
}

void LOCALF fi_touprb(pBIN sp)
{ // touprb
  *(pP4B)(sp + 4) = (P4B)touprb(*(pP4B)sp, *(rP4B)(sp + 4));
}

void LOCALF fi_tolwrb(pBIN sp)
{ // tolwrb
  *(pP4B)(sp + 4) = (P4B)tolwrb(*(pP4B)sp, *(rP4B)(sp + 4));
}

void LOCALF fi_tohirab(pBIN sp)
{ // tohirab
  *(pP4B)(sp + 4) = (P4B)tohirab(*(pP4B)sp, *(rP4B)(sp + 4));
}

void LOCALF fi_tokatab(pBIN sp)
{ // tokatab
  *(pP4B)(sp + 4) = (P4B)tokatab(*(pP4B)sp, *(rP4B)(sp + 4));
}

void LOCALF fi_ltrimb(pBIN sp)
{ // ltrimb
  *(pP4B)(sp + 4) = (P4B)ltrimb(*(pP4B)sp, *(rP4B)(sp + 4));
}

void LOCALF fi_rtrimb(pBIN sp)
{ // rtrimb
  *(pP4B)(sp + 4) = (P4B)rtrimb(*(pP4B)sp, *(rP4B)(sp + 4));
}

void LOCALF fi_btrimb(pBIN sp)
{ // btrimb
  *(pP4B)(sp + 4) = (P4B)btrimb(*(pP4B)sp, *(rP4B)(sp + 4));
}

void LOCALF fi_delspcb(pBIN sp)
{ // delspcb
  *(pP4B)(sp + 4) = (P4B)delspcb(*(pP4B)sp, *(rP4B)(sp + 4));
}

void LOCALF fi_delctlb(pBIN sp)
{ // delctlb
  *(pP4B)(sp + 4) = (P4B)delctlb(*(pP4B)sp, *(rP4B)(sp + 4));
}

void LOCALF fi_ctlspcb(pBIN sp)
{ // ctlspcb
  *(pP4B)(sp + 4) = (P4B)ctlspcb(*(pP4B)sp, *(rP4B)(sp + 4));
}

void LOCALF fi_cipherb(pBIN sp)
{ // cipherb
  *(pP4B)(sp + 4) = (P4B)cipherb(*(pP4B)sp, *(rP4B)(sp + 4));
}

void LOCALF fi_inscmab(pBIN sp)
{ // inscmab
  *(pP4B)(sp + 4) = (P4B)inscmab(*(pP4B)sp, *(rP4B)(sp + 4));
}

void LOCALF fi_delcmab(pBIN sp)
{ // delcmab
  *(pP4B)(sp + 4) = (P4B)delcmab(*(pP4B)sp, *(rP4B)(sp + 4));
}

void LOCALF fi_extascb(pBIN sp)
{ // extascb
  *(pP4B)(sp + 4) = (P4B)extascb(*(pP4B)sp, *(rP4B)(sp + 4));
}

void LOCALF fi_midstrb(pBIN sp)
{ // midstrb
  *(pP4B)(sp +12) = (P4B)midstrb(*(pP4B)sp, *(rP4B)(sp + 4), *(rI4B)(sp + 8), *(rI4B)(sp +12));
}

void LOCALF fi_strreplb(pBIN sp)
{ // strreplb
  *(pP4B)(sp +12) = (P4B)strreplb(*(pP4B)sp, *(rP4B)(sp + 4), *(rP4B)(sp + 8), *(rP4B)(sp +12));
}

void LOCALF fi_strconcb(pBIN sp)
{ // strconcb
  *(pP4B)(sp + 8) = (P4B)strconcb(*(pP4B)sp, *(rP4B)(sp + 4), *(rP4B)(sp + 8));
}

void LOCALF fi_tozen(pBIN sp)
{ // tozen
  *(pP4B)sp = (P4B)tozen(*(rP4B)sp);
}

void LOCALF fi_tohan(pBIN sp)
{ // tohan
  *(pP4B)sp = (P4B)tohan(*(rP4B)sp);
}

void LOCALF fi_toupr(pBIN sp)
{ // toupr
  *(pP4B)sp = (P4B)toupr(*(rP4B)sp);
}

void LOCALF fi_tolwr(pBIN sp)
{ // tolwr
  *(pP4B)sp = (P4B)tolwr(*(rP4B)sp);
}

void LOCALF fi_tohira(pBIN sp)
{ // tohira
  *(pP4B)sp = (P4B)tohira(*(rP4B)sp);
}

void LOCALF fi_tokata(pBIN sp)
{ // tokata
  *(pP4B)sp = (P4B)tokata(*(rP4B)sp);
}

void LOCALF fi_ltrim(pBIN sp)
{ // ltrim
  *(pP4B)sp = (P4B)ltrim(*(rP4B)sp);
}

void LOCALF fi_rtrim(pBIN sp)
{ // rtrim
  *(pP4B)sp = (P4B)rtrim(*(rP4B)sp);
}

void LOCALF fi_btrim(pBIN sp)
{ // btrim
  *(pP4B)sp = (P4B)btrim(*(rP4B)sp);
}

void LOCALF fi_delspc(pBIN sp)
{ // delspc
  *(pP4B)sp = (P4B)delspc(*(rP4B)sp);
}

void LOCALF fi_delctl(pBIN sp)
{ // delctl
  *(pP4B)sp = (P4B)delctl(*(rP4B)sp);
}

void LOCALF fi_ctlspc(pBIN sp)
{ // ctlspc
  *(pP4B)sp = (P4B)ctlspc(*(rP4B)sp);
}

void LOCALF fi_cipher(pBIN sp)
{ // cipher
  *(pP4B)sp = (P4B)cipher(*(rP4B)sp);
}

void LOCALF fi_inscma(pBIN sp)
{ // inscma
  *(pP4B)sp = (P4B)inscma(*(rP4B)sp);
}

void LOCALF fi_delcma(pBIN sp)
{ // delcma
  *(pP4B)sp = (P4B)delcma(*(rP4B)sp);
}

void LOCALF fi_extasc(pBIN sp)
{ // extasc
  *(pP4B)sp = (P4B)extasc(*(rP4B)sp);
}

void LOCALF fi_midstr(pBIN sp)
{ // midstr
  *(pP4B)(sp + 8) = (P4B)midstr(*(rP4B)sp, *(rI4B)(sp + 4), *(rI4B)(sp + 8));
}

void LOCALF fi_strrepl(pBIN sp)
{ // strrepl
  *(pP4B)(sp + 8) = (P4B)strrepl(*(rP4B)sp, *(rP4B)(sp + 4), *(rP4B)(sp + 8));
}

void LOCALF fi_strconc(pBIN sp)
{ // strconc
  *(pP4B)(sp + 4) = (P4B)strconc(*(rP4B)sp, *(rP4B)(sp + 4));
}

void LOCALF fi_csprintf(pBIN sp)
{ // csprintf
  I4B sz = fmtasz(*(rP4B)(sp + 4));
  I1B bf[LBUF];

  vsprintf_s(bf, LBUF - 1, *(rP4B)(sp + 4), sp + 8);
  *(pI4B)(sp + 4 + sz) = strlen(inscmab(*(pP4B)sp, bf));
}

void LOCALF fi_format(pBIN sp)
{ // format
  I4B sz = fmtasz(*(rP4B)sp);
  I1B bf[LBUF];

  vsprintf_s(bf, LBUF - 1, *(rP4B)sp, sp + 4);
  *(pP4B)(sp + sz) = (P4B)strcpys(talloc(strlen(bf) + 1), bf);
}

void LOCALF fi_cformat(pBIN sp)
{ // cformat
  I4B sz = fmtasz(*(rP4B)sp);
  I1B bf[LBUF];

  vsprintf_s(bf, LBUF - 1, *(rP4B)sp, sp + 4);
  *(pP4B)(sp + sz) = (P4B)inscmab(talloc(strlen(bf) * 4 / 3 + 1), bf);
}

void LOCALF fi_ztoi(pBIN sp)
{ // ztoi
  *(pI4B)sp = ztoi(*(rP4B)sp);
}

void LOCALF fi_ztou(pBIN sp)
{ // ztou
  *(pU4B)sp = ztou(*(rP4B)sp);
}

void LOCALF fi_ztoi64(pBIN sp)
{ // ztoi64
  *(pI8B)(sp - 4) = ztoi64(*(rP4B)sp);
}

void LOCALF fi_ztou64(pBIN sp)
{ // ztou64
  *(pU8B)(sp - 4) = ztou64(*(rP4B)sp);
}

void LOCALF fi_ztof(pBIN sp)
{ // ztof
  *(pF8B)(sp - 4) = ztof(*(rP4B)sp);
}

void LOCALF fi_cztoi(pBIN sp)
{ // cztoi
  *(pI4B)sp = cztoi(*(rP4B)sp);
}

void LOCALF fi_cztou(pBIN sp)
{ // cztou
  *(pU4B)sp = cztou(*(rP4B)sp);
}

void LOCALF fi_cztoi64(pBIN sp)
{ // cztoi64
  *(pI8B)(sp - 4) = cztoi64(*(rP4B)sp);
}

void LOCALF fi_cztou64(pBIN sp)
{ // cztou64
  *(pU8B)(sp - 4) = cztou64(*(rP4B)sp);
}

void LOCALF fi_cztof(pBIN sp)
{ // cztof
  *(pF8B)(sp - 4) = cztof(*(rP4B)sp);
}

void LOCALF fi_is_leap_year(pBIN sp)
{ // is_leap_year
  *(pI4B)sp = is_leap_year(*(rI4B)sp);
}

void LOCALF fi_days_of_month(pBIN sp)
{ // days_of_month
  *(pI4B)(sp + 4) = days_of_month(*(rI4B)sp, *(rI4B)(sp + 4));
}

void LOCALF fi_day_of_week(pBIN sp)
{ // day_of_week
  *(pI4B)(sp + 8) = day_of_week(*(rI4B)sp, *(rI4B)(sp + 4), *(rI4B)(sp + 8));
}

void LOCALF fi_date_serial(pBIN sp)
{ // date_serial
  *(pI4B)(sp + 8) = date_serial(*(rI4B)sp, *(rI4B)(sp + 4), *(rI4B)(sp + 8));
}

void LOCALF fi_year(pBIN sp)
{ // year
  *(pI4B)sp = year(*(rI4B)sp);
}

void LOCALF fi_month(pBIN sp)
{ // month
  *(pI4B)sp = month(*(rI4B)sp);
}

void LOCALF fi_day(pBIN sp)
{ // day
  *(pI4B)sp = day(*(rI4B)sp);
}

void LOCALF fi_youbi(pBIN sp)
{ // youbi
  *(pI4B)sp = youbi(*(rI4B)sp);
}

void LOCALF fi_era_year(pBIN sp)
{ // era_year
  *(pI4B)sp = era_year(*(rI4B)sp);
}

void LOCALF fi_today(pBIN sp)
{ // today
  *(pI4B)(sp - 4) = today();
}

void LOCALF fi_date_diff(pBIN sp)
{ // date_diff
  *(pI4B)(sp + 8) = date_diff(*(rI4B)sp, *(rI4B)(sp + 4), *(rI4B)(sp + 8));
}

void LOCALF fi_ztod(pBIN sp)
{ // ztod
  *(pI4B)sp = ztod(*(rP4B)sp);
}

void LOCALF fi_ztod2(pBIN sp)
{ // ztod2
  *(pI4B)(sp + 4) = ztod2(*(rP4B)sp, *(rI4B)(sp + 4));
}

void LOCALF fi_ztom(pBIN sp)
{ // ztom
  *(pI4B)sp = ztom(*(rP4B)sp);
}

void LOCALF fi_dprintf(pBIN sp)
{ // dprintf
  *(pI4B)(sp + 8) = dprintf(*(pP4B)sp, *(rP4B)(sp + 4), *(rI4B)(sp + 8));
}

void LOCALF fi_dformat(pBIN sp)
{ // dformat
  *(pP4B)(sp + 4) = (P4B)dformat(*(rP4B)sp, *(rI4B)(sp + 4));
}

void LOCALF fi_time_serial(pBIN sp)
{ // time_serial
  *(pI4B)(sp + 8) = time_serial(*(rI4B)sp, *(rI4B)(sp + 4), *(rI4B)(sp + 8));
}

void LOCALF fi_hour(pBIN sp)
{ // hour
  *(pI4B)sp = hour(*(rI4B)sp);
}

void LOCALF fi_minute(pBIN sp)
{ // minute
  *(pI4B)sp = minute(*(rI4B)sp);
}

void LOCALF fi_second(pBIN sp)
{ // second
  *(pI4B)sp = second(*(rI4B)sp);
}

void LOCALF fi_ztot(pBIN sp)
{ // ztot
  *(pI4B)sp = ztot(*(rP4B)sp);
}

void LOCALF fi_tprintf(pBIN sp)
{ // tprintf
  *(pI4B)(sp + 8) = tprintf(*(pP4B)sp, *(rP4B)(sp + 4), *(rI4B)(sp + 8));
}

void LOCALF fi_tformat(pBIN sp)
{ // tformat
  *(pP4B)(sp + 4) = (P4B)tformat(*(rP4B)sp, *(rI4B)(sp + 4));
}

void LOCALF fi_now(pBIN sp)
{ // now
  *(pF8B)(sp - 8) = now();
}

void LOCALF fi_ztodt(pBIN sp)
{ // ztodt
  *(pF8B)(sp - 4) = ztodt(*(rP4B)sp);
}

void LOCALF fi_dtprintf(pBIN sp)
{ // dtprintf
  *(pI4B)(sp +12) = dtprintf(*(pP4B)sp, *(rP4B)(sp + 4), *(rF8B)(sp + 8));
}

void LOCALF fi_dtformat(pBIN sp)
{ // dtformat
  *(pP4B)(sp + 8) = (P4B)dtformat(*(rP4B)sp, *(rF8B)(sp + 4));
}

void LOCALF fi_get_system_time(pBIN sp)
{ // get_system_time
  get_system_time(*(pP4B)sp);
}

void LOCALF fi_get_local_time(pBIN sp)
{ // get_local_time
  get_local_time(*(pP4B)sp);
}

void LOCALF fi_get_tick_count(pBIN sp)
{ // get_tick_count
  *(pU4B)(sp - 4) = get_tick_count();
}

void LOCALF fi_wait_millisec(pBIN sp)
{ // wait_millisec
  wait_millisec(*(rI4B)sp);
}

void LOCALF fi_compare_file_time(pBIN sp)
{ // compare_file_time
  *(pI4B)(sp + 4) = compare_file_time(*(rP4B)sp, *(rP4B)(sp + 4));
}

void LOCALF fi_file_time_to_system_time(pBIN sp)
{ // file_time_to_system_time
  *(pI4B)(sp + 4) = file_time_to_system_time(*(pP4B)sp, *(rP4B)(sp + 4));
}

void LOCALF fi_system_time_to_file_time(pBIN sp)
{ // system_time_to_file_time
  *(pI4B)(sp + 4) = system_time_to_file_time(*(pP4B)sp, *(rP4B)(sp + 4));
}

void LOCALF fi_check_path(pBIN sp)
{ // check_path
  *(pI4B)sp = check_path(*(rP4B)sp);
}

void LOCALF fi_change_path(pBIN sp)
{ // change_path
  *(pP4B)(sp + 8) = change_path(*(pP4B)sp, *(rP4B)(sp + 4), *(rI4B)(sp + 8));
}

void LOCALF fi_open_file(pBIN sp)
{ // open_file
  *(pP4B)(sp + 4) = open_file(*(rP4B)sp, *(rU4B)(sp + 4));
}

void LOCALF fi_close_file(pBIN sp)
{ // close_file
  *(pI4B)sp = close_file(*(rP4B)sp);
}

void LOCALF fi_set_file_ptr(pBIN sp)
{ // set_file_ptr
  *(pU4B)(sp + 8) = set_file_ptr(*(rP4B)sp, *(rI4B)(sp + 4), *(rU4B)(sp + 8));
}

void LOCALF fi_set_end_of_file(pBIN sp)
{ // set_end_of_file
  *(pI4B)sp = set_end_of_file(*(rP4B)sp);
}

void LOCALF fi_get_file_size(pBIN sp)
{ // get_file_size
  *(pU4B)sp = get_file_size(*(rP4B)sp);
}

void LOCALF fi_read_file(pBIN sp)
{ // read_file
  *(pI4B)(sp + 8) = read_file(*(rP4B)sp, *(pP4B)(sp + 4), *(rU4B)(sp + 8));
}

void LOCALF fi_write_file(pBIN sp)
{ // write_file
  *(pI4B)(sp + 8) = write_file(*(rP4B)sp, *(rP4B)(sp + 4), *(rU4B)(sp + 8));
}

void LOCALF fi_read_line(pBIN sp)
{ // read_line
  *(pI4B)(sp + 8) = read_line(*(rP4B)sp, *(pP4B)(sp + 4), *(rI4B)(sp + 8));
}

void LOCALF fi_write_line(pBIN sp)
{ // write_line
  *(pI4B)(sp + 4) = write_line(*(rP4B)sp, *(rP4B)(sp + 4));
}

void LOCALF fi_find_first_file(pBIN sp)
{ // find_first_file
  *(pP4B)(sp + 4) = find_first_file(*(rP4B)sp, *(pP4B)(sp + 4));
}

void LOCALF fi_find_next_file(pBIN sp)
{ // find_next_file
  *(pI4B)(sp + 4) = find_next_file(*(rP4B)sp, *(pP4B)(sp + 4));
}

void LOCALF fi_find_close(pBIN sp)
{ // find_close
  *(pI4B)sp = find_close(*(rP4B)sp);
}

void LOCALF fi_path_exists(pBIN sp)
{ // path_exists
  *(pI4B)sp = path_exists(*(rP4B)sp);
}

void LOCALF fi_file_exists(pBIN sp)
{ // file_exists
  *(pI4B)sp = file_exists(*(rP4B)sp);
}

void LOCALF fi_get_file_info(pBIN sp)
{ // get_file_info
  *(pI4B)(sp + 4) = get_file_info(*(rP4B)sp, *(pP4B)(sp + 4));
}

void LOCALF fi_file_size(pBIN sp)
{ // file_size
  *(pU4B)sp = file_size(*(rP4B)sp);
}

void LOCALF fi_new_file(pBIN sp)
{ // new_file
  *(pI4B)sp = new_file(*(rP4B)sp);
}

void LOCALF fi_new_file_if_not_exists(pBIN sp)
{ // new_file_if_not_exists
  *(pI4B)sp = new_file_if_not_exists(*(rP4B)sp);
}

void LOCALF fi_move_file(pBIN sp)
{ // move_file
  *(pI4B)(sp + 4) = move_file(*(rP4B)sp, *(rP4B)(sp + 4));
}

void LOCALF fi_force_move_file(pBIN sp)
{ // force_move_file
  *(pI4B)(sp + 4) = force_move_file(*(rP4B)sp, *(rP4B)(sp + 4));
}

void LOCALF fi_copy_file(pBIN sp)
{ // copy_file
  *(pI4B)(sp + 4) = copy_file(*(rP4B)sp, *(rP4B)(sp + 4));
}

void LOCALF fi_delete_file(pBIN sp)
{ // delete_file
  *(pI4B)sp = delete_file(*(rP4B)sp);
}

void LOCALF fi_new_path(pBIN sp)
{ // new_path
  *(pI4B)sp = new_path(*(rP4B)sp);
}

void LOCALF fi_new_path_if_not_exists(pBIN sp)
{ // new_path_if_not_exists
  *(pI4B)sp = new_path_if_not_exists(*(rP4B)sp);
}

void LOCALF fi_move_file_to(pBIN sp)
{ // move_file_to
  *(pI4B)(sp + 4) = move_file_to(*(rP4B)sp, *(rP4B)(sp + 4));
}

void LOCALF fi_copy_file_to(pBIN sp)
{ // copy_file_to
  *(pI4B)(sp + 4) = copy_file_to(*(rP4B)sp, *(rP4B)(sp + 4));
}

void LOCALF fi_get_working_path(pBIN sp)
{ // get_working_path
  get_working_path(*(pP4B)sp, *(rI4B)(sp + 4));
}

void LOCALF fi_set_working_path(pBIN sp)
{ // set_working_path
  *(pI4B)sp = set_working_path(*(rP4B)sp);
}

void LOCALF fi_get_user_name(pBIN sp)
{ // get_user_name
  get_user_name(*(pP4B)sp, *(rI4B)(sp + 4));
}

void LOCALF fi_get_computer_name(pBIN sp)
{ // get_computer_name
  get_computer_name(*(pP4B)sp, *(rI4B)(sp + 4));
}

void LOCALF fi_set_error_msg_index_base(pBIN sp)
{ // set_error_message_index_base
  *(pI4B)sp = set_error_message_index_base(*(rI4B)sp);
}

void LOCALF fi_error_msg_index_base(pBIN sp)
{ // error_message_index_base
  *(pI4B)(sp - 4) = error_message_index_base();
}

void LOCALF fi_set_error_log_file(pBIN sp)
{ // set_error_log_file
  set_error_log_file(*(rP4B)sp);
}

void LOCALF fi_error_log_file(pBIN sp)
{ // error_log_file
  *(pP4B)(sp - 4) = (P4B)error_log_file();
}

void LOCALF fi_srchenm(pBIN sp)
{ // srchenm
  *(pI4B)(sp + 4) = srchenm(*(rP4B)sp, *(rP4B)(sp + 4));
}

void LOCALF fi_srchcod(pBIN sp)
{ // srchcod
  *(pI4B)(sp + 4) = srchcod(*(rP4B)sp, *(rP4B)(sp + 4));
}

  // 價儖僩僀儞娭悢
static BFNC fiCOM[1024] = {
  // 000-031
  fi_0,                        fi_sqrt,                     fi_sin,                      fi_cos,
  fi_tan,                      fi_asin,                     fi_acos,                     fi_atan,
  fi_atan2,                    fi_exp,                      fi_pow,                      fi_log,
  fi_log10,                    fi_ceil,                     fi_floor,                    fi_fabs,
  fi_abs,                      fi_atoi,                     fi_atof,                     fi_rand,
  fi_srand,                    fi_calloc,                   fi_malloc,                   fi_realloc,
  fi_free,                     fi_memchr,                   fi_memcmp,                   fi_memcpy,
  fi_memmove,                  fi_memset,                   fi_strchr,                   fi_strcmp,
  // 032-063
  fi_stricmp,                  fi_strncmp,                  fi_strnicmp,                 fi_strcpy,
  fi_strcat,                   fi_strlen,                   fi_strspn,                   fi_strtol,
  fi_strtoul,                  fi_strtod,                   fi_sprintf,                  fi_atoi64,
  fi_strtoi64,                 fi_strtoui64,                fi_0, /* 046 */              fi_0, /* 047 */
  fi_0, /* 048 */              fi_0, /* 049 */              fi_0, /* 050 */              fi_0, /* 051 */
  fi_0, /* 052 */              fi_0, /* 053 */              fi_fopen,                    fi_fclose,
  fi_fprintf,                  fi_0, /* 057 */              fi_0, /* 058 */              fi_0, /* 059 */
  fi_0, /* 060 */              fi_memswap,                  fi_memrotl,                  fi_memrotr,
  // 064-095
  fi_sign,                     fi_iround,                   fi_hash,                     fi_nbound,
  fi_halloc,                   fi_hrealloc,                 fi_hfree,                    fi_0, /* 071 */
  fi_talloc,                   fi_ualloc,                   fi_valloc,                   fi_0, /* 075 */
  fi_idxval,                   fi_srchidx,                  fi_mapval,                   fi_srchmap,
  fi_enmstr,                   fi_srchenm0,                 fi_codstr,                   fi_srchcod0,
  fi_register_error_dsc,       fi_error_dsc,                fi_first_error,              fi_last_error,
  fi_reset_error,              fi_enable_error_reporting,   fi_disable_error_reporting,  fi_enable_error_logging,
  fi_disable_error_logging,    fi_ierr,                     fi_ferr,                     fi_serr,
  // 096-127
  fi_CreateIMG,                fi_DuplicateIMG,             fi_DeleteIMG,                fi_MoveIMG,
  fi_PasteIMG,                 fi_TrimIMG,                  fi_SetXFMQ,                  fi_TransformIMG,
  fi_InvertIMG,                fi_RotateIMG,                fi_ResizeIMGX,               fi_ResizeIMG,
  fi_isspc,                    fi_isctl,                    fi_issym,                    fi_isdig,
  fi_isodig,                   fi_isxdig,                   fi_isupr,                    fi_islwr,
  fi_isalp,                    fi_isalpx,                   fi_isaln,                    fi_isalnx,
  fi_isasc,                    fi_ishan,                    fi_isprn,                    fi_iszen1,
  fi_iszen2,                   fi_iszen,                    fi_isret,                    fi_iszspc,
  // 128-159
  fi_spncpy,                   fi_strcpyn,                  fi_strcpyx,                  fi_nthzen1,
  fi_nthyen,                   fi_mbschr,                   fi_mbsrchr,                  fi_mbslen,
  fi_strmatchx,                fi_strmatch,                 fi_strfindx,                 fi_strfind,
  fi_strlfind,                 fi_strrfind,                 fi_strifind,                 fi_strilfind,
  fi_strirfind,                fi_strlike,                  fi_strmlike,                 fi_strllike,
  fi_strrlike,                 fi_strcount,                 fi_tozenb,                   fi_tohanb,
  fi_touprb,                   fi_tolwrb,                   fi_tohirab,                  fi_tokatab,
  fi_ltrimb,                   fi_rtrimb,                   fi_btrimb,                   fi_delspcb,
  // 160-191
  fi_delctlb,                  fi_ctlspcb,                  fi_cipherb,                  fi_inscmab,
  fi_delcmab,                  fi_extascb,                  fi_midstrb,                  fi_strreplb,
  fi_strconcb,                 fi_tozen,                    fi_tohan,                    fi_toupr,
  fi_tolwr,                    fi_tohira,                   fi_tokata,                   fi_ltrim,
  fi_rtrim,                    fi_btrim,                    fi_delspc,                   fi_delctl,
  fi_ctlspc,                   fi_cipher,                   fi_inscma,                   fi_delcma,
  fi_extasc,                   fi_midstr,                   fi_strrepl,                  fi_strconc,
  fi_sprintf,                  fi_csprintf,                 fi_format,                   fi_cformat,
  // 192-223
  fi_ztoi,                     fi_ztou,                     fi_ztoi64,                   fi_ztou64,
  fi_ztof,                     fi_cztoi,                    fi_cztou,                    fi_cztoi64,
  fi_cztou64,                  fi_cztof,                    fi_strcpy,                   fi_strcat,
  fi_is_leap_year,             fi_days_of_month,            fi_day_of_week,              fi_date_serial,
  fi_year,                     fi_month,                    fi_day,                      fi_youbi,
  fi_era_year,                 fi_today,                    fi_date_diff,                fi_ztod,
  fi_ztod2,                    fi_ztom,                     fi_dprintf,                  fi_dformat,
  fi_time_serial,              fi_hour,                     fi_minute,                   fi_second,
  // 224-255
  fi_ztot,                     fi_tprintf,                  fi_tformat,                  fi_now,
  fi_ztodt,                    fi_dtprintf,                 fi_dtformat,                 fi_get_system_time,
  fi_get_local_time,           fi_get_tick_count,           fi_wait_millisec,            fi_compare_file_time,
  fi_file_time_to_system_time, fi_system_time_to_file_time, fi_check_path,               fi_change_path,
  fi_open_file,                fi_close_file,               fi_set_file_ptr,             fi_set_end_of_file,
  fi_get_file_size,            fi_read_file,                fi_write_file,               fi_read_line,
  fi_write_line,               fi_find_first_file,          fi_find_next_file,           fi_find_close,
  fi_path_exists,              fi_file_exists,              fi_get_file_info,            fi_file_size,
  // 256-283
  fi_new_file,                 fi_new_file_if_not_exists,   fi_move_file,                fi_force_move_file,
  fi_copy_file,                fi_delete_file,              fi_new_path,                 fi_new_path_if_not_exists,
  fi_move_file_to,             fi_copy_file_to,             fi_get_working_path,         fi_set_working_path,
  fi_get_user_name,            fi_get_computer_name,        fi_set_error_msg_index_base, fi_error_msg_index_base,
  fi_set_error_log_file,       fi_error_log_file,           fi_fopen,                    fi_fclose,
  fi_fprintf,                  fi_srchenm,                  fi_srchcod,                  fi_0, /* 279 */
  fi_0, /* 280 */              fi_0,                        fi_0,                        fi_0, /* 283 */
};
static BFNS fsCOM = { fiCOM, 283 + 1 };

BOOL WINAPI RegisterAPIs(rBFNS bf)
{ // 價儖僩僀儞娭悢偺搊榐
  if (fsCOM.ni + bf->ni > _countof(fiCOM)) { return (BOOL)ierr(E_CAP);}
  memcpy(&fsCOM.fn[fsCOM.ni], bf->fn, bf->ni * sizeof(BFNC));
  fsCOM.ni += bf->ni;
  return TRUE;
}

HEXE WINAPI CreateExecEnv(I4B ssz, I4B dsz, I4B esz, rBFNS bf, rCFNS cf)
{ // 僶僀僩僐乕僪幚峴娐嫬嶌惉
  HEXE xe;

  ssz = (ssz + 7) &~7; if (ssz <= 0) { return ierr(E_PAR);}
  dsz = (dsz + 7) &~7; if (dsz < 0)  { return ierr(E_PAR);}
  esz = (esz + 7) &~7; if (esz < 0)  { return ierr(E_PAR);}
  xe = halloc(sizeof(EXEE) + 8 + dsz + 8 + esz + 8 + ssz + 8, TRUE); if (!xe) { return ierr(E_MEM);}
  xe->ds = (pBIN)xe + sizeof(EXEE) + 8;
  xe->de = xe->ds + dsz;
  xe->es = xe->de + 8;
  xe->ee = xe->es + esz;
  xe->ss = xe->ee + 8;
  xe->se = xe->ss + ssz;
  xe->sp = xe->bp = xe->se;
  xe->bf = bf;
  xe->cf = cf;
  return xe;
}

void WINAPI DeleteExecEnv(HEXE xe)
{ // 僶僀僩僐乕僪幚峴娐嫬偺嶍彍
  hfree(xe);
}

HEXE LOCALF MakeExecEnv(pANY pv, U4B sz)
{ // 掕悢幃昡壙梡僶僀僩僐乕僪幚峴娐嫬偺妱傝摉偰
  HEXE xe;

  xe = memset(pv, 0, sz);
  xe->de = xe->ds = (pBIN)xe + sizeof(EXEE) + 8;
  xe->ee = xe->es = xe->de + 8;
  xe->ss = xe->ee + 8;
  xe->se = xe->ss + sz - sizeof(EXEE) - 32;
  xe->sp = xe->bp = xe->se;
  return xe;
}

  // 僆儁儔儞僪挿
static U1B  OSZ[256] = {
  0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  1, 1, 2, 2, 4, 8, 4, 8, 1, 2, 2, 4, 2, 4, 2, 4,
  0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2, 4, 2, 4, 2, 4,
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  0, 1, 2, 4, 0, 0, 2, 2, 0, 1, 2, 4, 0, 0, 2, 2,
  0, 1, 2, 4, 0, 0, 2, 2, 0, 1, 2, 4, 0, 0, 2, 2,
  0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 2,
  0, 1, 2, 4, 0, 0, 0, 0, 0, 1, 2, 4, 0, 0, 4, 0,
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0, 0, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 2, 2,
  0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 2, 2,
};

I4B  WINAPI cmdsiz(I4B oc)
{ // 柦椷挿
  return 1 + OSZ[(U1B)oc];
}

void WINAPI SetExecCS(HEXE xe, rSEGS pc)
{ // 僐乕僪僙僌儊儞僩偺愝掕
  xe->cs = pc->pb;
  xe->ce = pc->pb + pc->sz;
}

void WINAPI SetExecDS(HEXE xe, rSEGS pd, rIDXS pr)
{ // 僨乕僞僙僌儊儞僩偺愝掕
  pI4B pi, pe;
  pBIN pt;

  memcpy(xe->ds, pd->pb, pd->sz);
  for (pi = pr->pi, pe = pi + pr->ni; pi < pe; pi++) {
    pt = xe->ds + *pi;
    switch (*(rU4B)pt & 0xff000000) {
    case TPX_DAT: *(pP4B)pt = xe->ds + (*(rU4B)pt & 0x00ffffff); break;
    case TPX_BSS: *(pP4B)pt = xe->es + (*(rU4B)pt & 0x00ffffff); break;
    default: ierr(E_BCD);
    }
  }
}

void LOCALF CallExecM(HEXE xe, I4B ofs, I4B asz, I4B bsz);

void LOCALF CallExecM(HEXE xe, I4B ofs, I4B asz, I4B bsz)
{ // 僶僀僩僐乕僪幚峴
  I4B ax, bx, cx, re = 0;
  pBIN px, bp = xe->sp, cp = xe->cs + ofs, sp = bp - bsz;
  F8B fx;
  pCFNI fn;

  while (!re) {
    switch (*cp++) {
    case drp_i:   sp += 4; break;
    case drp_d:   sp += 8; break;
    case swp_i:   ax = *(rI4B)sp; *(pI4B)sp = *(rI4B)(sp + 4); *(pI4B)(sp + 4) = ax; break;
    case swp_d:   fx = *(rF8B)sp; *(pF8B)sp = *(rF8B)(sp + 8); *(pF8B)(sp + 8) = fx; break;
    case swp_d_i: ax = *(rI4B)sp; *(pF8B)sp = *(rF8B)(sp + 4); *(pI4B)(sp + 8) = ax; break;
    case swp_i_d: fx = *(rF8B)sp; *(pI4B)sp = *(rI4B)(sp + 8); *(pF8B)(sp + 4) = fx; break;
    case swp_b:   *(pI4B)sp = SWAP1B(*(rU4B)sp); break;
    case swp_w:   *(pI4B)sp = SWAP2B(*(rU4B)sp); break;
    case dup_i:   *(pI4B)(sp - 4) = *(rI4B)sp; sp -= 4; break;
    case dup_d:   *(pF8B)(sp - 8) = *(rF8B)sp; sp -= 8; break;
    case psh_i_0: *(pI4B)(sp -= 4) = 0; break;
    case psh_d_0: *(pF8B)(sp -= 8) = 0.0; break;
    case psh_c:   *(pI4B)(sp -= 4) = *((rI1B)cp)++; break;
    case psh_b:   *(pI4B)(sp -= 4) = *((rU1B)cp)++; break;
    case psh_s:   *(pI4B)(sp -= 4) = *((rI2B)cp)++; break;
    case psh_w:   *(pI4B)(sp -= 4) = *((rU2B)cp)++; break;
    case psh_i:   *(pI4B)(sp -= 4) = *((rI4B)cp)++; break;
    case psh_l:   *(pI8B)(sp -= 8) = *((rI8B)cp)++; break;
    case psh_f:   *(pF8B)(sp -= 8) = *((rF4B)cp)++; break;
    case psh_d:   *(pF8B)(sp -= 8) = *((rF8B)cp)++; break;
    case bfn_b:   *(pI4B)(sp -= 4) = NSX_BFN | *((rU1B)cp)++; break;
    case bfn_w:   *(pI4B)(sp -= 4) = NSX_BFN | *((rU2B)cp)++; break;
    case psh_bs:  *(pP4B)(sp -= 4) = bp - *((rI2B)cp)++; break;
    case psh_bi:  *(pP4B)(sp -= 4) = bp - *((rI4B)cp)++; break;
    case psh_dw:  *(pP4B)(sp -= 4) = xe->ds + *((rU2B)cp)++; break;
    case psh_du:  *(pP4B)(sp -= 4) = xe->ds + *((rU4B)cp)++; break;
    case psh_ew:  *(pP4B)(sp -= 4) = xe->es + *((rU2B)cp)++; break;
    case psh_eu:  *(pP4B)(sp -= 4) = xe->es + *((rU4B)cp)++; break;
    case fch_c:   *(pI4B)sp = *(rI1B)*(rP4B)sp; break;
    case fch_b:   *(pI4B)sp = *(rU1B)*(rP4B)sp; break;
    case fch_s:   *(pI4B)sp = *(rI2B)*(rP4B)sp; break;
    case fch_w:   *(pI4B)sp = *(rU2B)*(rP4B)sp; break;
    case fch_i:   *(pI4B)sp = *(rI4B)*(rP4B)sp; break;
    case fch_l:   *(pI8B)(sp - 4) = *(rI8B)*(rP4B)sp; sp -= 4; break;
    case fch_f:   *(pF8B)(sp - 4) = *(rF4B)*(rP4B)sp; sp -= 4; break;
    case fch_d:   *(pF8B)(sp - 4) = *(rF8B)*(rP4B)sp; sp -= 4; break;
    case cfn_b:   *(pI4B)(sp -= 4) = NSX_CFN | *((rU1B)cp)++; break;
    case cfn_w:   *(pI4B)(sp -= 4) = NSX_CFN | *((rU2B)cp)++; break;
    case fch_bs:  *(pI4B)(sp -= 4) = *(rI4B)(bp - *((rI2B)cp)++); break;
    case fch_bi:  *(pI4B)(sp -= 4) = *(rI4B)(bp - *((rI4B)cp)++); break;
    case fch_dw:  *(pI4B)(sp -= 4) = *(rI4B)(xe->ds + *((rU2B)cp)++); break;
    case fch_du:  *(pI4B)(sp -= 4) = *(rI4B)(xe->ds + *((rU4B)cp)++); break;
    case fch_ew:  *(pI4B)(sp -= 4) = *(rI4B)(xe->es + *((rU2B)cp)++); break;
    case fch_eu:  *(pI4B)(sp -= 4) = *(rI4B)(xe->es + *((rU4B)cp)++); break;
    case sto_c:   *(pI4B)(sp + 4) = *(pI1B)*(pP4B)(sp + 4) = (I1B)*(rI4B)sp; sp += 4; break;
    case sto_s:   *(pI4B)(sp + 4) = *(pI2B)*(pP4B)(sp + 4) = (I2B)*(rI4B)sp; sp += 4; break;
    case sto_i:   *(pI4B)(sp + 4) = *(pI4B)*(pP4B)(sp + 4) = *(rI4B)sp; sp += 4; break;
    case sto_l:   *(pI8B)(sp + 4) = *(pI8B)*(pP4B)(sp + 8) = *(rI8B)sp; sp += 4; break;
    case sto_f:   *(pF8B)(sp + 4) = *(pF4B)*(pP4B)(sp + 8) = (F4B)*(rF8B)sp; sp += 4; break;
    case sto_d:   *(pF8B)(sp + 4) = *(pF8B)*(pP4B)(sp + 8) = *(rF8B)sp; sp += 4; break;
    case sto_c_v: *(pI1B)*(pP4B)(sp + 4) = (I1B)*(rI4B)sp; sp += 8; break;
    case sto_s_v: *(pI2B)*(pP4B)(sp + 4) = (I2B)*(rI4B)sp; sp += 8; break;
    case sto_i_v: *(pI4B)*(pP4B)(sp + 4) = *(rI4B)sp; sp += 8; break;
    case sto_l_v: *(pI8B)*(pP4B)(sp + 8) = *(rI8B)sp; sp += 12; break;
    case sto_f_v: *(pF4B)*(pP4B)(sp + 8) = (F4B)*(rF8B)sp; sp += 12; break;
    case sto_d_v: *(pF8B)*(pP4B)(sp + 8) = *(rF8B)sp; sp += 12; break;
    case add_i:   *(pI4B)(sp + 4) += *(rI4B)sp; sp += 4; break;
    case add_i_b: *(pI4B)sp += *((rU1B)cp)++; break;
    case add_i_w: *(pI4B)sp += *((rU2B)cp)++; break;
    case add_i_i: *(pI4B)sp += *((rI4B)cp)++; break;
    case add_l:   *(pI8B)(sp + 8) += *(rI8B)sp; sp += 8; break;
    case add_d:   *(pF8B)(sp + 8) += *(rF8B)sp; sp += 8; break;
    case add_p_i: *(pI4B)(sp + 4) += *(rI4B)sp * *((rU2B)cp)++; sp += 4; break;
    case add_i_p: *(pI4B)(sp + 4) = *(pI4B)sp + (*(rI4B)(sp + 4) * *((rU2B)cp)++); sp += 4; break;
    case mul_i:   *(pI4B)(sp + 4) *= *(rI4B)sp; sp += 4; break;
    case mul_i_b: *(pI4B)sp *= *((rU1B)cp)++; break;
    case mul_i_w: *(pI4B)sp *= *((rU2B)cp)++; break;
    case mul_i_i: *(pI4B)sp *= *((rI4B)cp)++; break;
    case mul_l:   *(pI8B)(sp + 8) *= *(rI8B)sp; sp += 8; break;
    case mul_d:   *(pF8B)(sp + 8) *= *(rF8B)sp; sp += 8; break;
    case jeq_i_0: ax = (*(rI4B)sp == 0); cp += 2 + ax * *(rI2B)cp; sp += 4; break;
    case jne_i_0: ax = (*(rI4B)sp != 0); cp += 2 + ax * *(rI2B)cp; sp += 4; break;
    case sub_i:   *(pI4B)(sp + 4) -= *(rI4B)sp; sp += 4; break;
    case sub_i_b: *(pI4B)sp -= *((rU1B)cp)++; break;
    case sub_i_w: *(pI4B)sp -= *((rU2B)cp)++; break;
    case sub_i_i: *(pI4B)sp -= *((rI4B)cp)++; break;
    case sub_l:   *(pI8B)(sp + 8) -= *(rI8B)sp; sp += 8; break;
    case sub_d:   *(pF8B)(sp + 8) -= *(rF8B)sp; sp += 8; break;
    case sub_p_i: *(pI4B)(sp + 4) -= *(rI4B)sp * *((rU2B)cp)++; sp += 4; break;
    case sub_p:   *(pI4B)(sp + 4) = ((rBIN)*(pP4B)(sp + 4) - (rBIN)*(pP4B)sp) / *((rU2B)cp)++; sp += 4; break;
    case div_i:   *(pI4B)(sp + 4) /= *(rI4B)sp; sp += 4; break;
    case div_i_b: *(pI4B)sp /= *((rU1B)cp)++; break;
    case div_i_w: *(pI4B)sp /= *((rU2B)cp)++; break;
    case div_i_i: *(pI4B)sp /= *((rI4B)cp)++; break;
    case div_l:   *(pI8B)(sp + 8) /= *(rI8B)sp; sp += 8; break;
    case div_d:   *(pF8B)(sp + 8) /= *(rF8B)sp; sp += 8; break;
    case jan_i:   ax = (*(rI4B)sp == 0); cp += 2 + ax * *(rI2B)cp; sp += !ax * 4; break;
    case jor_i:   ax = (*(rI4B)sp != 0); cp += 2 + ax * *(rI2B)cp; sp += !ax * 4; break;
    case shr_i:   *(pI4B)(sp + 4) >>= *(rI4B)sp; sp += 4; break;
    case shr_i_b: *(pI4B)sp >>= *((rI1B)cp)++; break;
    case shr_u:   *(pU4B)(sp + 4) >>= *(rU4B)sp; sp += 4; break;
    case shr_u_b: *(pU4B)sp >>= *((rU1B)cp)++; break;
    case shr_l:   *(pI8B)(sp + 8) >>= *(rI8B)sp; sp += 8; break;
    case shr_q:   *(pU8B)(sp + 8) >>= *(rU8B)sp; sp += 8; break;
    case not_i:   *(pI4B)sp = ~(*(rI4B)sp); break;
    case not_l:   *(pI8B)sp = ~(*(rI8B)sp); break;
    case shl_i:   *(pI4B)(sp + 4) <<= *(rI4B)sp; sp += 4; break;
    case shl_i_b: *(pI4B)sp <<= *((rU1B)cp)++; break;
    case shl_l:   *(pI8B)(sp + 8) <<= *(rI8B)sp; sp += 8; break;
    case mod_i:   *(pI4B)(sp + 4) %= *(rI4B)sp; sp += 4; break;
    case mod_i_b: *(pI4B)sp %= *((rU1B)cp)++; break;
    case mod_l:   *(pI8B)(sp + 8) %= *(rI8B)sp; sp += 8; break;
    case nop_v:   break;
    case jmp_v:   cp += 2 + *(rI2B)cp; break;
    case and_i:   *(pI4B)(sp + 4) &= *(rI4B)sp; sp += 4; break;
    case and_i_b: *(pI4B)sp &= *((rU1B)cp)++; break;
    case and_i_w: *(pI4B)sp &= *((rU2B)cp)++; break;
    case and_i_i: *(pI4B)sp &= *((rI4B)cp)++; break;
    case and_l:   *(pI8B)(sp + 8) &= *(rI8B)sp; sp += 8; break;
    case neg_i:   *(pI4B)sp = -(*(rI4B)sp); break;
    case neg_l:   *(pI8B)sp = -(*(rI8B)sp); break;
    case neg_d:   *(pF8B)sp = -(*(rF8B)sp); break;
    case or_i:    *(pI4B)(sp + 4) |= *(rI4B)sp; sp += 4; break;
    case or_i_b:  *(pI4B)sp |= *((rU1B)cp)++; break;
    case or_i_w:  *(pI4B)sp |= *((rU2B)cp)++; break;
    case or_i_i:  *(pI4B)sp |= *((rI4B)cp)++; break;
    case or_l:    *(pI8B)(sp + 8) |= *(rI8B)sp; sp += 8; break;
    case xor_i:   *(pI4B)(sp + 4) ^= *(rI4B)sp; sp += 4; break;
    case xor_i_i: *(pI4B)sp ^= *((rI4B)cp)++; break;
    case xor_l:   *(pI8B)(sp + 8) ^= *(rI8B)sp; sp += 8; break;
    case cnv_i_c: *(pI4B)sp = (I1B)*(rI4B)sp; break;
    case cnv_i_b: *(pI4B)sp = (U1B)*(rI4B)sp; break;
    case cnv_i_s: *(pI4B)sp = (I2B)*(rI4B)sp; break;
    case cnv_i_w: *(pI4B)sp = (U2B)*(rI4B)sp; break;
    case cnv_i_l: *(pI8B)(sp - 4) = (I8B)*(rI4B)sp; sp -= 4; break;
    case cnv_i_d: *(pF8B)(sp - 4) = (F8B)*(rI4B)sp; sp -= 4; break;
    case cnv_u_l: *(pI8B)(sp - 4) = (I8B)*(rU4B)sp; sp -= 4; break;
    case cnv_u_d: *(pF8B)(sp - 4) = (F8B)*(rU4B)sp; sp -= 4; break;
    case cnv_l_c: *(pI4B)(sp + 4) = (I1B)*(rI8B)sp; sp += 4; break;
    case cnv_l_b: *(pI4B)(sp + 4) = (U1B)*(rI8B)sp; sp += 4; break;
    case cnv_l_s: *(pI4B)(sp + 4) = (I2B)*(rI8B)sp; sp += 4; break;
    case cnv_l_w: *(pI4B)(sp + 4) = (U2B)*(rI8B)sp; sp += 4; break;
    case cnv_l_i: *(pI4B)(sp + 4) = (I4B)*(rI8B)sp; sp += 4; break;
    case cnv_l_u: *(pU4B)(sp + 4) = (U4B)*(rI8B)sp; sp += 4; break;
    case cnv_l_d: *(pF8B)sp = (F8B)*(rI8B)sp; break;
    case cnv_q_d: *(pF8B)sp = (F8B)*(rU8B)sp; break;
    case cnv_d_c: *(pI4B)(sp + 4) = (I1B)*(rF8B)sp; sp += 4; break;
    case cnv_d_b: *(pI4B)(sp + 4) = (U1B)*(rF8B)sp; sp += 4; break;
    case cnv_d_s: *(pI4B)(sp + 4) = (I2B)*(rF8B)sp; sp += 4; break;
    case cnv_d_w: *(pI4B)(sp + 4) = (U2B)*(rF8B)sp; sp += 4; break;
    case cnv_d_i: *(pI4B)(sp + 4) = (I4B)*(rF8B)sp; sp += 4; break;
    case cnv_d_u: *(pU4B)(sp + 4) = (U4B)*(rF8B)sp; sp += 4; break;
    case cnv_d_l: *(pI8B)sp = (I8B)*(rF8B)sp; break;
    case cnv_d_q: *(pU8B)sp = (U8B)*(rF8B)sp; break;
    case hib_i:   *(pI4B)sp = *(rU1B)(sp + 1); break;
    case hiw_i:   *(pI4B)sp = *(rU2B)(sp + 2); break;
    case mkw_i:   *(pI4B)(sp + 4) = MKU2B(*(rI4B)(sp + 4), *(rI4B)sp); sp += 4; break;
    case mku_i:   *(pI4B)(sp + 4) = MKU4B(*(rI4B)(sp + 4), *(rI4B)sp); sp += 4; break;
    case chk_b:   *(pI4B)sp = ISU1B(*(rI4B)sp); break;
    case chk_w:   *(pI4B)sp = ISU2B(*(rI4B)sp); break;
    case chk_c:   *(pI4B)sp = ISI1BN(*(rI4B)sp); break;
    case chk_s:   *(pI4B)sp = ISI2BN(*(rI4B)sp); break;
    case lt_i:    *(pI4B)(sp + 4) = (*(rI4B)(sp + 4) < *(rI4B)sp); sp += 4; break;
    case lt_u:    *(pI4B)(sp + 4) = (*(rU4B)(sp + 4) < *(rU4B)sp); sp += 4; break;
    case lt_l:    *(pI4B)(sp +12) = (*(rI8B)(sp + 8) < *(rI8B)sp); sp +=12; break;
    case lt_q:    *(pI4B)(sp +12) = (*(rU8B)(sp + 8) < *(rU8B)sp); sp +=12; break;
    case lt_d:    *(pI4B)(sp +12) = (*(rF8B)(sp + 8) < *(rF8B)sp); sp +=12; break;
    case lt_i_0:  *(pI4B)sp = (*(rI4B)sp < 0); break;
    case lt_l_0:  *(pI4B)(sp + 4) = (*(rI8B)sp < 0LL); sp += 4; break;
    case lt_d_0:  *(pI4B)(sp + 4) = (*(rF8B)sp < 0.0); sp += 4; break;
    case le_i:    *(pI4B)(sp + 4) = (*(rI4B)(sp + 4) <= *(rI4B)sp); sp += 4; break;
    case le_u:    *(pI4B)(sp + 4) = (*(rU4B)(sp + 4) <= *(rU4B)sp); sp += 4; break;
    case le_l:    *(pI4B)(sp +12) = (*(rI8B)(sp + 8) <= *(rI8B)sp); sp +=12; break;
    case le_q:    *(pI4B)(sp +12) = (*(rU8B)(sp + 8) <= *(rU8B)sp); sp +=12; break;
    case le_d:    *(pI4B)(sp +12) = (*(rF8B)(sp + 8) <= *(rF8B)sp); sp +=12; break;
    case le_i_0:  *(pI4B)sp = (*(rI4B)sp <= 0); break;
    case le_l_0:  *(pI4B)(sp + 4) = (*(rI8B)sp <= 0LL); sp += 4; break;
    case le_d_0:  *(pI4B)(sp + 4) = (*(rF8B)sp <= 0.0); sp += 4; break;
    case gt_i:    *(pI4B)(sp + 4) = (*(rI4B)(sp + 4) > *(rI4B)sp); sp += 4; break;
    case gt_u:    *(pI4B)(sp + 4) = (*(rU4B)(sp + 4) > *(rU4B)sp); sp += 4; break;
    case gt_l:    *(pI4B)(sp +12) = (*(rI8B)(sp + 8) > *(rI8B)sp); sp +=12; break;
    case gt_q:    *(pI4B)(sp +12) = (*(rU8B)(sp + 8) > *(rU8B)sp); sp +=12; break;
    case gt_d:    *(pI4B)(sp +12) = (*(rF8B)(sp + 8) > *(rF8B)sp); sp +=12; break;
    case gt_i_0:  *(pI4B)sp = (*(rI4B)sp > 0); break;
    case gt_l_0:  *(pI4B)(sp + 4) = (*(rI8B)sp > 0LL); sp += 4; break;
    case gt_d_0:  *(pI4B)(sp + 4) = (*(rF8B)sp > 0.0); sp += 4; break;
    case ge_i:    *(pI4B)(sp + 4) = (*(rI4B)(sp + 4) >= *(rI4B)sp); sp += 4; break;
    case ge_u:    *(pI4B)(sp + 4) = (*(rU4B)(sp + 4) >= *(rU4B)sp); sp += 4; break;
    case ge_l:    *(pI4B)(sp +12) = (*(rI8B)(sp + 8) >= *(rI8B)sp); sp +=12; break;
    case ge_q:    *(pI4B)(sp +12) = (*(rU8B)(sp + 8) >= *(rU8B)sp); sp +=12; break;
    case ge_d:    *(pI4B)(sp +12) = (*(rF8B)(sp + 8) >= *(rF8B)sp); sp +=12; break;
    case ge_i_0:  *(pI4B)sp = (*(rI4B)sp >= 0); break;
    case ge_l_0:  *(pI4B)(sp + 4) = (*(rI8B)sp >= 0LL); sp += 4; break;
    case ge_d_0:  *(pI4B)(sp + 4) = (*(rF8B)sp >= 0.0); sp += 4; break;
    case eq_i:    *(pI4B)(sp + 4) = (*(rI4B)(sp + 4) == *(rI4B)sp); sp += 4; break;
    case eq_l:    *(pI4B)(sp +12) = (*(rI8B)(sp + 8) == *(rI8B)sp); sp +=12; break;
    case eq_d:    *(pI4B)(sp +12) = (*(rF8B)(sp + 8) == *(rF8B)sp); sp +=12; break;
    case eq_i_0:  *(pI4B)sp = (*(rI4B)sp == 0); break;
    case eq_d_0:  *(pI4B)(sp + 4) = (*(rF8B)sp == 0.0); sp += 4; break;
    case fnc_v:   cx = 0; goto _10;
    case fnc_i:   cx = 4; goto _10;
    case fnc_d:   cx = 8; _10:
      ax = *((rU2B)cp)++; bx = *(rI4B)sp; sp += 4; xe->sp = sp;
      switch (bx & 0xffff0000) {
      case NSX_BFN: xe->bf->fn[(U2B)bx](sp); break;
      case NSX_CFN: fn = &xe->cf->fn[(U2B)bx]; CallExecM(xe, fn->ofs, ax, fn->bsz); break;
      default: re = E_ORD; break;
      }
      sp += ax - cx; break;
    case ne_i:    *(pI4B)(sp + 4) = (*(rI4B)(sp + 4) != *(rI4B)sp); sp += 4; break;
    case ne_l:    *(pI4B)(sp +12) = (*(rI8B)(sp + 8) != *(rI8B)sp); sp +=12; break;
    case ne_d:    *(pI4B)(sp +12) = (*(rF8B)(sp + 8) != *(rF8B)sp); sp +=12; break;
    case ne_i_0:  *(pI4B)sp = (*(rI4B)sp != 0); break;
    case ne_d_0:  *(pI4B)(sp + 4) = (*(rF8B)sp != 0.0); sp += 4; break;
    case ret_v:   sp = bp + asz; re = TRUE; break;
    case ret_i:   px = bp + asz - 4; *(pI4B)px = *(rI4B)sp; sp = px; re = TRUE; break;
    case ret_d:   px = bp + asz - 8; *(pF8B)px = *(rF8B)sp; sp = px; re = TRUE; break;
    case inc_c:   *(pI4B)sp = ++*(pI1B)*(pP4B)sp; break;
    case inc_s:   *(pI4B)sp = ++*(pI2B)*(pP4B)sp; break;
    case inc_i:   *(pI4B)sp = ++*(pI4B)*(pP4B)sp; break;
    case inc_l:   *(pI8B)(sp - 4) = ++*(pI8B)*(pP4B)sp; sp -= 4; break;
    case inc_f:   *(pF8B)(sp - 4) = ++*(pF4B)*(pP4B)sp; sp -= 4; break;
    case inc_d:   *(pF8B)(sp - 4) = ++*(pF8B)*(pP4B)sp; sp -= 4; break;
    case inc_p:   *(pI4B)sp = *(pI4B)*(pP4B)sp += *((rU2B)cp)++; break;
    case inc_i_i: px = *(pP4B)sp; *(pI4B)sp = *(rI4B)px; (*(pI4B)px)++; break;
    case inc_c_v: ++*(pI1B)*(pP4B)sp; sp += 4; break;
    case inc_s_v: ++*(pI2B)*(pP4B)sp; sp += 4; break;
    case inc_i_v: ++*(pI4B)*(pP4B)sp; sp += 4; break;
    case inc_l_v: ++*(pI8B)*(pP4B)sp; sp += 4; break;
    case inc_f_v: ++*(pF4B)*(pP4B)sp; sp += 4; break;
    case inc_d_v: ++*(pF8B)*(pP4B)sp; sp += 4; break;
    case inc_p_v: *(pI4B)*(pP4B)sp += *((rU2B)cp)++; sp += 4; break;
    case inc_p_p: px = *(rP4B)sp; *(pP4B)sp = *(rP4B)px; *(pI4B)px += *((rU2B)cp)++; break;
    case dec_c:   *(pI4B)sp = --*(pI1B)*(pP4B)sp; break;
    case dec_s:   *(pI4B)sp = --*(pI2B)*(pP4B)sp; break;
    case dec_i:   *(pI4B)sp = --*(pI4B)*(pP4B)sp; break;
    case dec_l:   *(pI8B)(sp - 4) = --*(pI8B)*(pP4B)sp; sp -= 4; break;
    case dec_f:   *(pF8B)(sp - 4) = --*(pF4B)*(pP4B)sp; sp -= 4; break;
    case dec_d:   *(pF8B)(sp - 4) = --*(pF8B)*(pP4B)sp; sp -= 4; break;
    case dec_p:   *(pI4B)sp = *(pI4B)*(pP4B)sp -= *((rU2B)cp)++; break;
    case dec_i_i: px = *(pP4B)sp; *(pI4B)sp = *(rI4B)px; (*(pI4B)px)--; break;
    case dec_c_v: --*(pI1B)*(pP4B)sp; sp += 4; break;
    case dec_s_v: --*(pI2B)*(pP4B)sp; sp += 4; break;
    case dec_i_v: --*(pI4B)*(pP4B)sp; sp += 4; break;
    case dec_l_v: --*(pI8B)*(pP4B)sp; sp += 4; break;
    case dec_f_v: --*(pF4B)*(pP4B)sp; sp += 4; break;
    case dec_d_v: --*(pF8B)*(pP4B)sp; sp += 4; break;
    case dec_p_v: *(pI4B)*(pP4B)sp -= *((rU2B)cp)++; sp += 4; break;
    case dec_p_p: px = *(rP4B)sp; *(pP4B)sp = *(rP4B)px; *(pI4B)px -= *((rU2B)cp)++; break;
    default: re = E_OPC; break;
    }
    if (sp <= xe->ss || sp > xe->se) { re = E_STK;}
    if (re > TRUE) { ierr(re);}
  }
  xe->sp = sp;
}

void WINAPI CallExecX(pANY pv, HEXE xe, I4B ofs, rANY arg, I4B asz, I4B bsz)
{ // 僆僼僙僢僩巜掕偱儐乕僓乕掕媊娭悢屇傃弌偟
  xe->sp = xe->bp;
  if (asz) { memcpy(xe->sp -= asz, arg, asz);}
  CallExecM(xe, ofs, asz, bsz);
  switch (xe->bp - xe->sp) {
  case 0: return;
  case 4: *(pI4B)pv = *(rI4B)xe->sp; break;
  case 8: *(pF8B)pv = *(rF8B)xe->sp; break;
  default: ierr(E_EXE); break;
  }
}

void WINAPI CallExecV(pANY pv, HEXE xe, I4B ent, rANY arg, I4B asz)
{ // 彉悢巜掕偱儐乕僓乕掕媊娭悢屇傃弌偟(壜曄堷悢)
  pCFNI fn = &xe->cf->fn[(U2B)ent]; CallExecX(pv, xe, fn->ofs, arg, asz, fn->bsz);
}

void WINAPI CallExec(pANY pv, HEXE xe, I4B ent, rANY arg)
{ // 彉悢巜掕偱儐乕僓乕掕媊娭悢屇傃弌偟(屌掕堷悢)
  pCFNI fn = &xe->cf->fn[(U2B)ent]; CallExecX(pv, xe, fn->ofs, arg, fn->asz, fn->bsz);
}

I4B  LOCALF maxord(rSEGS pc)
{ // 彉悢偺嵟戝抣
  I4B mx = 0;
  rBIN cp, ce;

  for (cp = pc->pb, ce = cp + pc->sz; cp < ce; cp += cmdsiz(*cp)) {
    if (*cp == ent_w) {
      if (*(rU2B)(cp+1) > mx) { mx = *(rU2B)(cp+1);}
    }
  }
  return mx;
}

void LOCALF SetCFNS(pCFNS cf, rSEGS pc)
{ // 娭悢僥乕僽儖崁栚偺愝掕
  rBIN cp, ce;
  pCFNI fn;

  for (cp = pc->pb, ce = cp + pc->sz; cp < ce; cp += cmdsiz(*cp)) {
    if (*cp == ent_w) {
      fn = &cf->fn[*(rU2B)(cp+1)];
      fn->ofs = cp - pc->pb + cmdsiz(ent_w);
      fn->asz = *(rU2B)(cp+3);
      fn->bsz = *(rU2B)(cp+5);
    }
  }
}

HBCD WINAPI CreateBCD(I4B app, I4B pro, I4B ent, I4B ssz, rSEGS pc, rSEGS pd, I4B esz, rIDXS pr)
{ // 僶僀僩僐乕僪嶌惉
  HBCD hb;

  hb = halloc(sizeof(BCDE), TRUE); if (!hb) { return ierr(E_MEM);}
  hb->app = app;
  hb->pro = pro;
  hb->ent = ent;
  hb->ssz = ssz? ssz: DEFSSZ;
  if (pc && pc->sz > 0) {
    hb->cs.sz = pc->sz;
    hb->cs.pb = halloc(pc->sz, FALSE); if (!hb->cs.pb) { ierr(E_MEM); goto _30;}
    memcpy(hb->cs.pb, pc->pb, pc->sz);
  }
  if (pd && pd->sz > 0) {
    hb->ds.sz = pd->sz;
    hb->ds.pb = halloc(pd->sz, FALSE); if (!hb->ds.pb) { ierr(E_MEM); goto _20;}
    memcpy(hb->ds.pb, pd->pb, pd->sz);
  }
  hb->esz = esz;
  if (pr && pr->ni > 0) {
    hb->rs.ni = pr->ni;
    hb->rs.pi = halloc(pr->ni * sizeof(I4B), FALSE); if (!hb->rs.pi) { ierr(E_MEM); goto _10;}
    memcpy(hb->rs.pi, pr->pi, pr->ni * sizeof(I4B));
  }
  return hb;

 _10: hfree(hb->ds.pb);
 _20: hfree(hb->cs.pb);
 _30: hfree(hb);
  return NULL;
}

void WINAPI DeleteBCD(HBCD hb)
{ // 僶僀僩僐乕僪偺嶍彍
  if (!hb) return;
  DeleteExecEnv(hb->xe);
  hfree(hb->fs.fn);
  hfree(hb->rs.pi);
  hfree(hb->ds.pb);
  hfree(hb->cs.pb);
  hfree(hb);
}

BOOL WINAPI AttachBCD(HBCD hb)
{ // 僶僀僩僐乕僪傪幚峴壜擻偵偡傞
  hb->fs.ni = maxord(&hb->cs) + 1;
  hb->fs.fn = halloc(hb->fs.ni * sizeof(CFNI), TRUE); if (!hb->fs.fn) { return (BOOL)ierr(E_MEM);}
  SetCFNS(&hb->fs, &hb->cs);
  hb->xe = CreateExecEnv(hb->ssz, hb->ds.sz, hb->esz, &fsCOM, &hb->fs);
  if (!hb->xe) { hfree(hb->fs.fn); return FALSE;}
  SetExecCS(hb->xe, &hb->cs);
  if (hb->ds.pb) { SetExecDS(hb->xe, &hb->ds, &hb->rs);}
  return TRUE;
}

BOOL WINAPI ReadBCDHeader(pBCDH ph, rSTR nam)
{ // 僶僀僩僐乕僪僼傽僀儖僿僢僟撉崬
  I4B re;
  HFIL hf;

  hf = open_file(nam, OP_RDO); if (!hf) return FALSE;
  re = read_file(hf, ph, sizeof(BCDH));
  close_file(hf);
  return re;
}

#define  SEG_COD  1
#define  SEG_DAT  2
#define  SEG_BSS  3
#define  SEG_REL  4

  // 僶僀僩僐乕僪僙僌儊儞僩僿僢僟
typedef struct {
  I4B   seg;
  I4B   len;
} SEGH;

HBCD WINAPI LoadBCD(rSTR nam, I4B app, I4B pro, I4B ssz)
{ // 僶僀僩僐乕僪僼傽僀儖撉崬
  I4B re;
  HFIL hf;
  HBCD hb;
  BCDH bhd;
  SEGH shd;

  hb = CreateBCD(0, 0, 0, ssz, NULL, NULL, 0, NULL); if (!hb) return NULL;
  hf = open_file(nam, OP_RDO); if (!hf) { ferr(E_FIR, nam); goto _50;}
  re = read_file(hf, &bhd, sizeof(BCDH)); if (!re) { ferr(E_FIR, nam); goto _40;}
  if (app != 0 && LOU2B(bhd.app) != LOU2B(app)) { ierr(E_BCD); goto _40;}
  if (app != 0 && HIU2B(bhd.app) != HIU2B(app)) { ierr(E_VER); goto _40;}
  if (pro != 0 && bhd.pro != pro) { ierr(E_PRO); goto _40;}
  hb->app = bhd.app;
  hb->pro = bhd.pro;
  hb->ent = bhd.ent;
  re = read_file(hf, &shd, sizeof(SEGH)); if (!re) { ferr(E_FIR, nam); goto _40;}
  if (shd.seg != SEG_COD) { ierr(E_BCD); goto _40;}
  if (shd.len > 0) {
    hb->cs.sz = shd.len;
    hb->cs.pb = halloc(shd.len, FALSE); if (!hb->cs.pb) { ierr(E_MEM); goto _40;}
    re = read_file(hf, hb->cs.pb, shd.len); if (!re) { ferr(E_FIR, nam); goto _30;}
  } else { ierr(E_BCD); goto _40;}
  re = read_file(hf, &shd, sizeof(SEGH)); if (!re) { ferr(E_FIR, nam); goto _30;}
  if (shd.seg != SEG_DAT) { ierr(E_BCD); goto _30;}
  if (shd.len > 0) {
    hb->ds.sz = shd.len;
    hb->ds.pb = halloc(shd.len, FALSE); if (!hb->ds.pb) { ierr(E_MEM); goto _30;}
    re = read_file(hf, hb->ds.pb, shd.len); if (!re) { ferr(E_FIR, nam); goto _20;}
  }
  re = read_file(hf, &shd, sizeof(SEGH)); if (!re) { ferr(E_FIR, nam); goto _20;}
  if (shd.seg != SEG_BSS) { ierr(E_BCD); goto _20;}
  hb->esz = shd.len;
  re = read_file(hf, &shd, sizeof(SEGH)); if (!re) { ferr(E_FIR, nam); goto _20;}
  if (shd.seg != SEG_REL) { ierr(E_BCD); goto _20;}
  if (shd.len > 0) {
    hb->rs.ni = shd.len;
    hb->rs.pi = halloc(shd.len * sizeof(I4B), FALSE); if (!hb->rs.pi) { ierr(E_MEM); goto _20;}
    re = read_file(hf, hb->rs.pi, shd.len * sizeof(I4B)); if (!re) { ferr(E_FIR, nam); goto _10;}
  }
  re = AttachBCD(hb); if (!re) goto _10;
  close_file(hf);
  return hb;

 _10: hfree(hb->rs.pi);
 _20: hfree(hb->ds.pb);
 _30: hfree(hb->cs.pb);
 _40: close_file(hf);
 _50: hfree(hb);
  return NULL;
}

BOOL WINAPI SaveBCD(rSTR nam, HBCD hb, rSTR tit, rSTR dsc)
{ // 僶僀僩僐乕僪僼傽僀儖彂弌
  I4B re;
  HFIL hf;
  BCDH bhd;
  SEGH shd;

  hf = open_file(nam, OP_WRI); if (!hf) { return (BOOL)ferr(E_FIW, nam);}
  bhd.app = hb->app;
  bhd.pro = hb->pro;
  bhd.ent = hb->ent;
  bhd.rsv = 0;
  strcpyx(bhd.tit, tit? tit: basnamx(nam), sizeof(bhd.tit) - 1);
  strcpyx(bhd.dsc, dsc? dsc: bhd.tit, sizeof(bhd.dsc) - 1);
  re = write_file(hf, &bhd, sizeof(BCDH)); if (!re) { ferr(E_FIW, nam); goto _10;}
  shd.seg = SEG_COD;
  shd.len = hb->cs.sz;
  re = write_file(hf, &shd, sizeof(SEGH)); if (!re) { ferr(E_FIW, nam); goto _10;}
  if (shd.len > 0) {
    re = write_file(hf, hb->cs.pb, shd.len); if (!re) { ferr(E_FIW, nam); goto _10;}
  }
  shd.seg = SEG_DAT;
  shd.len = hb->ds.sz;
  re = write_file(hf, &shd, sizeof(SEGH)); if (!re) { ferr(E_FIW, nam); goto _10;}
  if (shd.len > 0) {
    re = write_file(hf, hb->ds.pb, shd.len); if (!re) { ferr(E_FIW, nam); goto _10;}
  }
  shd.seg = SEG_BSS;
  shd.len = hb->esz;
  re = write_file(hf, &shd, sizeof(SEGH)); if (!re) { ferr(E_FIW, nam); goto _10;}
  shd.seg = SEG_REL;
  shd.len = hb->rs.ni;
  re = write_file(hf, &shd, sizeof(SEGH)); if (!re) { ferr(E_FIW, nam); goto _10;}
  if (shd.len > 0) {
    re = write_file(hf, hb->rs.pi, shd.len * sizeof(I4B)); if (!re) { ferr(E_FIW, nam); goto _10;}
  }
 _10:
  close_file(hf);
  return re;
}

void WINAPI CallBCD(pANY pv, HBCD hb, I4B ent, rANY arg)
{ // 僶僀僩僐乕僪偺幚峴
  CallExec(pv, hb->xe, ent, arg);
}

void WINAPI ExecBCD(pANY pv, HBCD hb, rANY arg)
{ // 僶僀僩僐乕僪偺幚峴
  CallExec(pv, hb->xe, hb->ent, arg);
}

//乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗//

 // 僄儞僩儕億僀儞僩偺儕僗僩
static I4B  liENT[1024];
static BLKE lsENT = { liENT, 0, _countof(liENT), sizeof(I4B) };

I4B  LOCALF entlist(HBLK ls, rSEGS pc)
{ // 僄儞僩儕億僀儞僩偺儕僗僩嶌惉
  rBIN cp, ce;

  SetLen(ls, 0);
  for (cp = pc->pb, ce = cp + pc->sz; cp < ce; cp += cmdsiz(*cp)) {
    if (*cp == ent_w) {
      *(pI4B)NewItem(ls) = cp - pc->pb;
    }
  }
  *(pI4B)NewItem(ls) = ce - pc->pb;
  return Len(ls) - 1;
}

  // 僕儍儞僾愭偺儕僗僩
static MAPI miJMP[1024];
static BLKE msJMP = { miJMP, 0, _countof(miJMP), sizeof(MAPI) };

void LOCALF regsjmp(HBLK ms, I4B ofs)
{ // 僕儍儞僾愭偺搊榐
  MAPI dat;

  if (LSearchItem(ms, fselI4B, ofs) < 0) {
    dat.ky = dat.va = ofs;
    AddItem(ms, &dat);
    SortItems(ms, fsrtI4B, 0);
  }
}

I4B  LOCALF jmplist(HBLK ms, rBIN cb, rBIN ce)
{ // 僕儍儞僾愭偺儕僗僩嶌惉
  rBIN cp;

  SetLen(ms, 0);
  regsjmp(ms, 0);
  for (cp = cb; cp < ce && *cp != end_v; cp += cmdsiz(*cp)) {
    switch (*cp) {
    case jeq_i_0: case jne_i_0: case jan_i: case jor_i: case jmp_v:
      regsjmp(ms, cp - cb + 3);
      regsjmp(ms, cp - cb + 3 + *(rI2B)(cp+1));
      break;
    }
  }
  regsjmp(ms, cp - cb + (*cp == end_v));
  return Len(ms) - 1;
}

void LOCALF movejmp(HBLK ms, I4B ofs, I4B gap)
{ // 僕儍儞僾愭偺堏摦
  pMAPI pc, pe;

  for (pc = Ptr(ms), pe = pc + Len(ms); pc < pe; pc++) {
    if (pc->ky >= ofs + gap) { pc->va -= gap;}
  }
}

I4B  LOCALF newjmp(HBLK ms, I4B ofs)
{ // 堏摦屻僕儍儞僾愭
  return mapval((rMAPS)ms, ofs);
}

void LOCALF fixnewjmp(pBIN cw, HBLK ms, rBIN cb, rBIN ce)
{ // 僕儍儞僾愭偺彂偒姺偊
  I4B ln0, ln1;
  rBIN cp;

  for (cp = cb; cp < ce && *cp != end_v; cp += cmdsiz(*cp)) {
    switch (*cp) {
    case jeq_i_0: case jne_i_0: case jan_i: case jor_i: case jmp_v:
      ln0 = newjmp(ms, cp - cb + 3);
      ln1 = newjmp(ms, cp - cb + 3 + *(rI2B)(cp+1));
      *(pI2B)(cw + ln0 - 2) = ln1 - ln0;
      break;
    }
  }
}

void LOCALF cpycmd(pSEGS pw, rBIN cp)
{ // 僐乕僪偺揮憲
  AddItems((HBLK)pw, cp, cmdsiz(*cp));
}

typedef void (CALLBACK *FSTG)(pSEGS pw, rBIN cb, rBIN cs, rBIN ce);

void LOCALF OptProc(pSEGS pc, FSTG fstg)
{ // 嵟揔壔(僕儍儞僾愭偺彂偒姺偊)
  I4B i, j, ni, nj;
  rBIN cb, ce;
  pBIN cw;
  pSEGS pw;

  ni = entlist(&lsENT, pc); if (ni <= 0) { ierr(E_DAT); return;}
  pw = (pSEGS)CreateArray(pc->sz, 1); if (!pw) return;
  for (i = 0; i < ni; i++) {
    cb = pc->pb + liENT[i];
    ce = pc->pb + liENT[i+1];
    cw = pw->pb + pw->sz;
    nj = jmplist(&msJMP, cb, ce);
    for (j = 0; j < nj; j++) {
      fstg(pw, cb, cb + miJMP[j].ky, cb + miJMP[j+1].ky);
    }
    fixnewjmp(cw, &msJMP, cb, ce);
  }
  if (pw->sz < pc->sz) {
    memcpy(pc->pb, pw->pb, pc->sz = pw->sz);
  }
  DeleteArray((HBLK)pw);
}

I4B  LOCALF altcmd(I4B oc)
{ // 億僀儞僞墘嶼
  switch (oc) {
  case add_p_i:
  case add_i_p: oc = add_i;   break;
  case sub_p_i:
  case sub_p:   oc = sub_i;   break;
  case inc_p:   oc = inc_i;   break;
  case inc_p_p: oc = inc_i_i; break;
  case dec_p:   oc = dec_i;   break;
  case dec_p_p: oc = dec_i_i; break;
  }
  return oc;
}

void LOCALF fstgOPT1(pSEGS pw, rBIN cb, rBIN cs, rBIN ce)
{ // 嵟揔壔(1)
  I4B u, sz;
  rBIN cp;
  U1B wk[8];

  for (cp = cs; cp < ce; cp += sz) {
    sz = cmdsiz(*cp);
    switch (*cp) {
    case psh_i:
      u = *(rI4B)(cp+1);
      if (u == 0) {
        *wk = psh_i_0; goto _10;
      } else if (ISU1B(u)) {
        *wk = psh_b; *(pU1B)(wk+1) = *(rU1B)(cp+1); goto _10;
      } else if (ISI1BN(u)) {
        *wk = psh_c; *(pI1B)(wk+1) = *(rI1B)(cp+1); goto _10;
      } else if (ISU2B(u)) {
        *wk = psh_w; *(pU2B)(wk+1) = *(rU2B)(cp+1); goto _10;
      } else if (ISI2BN(u)) {
        *wk = psh_s; *(pI2B)(wk+1) = *(rI2B)(cp+1); goto _10;
      } else if (!!(u & NSX_BFN) && ISU1B(u &~ NSX_BFN)) {
        *wk = bfn_b; *(pU1B)(wk+1) = *(rU1B)(cp+1); goto _10;
      } else if (!!(u & NSX_BFN) && ISU2B(u &~ NSX_BFN)) {
        *wk = bfn_w; *(pU2B)(wk+1) = *(rU2B)(cp+1); goto _10;
      } else if (!!(u & NSX_CFN) && ISU1B(u &~ NSX_CFN)) {
        *wk = cfn_b; *(pU1B)(wk+1) = *(rU1B)(cp+1); goto _10;
      } else if (!!(u & NSX_CFN) && ISU2B(u &~ NSX_CFN)) {
        *wk = cfn_w; *(pU2B)(wk+1) = *(rU2B)(cp+1); goto _10;
      }
      goto _20;
    case psh_l:
    case psh_d:
      if (*(rF8B)(cp+1) == 0.0) {
        *wk = psh_d_0; goto _10;
      }
      goto _20;
    case psh_bi:
      u = *(rI4B)(cp+1);
      if (ISU2B(u) || ISI2BN(u)) {
        *wk = psh_bs; *(pI2B)(wk+1) = *(rI2B)(cp+1); goto _10;
      }
      goto _20;
    case psh_du:
      if (ISU2B(*(rU4B)(cp+1))) {
        *wk = psh_dw; *(pU2B)(wk+1) = *(rU2B)(cp+1); goto _10;
      }
      goto _20;
    case psh_eu:
      if (ISU2B(*(rU4B)(cp+1))) {
        *wk = psh_ew; *(pU2B)(wk+1) = *(rU2B)(cp+1); goto _10;
      }
      goto _20;
    case add_p_i:
    case add_i_p:
    case sub_p_i:
    case sub_p:
    case inc_p:
    case inc_p_p:
    case dec_p:
    case dec_p_p:
      if (*(rU2B)(cp+1) == 1) {
        *wk = altcmd(*cp); goto _10;
      }
      goto _20;
     _10:
      cpycmd(pw, wk);
      movejmp(&msJMP, cp - cb + cmdsiz(*wk), sz - cmdsiz(*wk));
      break;
    default: _20:
      cpycmd(pw, cp);
      break;
    }
  }
}

I4B  LOCALF fchcmd(I4B oc)
{ // 抣傪庢摼偡傞
  switch (oc) {
  case psh_bs: oc = fch_bs; break;
  case psh_bi: oc = fch_bi; break;
  case psh_dw: oc = fch_dw; break;
  case psh_du: oc = fch_du; break;
  case psh_ew: oc = fch_ew; break;
  case psh_eu: oc = fch_eu; break;
  }
  return oc;
}

void LOCALF fstgOPT2(pSEGS pw, rBIN cb, rBIN cs, rBIN ce)
{ // 嵟揔壔(2)
  I4B sz, nx;
  rBIN cp;
  U1B wk[8];

  for (cp = cs; cp < ce; cp += sz) {
    sz = cmdsiz(*cp);
    nx = (cp + sz < ce)? *(cp + sz): 0;
    switch (*cp) {
    case psh_b:
      switch (nx) {
      case add_i: *wk = add_i_b; goto _01;
      case mul_i: *wk = mul_i_b; goto _01;
      case sub_i: *wk = sub_i_b; goto _01;
      case div_i: *wk = div_i_b; goto _01;
      case shr_i: *wk = shr_i_b; goto _01;
      case shr_u: *wk = shr_u_b; goto _01;
      case shl_i: *wk = shl_i_b; goto _01;
      case mod_i: *wk = mod_i_b; goto _01;
      case and_i: *wk = and_i_b; goto _01;
      case or_i:  *wk = or_i_b;  _01:
        *(pU1B)(wk+1) = *(rU1B)(cp+1); sz++; goto _10;
      }
      goto _20;
    case psh_w:
      switch (nx) {
      case add_i: *wk = add_i_w; goto _02;
      case mul_i: *wk = mul_i_w; goto _02;
      case sub_i: *wk = sub_i_w; goto _02;
      case div_i: *wk = div_i_w; goto _02;
      case and_i: *wk = and_i_w; goto _02;
      case or_i:  *wk = or_i_w;  _02:
        *(pU2B)(wk+1) = *(rU2B)(cp+1); sz++; goto _10;
      }
      goto _20;
    case psh_i:
      switch (nx) {
      case add_i: *wk = add_i_i; goto _03;
      case mul_i: *wk = mul_i_i; goto _03;
      case sub_i: *wk = sub_i_i; goto _03;
      case div_i: *wk = div_i_i; goto _03;
      case and_i: *wk = and_i_i; goto _03;
      case or_i:  *wk = or_i_i;  goto _03;
      case xor_i: *wk = xor_i_i; _03:
        *(pI4B)(wk+1) = *(rI4B)(cp+1); sz++; goto _10;
      }
      goto _20;
    case psh_bs:
    case psh_dw:
    case psh_ew:
      if (nx == fch_i) {
        *wk = fchcmd(*cp); *(pU2B)(wk+1) = *(rU2B)(cp+1); sz++; goto _10;
      }
      goto _20;
    case psh_bi:
    case psh_du:
    case psh_eu:
      if (nx == fch_i) {
        *wk = fchcmd(*cp); *(pI4B)(wk+1) = *(rI4B)(cp+1); sz++; goto _10;
      }
      goto _20;
     _10:
      cpycmd(pw, wk);
      movejmp(&msJMP, cp - cb + cmdsiz(*wk), sz - cmdsiz(*wk));
      break;
    default: _20:
      cpycmd(pw, cp);
      break;
    }
  }
}

I4B  LOCALF drpcmd(I4B oc)
{ // 抣傪幪偰傞
  switch (oc) {
  case sto_c: oc = sto_c_v; break;
  case sto_s: oc = sto_s_v; break;
  case sto_i: oc = sto_i_v; break;
  case sto_l: oc = sto_l_v; break;
  case sto_f: oc = sto_f_v; break;
  case sto_d: oc = sto_d_v; break;
  case fnc_i:
  case fnc_d: oc = fnc_v;   break;
  case inc_c: oc = inc_c_v; break;
  case inc_s: oc = inc_s_v; break;
  case inc_i_i:
  case inc_i: oc = inc_i_v; break;
  case inc_l: oc = inc_l_v; break;
  case inc_f: oc = inc_f_v; break;
  case inc_d: oc = inc_d_v; break;
  case inc_p_p:
  case inc_p: oc = inc_p_v; break;
  case dec_c: oc = dec_c_v; break;
  case dec_s: oc = dec_s_v; break;
  case dec_i_i:
  case dec_i: oc = dec_i_v; break;
  case dec_l: oc = dec_l_v; break;
  case dec_f: oc = dec_f_v; break;
  case dec_d: oc = dec_d_v; break;
  case dec_p_p:
  case dec_p: oc = dec_p_v; break;
  }
  return oc;
}

void LOCALF fstgOPT3(pSEGS pw, rBIN cb, rBIN cs, rBIN ce)
{ // 嵟揔壔(3)
  I4B sz, nx;
  rBIN cp;
  U1B wk[8];

  for (cp = cs; cp < ce; cp += sz) {
    sz = cmdsiz(*cp);
    nx = (cp + sz < ce)? *(cp + sz): 0;
    switch (*cp) {
    case sto_c: case sto_s: case sto_i:
    case inc_c: case inc_s: case inc_i: case inc_i_i:
    case dec_c: case dec_s: case dec_i: case dec_i_i:
      if (nx == drp_i) {
        *wk = drpcmd(*cp); sz++; goto _10;
      }
      goto _20;
    case fnc_i:
    case inc_p: case inc_p_p:
    case dec_p: case dec_p_p:
      if (nx == drp_i) {
        *wk = drpcmd(*cp); *(pU2B)(wk+1) = *(rU2B)(cp+1); sz++; goto _10;
      }
      goto _20;
    case sto_l: case sto_f: case sto_d:
    case inc_l: case inc_f: case inc_d:
    case dec_l: case dec_f: case dec_d:
      if (nx == drp_d) {
        *wk = drpcmd(*cp); sz++; goto _10;
      }
      goto _20;
    case fnc_d:
      if (nx == drp_d) {
        *wk = drpcmd(*cp); *(pU2B)(wk+1) = *(rU2B)(cp+1); sz++; goto _10;
      }
      goto _20;
     _10:
      cpycmd(pw, wk);
      movejmp(&msJMP, cp - cb + cmdsiz(*wk), sz - cmdsiz(*wk));
      break;
    default: _20:
      cpycmd(pw, cp);
      break;
    }
  }
}

void LOCALF fstgOPT4(pSEGS pw, rBIN cb, rBIN cs, rBIN ce)
{ // 嵟揔壔(4)
  I4B sz, nx;
  rBIN cp;
  U1B wk[8];

  for (cp = cs; cp < ce; cp += sz) {
    sz = cmdsiz(*cp);
    nx = (cp + sz < ce)? *(cp + sz): 0;
    switch (*cp) {
    case psh_i_0:
      switch (nx) {
      case add_i:
      case sub_i:
      case shr_i:
      case shr_u:
      case shl_i:
      case or_i:  *wk = nop_v;  sz++; goto _10;
      case lt_i:
      case lt_u:  *wk = lt_i_0; sz++; goto _10;
      case le_i:
      case le_u:  *wk = le_i_0; sz++; goto _10;
      case gt_i:
      case gt_u:  *wk = gt_i_0; sz++; goto _10;
      case ge_i:
      case ge_u:  *wk = ge_i_0; sz++; goto _10;
      case eq_i:  *wk = eq_i_0; sz++; goto _10;
      case ne_i:  *wk = ne_i_0; sz++; goto _10;
      }
      goto _20;
    case psh_d_0:
      switch (nx) {
      case add_l:
      case add_d:
      case sub_l:
      case sub_d: *wk = nop_v;  sz++; goto _10;
      case lt_l:
      case lt_q:  *wk = lt_l_0; sz++; goto _10;
      case le_l:
      case le_q:  *wk = le_l_0; sz++; goto _10;
      case gt_l:
      case gt_q:  *wk = gt_l_0; sz++; goto _10;
      case ge_l:
      case ge_q:  *wk = ge_l_0; sz++; goto _10;
      case eq_l:
      case eq_d:  *wk = eq_d_0; sz++; goto _10;
      case ne_l:
      case ne_d:  *wk = ne_d_0; sz++; goto _10;
      case lt_d:  *wk = lt_d_0; sz++; goto _10;
      case le_d:  *wk = le_d_0; sz++; goto _10;
      case gt_d:  *wk = gt_d_0; sz++; goto _10;
      case ge_d:  *wk = ge_d_0; sz++; goto _10;
      }
      goto _20;
     _10:
      cpycmd(pw, wk);
      movejmp(&msJMP, cp - cb + 1, sz - 1);
      break;
    default: _20:
      cpycmd(pw, cp);
      break;
    }
  }
}

I4B LOCALF negcmd(I4B oc)
{ // 忦審斀揮
  switch (oc) {
  case lt_i: case lt_u: case lt_l: case lt_q: case lt_d: case lt_i_0: case lt_l_0: case lt_d_0:
    oc += (ge_i - lt_i); break;
  case le_i: case le_u: case le_l: case le_q: case le_d: case le_i_0: case le_l_0: case le_d_0:
    oc += (gt_i - le_i); break;
  case gt_i: case gt_u: case gt_l: case gt_q: case gt_d: case gt_i_0: case gt_l_0: case gt_d_0:
    oc -= (gt_i - le_i); break;
  case ge_i: case ge_u: case ge_l: case ge_q: case ge_d: case ge_i_0: case ge_l_0: case ge_d_0:
    oc -= (ge_i - lt_i); break;
  case eq_i: case eq_l: case eq_d: case eq_i_0: case eq_d_0:
    oc += (ne_i - eq_i); break;
  case ne_i: case ne_l: case ne_d: case ne_i_0: case ne_d_0:
    oc -= (ne_i - eq_i); break;
  }
  return oc;
}

void LOCALF fstgOPT5(pSEGS pw, rBIN cb, rBIN cs, rBIN ce)
{ // 嵟揔壔(5)
  I4B sz, nx;
  rBIN cp;
  U1B wk[8];

  for (cp = cs; cp < ce; cp += sz) {
    sz = cmdsiz(*cp);
    nx = (cp + sz < ce)? *(cp + sz): 0;
    switch (*cp) {
    case lt_i: case lt_u: case lt_l: case lt_q: case lt_d: case lt_i_0: case lt_l_0: case lt_d_0:
    case le_i: case le_u: case le_l: case le_q: case le_d: case le_i_0: case le_l_0: case le_d_0:
    case gt_i: case gt_u: case gt_l: case gt_q: case gt_d: case gt_i_0: case gt_l_0: case gt_d_0:
    case ge_i: case ge_u: case ge_l: case ge_q: case ge_d: case ge_i_0: case ge_l_0: case ge_d_0:
    case eq_i: case eq_l: case eq_d: case eq_i_0: case eq_d_0:
    case ne_i: case ne_l: case ne_d: case ne_i_0: case ne_d_0:
      switch (nx) {
      case eq_i_0: *wk = negcmd(*cp); sz++; goto _10;
      case ne_i_0: *wk = *cp;         sz++; goto _10;
      }
      goto _20;
     _10:
      cpycmd(pw, wk);
      movejmp(&msJMP, cp - cb + 1, sz - 1);
      break;
    default: _20:
      cpycmd(pw, cp);
      break;
    }
  }
}

void LOCALF fstgOPT6(pSEGS pw, rBIN cb, rBIN cs, rBIN ce)
{ // 嵟揔壔(6)
  I4B sz, nx;
  rBIN cp;
  U1B wk[8];

  for (cp = cs; cp < ce; cp += sz) {
    sz = cmdsiz(*cp);
    nx = (cp + sz < ce)? *(cp + sz): 0;
    switch (*cp) {
    case eq_i_0:
    case ne_i_0:
      if (nx == ne_i_0) {
        *wk = *cp; sz++; goto _10;
      }
      goto _20;
     _10:
      cpycmd(pw, wk);
      movejmp(&msJMP, cp - cb + 1, sz - 1);
      break;
    default: _20:
      cpycmd(pw, cp);
      break;
    }
  }
}

I4B  LOCALF fstgOPT7a(pSEGS pc)
{ // 嵟揔壔(7a)
  I4B cn = 0;
  pBIN cp, ce, cx;

  for (cp = pc->pb, ce = cp + pc->sz; cp < ce; cp += cmdsiz(*cp)) {
    switch (*cp) {
    case jeq_i_0: case jne_i_0: case jan_i: case jor_i: case jmp_v:
      cx = cp + 3 + *(rI2B)(cp+1);
      if (*cx == jmp_v) {
        *(pI2B)(cp+1) += (3 + *(rI2B)(cx+1));
        cn++;
      }
      break;
    }
  }
  return cn;
}

void LOCALF fstgOPT7b(pSEGS pw, rBIN cb, rBIN cs, rBIN ce)
{ // 嵟揔壔(7b)
  rBIN cp;

  for (cp = cs; cp < ce; cp += cmdsiz(*cp)) {
    switch (*cp) {
    case nop_v:
      movejmp(&msJMP, cp - cb, 1);
      break;
    default:
      cpycmd(pw, cp);
      break;
    }
  }
}

I4B  LOCALF fstgOPT7c(pSEGS pc)
{ // 嵟揔壔(7c)
  I4B cn = 0;
  pBIN cp, ce;

  for (cp = pc->pb, ce = cp + pc->sz; cp < ce; cp += cmdsiz(*cp)) {
    switch (*cp) {
    case jmp_v:
      if (*(rI2B)(cp+1) == 0) {
        *cp = *(cp+1) = *(cp+2) = nop_v;
        cn++;
      } else if (*(cp+3) == jmp_v) {
        *(cp+3) = *(cp+4) = *(cp+5) = nop_v;
        cn++;
      }
      break;
    }
  }
  return cn;
}

void WINAPI OptimizeBCD(pSEGS pc, I4B opt)
{ // 嵟揔壔
  if (!(opt & DISABLE_OPT_1)) {
    OptProc(pc, fstgOPT1);
  }
  if (!(opt & DISABLE_OPT_2)) {
    OptProc(pc, fstgOPT2);
  }
  if (!(opt & DISABLE_OPT_3)) {
    OptProc(pc, fstgOPT3);
  }
  if (!(opt & DISABLE_OPT_4)) {
    OptProc(pc, fstgOPT4);
  }
  if (!(opt & DISABLE_OPT_5)) {
    OptProc(pc, fstgOPT5);
  }
  if (!(opt & DISABLE_OPT_6)) {
    OptProc(pc, fstgOPT6);
  }
  if (!(opt & DISABLE_OPT_7)) {
    while (fstgOPT7a(pc)) {}
    do {
      OptProc(pc, fstgOPT7b);
    } while (fstgOPT7c(pc));
  }
}

//乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗//

  // 尰嵼偺僶僀僩僐乕僪奿擺堟
static HBLK CS;

HBLK WINAPI SelectCodBlk(HBLK bb)
{ // 僶僀僩僐乕僪奿擺堟偺慖戰
  HBLK bk = CS; CS = bb; return bk;
}

void WINAPIV outcod(I4B oc, ...)
{ // 僶僀僩僐乕僪偺奿擺
  va_list ap;
  U1B wk[8], *cp = wk;

  if (!CS) { ierr(E_ALO); return;}
  va_start(ap, oc);
  switch (*cp++ = oc) {
  case ent_w:
    *((pU2B)cp)++ = va_arg(ap, U2B); *((pU2B)cp)++ = va_arg(ap, U2B); *((pU2B)cp)++ = va_arg(ap, U2B); break;
  case psh_c:
    *((pI1B)cp)++ = va_arg(ap, I1B); break;
  case psh_b:   case bfn_b:   case cfn_b:   case add_i_b: case sub_i_b: case mul_i_b: case div_i_b:
  case shr_i_b: case shr_u_b: case shl_i_b: case mod_i_b: case and_i_b: case or_i_b:
    *((pU1B)cp)++ = va_arg(ap, U1B); break;
  case psh_s:   case psh_bs:  case fch_bs:
  case jeq_i_0: case jne_i_0: case jan_i:   case jor_i:   case jmp_v:
    *((pI2B)cp)++ = va_arg(ap, I2B); break;
  case psh_w:   case bfn_w:   case cfn_w:   case psh_dw:  case psh_ew:  case fch_dw:  case fch_ew:
  case add_i_w: case sub_i_w: case add_p_i: case add_i_p: case sub_p_i: case sub_p:
  case mul_i_w: case div_i_w: case and_i_w: case or_i_w:  case fnc_v:   case fnc_i:   case fnc_d:
  case inc_p:   case inc_p_v: case inc_p_p: case dec_p:   case dec_p_v: case dec_p_p:
    *((pU2B)cp)++ = va_arg(ap, U2B); break;
  case psh_i:   case psh_bi:  case fch_bi:  case add_i_i: case sub_i_i: case mul_i_i: case div_i_i:
  case and_i_i: case or_i_i:  case xor_i_i:
  case psh_du:  case psh_eu:  case fch_du:  case fch_eu:
    *((pI4B)cp)++ = va_arg(ap, I4B); break;
  case psh_l:
    *((pI8B)cp)++ = va_arg(ap, I8B); break;
  case psh_f:
    *((pF4B)cp)++ = (F4B)va_arg(ap, F8B); break;
  case psh_d:
    *((pF8B)cp)++ = va_arg(ap, F8B); break;
  }
  va_end(ap);
  AddItems(CS, wk, cp - wk);
}

I4B  WINAPI codlen(void)
{ // 僶僀僩僐乕僪偺奿擺挿偝
  if (!CS) { return (I4B)ierr(E_ALO);}
  return Len(CS);
}

void WINAPI setcodlen(I4B ln)
{ // 僶僀僩僐乕僪偺奿擺挿偝嵞愝掕
  SetLen(CS, ln);
}

void WINAPI fixcod1(I4B ln, I4B va)
{ // 僶僀僩僐乕僪偺廋惓
  *(pU1B)Item(CS, ln) = va;
}

void WINAPI fixcod2(I4B ln, I4B va)
{ // 僶僀僩僐乕僪偺廋惓
  *(pU2B)Item(CS, ln) = va;
}

void WINAPI fixcod4(I4B ln, I4B va)
{ // 僶僀僩僐乕僪偺廋惓
  *(pI4B)Item(CS, ln) = va;
}

void WINAPI xfercodblk(HBLK bb, I4B ln)
{ // 尰嵼偺奿擺堟偺巜掕埵抲埲崀偺僐乕僪傪堦帪奿擺堟偵揮憲偡傞
  if (!CS) { ierr(E_ALO); return;}
  AddItems(bb, Item(CS, ln), Len(CS) - ln);
  SetLen(CS, ln);
}

void WINAPI outcodblk(HBLK bb)
{ // 堦帪奿擺堟偺僐乕僪傪尰嵼偺奿擺堟偵揮憲偡傞
  if (!CS) { ierr(E_ALO); return;}
  AddItems(CS, Ptr(bb), Len(bb));
}

BOOL WINAPI iscnsexpr(HBLK bb, I4B sw)
{ // 掕悢幃
  rSEGS cs = (rSEGS)bb;
  rBIN cp, ce;

  for (cp = cs->pb, ce = cp + cs->sz; cp < ce && *cp != end_v; cp += cmdsiz(*cp)) {
    switch (*cp) {
    case psh_bs: case psh_bi: case fch_c: case fch_b: case fch_s: case fch_w:
    case fch_i: case fch_l: case fch_f: case fch_d:
    case fch_bs: case fch_bi: case fch_dw: case fch_du: case fch_ew: case fch_eu:
    case sto_c: case sto_s: case sto_i: case sto_l: case sto_f: case sto_d:
    case sto_c_v: case sto_s_v: case sto_i_v: case sto_l_v: case sto_f_v: case sto_d_v:
    case fnc_v: case fnc_i: case fnc_d:
    case inc_c: case inc_s: case inc_i: case inc_l: case inc_f: case inc_d: case inc_p:
    case inc_i_i: case inc_c_v: case inc_s_v: case inc_i_v: case inc_l_v: case inc_f_v:
    case inc_d_v: case inc_p_v: case inc_p_p:
    case dec_c: case dec_s: case dec_i: case dec_l: case dec_f: case dec_d: case dec_p:
    case dec_i_i: case dec_c_v: case dec_s_v: case dec_i_v: case dec_l_v: case dec_f_v:
    case dec_d_v: case dec_p_v: case dec_p_p:
      return FALSE;
    case psh_dw: case psh_du: if (sw == SW_DAT) break;  else return FALSE;
    case psh_ew: case psh_eu: if (sw == SW_BSS) break;  else return FALSE;
    }
  }
  return TRUE;
}

void WINAPI evalcnsexpr(pANY pv, HBLK bb, I4B sw)
{ // 掕悢幃偺昡壙
  pSEGS cs = (pSEGS)bb;
  pBIN cp, ce;
  U1B wk[1024];
  HEXE ex = MakeExecEnv(wk, sizeof(wk));

  if (sw) {
    for (cp = cs->pb, ce = cp + cs->sz; cp < ce && *cp != end_v; cp += cmdsiz(*cp)) {
      switch (*cp) {
      case psh_dw: case psh_ew: *cp = psh_w; break;
      case psh_du: case psh_eu: *cp = psh_i; break;
      }
    }
  }
  SetExecCS(ex, cs);
  CallExecX(pv, ex, 0, NULL, 0, 0);
}

//乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗//

pSTR WINAPI unescb(pSTR bf, rSTR st)
{ // 僄僗働乕僾僔乕働儞僗偺張棟
  pSTR pt, pe;
  I1B ec[4];

  pt = bf;
  while (!!*st) {
    if (*st == '\\') {
      st++;
      switch (*st++) {
      case '0':  *pt++ = '\0'; break;
      case 'a':  *pt++ = '\a'; break;
      case 'b':  *pt++ = '\b'; break;
      case 't':  *pt++ = '\t'; break;
      case 'n':  *pt++ = '\n'; break;
      case 'v':  *pt++ = '\v'; break;
      case 'f':  *pt++ = '\f'; break;
      case 'r':  *pt++ = '\r'; break;
      case '\\': *pt++ = '\\'; break;
      case '\?': *pt++ = '\?'; break;
      case '\'': *pt++ = '\''; break;
      case '\"': *pt++ = '\"'; break;
      case 'x':
        pe = ec;
        if (isxdig(st)) { *pe++ = *st++;} else break;
        if (isxdig(st)) { *pe++ = *st++;}
        *pe = '\0';
        *pt++ = (I1B)strtoul(ec, NULL, 16);
        break;
      case 'o':
        pe = ec;
        if (isodig(st)) { *pe++ = *st++;} else break;
        if (isodig(st)) { *pe++ = *st++;}
        if (isodig(st)) { *pe++ = *st++;}
        *pe = '\0';
        *pt++ = (I1B)strtoul(ec, NULL, 8);
        break;
      default:
        *pt++ = '\\'; st--; break;
      }
    } else if (iszen(st)) {
      *((pU2B)pt)++ = *((pU2B)st)++;
    } else {
      *pt++ = *st++;
    }
  }
  *pt = '\0';
  return bf;
}

rSTR WINAPI unesc(rSTR st)
{ // 僄僗働乕僾僔乕働儞僗偺張棟
  return unescb(talloc(strlen(st) + 1), st);
}

I4B  LOCALF fspcC89(rSTR *pp, pBIN bf, uANY pa)
{ // 嬻敀
  rSTR pt = *pp;

  for (;;) {
    if (isspc(pt)) {
      do { pt++; } while (isspc(pt));
    } else if (*pt == '/' && *(pt+1) == '*') {
      pt += 2;
      while (!(*pt == '*' && *(pt+1) == '/')) {
        if (!*pt) { *pp = pt; return TKN_END;}
        pt++;
      }
      pt += 2;
    } else if (*pt == '/' && *(pt+1) == '/') {
      pt += 2;
      while (*pt != '\n') {
        if (!*pt) { *pp = pt; return TKN_END;}
        pt++;
      }
      pt++;
    } else break;
  }
  *pp = pt;
  return *pt? 0: TKN_END;
}

I4B  LOCALF fcnsC89(rSTR *pp, pBIN bf, uANY pa)
{ // 掕悢儕僥儔儖
  I4B b, cd;
  rSTR pb, pt = *pp, px;
  I1B wk[LBUF];

  if (isdig(pt) || (*pt == '.' && isdig(pt+1))) {
    b = 10; cd = 0;
    if (*pt == '0' && (*(pt+1) == 'X' || *(pt+1) == 'x')) {
      pt += 2;
      pb = pt;
      while (isxdig(pt)) { pt++;}
      if (pt == pb) return 0;
      b = 16;
    } else if (*pt == '0' && *(pt+1) != '.') {
      pb = pt;
      do { pt++;} while (isodig(pt));
      b = 8;
    } else {
      pb = pt;
      while (isdig(pt)) { pt++;}
      if (*pt == '.') {
        do { pt++;} while (isdig(pt));
        cd = TKN_F8B;
      }
      if (*pt == 'E' || *pt == 'e') {
        pt++;
        if (*pt == '+' || *pt == '-') { pt++;}
        px = pt;
        while (isdig(pt)) { pt++;}
        if (pt == px) return 0;
        cd = TKN_F8B;
      }
    }
    if (!cd) {
      if (*pt == 'L' || *pt == 'l') {
        pt++;
        if (*pt == 'L' || *pt == 'l') {
          pt++; cd += 2;
        }
        if (*pt == 'U' || *pt == 'u') {
          pt++; cd++;
        }
      } else if (*pt == 'U' || *pt == 'u') {
        pt++; cd++;
        if (*pt == 'L' || *pt == 'l') {
          pt++;
          if (*pt == 'L' || *pt == 'l') {
            pt++; cd += 2;
          }
        }
      }
      switch (cd) {
      case 0: cd = TKN_I4B; break;
      case 1: cd = TKN_U4B; break;
      case 2: cd = TKN_I8B; break;
      case 3: cd = TKN_U8B; break;
      }
    }
    if (pt - pb >= LBUF) return 0;
    spncpy(bf, pb, pt);
    switch (cd) {
    case TKN_I4B:
    case TKN_U4B: *(pU4B)bf = strtoul(bf, NULL, b); break;
    case TKN_I8B:
    case TKN_U8B: *(pU8B)bf = _strtoui64(bf, NULL, b); break;
    case TKN_F8B: *(pF8B)bf = strtod(bf, NULL); break;
    }
  } else if (*pt == '\'') {
    cd = TKN_I4B;
    pt++;
    pb = pt;
    while (*pt != '\'') {
      if (*pt == '\\' && (*(pt+1) == '\\' || *(pt+1) == '\'')) { pt += 2;}
      else if (iszen(pt)) { ((pU2B)pt)++;}
      else if (isprn(pt)) { pt++;}
      else return 0;
    }
    if (pt - pb >= LBUF) return 0;
    spncpy(wk, pb, pt);
    pt++;
    unescb(bf, wk);
    switch (strlen(bf)) {
    case 0: *(pU4B)bf = 0; break;
    case 1: *(pU4B)bf = *(rU1B)bf; break;
    case 2: *(pU4B)bf = SWAP1B(*(rU2B)bf); break;
    default: return 0;
    }
  } else return 0;
  *pp = pt;
  return cd;
}

I4B  LOCALF fstrC89(rSTR *pp, pBIN bf, uANY pa)
{ // 暥帤楍
  rSTR pb, pt = *pp;
  I1B wk[LBUF];

  if (*pt == '\"') { pt++;} else return 0;
  pb = pt;
  while (*pt != '\"') {
    if (*pt == '\\' && (*(pt+1) == '\\' || *(pt+1) == '\"')) { pt += 2;}
    else if (iszen(pt)) { ((pU2B)pt)++;}
    else if (isprn(pt)) { pt++;}
    else return 0;
  }
  if (pt - pb >= LBUF) return 0;
  spncpy(wk, pb, pt);
  pt++;
  unescb(bf, wk);
  *pp = pt;
  return TKN_STR;
}

enum {
  COP_SEM = TKN_OPR,
            COP_LBK,  COP_RBK,  COP_CMA,  COP_CLN,  COP_ASN,  COP_LBC,  COP_RBC,
  COP_LPA,  COP_RPA,  COP_ELP,  COP_PLE,  COP_MNE,  COP_MLE,  COP_DVE,  COP_MOE,
  COP_SLE,  COP_SRE,  COP_BAE,  COP_BOE,  COP_BXE,  COP_QUE,  COP_LOR,  COP_LAN,
  COP_BOR,  COP_BXO,  COP_BAN,  COP_LEQ,  COP_LNE,  COP_LLT,  COP_LGT,  COP_LLE,
  COP_LGE,  COP_SHL,  COP_SHR,  COP_PLS,  COP_MNS,  COP_AST,  COP_DIV,  COP_MOD,
  COP_INC,  COP_DEC,  COP_BNT,  COP_LNT,  COP_DOT,  COP_ARW,  COP_SZO,  COP_OFO,
  CKW_TDF = TKN_KWD,
            CKW_IMM,  CKW_STU,  CKW_CNS,  CKW_ENM,  CKW_AUT,  CKW_STA,  CKW_IF_,
  CKW_ELS,  CKW_SWI,  CKW_CAS,  CKW_DEF,  CKW_FOR,  CKW_WHI,  CKW_DO_,  CKW_GOT,
  CKW_CNT,  CKW_BRK,  CKW_RET,  CKW_I1B,  CKW_U1B,  CKW_I2B,  CKW_U2B,  CKW_I4B,
  CKW_U4B,  CKW_I8B,  CKW_U8B,  CKW_F4B,  CKW_F8B,  CKW_VOI,  CKW_NUL,  CKW_NEL,
  CKW_LOB,  CKW_HIB,  CKW_LOW,  CKW_HIW,  CKW_MKW,  CKW_MKU,  CKW_SWB,  CKW_SWW,
  CKW_CHB,  CKW_CHW,  CKW_CHC,  CKW_CHS,  CKW_STR,  CKW_BIN,  CKW_ASC,  CKW_CAL,
};
  // 僉乕儚乕僪(墘嶼巕丄嬫愗巕傪娷傓)
static CODI diC89[] = {
  { COP_SEM,  ";"        }, { COP_LBK,  "["        }, { COP_RBK,  "]"        }, { COP_CMA,  ","        },
  { COP_CLN,  ":"        }, { COP_ASN,  "="        }, { COP_LBC,  "{"        }, { COP_RBC,  "}"        },
  { COP_LPA,  "("        }, { COP_RPA,  ")"        }, { COP_ELP,  "..."      }, { COP_PLE,  "+="       },
  { COP_MNE,  "-="       }, { COP_MLE,  "*="       }, { COP_DVE,  "/="       }, { COP_MOE,  "%="       },
  { COP_SLE,  "<<="      }, { COP_SRE,  ">>="      }, { COP_BAE,  "&="       }, { COP_BOE,  "|="       },
  { COP_BXE,  "^="       }, { COP_QUE,  "?"        }, { COP_LOR,  "||"       }, { COP_LAN,  "&&"       },
  { COP_BOR,  "|"        }, { COP_BXO,  "^"        }, { COP_BAN,  "&"        }, { COP_LEQ,  "=="       },
  { COP_LNE,  "!="       }, { COP_LLT,  "<"        }, { COP_LGT,  ">"        }, { COP_LLE,  "<="       },
  { COP_LGE,  ">="       }, { COP_SHL,  "<<"       }, { COP_SHR,  ">>"       }, { COP_PLS,  "+"        },
  { COP_MNS,  "-"        }, { COP_AST,  "*"        }, { COP_DIV,  "/"        }, { COP_MOD,  "%"        },
  { COP_INC,  "++"       }, { COP_DEC,  "--"       }, { COP_BNT,  "~"        }, { COP_LNT,  "!"        },
  { COP_DOT,  "."        }, { COP_ARW,  "->"       }, { COP_SZO,  "sizeof"   }, { COP_OFO,  "offsetof" },
  { CKW_TDF,  "typedef"  }, { CKW_IMM,  "const"    }, { CKW_STU,  "struct"   }, { CKW_CNS,  "#define"  },
  { CKW_ENM,  "enum"     }, { CKW_AUT,  "auto"     }, { CKW_STA,  "static"   }, { CKW_IF_,  "if"       },
  { CKW_ELS,  "else"     }, { CKW_SWI,  "switch"   }, { CKW_CAS,  "case"     }, { CKW_DEF,  "default"  },
  { CKW_FOR,  "for"      }, { CKW_WHI,  "while"    }, { CKW_DO_,  "do"       }, { CKW_GOT,  "goto"     },
  { CKW_CNT,  "continue" }, { CKW_BRK,  "break"    }, { CKW_RET,  "return"   },
  { CKW_I1B,  "I1B"      }, { CKW_I1B,  "char"     }, { CKW_U1B,  "U1B"      }, { CKW_U1B,  "BYTE"     },
  { CKW_I2B,  "I2B"      }, { CKW_I2B,  "short"    }, { CKW_U2B,  "U2B"      }, { CKW_U2B,  "WORD"     },
  { CKW_I4B,  "I4B"      }, { CKW_I4B,  "int"      }, { CKW_I4B,  "BOOL"     }, { CKW_I4B,  "LONG"     },
  { CKW_U4B,  "U4B"      }, { CKW_U4B,  "UINT"     }, { CKW_I8B,  "I8B"      }, { CKW_I8B,  "INT64"    },
  { CKW_U8B,  "U8B"      }, { CKW_U8B,  "UINT64"   }, { CKW_U2B,  "USHORT"   }, { CKW_U4B,  "DWORD"    },
  { CKW_F4B,  "F4B"      }, { CKW_F4B,  "float"    }, { CKW_F8B,  "F8B"      }, { CKW_F8B,  "double"   },
  { CKW_VOI,  "void"     }, { CKW_NUL,  "NULL"     }, { CKW_NEL,  "_countof" }, { CKW_NEL,  "NELEM"    },
  { CKW_LOB,  "LOU1B"    }, { CKW_LOB,  "LOBYTE"   }, { CKW_HIB,  "HIU1B"    }, { CKW_HIB,  "HIBYTE"   },
  { CKW_LOW,  "LOU2B"    }, { CKW_LOW,  "LOWORD"   }, { CKW_HIW,  "HIU2B"    }, { CKW_HIW,  "HIWORD"   },
  { CKW_MKW,  "MKU2B"    }, { CKW_MKW,  "MAKEWORD" }, { CKW_MKU,  "MKU4B"    }, { CKW_MKU,  "MAKEUINT" },
  { CKW_MKU,  "MAKELONG" }, { CKW_SWB,  "SWAP1B"   }, { CKW_SWW,  "SWAP2B"   }, { CKW_CHB,  "ISU1B"    },
  { CKW_CHW,  "ISU2B"    }, { CKW_CHC,  "ISI1BN"   }, { CKW_CHS,  "ISI2BN"   }, { CKW_MKW,  "ITP"      },
  { CKW_MKW,  "ATR"      }, { CKW_MKU,  "ALT"      }, { CKW_MKU,  "RKY"      }, { CKW_STR,  "STR"      },
  { CKW_BIN,  "BIN"      }, { CKW_ASC,  "ASC"      }, { CKW_CAL,  "CAL"      },
};
static CODS dsC89 = { diC89, _countof(diC89) };

  // 僉乕儚乕僪梫慺
static rSTR SELM[256];
static ENMS esELM = { SELM, 0 };

  // 僉乕儚乕僪
static MAPI miKWD[256];
static MAPS msKWD = { miKWD, 0 };

I4B  LOCALF scankwd(rSTR *pp, rENMS ls)
{ // 幆暿巕宆僉乕儚乕僪梫慺偺専嶕
  I4B i, n;
  rSTR st = *pp;

  for (i = 0; i < ls->ni; i++) {
    n = strlen(ls->ps[i]);
    if (!strncmp(ls->ps[i], st, n) && !isalnx(st + n)) {
      *pp = st + n; return i;
    }
  }
  return -1;
}

I4B  LOCALF scanopr(rSTR *pp, rENMS ls)
{ // 摿庩暥帤宆僉乕儚乕僪梫慺偺専嶕
  I4B i, n, f = -1, m = 0;
  rSTR st = *pp;

  for (i = 0; i < ls->ni; i++) {
    n = strlen(ls->ps[i]);
    if (!strncmp(ls->ps[i], st, n) && n > m) {
      f = i; m = n;
    }
  }
  if (f >= 0) { *pp = st + m;}
  return f;
}

I4B  LOCALF srchtkn(pI4B pi, rMAPS ls, I4B va)
{ // 僉乕儚乕僪偺僩乕僋儞庬暿僐乕僪
  I4B i, n = 0;
  rMAPI pc, pe;

  for (i = 0; i < 4; i++) {
    if (((rI1B)&va)[i]) { n++;}
  }
  for (i = 0; i < n; i++) {
    for (pc = ls->pv, pe = pc + ls->ni; pc < pe; pc++) {
      if (pc->va == va && (!lookahead() || pc->ky == lookahead())) {
        *pi = pc->ky;
        return n - i;
      }
    }
    va &=~(0xff << (8 * (n - i - 1)));
  }
  return 0;
}

I4B  LOCALF fkwdC89(rSTR *pp, pBIN bf, uANY pa)
{ // 僉乕儚乕僪
  I4B i, f, va = 0, cd;
  rSTR pb, pt = *pp, pw[4];

  for (i = 0; i < 4; i++) {
    pw[i] = pb = pt;
    if (isalpx(pt)) {
      f = scankwd(&pt, &esELM);
      if (f < 0) {
        if (i == 0) return 0; else break;
      }
    } else if (issym(pt)) {
      f = scanopr(&pt, &esELM);
      if (f < 0) break;
    } else break;
    va |= ((f + 1) << (8 * i));
    while (isspc(pt)) { pt++;}
  }
  if (!va || !(i = srchtkn(&cd, &msKWD, va))) return 0;
  if (i < 4) { pt = pw[i];}
  *pp = pt;
  return cd;
}

I4B  LOCALF fidnC89(rSTR *pp, pBIN bf, uANY pa)
{ // 幆暿巕
  rSTR pb, pt;

  pb = pt = *pp;
  if (isalpx(pt)) {
    do { pt++;} while (isalnx(pt));
    if (pt - pb >= LIDN) return 0;
    spncpy(bf, pb, pt);
  } else return 0;
  *pp = pt;
  return TKN_IDN;
}

  // 帤嬪夝愅忣曬
static LEXI xiC89 = { fspcC89, fcnsC89, fstrC89, fkwdC89, fidnC89, 0 };

void LOCALF PrepPars(rCODS ls)
{ // 帤嬪夝愅偺慜張棟
  I4B i, f, va;
  rSTR pb, pt;
  rCODI pc, pe;
  MAPI dat;
  I1B bf[LIDN];

  esELM.ni = msKWD.ni = 0;
  for (pc = ls->pv, pe = pc + ls->ni; pc < pe && pc->va != 0; pc++) {
    pt = pc->st;
    va = 0;
    for (i = 0; i < 4 && *pt != '\0'; i++) {
      pb = pt;
      if (isalpx(pt)) {
        do { pt++;} while (isalnx(pt));
        goto _10;
      } else if (issym(pt)) {
        do { pt++;} while (issym(pt));
       _10:
        if (pt - pb >= LIDN) { ierr(E_TKN); return;}
        spncpy(bf, pb, pt);
        f = srchenm0(&esELM, bf);
        if (f < 0) {
          if (esELM.ni >= _countof(SELM)) { ierr(E_CAP); return;}
          f = esELM.ni++;
          esELM.ps[f] = stostr(bf);
        }
      } else { ierr(E_TKN); return;}
      va |= ((f + 1) << (8 * i));
      while (isspc(pt)) { pt++;}
    }
    if (!va) { ierr(E_DAT); return;}
    if (msKWD.ni >= _countof(miKWD)) { ierr(E_CAP); return;}
    dat.ky = pc->va;
    dat.va = va;
    msKWD.pv[msKWD.ni++] = dat;
  }
}

rCODS WINAPI test_keywords(void) { return &dsC89;}
rENMS WINAPI test_reserved(void) { return &esELM;}

pSTR WINAPI strcpyi(pSTR sd, rSTR ss)
{ // 幆暿巕暥帤楍偺僐僺乕
  return strcpyn(sd, ss, LIDN - 1);
}

pSTR WINAPI strcpyl(pSTR sd, rSTR ss)
{ // 暥帤楍儕僥儔儖偺僐僺乕
  return strcpyn(sd, ss, LLIT - 1);
}

BOOL WINAPI strlitconc(pBIN bf, I4B sz)
{ // 椬愙偡傞暥帤楍儕僥儔儖偺楢寢
  I4B ln;
  pBIN pt = bf;

  do {
    ln = strlen(buf());
    if (pt - bf + ln > sz) return FALSE;
    memcpy(pt, buf(), ln);
    pt += ln;
  } while (token_is(TKN_STR));
  if (pt - bf < sz) { *pt = '\0';}
  return TRUE;
}

//乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗//

#define  LWRK  512
#define  LARG   32
  // 嶌嬈梡儊儌儕娗棟忣曬
static HMEM hWRK;

HBLK LOCALF CreateTmpBlk(void)
{ // 僶僀僩僐乕僪堦帪奿擺堟嶌惉
  HBLK bb;

  bb = walloc(hWRK, sizeof(BLKE) + LWRK, FALSE); if (!bb) return NULL;
  return BuildArray(bb, (pBIN)bb + sizeof(BLKE), 0, LWRK, 1);
}

void LOCALF DeleteTmpBlk(HBLK bb)
{ // 僶僀僩僐乕僪堦帪奿擺堟偺嶍彍
  wfree(hWRK, bb);
}

HBLK LOCALF CreateArgBlk(void)
{ // 僶僀僩僐乕僪堦帪奿擺堟(堷悢梡)嶌惉
  I4B i;
  HBLK bb, bi;

  bb = walloc(hWRK, sizeof(BLKE) + LARG * (sizeof(BLKE) + LWRK), FALSE); if (!bb) return NULL;
  BuildArray(bb, (pBIN)bb + sizeof(BLKE), 0, LARG, sizeof(BLKE) + LWRK);
  for (i = 0; i < LARG; i++) {
    bi = Item(bb, i);
    BuildArray(bi, (pBIN)bi + sizeof(BLKE), 0, LWRK, 1);
  }
  return bb;
}

#define  DeleteArgBlk(bb)  DeleteTmpBlk(bb)

HBLK LOCALF Arg(HBLK bb, I4B i)
{ // i斣栚堷悢偺僶僀僩僐乕僪堦帪奿擺堟
  if (i >= Len(bb)) {
    if (i < Capacity(bb)) { SetLen(bb, i + 1);} else { ierr(E_CAP);}
  }
  return Item(bb, i);
}

void LOCALF outarg(HBLK bb)
{ // 堦帪奿擺堟偺僐乕僪傪塃偐傜弴偵尰嵼偺奿擺堟偵揮憲偡傞
  I4B i;

  for (i = Len(bb) - 1; i >= 0; i--) {
    outcodblk(Arg(bb, i));
  }
}

  // 宆忣曬
typedef struct {
  I4B   nsp;
  I4B   typ;
  I4B   len;
  I4B   osz;
} TYPE;
typedef TYPE *pTYPE;
typedef const TYPE *rTYPE;

#define  CreateTypBlk(cap)  CreateMemBlk(cap, sizeof(TYPE))
#define  DeleteTypBlk(mb)  DeleteMemBlk(mb)

  // 幆暿巕忣曬
typedef struct {
  I4B   nsp;
  I4B   typ;
  rSTR  nam;
  I4B   ofs;
} NAME;
typedef NAME *pNAME;
typedef const NAME *rNAME;

#define  CreateNamBlk(cap)  CreateMemBlk(cap, sizeof(NAME))
#define  DeleteNamBlk(mb)  DeleteMemBlk(mb)

#define  CreateDefBlk(cap)  CreateBinBlk(cap)
#define  DeleteDefBlk(bb)  DeleteBinBlk(bb)

#define  CreateDatBlk(cap)  CreateBinBlk(cap)
#define  DeleteDatBlk(bb)  DeleteBinBlk(bb)

#define  CreateRelBlk(cap)  CreateMemBlk(cap, sizeof(I4B))
#define  DeleteRelBlk(mb)  DeleteMemBlk(mb)

HCPL WINAPI CreateCmplEnv(I4B csz, I4B dsz)
{ // 僐儞僷僀儖忣曬嶌惉
  HCPL ce;

  ce = halloc(sizeof(CPLE), TRUE); if (!ce) { return ierr(E_MEM);}
  ce->sbk = SelectStrBlk(ce->sym = CreateStrBlk(csz)); if (!ce->sym) { SelectStrBlk(ce->sbk); goto _70;}
  ce->typ = CreateTypBlk(csz /16); if (!ce->typ) goto _60;
  ce->idn = CreateNamBlk(csz / 8); if (!ce->idn) goto _50;
  ce->cbk = SelectCodBlk(ce->cod = CreateCodBlk(csz)); if (!ce->cod) { SelectCodBlk(ce->cbk); goto _40;}
  ce->def = CreateDefBlk(dsz / 4); if (!ce->def) goto _30;
  ce->dat = CreateDatBlk(dsz);     if (!ce->dat) goto _20;
  ce->rel = CreateRelBlk(dsz /32); if (!ce->rel) goto _10;
  return ce;

 _10: DeleteDatBlk(ce->dat);
 _20: DeleteDefBlk(ce->def);
 _30: DeleteCodBlk(SelectCodBlk(ce->cbk));
 _40: DeleteNamBlk(ce->idn);
 _50: DeleteTypBlk(ce->typ);
 _60: DeleteStrBlk(SelectStrBlk(ce->sbk));
 _70: hfree(ce);
  return NULL;
}

void WINAPI DeleteCmplEnv(HCPL ce)
{ // 僐儞僷僀儖忣曬偺嶍彍
  if (!ce) return;
  DeleteRelBlk(ce->rel);
  DeleteDatBlk(ce->dat);
  DeleteDefBlk(ce->def);
  DeleteCodBlk(SelectCodBlk(ce->cbk));
  DeleteNamBlk(ce->idn);
  DeleteTypBlk(ce->typ);
  DeleteStrBlk(SelectStrBlk(ce->sbk));
  hfree(ce);
}

  // 尰嵼偺僐儞僷僀儖忣曬
static HCPL CE;

HCPL WINAPI SelectCmplEnv(HCPL ce)
{ // 僐儞僷僀儖忣曬偺慖戰
  HCPL bk = CE; CE = ce; return bk;
}

rTYPE LOCALF regstyp(I4B nsp, I4B typ, I4B len, I4B osz)
{ // 宆忣曬偺搊榐
  pTYPE pt;

  if (!CE || !CE->typ) { return ierr(E_ALO);}
  pt = NewItem(CE->typ);
  pt->nsp = nsp; pt->typ = typ; pt->len = len; pt->osz = osz;
  return pt;
}

rTYPE LOCALF typptr(I4B tpi)
{ // 宆忣曬
  return (rTYPE)Item(CE->typ, tpi);
}

I4B  LOCALF typidx(rTYPE pt)
{ // 億僀儞僞偐傜僀儞僨僢僋僗傪媮傔傞
  return ItemIndex(CE->typ, pt);
}

rTYPE LOCALF srchtyp(I4B nsp, I4B typ, I4B len)
{ // 宆忣曬偺僒乕僠
  rTYPE pt, pb;

  for (pb = Ptr(CE->typ), pt = pb + Len(CE->typ) - 1; pt >= pb; pt--) {
    if (pt->nsp == nsp && pt->typ == typ && pt->len == len) { return pt;}
  }
  return NULL;
}

pNAME LOCALF regsnam(I4B nsp, I4B typ, rSTR st, I4B ofs)
{ // 幆暿巕偺搊榐
  pNAME pi;

  if (!CE->idn) { return ierr(E_ALO);}
  pi = NewItem(CE->idn);
  pi->nsp = nsp; pi->typ = typ; pi->nam = stostr(st), pi->ofs = ofs;
  return pi;
}

pNAME LOCALF namptr(I4B lid)
{ // 幆暿巕忣曬
  return (pNAME)Item(CE->idn, lid);
}

I4B  LOCALF namidx(rNAME pi)
{ // 億僀儞僞偐傜僀儞僨僢僋僗傪媮傔傞
  return ItemIndex(CE->idn, pi);
}

pNAME LOCALF srchnam(I4B nsp, rSTR st)
{ // 幆暿巕偺僒乕僠
  pNAME pi, pb;

  for (pb = Ptr(CE->idn), pi = pb + Len(CE->idn) - 1; pi >= pb; pi--) {
    if (pi->nsp == nsp && !strcmp(pi->nam, st)) { return pi;}
  }
  return NULL;
}

pNAME LOCALF srchord(I4B nsp, I4B ord)
{ // 彉悢偵傛傞幆暿巕偺僒乕僠
  I4B cn = 0;
  pNAME pi, pe;

  for (pi = Ptr(CE->idn), pe = pi + Len(CE->idn); pi < pe; pi++) {
    if (pi->nsp == nsp && cn++ == ord) { return pi;}
  }
  return NULL;
}

I4B  LOCALF obound(I4B ln, I4B sz)
{ // 係傑偨偼俉僶僀僩嫬奅偵愗傝忋偘
  return nbound(ln, (sz <= 4)? 4: 8);
}

I4B  LOCALF outdef(rANY pv, I4B sz)
{ // 掕悢偺奿擺
  I4B ln, lo;

  if (!CE) { return (I4B)ierr(E_ALO);}
  lo = Len(CE->def);
  ln = obound(lo, sz);
  AddItems(CE->def, NULL, ln - lo);
  AddItems(CE->def, pv, sz);
  return ln;
}

rANY LOCALF pvdef(I4B ofs)
{ // 掕悢
  return (rANY)Item(CE->def, ofs);
}

I4B  WINAPI outdat(rSEGS ds, rIDXS rl)
{ // 弶婜抣偁傝惷揑曄悢偍傛傃嵞攝抲忣曬偺奿擺
  I4B i, ln, lo;

  if (!CE) { return (I4B)ierr(E_ALO);}
  lo = Len(CE->dat);
  ln = obound(lo, ds->sz);
  AddItems(CE->dat, NULL, ln - lo);
  AddItems(CE->dat, ds->pb, ds->sz);
  if (rl) {
    for (i = 0; i < rl->ni; i++) {
      *(pU4B)NewItem(CE->rel) = ln + rl->pi[i];
    }
  }
  return ln;
}

I4B  WINAPI outstr(rSTR st)
{ // 暥帤楍偺奿擺
  I4B ln, lo, sz;

  if (!CE) { return (I4B)ierr(E_ALO);}
  lo = Len(CE->dat);
  ln = obound(lo, sz = strlen(st) + 1);
  AddItems(CE->dat, NULL, ln - lo);
  AddItems(CE->dat, st, sz);
  return ln;
}

HBLK LOCALF CreateDatBuf(I4B sz)
{ // 弶婜抣偁傝惷揑曄悢堦帪婰榐堟嶌惉
  HBLK bb;

  bb = walloc(hWRK, sizeof(BLKE) + sz, TRUE); if (!bb) return NULL;
  return BuildArray(bb, (pBIN)bb + sizeof(BLKE), 0, sz, 1);
}

#define  DeleteDatBuf(bb)  DeleteTmpBlk(bb)

pANY LOCALF datptr(HBLK bb)
{ // 梫慺偺捛壛埵抲
  return Item(bb, Len(bb));
}

void LOCALF incdatptr(HBLK bb, I4B sz)
{ // 梫慺偑捛壛偝傟偨傕偺偲偡傞
  AddLen(bb, sz);
}

HBLK LOCALF CreateRelBuf(I4B ni)
{ // 嵞攝抲忣曬堦帪婰榐堟嶌惉
  HBLK rl;

  rl = walloc(hWRK, sizeof(BLKE) + ni * sizeof(I4B), FALSE); if (!rl) return NULL;
  return BuildArray(rl, (pBIN)rl + sizeof(BLKE), 0, ni, sizeof(I4B));
}

#define  DeleteRelBuf(rl)  DeleteTmpBlk(rl)

void LOCALF memrel(HBLK rl, HBLK bb)
{ // 嵞攝抲忣曬堦帪婰榐
  I4B ofs = Len(bb);

  AddItem(rl, &ofs);
}

I4B  LOCALF outbss(I4B sz)
{ // 弶婜抣側偟惷揑曄悢椞堟偺妋曐
  I4B ln;

  ln = obound(CE->sof, sz);
  CE->sof = ln + sz;
  return ln;
}

I4B  LOCALF outaut(I4B sz)
{ // 帺摦曄悢椞堟偺妋曐
  return CE->aof = obound(CE->aof, sz) + sz;
}

I4B  LOCALF autlen(void)
{ // 帺摦曄悢椞堟偺挿偝
  return CE->aof;
}

I4B  LOCALF newstu(void)
{ // 怴偟偄峔憿懱偺彉悢
  return ++CE->nst;
}

I4B  LOCALF newbfn(void)
{ // 怴偟偄價儖僩僀儞娭悢偺彉悢
  return ++CE->nbf;
}

I4B  LOCALF newcfn(void)
{ // 怴偟偄儐乕僓乕掕媊娭悢偺彉悢
  return ++CE->ncf;
}

void LOCALF begincfn(rTYPE pt, pNAME pc)
{ // 儐乕僓乕掕媊娭悢杮懱僗僐乕僾偺巒傑傝
  CE->aof = 0;
  outcod(ent_w, CE->cfn = LOU2B(pt->nsp), pt->osz, 0);
  pc->ofs = codlen();
}

void LOCALF endcfn(rTYPE pt, pNAME pc)
{ // 儐乕僓乕掕媊娭悢杮懱僗僐乕僾偺廔傢傝
  fixcod2(pc->ofs - 2, nbound(CE->aof, 4));
  CE->cfn = 0;
}

I4B  LOCALF cfn(void)
{ // 尰嵼偺僗僐乕僾傪帵偡儐乕僓乕掕媊娭悢偺彉悢
  return CE->cfn;
}

#define  TRN_HDR  0x00000001
#define  TRN_MAI  0x00000002
#define  TRN_INI  0x00000008

void LOCALF setbits(I4B f)
{ // 僼儔僌愝掕
  CE->flg |= f;
}

void LOCALF resetbits(I4B f)
{ // 僼儔僌愝掕庢徚
  CE->flg &=~f;
}

BOOL LOCALF chkbits(I4B f)
{ // 僼儔僌専嵏
  return !!(CE->flg & f);
}

static jmp_buf  JB;

#define  errchk()  setjmp(JB)
#define  cerr(ec)  longjmp(JB, MKU4B(ec, __LINE__))

#define  xerr(er, fn)  throw_error(MODNAM, er, fn, errpos())

#define  NSP_GLO  0
#define  NSX_STU  0x10000000
#define  NSX_BFN  0x20000000
#define  NSX_CFN  0x30000000
#define  NSX_LAB  0x40000000
#define  NSX_JPL  0x50000000
#define  NSX_JPS  0x60000000

I4B  LOCALF nsxof(I4B nsp) { return nsp & 0xf0000000;}

#define  TPX_VAL  0
#define  TPX_IMM  0x08000000
#define  TPX_OBJ  0x01000000
#define  TPX_DAT  0x02000000
#define  TPX_BSS  0x03000000
#define  TPX_AUT  0x04000000
#define  TPX_TYP  0x06000000

I4B  LOCALF tpxof(I4B typ) { return typ & 0xff000000;}
I4B  LOCALF clsof(I4B typ) { return typ & 0xf7000000;}
I4B  LOCALF valof(I4B typ) { return typ & 0x08ffffff;}
I4B  LOCALF idxof(I4B typ) { return typ & 0x0000ffff;}

#define  REF_IM1  0x00020000
#define  REF_IM2  0x00080000
#define  REF_IM3  0x00200000
#define  REF_IM4  0x00800000
#define  REF_MIM  (REF_IM1|REF_IM2|REF_IM3|REF_IM4)

#define  REF_PT1  0x00010000
#define  REF_PT2  0x00040000
#define  REF_PT3  0x00100000
#define  REF_PT4  0x00400000
#define  REF_MPT  (REF_PT1|REF_PT2|REF_PT3|REF_PT4)

BOOL LOCALF isimm(I4B typ)
{ // 晄曄
  return !!(typ & TPX_IMM);
}

BOOL LOCALF ismut(I4B typ)
{ // 壜曄
  return !(typ & TPX_IMM);
}

BOOL LOCALF iscns(I4B typ)
{ // 掕悢抣(晄曄側塃曈抣)
  return isimm(typ) && clsof(typ) == TPX_VAL;
}

BOOL LOCALF isvar(I4B typ)
{ // 曄悢抣(壜曄側塃曈抣)
  return ismut(typ) && clsof(typ) == TPX_VAL;
}

BOOL LOCALF isobj(I4B typ)
{ // 嵍曈抣
  return clsof(typ) == TPX_OBJ;
}

BOOL LOCALF isdat(I4B typ)
{ // 弶婜抣偁傝惷揑曄悢
  return clsof(typ) == TPX_DAT;
}

BOOL LOCALF isbss(I4B typ)
{ // 弶婜抣側偟惷揑曄悢
  return clsof(typ) == TPX_BSS;
}

BOOL LOCALF isaut(I4B typ)
{ // 帺摦曄悢
  return clsof(typ) == TPX_AUT;
}

BOOL LOCALF istyp(I4B typ)
{ // 宆柤
  return clsof(typ) == TPX_TYP;
}

I4B  LOCALF toimm(I4B typ)
{ // 晄曄壔
  return typ | TPX_IMM;
}

I4B  LOCALF tomut(I4B typ)
{ // 壜曄壔
  return typ &~TPX_IMM;
}

I4B  LOCALF tocns(I4B typ)
{ // 掕悢抣壔
  return toimm(valof(typ));
}

I4B  LOCALF tovar(I4B typ)
{ // 曄悢抣壔
  return tomut(valof(typ));
}

I4B  LOCALF toobj(I4B typ)
{ // 嵍曈抣壔
  return valof(typ) | TPX_OBJ;
}

I4B  LOCALF todat(I4B typ)
{ // 弶婜抣偁傝惷揑曄悢壔
  return valof(typ) | TPX_DAT;
}

I4B  LOCALF tobss(I4B typ)
{ // 弶婜抣側偟惷揑曄悢壔
  return valof(typ) | TPX_BSS;
}

I4B  LOCALF toaut(I4B typ)
{ // 帺摦曄悢壔
  return valof(typ) | TPX_AUT;
}

I4B  LOCALF totyp(I4B typ)
{ // 宆柤壔
  return valof(typ) | TPX_TYP;
}

void LOCALF register_primitive_types(void)
{ // 婎杮宆忣曬偺搊榐
  I4B i;

  for (i = CT_VOI; i <= CT_F8B; i++) {
    regstyp(NSP_GLO, 0, 0, ctpsiz(i));
  }
}

I4B  LOCALF typnsp(I4B typ)
{ // 柤慜嬻娫
  return typptr(idxof(typ))->nsp;
}

BOOL LOCALF isvoi(I4B typ)
{ // 嬻宆
  return tovar(typ) == CT_VOI;
}

BOOL LOCALF isari(I4B typ)
{ // 嶼弍宆
  return tovar(typ) >= CT_I1B && tovar(typ) <= CT_F8B;
}

BOOL LOCALF isptr(I4B typ)
{ // 嶲徠宆
  return !!(typ & REF_PT1);
}

BOOL LOCALF isbas(I4B typ)
{ // 婎杮宆傑偨偼嶲徠宆
  return isvoi(typ) || isari(typ) || isptr(typ);
}

BOOL LOCALF isary(I4B typ)
{ // 攝楍宆
  return !isbas(typ) && typnsp(typ) == 0;
}

BOOL LOCALF isstu(I4B typ)
{ // 峔憿懱宆
  return !isbas(typ) && nsxof(typnsp(typ)) == NSX_STU;
}

BOOL LOCALF isbfn(I4B typ)
{ // 價儖僩僀儞娭悢宆
  return !isbas(typ) && nsxof(typnsp(typ)) == NSX_BFN;
}

BOOL LOCALF iscfn(I4B typ)
{ // 儐乕僓乕掕媊娭悢宆
  return !isbas(typ) && nsxof(typnsp(typ)) == NSX_CFN;
}

BOOL LOCALF isfun(I4B typ)
{ // 娭悢宆
  return isbfn(typ) || iscfn(typ);
}

BOOL LOCALF issca(I4B typ)
{ // 僗僇儔宆傑偨偼娭悢宆
  return isari(typ) || isptr(typ) || isfun(typ);
}

BOOL LOCALF isint(I4B typ)
{ // 係僶僀僩惍悢宆
  return tovar(typ) == CT_I4B || tovar(typ) == CT_U4B;
}

BOOL LOCALF isflo(I4B typ)
{ // 俉僶僀僩幚悢宆
  return tovar(typ) == CT_F8B;
}

BOOL LOCALF isvoiptr(I4B typ)
{ // 斈梡偺嶲徠宆
  return (tovar(typ) &~REF_IM1) == (REF_PT1|CT_VOI);
}

I4B  LOCALF elmtyp(I4B typ)
{ // 攝楍偺梫慺偺宆
  return typptr(idxof(typ))->typ;
}

I4B  LOCALF nelm(I4B typ)
{ // 攝楍偺梫慺悢
  return typptr(idxof(typ))->len;
}

I4B  LOCALF nmem(I4B typ)
{ // 峔憿懱偺儊儞僶乕悢
  return typptr(idxof(typ))->len;
}

I4B  LOCALF rettyp(I4B typ)
{ // 娭悢偺栠傝抣偺宆
  return typptr(idxof(typ))->typ;
}

I4B  LOCALF narg(I4B typ)
{ // 娭悢偺堷悢偺悢
  return typptr(idxof(typ))->len;
}

I4B  LOCALF tonum(I4B typ)
{ // 嶲徠宆傑偨偼娭悢宆偼UINT宆偲傒側偡
  return (isptr(typ) || isfun(typ))? CT_U4B: tovar(typ);
}

I4B  LOCALF sizof0(I4B typ)
{ // 僆僽僕僃僋僩偺僒僀僘
  return (isptr(typ) || isfun(typ))? 4: typptr(idxof(typ))->osz;
}

I4B  LOCALF sizof(I4B typ)
{ // 僆僽僕僃僋僩偺僒僀僘
  if (isvoi(typ)) { cerr(E_VOI);}
  return sizof0(typ);
}

I4B  LOCALF ptrto(I4B typ)
{ // 嶲徠
  if (isimm(typ)) {
    if (!(typ & REF_PT1)) { return (typ &~TPX_IMM) | REF_IM1 | REF_PT1;}
    if (!(typ & REF_PT2)) { return (typ &~TPX_IMM) | REF_IM2 | REF_PT2;}
    if (!(typ & REF_PT3)) { return (typ &~TPX_IMM) | REF_IM3 | REF_PT3;}
    if (!(typ & REF_PT4)) { return (typ &~TPX_IMM) | REF_IM4 | REF_PT4;}
  } else {
    if (!(typ & REF_PT1)) { return typ | REF_PT1;}
    if (!(typ & REF_PT2)) { return typ | REF_PT2;}
    if (!(typ & REF_PT3)) { return typ | REF_PT3;}
    if (!(typ & REF_PT4)) { return typ | REF_PT4;}
  }
  cerr(E_MUL);
}

I4B  LOCALF deref(I4B typ)
{ // 媡嶲徠
  if (typ & REF_PT4) { return ((typ & REF_IM4)? TPX_IMM: 0) | (typ &~(TPX_IMM|REF_IM4|REF_PT4));}
  if (typ & REF_PT3) { return ((typ & REF_IM3)? TPX_IMM: 0) | (typ &~(TPX_IMM|REF_IM3|REF_PT3));}
  if (typ & REF_PT2) { return ((typ & REF_IM2)? TPX_IMM: 0) | (typ &~(TPX_IMM|REF_IM2|REF_PT2));}
  if (typ & REF_PT1) { return ((typ & REF_IM1)? TPX_IMM: 0) | (typ &~(TPX_IMM|REF_IM1|REF_PT1));}
  cerr(E_PTR);
}

I4B  LOCALF aryof(I4B typ, I4B ne)
{ // 僆僽僕僃僋僩偺攝楍宆
  rTYPE pt;

  if (!(pt = srchtyp(NSP_GLO, tovar(typ), ne))) {
    pt = regstyp(NSP_GLO, tovar(typ), ne, ne * sizof(typ));
  }
  return tpxof(typ) | typidx(pt);
}

I4B  LOCALF prom(I4B typ)
{ // 奿忋偘
  switch (tovar(typ)) {
  case CT_I1B: case CT_U1B: case CT_I2B: case CT_U2B: return tpxof(typ) | CT_I4B;
  case CT_F4B: return tpxof(typ) | CT_F8B;
  }
  return typ;
}

BOOL LOCALF iscmpptr0(I4B ltp, I4B rtp)
{ // 戙擖壜擻側億僀儞僞宆
  ltp = tovar(deref(ltp)); rtp = tovar(deref(rtp));
  return ltp == rtp || (ltp <= CT_U8B && rtp <= CT_U8B && sizof(ltp) == sizof(rtp));
}

BOOL LOCALF iscmpptr(I4B ltp, I4B rtp)
{ // 戙擖壜擻側億僀儞僞宆
  if (!isptr(ltp) || !isptr(rtp)) return FALSE;
  return isvoiptr(ltp) || isvoiptr(rtp) || iscmpptr0(ltp, rtp);
}

BOOL LOCALF iscmpfun(I4B ltp, I4B rtp)
{ // 戙擖壜擻側娭悢宆
  rTYPE pl, pr;

  if (!(isfun(ltp) || isfun(rtp))) return FALSE;
  if (isvoiptr(ltp) || isvoiptr(rtp) || tovar(ltp) == tovar(rtp)) return TRUE;
  pl = typptr(idxof(ltp)); pr = typptr(idxof(rtp));
  return pl->typ == pr->typ && pl->osz == pr->osz;
}

void LOCALF glocns(I4B typ, rSTR st, rANY pv)
{ // 掕悢
  rNAME pi;

  if (!!(pi = srchnam(NSP_GLO, st))) {
    if (pi->typ != tocns(typ) || memcmp(pvdef(pi->ofs), pv, sizof(typ))) { cerr(E_DUP);}
  } else {
    regsnam(NSP_GLO, tocns(typ), st, outdef(pv, sizof(typ)));
  }
}

void LOCALF glodat(I4B typ, rSTR st, HBLK bb, HBLK rl)
{ // 弶婜抣偁傝奜晹曄悢
  if (srchnam(NSP_GLO, st)) { cerr(E_DUP);}
  regsnam(NSP_GLO, todat(typ), st, outdat((rSEGS)bb, (rIDXS)rl));
}

void LOCALF globss(I4B typ, rSTR st)
{ // 弶婜抣側偟奜晹曄悢
  if (srchnam(NSP_GLO, st)) { cerr(E_DUP);}
  regsnam(NSP_GLO, tobss(typ), st, outbss(sizof(typ)));
}

void LOCALF locdat(I4B typ, rSTR st, HBLK bb, HBLK rl)
{ // 弶婜抣偁傝惷揑曄悢
  if (srchnam(NSX_CFN | cfn(), st)) { cerr(E_DUP);}
  regsnam(NSX_CFN | cfn(), todat(typ), st, outdat((rSEGS)bb, (rIDXS)rl));
}

void LOCALF locbss(I4B typ, rSTR st)
{ // 弶婜抣側偟惷揑曄悢
  if (srchnam(NSX_CFN | cfn(), st)) { cerr(E_DUP);}
  regsnam(NSX_CFN | cfn(), tobss(typ), st, outbss(sizof(typ)));
}

void LOCALF locaut(I4B typ, rSTR st)
{ // 帺摦曄悢
  if (srchnam(NSX_CFN | cfn(), st)) { cerr(E_DUP);}
  regsnam(NSX_CFN | cfn(), toaut(typ), st, outaut(sizof(typ)));
}

I4B  LOCALF regslab(rSTR st)
{ // 儔儀儖偺搊榐
  pNAME pi;

  if (st) {
    if (!(pi = srchnam(NSX_LAB | cfn(), st))) {
      pi = regsnam(NSX_LAB | cfn(), 0, st, codlen());
    } else {
      if (pi->ofs == 0) { pi->ofs = codlen();} else { cerr(E_DUP);}
    }
  } else {
    pi = regsnam(NSX_JPL | cfn(), 0, "_", codlen());
  }
  return namidx(pi);
}

void LOCALF fixlab(I4B lid)
{ // 儔儀儖偺廋惓
  namptr(lid)->ofs = codlen();
}

void LOCALF jmplid(I4B lid)
{ // break暥丄continue暥丄return暥偵傛傞僕儍儞僾
  outcod(jmp_v, 0);
  regsnam(NSX_JPS | cfn(), lid, "_", codlen());
}

void LOCALF jmplab(rSTR st)
{ // goto暥偵傛傞僕儍儞僾
  rNAME pi;

  if (!(pi = srchnam(NSX_LAB | cfn(), st))) {
    pi = regsnam(NSX_LAB | cfn(), 0, st, 0);
  }
  jmplid(namidx(pi));
}

void LOCALF fixjmp(void)
{ // 僕儍儞僾愭偺夝寛
  I4B i, ln0, ln1, nsp;
  rNAME pi;

  nsp = NSX_JPS | cfn();
  for (i = 0; !!(pi = srchord(nsp, i)); i++) {
    ln0 = pi->ofs;
    ln1 = namptr(pi->typ)->ofs; if (ln1 == 0) { cerr(E_JMP);}
    fixcod2(ln0 - 2, ln1 - ln0);
  }
}

I4B  LOCALF fetch(I4B typ)
{ // 嵍曈抣側傜抣傪庢傝弌偡
  if (isvoi(typ)) { cerr(E_VOI);}
  if (isary(typ)) { return ptrto(elmtyp(typ));}
  if (isobj(typ)) {
    if (chkbits(TRN_INI)) { cerr(E_INI);}
    if (!issca(typ)) { cerr(E_SCA);}
    switch (tonum(typ)) {
    case CT_I1B: outcod(fch_c); break;
    case CT_U1B: outcod(fch_b); break;
    case CT_I2B: outcod(fch_s); break;
    case CT_U2B: outcod(fch_w); break;
    case CT_I4B:
    case CT_U4B: outcod(fch_i); break;
    case CT_I8B:
    case CT_U8B: outcod(fch_l); break;
    case CT_F4B: outcod(fch_f); break;
    case CT_F8B: outcod(fch_d); break;
    }
    typ = tovar(typ);
  }
  return prom(typ);
}

I4B  LOCALF preinc(I4B typ)
{ // 慜抲憹暘
  if (!isobj(typ)) { cerr(E_OBJ);}
  if (!ismut(typ)) { cerr(E_IMM);}
  if (chkbits(TRN_INI)) { cerr(E_INI);}
  if (!(isari(typ) || isptr(typ))) { cerr(E_ASN);}
  switch (tovar(typ)) {
  case CT_I1B:
  case CT_U1B: outcod(inc_c); break;
  case CT_I2B:
  case CT_U2B: outcod(inc_s); break;
  case CT_I4B:
  case CT_U4B: outcod(inc_i); break;
  case CT_I8B:
  case CT_U8B: outcod(inc_l); break;
  case CT_F4B: outcod(inc_f); break;
  case CT_F8B: outcod(inc_d); break;
  default: outcod(inc_p, sizof(deref(typ))); break;
  }
  return prom(tovar(typ));
}

I4B  LOCALF predec(I4B typ)
{ // 慜抲尭暘
  if (!isobj(typ)) { cerr(E_OBJ);}
  if (!ismut(typ)) { cerr(E_IMM);}
  if (chkbits(TRN_INI)) { cerr(E_INI);}
  if (!(isari(typ) || isptr(typ))) { cerr(E_ASN);}
  switch (tovar(typ)) {
  case CT_I1B:
  case CT_U1B: outcod(dec_c); break;
  case CT_I2B:
  case CT_U2B: outcod(dec_s); break;
  case CT_I4B:
  case CT_U4B: outcod(dec_i); break;
  case CT_I8B:
  case CT_U8B: outcod(dec_l); break;
  case CT_F4B: outcod(dec_f); break;
  case CT_F8B: outcod(dec_d); break;
  default: outcod(dec_p, sizof(deref(typ))); break;
  }
  return prom(tovar(typ));
}

void LOCALF posopr(I4B c1, I4B c2, I4B c3)
{ // 屻抲憹暘丄尭暘
  outcod(dup_i); outcod(c1); outcod(c2); outcod(c3); outcod(drp_i);
}

I4B  LOCALF posinc(I4B typ)
{ // 屻抲憹暘
  if (!isobj(typ)) { cerr(E_OBJ);}
  if (!ismut(typ)) { cerr(E_IMM);}
  if (chkbits(TRN_INI)) { cerr(E_INI);}
  if (!(isari(typ) || isptr(typ))) { cerr(E_ASN);}
  switch (tovar(typ)) {
  case CT_I1B: posopr(fch_c, swp_i, inc_c); break;
  case CT_U1B: posopr(fch_b, swp_i, inc_c); break;
  case CT_I2B: posopr(fch_s, swp_i, inc_s); break;
  case CT_U2B: posopr(fch_w, swp_i, inc_s); break;
  case CT_I4B:
  case CT_U4B: outcod(inc_i_i); break;
  case CT_I8B:
  case CT_U8B: posopr(fch_l, swp_i_d, inc_l); break;
  case CT_F4B: posopr(fch_f, swp_i_d, inc_f); break;
  case CT_F8B: posopr(fch_d, swp_i_d, inc_d); break;
  default: outcod(inc_p_p, sizof(deref(typ))); break;
  }
  return prom(tovar(typ));
}

I4B  LOCALF posdec(I4B typ)
{ // 屻抲尭暘
  if (!isobj(typ)) { cerr(E_OBJ);}
  if (!ismut(typ)) { cerr(E_IMM);}
  if (chkbits(TRN_INI)) { cerr(E_INI);}
  if (!(isari(typ) || isptr(typ))) { cerr(E_ASN);}
  switch (tovar(typ)) {
  case CT_I1B: posopr(fch_c, swp_i, dec_c); break;
  case CT_U1B: posopr(fch_b, swp_i, dec_c); break;
  case CT_I2B: posopr(fch_s, swp_i, dec_s); break;
  case CT_U2B: posopr(fch_w, swp_i, dec_s); break;
  case CT_I4B:
  case CT_U4B: outcod(dec_i_i); break;
  case CT_I8B:
  case CT_U8B: posopr(fch_l, swp_i_d, dec_l); break;
  case CT_F4B: posopr(fch_f, swp_i_d, dec_f); break;
  case CT_F8B: posopr(fch_d, swp_i_d, dec_d); break;
  default: outcod(dec_p_p, sizof(deref(typ))); break;
  }
  return prom(tovar(typ));
}

void LOCALF iassign(I4B ltp, I4B rtp, pANY lpv, rANY rpv)
{ // 戙擖(弶婜壔)

  if (!(isari(ltp) && isari(rtp) || iscmpptr(ltp, rtp) || iscmpfun(ltp, rtp))) { cerr(E_ASN);}
  switch (tonum(ltp)) {
  case CT_I1B:
    switch (tonum(rtp)) {
    case CT_I4B:
    case CT_U4B: *(pI1B)lpv = (I1B)*(rI4B)rpv; break;
    case CT_I8B:
    case CT_U8B: *(pI1B)lpv = (I1B)*(rI8B)rpv; break;
    case CT_F8B: *(pI1B)lpv = (I1B)*(rF8B)rpv; break;
    default: cerr(E_NAC);
    } break;
  case CT_U1B:
    switch (tonum(rtp)) {
    case CT_I4B:
    case CT_U4B: *(pU1B)lpv = (U1B)*(rI4B)rpv; break;
    case CT_I8B:
    case CT_U8B: *(pU1B)lpv = (U1B)*(rI8B)rpv; break;
    case CT_F8B: *(pU1B)lpv = (U1B)*(rF8B)rpv; break;
    default: cerr(E_NAC);
    } break;
  case CT_I2B:
    switch (tonum(rtp)) {
    case CT_I4B:
    case CT_U4B: *(pI2B)lpv = (I2B)*(rI4B)rpv; break;
    case CT_I8B:
    case CT_U8B: *(pI2B)lpv = (I2B)*(rI8B)rpv; break;
    case CT_F8B: *(pI2B)lpv = (I2B)*(rF8B)rpv; break;
    default: cerr(E_NAC);
    } break;
  case CT_U2B:
    switch (tonum(rtp)) {
    case CT_I4B:
    case CT_U4B: *(pU2B)lpv = (U2B)*(rI4B)rpv; break;
    case CT_I8B:
    case CT_U8B: *(pU2B)lpv = (U2B)*(rI8B)rpv; break;
    case CT_F8B: *(pU2B)lpv = (U2B)*(rF8B)rpv; break;
    default: cerr(E_NAC);
    } break;
  case CT_I4B:
    switch (tonum(rtp)) {
    case CT_I4B:
    case CT_U4B: *(pI4B)lpv = *(rI4B)rpv; break;
    case CT_I8B:
    case CT_U8B: *(pI4B)lpv = (I4B)*(rI8B)rpv; break;
    case CT_F8B: *(pI4B)lpv = (I4B)*(rF8B)rpv; break;
    default: cerr(E_NAC);
    } break;
  case CT_U4B:
    switch (tonum(rtp)) {
    case CT_I4B:
    case CT_U4B: *(pU4B)lpv = *(rI4B)rpv; break;
    case CT_I8B:
    case CT_U8B: *(pU4B)lpv = (U4B)*(rI8B)rpv; break;
    case CT_F8B: *(pU4B)lpv = (U4B)*(rF8B)rpv; break;
    default: cerr(E_NAC);
    } break;
  case CT_I8B:
    switch (tonum(rtp)) {
    case CT_I4B: *(pI8B)lpv = (I8B)*(rI4B)rpv; break;
    case CT_U4B: *(pI8B)lpv = (I8B)*(rU4B)rpv; break;
    case CT_I8B:
    case CT_U8B: *(pI8B)lpv = *(rI8B)rpv; break;
    case CT_F8B: *(pI8B)lpv = (I8B)*(rF8B)rpv; break;
    default: cerr(E_NAC);
    } break;
  case CT_U8B:
    switch (tonum(rtp)) {
    case CT_I4B: *(pU8B)lpv = (U8B)*(rI4B)rpv; break;
    case CT_U4B: *(pU8B)lpv = (U8B)*(rU4B)rpv; break;
    case CT_I8B:
    case CT_U8B: *(pU8B)lpv = *(rU8B)rpv; break;
    case CT_F8B: *(pU8B)lpv = (U8B)*(rF8B)rpv; break;
    default: cerr(E_NAC);
    } break;
  case CT_F4B:
    switch (tonum(rtp)) {
    case CT_I4B: *(pF4B)lpv = (F4B)*(rI4B)rpv; break;
    case CT_U4B: *(pF4B)lpv = (F4B)*(rU4B)rpv; break;
    case CT_I8B: *(pF4B)lpv = (F4B)*(rI8B)rpv; break;
    case CT_U8B: *(pF4B)lpv = (F4B)*(rU8B)rpv; break;
    case CT_F8B: *(pF4B)lpv = (F4B)*(rF8B)rpv; break;
    default: cerr(E_NAC);
    } break;
  case CT_F8B:
    switch (tonum(rtp)) {
    case CT_I4B: *(pF8B)lpv = (F8B)*(rI4B)rpv; break;
    case CT_U4B: *(pF8B)lpv = (F8B)*(rU4B)rpv; break;
    case CT_I8B: *(pF8B)lpv = (F8B)*(rI8B)rpv; break;
    case CT_U8B: *(pF8B)lpv = (F8B)*(rU8B)rpv; break;
    case CT_F8B: *(pF8B)lpv = *(rF8B)rpv; break;
    default: cerr(E_NAC);
    } break;
  default: cerr(E_NAC);
  }
}

I4B  LOCALF assign(I4B ltp, I4B rtp)
{ // 戙擖
  if (!isobj(ltp)) { cerr(E_OBJ);}
  if (!ismut(ltp)) { cerr(E_IMM);}
  if (chkbits(TRN_INI)) { cerr(E_INI);}
  if (!(isari(ltp) && isari(rtp) || iscmpptr(ltp, rtp) || iscmpfun(ltp, rtp))) { cerr(E_ASN);}
  switch (tonum(ltp)) {
  case CT_I1B:
    switch (tonum(rtp)) {
    case CT_I4B:
    case CT_U4B: outcod(sto_c); break;
    case CT_I8B:
    case CT_U8B: outcod(cnv_l_c); outcod(sto_c); break;
    case CT_F8B: outcod(cnv_d_i); outcod(sto_c); break;
    default: cerr(E_NAC);
    } break;
  case CT_U1B:
    switch (tonum(rtp)) {
    case CT_I4B:
    case CT_U4B: outcod(sto_c); break;
    case CT_I8B:
    case CT_U8B: outcod(cnv_l_b); outcod(sto_c); break;
    case CT_F8B: outcod(cnv_d_i); outcod(sto_c); break;
    default: cerr(E_NAC);
    } break;
  case CT_I2B:
    switch (tonum(rtp)) {
    case CT_I4B:
    case CT_U4B: outcod(sto_s); break;
    case CT_I8B:
    case CT_U8B: outcod(cnv_l_s); outcod(sto_s); break;
    case CT_F8B: outcod(cnv_d_i); outcod(sto_s); break;
    default: cerr(E_NAC);
    } break;
  case CT_U2B:
    switch (tonum(rtp)) {
    case CT_I4B:
    case CT_U4B: outcod(sto_s); break;
    case CT_I8B:
    case CT_U8B: outcod(cnv_l_w); outcod(sto_s); break;
    case CT_F8B: outcod(cnv_d_i); outcod(sto_s); break;
    default: cerr(E_NAC);
    } break;
  case CT_I4B:
    switch (tonum(rtp)) {
    case CT_I4B:
    case CT_U4B: outcod(sto_i); break;
    case CT_I8B:
    case CT_U8B: outcod(cnv_l_i); outcod(sto_i); break;
    case CT_F8B: outcod(cnv_d_i); outcod(sto_i); break;
    default: cerr(E_NAC);
    } break;
  case CT_U4B:
    switch (tonum(rtp)) {
    case CT_I4B:
    case CT_U4B: outcod(sto_i); break;
    case CT_I8B:
    case CT_U8B: outcod(cnv_l_i); outcod(sto_i); break;
    case CT_F8B: outcod(cnv_d_i); outcod(sto_i); break;
    default: cerr(E_NAC);
    } break;
  case CT_I8B:
    switch (tonum(rtp)) {
    case CT_I4B: outcod(cnv_i_l); outcod(sto_l); break;
    case CT_U4B: outcod(cnv_u_l); outcod(sto_l); break;
    case CT_I8B:
    case CT_U8B: outcod(sto_l); break;
    case CT_F8B: outcod(cnv_d_l); outcod(sto_l); break;
    default: cerr(E_NAC);
    } break;
  case CT_U8B:
    switch (tonum(rtp)) {
    case CT_I4B: outcod(cnv_i_l); outcod(sto_l); break;
    case CT_U4B: outcod(cnv_u_l); outcod(sto_l); break;
    case CT_I8B:
    case CT_U8B: outcod(sto_l); break;
    case CT_F8B: outcod(cnv_d_q); outcod(sto_l); break;
    default: cerr(E_NAC);
    } break;
  case CT_F4B:
    switch (tonum(rtp)) {
    case CT_I4B: outcod(cnv_i_d); outcod(sto_f); break;
    case CT_U4B: outcod(cnv_u_d); outcod(sto_f); break;
    case CT_I8B: outcod(cnv_l_d); outcod(sto_f); break;
    case CT_U8B: outcod(cnv_q_d); outcod(sto_f); break;
    case CT_F8B: outcod(sto_f); break;
    default: cerr(E_NAC);
    } break;
  case CT_F8B:
    switch (tonum(rtp)) {
    case CT_I4B: outcod(cnv_i_d); outcod(sto_d); break;
    case CT_U4B: outcod(cnv_u_d); outcod(sto_d); break;
    case CT_I8B: outcod(cnv_l_d); outcod(sto_d); break;
    case CT_U8B: outcod(cnv_q_d); outcod(sto_d); break;
    case CT_F8B: outcod(sto_d); break;
    default: cerr(E_NAC);
    } break;
  default: cerr(E_NAC);
  }
  return tovar(ltp);
}

void LOCALF typcnv0(I4B ltp, I4B rtp)
{ // 宆曄姺
  switch (tonum(ltp)) {
  case CT_I1B:
    switch (tonum(rtp)) {
    case CT_I4B:
    case CT_U4B: outcod(cnv_i_c); break;
    case CT_I8B:
    case CT_U8B: outcod(cnv_l_c); break;
    case CT_F8B: outcod(cnv_d_c); break;
    default: cerr(E_NAC);
    } break;
  case CT_U1B:
    switch (tonum(rtp)) {
    case CT_I4B:
    case CT_U4B: outcod(cnv_i_b); break;
    case CT_I8B:
    case CT_U8B: outcod(cnv_l_b); break;
    case CT_F8B: outcod(cnv_d_b); break;
    default: cerr(E_NAC);
    } break;
  case CT_I2B:
    switch (tonum(rtp)) {
    case CT_I4B:
    case CT_U4B: outcod(cnv_i_s); break;
    case CT_I8B:
    case CT_U8B: outcod(cnv_l_s); break;
    case CT_F8B: outcod(cnv_d_s); break;
    default: cerr(E_NAC);
    } break;
  case CT_U2B:
    switch (tonum(rtp)) {
    case CT_I4B:
    case CT_U4B: outcod(cnv_i_w); break;
    case CT_I8B:
    case CT_U8B: outcod(cnv_l_w); break;
    case CT_F8B: outcod(cnv_d_w); break;
    default: cerr(E_NAC);
    } break;
  case CT_I4B:
    switch (tonum(rtp)) {
    case CT_I4B:
    case CT_U4B: break;
    case CT_I8B:
    case CT_U8B: outcod(cnv_l_i); break;
    case CT_F8B: outcod(cnv_d_i); break;
    default: cerr(E_NAC);
    } break;
  case CT_U4B:
    switch (tonum(rtp)) {
    case CT_I4B:
    case CT_U4B: break;
    case CT_I8B:
    case CT_U8B: outcod(cnv_l_u); break;
    case CT_F8B: outcod(cnv_d_u); break;
    default: cerr(E_NAC);
    } break;
  case CT_I8B:
    switch (tonum(rtp)) {
    case CT_I4B: outcod(cnv_i_l); break;
    case CT_U4B: outcod(cnv_u_l); break;
    case CT_I8B:
    case CT_U8B: break;
    case CT_F8B: outcod(cnv_d_l); break;
    default: cerr(E_NAC);
    } break;
  case CT_U8B:
    switch (tonum(rtp)) {
    case CT_I4B: outcod(cnv_i_l); break;
    case CT_U4B: outcod(cnv_u_l); break;
    case CT_I8B:
    case CT_U8B: break;
    case CT_F8B: outcod(cnv_d_q); break;
    default: cerr(E_NAC);
    } break;
  case CT_F4B:
  case CT_F8B:
    switch (tonum(rtp)) {
    case CT_I4B: outcod(cnv_i_d); break;
    case CT_U4B: outcod(cnv_u_d); break;
    case CT_I8B: outcod(cnv_l_d); break;
    case CT_U8B: outcod(cnv_q_d); break;
    case CT_F8B: break;
    default: cerr(E_NAC);
    } break;
  default: cerr(E_NAC);
  }
}

I4B  LOCALF argprom(I4B ltp, I4B rtp)
{ // 幚堷悢奼挘
  if (!(isari(ltp) && isari(rtp) || iscmpptr(ltp, rtp) || iscmpfun(ltp, rtp))) { cerr(E_ASN);}
  typcnv0(ltp, rtp);
  return prom(tovar(ltp));
}

void LOCALF eztest(I4B typ)
{ // 楇専嵏
  switch (sizof(fetch(typ))) {
  case 4:  outcod(eq_i_0); break;
  case 8:  outcod(eq_d_0); break;
  default: cerr(E_NAC);
  }
}

void LOCALF nztest(I4B typ)
{ // 旕楇専嵏
  switch (sizof(fetch(typ))) {
  case 4:  outcod(ne_i_0); break;
  case 8:  outcod(ne_d_0); break;
  default: cerr(E_NAC);
  }
}

BOOL LOCALF drop(I4B typ)
{ // 抣傪幪偰傞
  if (isvoi(typ)) return TRUE;
  if (isobj(typ)) { outcod(drp_i); return TRUE;}
  switch (sizof0(prom(typ))) {
  case 4:  outcod(drp_i); break;
  case 8:  outcod(drp_d); break;
  default: cerr(E_NAC);
  }
  return TRUE;
}

I4B  LOCALF typcnv(I4B ltp, I4B rtp)
{ // 宆曄姺
  if (isvoi(ltp)) { drop(rtp); return ltp;}
  if (isvoi(rtp)) { cerr(E_VOI);}
  if (!issca(ltp) || !(issca(rtp) || isary(rtp))) { cerr(E_CST);}
  if (isari(ltp) || isary(rtp)) { rtp = fetch(rtp);}
  typcnv0(ltp, rtp);
  return tpxof(rtp) | tovar(ltp);
}

I4B  LOCALF aricnv(I4B ltp, I4B rtp)
{ // 捠忢偺嶼弍曄姺
  I4B typ;

  if (!(isari(ltp) && isari(rtp))) { cerr(E_OPR);}
  switch (tovar(ltp)) {
  case CT_I4B:
    switch (tovar(rtp)) {
    case CT_I4B:
    case CT_U4B: typ = rtp; break;
    case CT_I8B:
    case CT_U8B: outcod(swp_i_d); outcod(cnv_i_l); outcod(swp_d); typ = rtp; break;
    case CT_F8B: outcod(swp_i_d); outcod(cnv_i_d); outcod(swp_d); typ = rtp; break;
    default: cerr(E_NAC);
    } break;
  case CT_U4B:
    switch (tovar(rtp)) {
    case CT_I4B:
    case CT_U4B: typ = ltp; break;
    case CT_I8B:
    case CT_U8B: outcod(swp_i_d); outcod(cnv_u_l); outcod(swp_d); typ = rtp; break;
    case CT_F8B: outcod(swp_i_d); outcod(cnv_u_d); outcod(swp_d); typ = rtp; break;
    default: cerr(E_NAC);
    } break;
  case CT_I8B:
    switch (tovar(rtp)) {
    case CT_I4B: outcod(cnv_i_l); typ = ltp; break;
    case CT_U4B: outcod(cnv_u_l); typ = ltp; break;
    case CT_I8B:
    case CT_U8B: typ = rtp; break;
    case CT_F8B: outcod(cnv_l_d); typ = rtp; break;
    default: cerr(E_NAC);
    } break;
  case CT_U8B:
    switch (tovar(rtp)) {
    case CT_I4B: outcod(cnv_i_l); typ = ltp; break;
    case CT_U4B: outcod(cnv_u_l); typ = ltp; break;
    case CT_I8B:
    case CT_U8B: typ = ltp; break;
    case CT_F8B: outcod(cnv_q_d); typ = rtp; break;
    default: cerr(E_NAC);
    } break;
  case CT_F8B:
    switch (tovar(rtp)) {
    case CT_I4B: outcod(cnv_i_d); typ = ltp; break;
    case CT_U4B: outcod(cnv_u_d); typ = ltp; break;
    case CT_I8B: outcod(cnv_l_d); typ = ltp; break;
    case CT_U8B: outcod(cnv_q_d); typ = ltp; break;
    case CT_F8B: typ = rtp; break;
    default: cerr(E_NAC);
    } break;
  default: cerr(E_NAC);
  }
  return typ;
}

I4B  LOCALF cndcnv(I4B ltp, I4B rtp, pI4B po)
{ // 嶼弍曄姺(忦審幃)
  if (iscmpptr(ltp, rtp) || iscmpfun(ltp, rtp)) return 0;
  if (!(isari(ltp) && isari(rtp))) return 3;
  switch (tovar(ltp)) {
  case CT_I4B:
    switch (tovar(rtp)) {
    case CT_I4B:
    case CT_U4B: return 0;
    case CT_I8B:
    case CT_U8B: *po = cnv_i_l; return 1;
    case CT_F8B: *po = cnv_i_d; return 1;
    default: cerr(E_NAC);
    } break;
  case CT_U4B:
    switch (tovar(rtp)) {
    case CT_I4B:
    case CT_U4B: return 0;
    case CT_I8B:
    case CT_U8B: *po = cnv_u_l; return 1;
    case CT_F8B: *po = cnv_u_d; return 1;
    default: cerr(E_NAC);
    } break;
  case CT_I8B:
    switch (tovar(rtp)) {
    case CT_I4B: *po = cnv_i_l; return 2;
    case CT_U4B: *po = cnv_u_l; return 2;
    case CT_I8B:
    case CT_U8B: return 0;
    case CT_F8B: *po = cnv_l_d; return 1;
    default: cerr(E_NAC);
    } break;
  case CT_U8B:
    switch (tovar(rtp)) {
    case CT_I4B: *po = cnv_i_l; return 2;
    case CT_U4B: *po = cnv_u_l; return 2;
    case CT_I8B:
    case CT_U8B: return 0;
    case CT_F8B: *po = cnv_q_d; return 1;
    default: cerr(E_NAC);
    } break;
  case CT_F8B:
    switch (tovar(rtp)) {
    case CT_I4B: *po = cnv_i_d; return 2;
    case CT_U4B: *po = cnv_u_d; return 2;
    case CT_I8B: *po = cnv_l_d; return 2;
    case CT_U8B: *po = cnv_q_d; return 2;
    case CT_F8B: return 0;
    default: cerr(E_NAC);
    } break;
  default: cerr(E_NAC);
  }
  return 3;
}

I4B  LOCALF postfix_name(void)
{ // 屻抲柤
  I4B typ;
  rSTR cp;
  rNAME pi;

  if (token() != TKN_IDN) { cerr(E_IDN);}
  if (!!(pi = srchnam(NSX_CFN | cfn(), buf()))) {
    typ = pi->typ;
    if (isaut(typ) || isdat(typ) || isbss(typ)) {
      typ = toobj(typ);
    } else { cerr(E_NAC);}
  } else if (!!(pi = srchnam(NSP_GLO, buf()))) {
    typ = pi->typ;
    if (iscns(typ)) {
      typ = tovar(typ);
    } else if (isdat(typ) || isbss(typ)) {
      typ = toobj(typ);
    } else if (isfun(typ)) {
      ;
    } else { cerr(E_NAC);}
  } else { cerr(E_UNK);}
  do {
    cp = cpos();
    switch (token()) {
    case COP_LBK:
      if (!isary(typ)) { cerr(E_ARY);}
      if (!token_is(TKN_I4B) && !token_is(TKN_U4B)) { cerr(E_UNX);}
      if (!token_is(COP_RBK)) { cerr(E_DLM);}
      typ = elmtyp(typ);
      break;
    case COP_ARW:
      typ = deref(typ);
      // fall through
    case COP_DOT:
      if (!isstu(typ)) { cerr(E_STU);}
      if (token() != TKN_IDN) { cerr(E_IDN);}
      if (!(pi = srchnam(typnsp(typ), buf()))) { cerr(E_NME);}
      typ = pi->typ;
      break;
    default:
      restart(cp);
      break;
    }
  } while (cp != cpos());
  return typ;
}

I4B  LOCALF type_specifier(void)
{ // 宆巜掕巕
  rNAME pi;

  switch (token()) {
  case TKN_IDN:
    pi = srchnam(NSP_GLO, buf()); if (!pi || !istyp(pi->typ)) { return CT_ERR;}
    return valof(pi->typ);
  case CKW_VOI: return CT_VOI;
  case CKW_I1B: return CT_I1B;
  case CKW_U1B: return CT_U1B;
  case CKW_I2B: return CT_I2B;
  case CKW_U2B: return CT_U2B;
  case CKW_I4B: return CT_I4B;
  case CKW_U4B: return CT_U4B;
  case CKW_I8B: return CT_I8B;
  case CKW_U8B: return CT_U8B;
  case CKW_F4B: return CT_F4B;
  case CKW_F8B: return CT_F8B;
  }
  return CT_ERR;
}

I4B  LOCALF type_name(void)
{ // 宆柤
  I4B imm, typ;

  imm = token_is(CKW_IMM);
  typ = type_specifier(); if (typ == CT_ERR) { return CT_ERR;}
  if (imm) { typ = toimm(typ);}
  while (token_is(COP_AST)) {
    imm = token_is(CKW_IMM);
    typ = ptrto(typ);
    if (imm) { typ = toimm(typ);}
  }
  return typ;
}

I4B  LOCALF type_identifier(void)
{ // 宆柤傑偨偼屻抲柤
  I4B typ;
  rSTR cp;

  cp = cpos();
  typ = type_name();
  if (typ == CT_ERR) {
    restart(cp);
    typ = postfix_name();
  }
  return typ;
}

I4B  LOCALF conditional_expression(void);

I4B  LOCALF constant_expression(pBIN bf)
{ // 掕悢幃
  I4B typ;
  rBIN pb;
  HBLK tmp, cod;

  tmp = CreateTmpBlk(); if (!tmp) { cerr(E_CPL);}
  cod = SelectCodBlk(tmp);
  setbits(TRN_INI);
  typ = fetch(conditional_expression());
  pb = Ptr(tmp);
  switch (*pb) {
  case psh_i: *(pI4B)bf = *(rI4B)(pb + 1); break;
  case psh_l: *(pI8B)bf = *(rI8B)(pb + 1); break;
  case psh_d: *(pF8B)bf = *(rF8B)(pb + 1); break;
  default: cerr(E_INI);
  }
  resetbits(TRN_INI);
  SelectCodBlk(cod);
  DeleteTmpBlk(tmp);
  return typ;
}

I4B  LOCALF declarator(I4B typ, pSTR st)
{ // 愰尵巕
  I4B n, f, rtp, ne[32];
  U1B wk[8];

  for (n = 0; token_is(COP_AST); n++) {
    if (n >= _countof(ne)) { cerr(E_CAP);}
    ne[n] = token_is(CKW_IMM);
  }
  if (token() != TKN_IDN) { cerr(E_IDN);}
  strcpyi(st, buf());
  f = n;
  while (n > 0) {
    typ = ptrto(typ);
    if (ne[--n]) { typ = toimm(typ);}
  }
  if (f) { return typ;}
  for (n = 0; token_is(COP_LBK); n++) {
    if (n >= _countof(ne)) { cerr(E_CAP);}
    rtp = constant_expression(wk);
    if (!isint(rtp) || (ne[n] = *(rI4B)wk) <= 0) { cerr(E_ASZ);}
    if (!token_is(COP_RBK)) { cerr(E_DLM);}
  }
  while (n > 0) {
    typ = aryof(typ, ne[--n]);
  }
  return typ;
}

I4B  LOCALF assignment_expression(void);

void LOCALF initializer(I4B typ, HBLK bb, HBLK rl)
{ // 弶婜壔巕
  I4B i, f, ne, nsp, rtp;
  U1B wk[8];

  if (issca(typ)) {
    rtp = constant_expression(wk);
    if (isdat(rtp) || isbss(rtp)) { memrel(rl, bb);}
    iassign(typ, prom(rtp), datptr(bb), wk);
    incdatptr(bb, sizof(typ));
  } else if (isary(typ)) {
    ne = nelm(typ);
    rtp = elmtyp(typ);
    if (token_is(TKN_STR)) {
      if (sizof(rtp) == 1) {
        if (!strlitconc(datptr(bb), ne)) { cerr(E_LEN);}
        incdatptr(bb, ne);
      } else { cerr(E_LIT);}
    } else if (token_is(COP_LBC)) {
      for (f = i = 0; i < ne; i++) {
        if (!f && token_is(COP_RBC)) { f = 1;}
        if (!f) {
          initializer(rtp, bb, rl);
        } else {
          incdatptr(bb, sizof(rtp));
        }
        if (!f) {
          if (i == ne - 1 && (token_is(COP_RBC) || (token_is(COP_CMA) && token_is(COP_RBC)))) {
            break;
          } else if (i < ne - 1 && (token_is(COP_CMA) || lookahead_is(COP_RBC))) {
            continue;
          } else { cerr(E_DLM);}
        }
      }
    } else { cerr(E_DLM);}
  } else if (isstu(typ)) {
    nsp = typnsp(typ);
    ne = nmem(typ);
    if (token_is(COP_LBC)) {
      for (f = i = 0; i < ne; i++) {
        rtp = srchord(nsp, i)->typ;
        if (!f && token_is(COP_RBC)) { f = 1;}
        if (!f) {
          initializer(rtp, bb, rl);
        } else {
          incdatptr(bb, sizof(rtp));
        }
        if (!f) {
          if (i == ne - 1 && (token_is(COP_RBC) || (token_is(COP_CMA) && token_is(COP_RBC)))) {
            break;
          } else if (i < ne - 1 && (token_is(COP_CMA) || lookahead_is(COP_RBC))) {
            continue;
          } else { cerr(E_DLM);}
        }
      }
    } else { cerr(E_DLM);}
  } else { cerr(E_NAC);}
}

void LOCALF init_declarator(I4B typ)
{ // 弶婜壔愰尵巕
  I4B rtp;
  HBLK bb, rl;
  I1B st[LIDN];

  typ = declarator(typ, st);
  if (token_is(COP_ASN)) {
    if (isaut(typ)) {
      if (issca(typ)) {
        locaut(typ, st);
        outcod(psh_bs, autlen());
        rtp = fetch(assignment_expression());
        drop(assign(toobj(typ), rtp));
      } else { cerr(E_AUT);}
    } else {
      bb = CreateDatBuf(sizof(typ)); if (!bb) { cerr(E_CPL);}
      rl = CreateRelBuf(sizof(typ) / 4); if (!rl) { cerr(E_CPL);}
      initializer(typ, bb, rl);
      if (cfn()) {
        locdat(typ, st, bb, rl);
      } else {
        glodat(typ, st, bb, rl);
      }
      DeleteRelBuf(rl);
      DeleteDatBuf(bb);
    }
  } else {
    if (isaut(typ)) {
      locaut(typ, st);
    } else {
      if (cfn()) {
        locbss(typ, st);
      } else {
        globss(typ, st);
      }
    }
  }
}

void LOCALF pshcns(I4B typ, rANY pv)
{ // 掕悢
  switch (tonum(typ)) {
  case CT_I4B:
  case CT_U4B: outcod(psh_i, *(rI4B)pv); break;
  case CT_I8B:
  case CT_U8B: outcod(psh_l, *(rI8B)pv); break;
  case CT_F8B: outcod(psh_d, *(rF8B)pv); break;
  default: cerr(E_NAC);
  }
}

I4B  LOCALF expression(void);

enum {
  TID_STR = 11,
  TID_BIN = 12,
  TID_ASC = 32,
};

#define  CAL_BIT  0x80

I4B  LOCALF primary_expression(void)
{ // 堦師幃
  I4B cd, typ;
  rNAME pi;
  I1B bf[LLIT];

  switch (token()) {
  case TKN_I4B: pshcns(typ = CT_I4B, buf()); break;
  case TKN_U4B: pshcns(typ = CT_U4B, buf()); break;
  case TKN_I8B: pshcns(typ = CT_I8B, buf()); break;
  case TKN_U8B: pshcns(typ = CT_U8B, buf()); break;
  case TKN_F8B: pshcns(typ = CT_F8B, buf()); break;
  case TKN_STR:
    if (!strlitconc(bf, LLIT - 1)) { cerr(E_TKN);}
    outcod(psh_du, outstr(bf));
    typ = (REF_PT1|REF_IM1|CT_I1B); break;
  case TKN_IDN:
    if (!!(pi = srchnam(NSX_CFN | cfn(), buf()))) {
      typ = pi->typ;
      if (isaut(typ)) {
        outcod(psh_bs, pi->ofs); typ = toobj(typ);
      } else if (isdat(typ)) {
        outcod(psh_du, pi->ofs); typ = toobj(typ);
      } else if (isbss(typ)) {
        outcod(psh_eu, pi->ofs); typ = toobj(typ);
      } else { cerr(E_NAC);}
    } else if (!!(pi = srchnam(NSP_GLO, buf()))) {
      typ = pi->typ;
      if (iscns(typ)) {
        pshcns(typ = tovar(typ), pvdef(pi->ofs));
      } else if (isdat(typ)) {
        outcod(psh_du, pi->ofs); typ = toobj(typ);
      } else if (isbss(typ)) {
        outcod(psh_eu, pi->ofs); typ = toobj(typ);
      } else if (istyp(typ)) {
        cerr(E_UNX);
      } else if (isfun(typ)) {
        outcod(psh_i, typnsp(typ));
      } else { cerr(E_NAC);}
    } else { cerr(E_UNK);}
    break;
  case CKW_NUL:
    outcod(psh_i, 0); typ = (REF_PT1|CT_VOI); break;
  case CKW_NEL:
    if (!token_is(COP_LPA)) { cerr(E_DLM);}
    typ = postfix_name(); if (!isary(typ)) { cerr(E_ARY);}
    if (!token_is(COP_RPA)) { cerr(E_DLM);}
    outcod(psh_i, nelm(typ)); typ = CT_U4B; break;
  case CKW_LOB: cd = cnv_i_b; goto _10;
  case CKW_HIB: cd = hib_i; goto _10;
  case CKW_LOW: cd = cnv_i_w; goto _10;
  case CKW_HIW: cd = hiw_i; goto _10;
  case CKW_SWB: cd = swp_b; goto _10;
  case CKW_SWW: cd = swp_w; goto _10;
  case CKW_CHB: cd = chk_b; goto _10;
  case CKW_CHW: cd = chk_w; goto _10;
  case CKW_CHC: cd = chk_c; goto _10;
  case CKW_CHS: cd = chk_s; _10:
    if (!token_is(COP_LPA)) { cerr(E_DLM);}
    typcnv(CT_U4B, assignment_expression());
    if (!token_is(COP_RPA)) { cerr(E_DLM);}
    outcod(cd); typ = CT_U4B; break;
  case CKW_MKW: cd = mkw_i; goto _20;
  case CKW_MKU: cd = mku_i; _20:
    if (!token_is(COP_LPA)) { cerr(E_DLM);}
    typcnv(CT_U4B, assignment_expression());
    token_is(COP_CMA);
    typcnv(CT_U4B, assignment_expression());
    if (!token_is(COP_RPA)) { cerr(E_DLM);}
    outcod(cd); typ = CT_U4B; break;
  case CKW_STR: outcod(psh_i, TID_STR); cd = mku_i; goto _10;
  case CKW_BIN: outcod(psh_i, TID_BIN); cd = mku_i; goto _10;
  case CKW_ASC: outcod(psh_i, TID_ASC); cd = mku_i; goto _10;
  case CKW_CAL: outcod(psh_i, CAL_BIT); cd = or_i;  goto _10;
  case COP_LPA:
    typ = expression();
    if (!token_is(COP_RPA)) { cerr(E_DLM);}
    break;
  case TKN_ERR: cerr(E_TKN);
  case TKN_END: cerr(E_END);
  default: cerr(E_UNX);
  }
  return typ;
}

I4B  LOCALF postfix_expression(void)
{ // 屻抲幃
  I4B i, ne, sz, va, nsp, ln0, typ, ltp, rtp;
  rSTR cp;
  rNAME pi;
  HBLK tmp, cod;

  ln0 = codlen();
  typ = primary_expression();
  do {
    cp = cpos();
    switch (token()) {
    case COP_LBK:
      ltp = fetch(typ);
      rtp = fetch(expression());
      if (!token_is(COP_RBK)) { cerr(E_DLM);}
      if (isptr(ltp) && isint(rtp)) {
        outcod(add_p_i, sizof(deref(ltp)));
        typ = toobj(deref(ltp));
      } else if (isint(ltp) && isptr(rtp)) {
        outcod(add_i_p, sizof(deref(rtp)));
        typ = toobj(deref(rtp));
      } else { cerr(E_OPR);}
      break;
    case COP_LPA:
      if (!isfun(typ)) { cerr(E_UNX);}
      fetch(typ);
      tmp = CreateArgBlk(); if (!tmp) { cerr(E_CPL);}
      xfercodblk(Arg(tmp, 0), ln0); setcodlen(ln0);
      cod = SelectCodBlk(NULL);
      nsp = typnsp(typ);
      ne = narg(typ); sz = 0;
      va = (ne > 1 && srchord(nsp, ne - 1)->typ == 0);
      for (i = 0; va || i < ne; i++) {
        SelectCodBlk(Arg(tmp, i + 1));
        ltp = (!va || i < ne - 1)? srchord(nsp, i)->typ: 0;
        rtp = fetch(assignment_expression());
        ltp = ltp? argprom(ltp, rtp): rtp;
        sz += sizof(ltp);
        if (!token_is(COP_CMA)) {
          if (i < ne - 1 - va) { cerr(E_DLM);} else if (va) break;
        }
      }
      if (!token_is(COP_RPA)) { cerr(E_DLM);}
      SelectCodBlk(cod);
      outarg(tmp);
      DeleteArgBlk(tmp);
      rtp = rettyp(typ);
      switch (sizof0(prom(rtp))) {
      case 0:  outcod(fnc_v, sz); break;
      case 4:  outcod(fnc_i, sz); break;
      case 8:  outcod(fnc_d, sz); break;
      default: cerr(E_NAC);
      }
      typ = prom(rtp);
      break;
    case COP_ARW:
      typ = deref(fetch(typ));
      // fall through
    case COP_DOT:
      if (!isstu(typ)) { cerr(E_STU);}
      if (token() != TKN_IDN) { cerr(E_IDN);}
      if (!(pi = srchnam(typnsp(typ), buf()))) { cerr(E_NME);}
      outcod(psh_i, pi->ofs);
      outcod(add_p_i, 1);
      typ = toobj(pi->typ);
      break;
    case COP_INC:
      typ = posinc(typ);
      break;
    case COP_DEC:
      typ = posdec(typ);
      break;
    default:
      restart(cp);
      break;
    }
  } while (cp != cpos());
  return typ;
}

I4B  LOCALF cast_expression(void);

I4B  LOCALF unary_expression(void)
{ // 扨崁幃
  I4B typ;
  rSTR cp;
  rNAME pi;

  cp = cpos();
  switch (token()) {
  case COP_INC:
    typ = preinc(unary_expression());
    break;
  case COP_DEC:
    typ = predec(unary_expression());
    break;
  case COP_BAN:
    typ = cast_expression();
    if (!isobj(typ)) { cerr(E_OBJ);}
    typ = ptrto(tovar(typ));
    break;
  case COP_AST:
    typ = fetch(cast_expression());
    if (!isptr(typ)) { cerr(E_PTR);}
    typ = toobj(deref(typ));
    break;
  case COP_PLS:
    typ = fetch(cast_expression());
    switch (typ) {
    case CT_I4B:
    case CT_U4B:
    case CT_I8B:
    case CT_U8B:
    case CT_F8B: break;
    default: cerr(E_OPR);
    }
    break;
  case COP_MNS:
    typ = fetch(cast_expression());
    switch (typ) {
    case CT_I4B:
    case CT_U4B: outcod(neg_i); break;
    case CT_I8B:
    case CT_U8B: outcod(neg_l); break;
    case CT_F8B: outcod(neg_d); break;
    default: cerr(E_OPR);
    }
    break;
  case COP_BNT:
    typ = fetch(cast_expression());
    switch (typ) {
    case CT_I4B:
    case CT_U4B: outcod(not_i); break;
    case CT_I8B:
    case CT_U8B: outcod(not_l); break;
    default: cerr(E_OPR);
    }
    break;
  case COP_LNT:
    eztest(cast_expression());
    typ = CT_I4B;
    break;
  case COP_SZO:
    if (!token_is(COP_LPA)) { cerr(E_DLM);}
    typ = type_identifier();
    if (!token_is(COP_RPA)) { cerr(E_DLM);}
    outcod(psh_i, sizof(typ));
    typ = CT_U4B;
    break;
  case COP_OFO:
    if (!token_is(COP_LPA)) { cerr(E_DLM);}
    typ = type_identifier();
    if (!isstu(typ)) { cerr(E_STU);}
    if (!token_is(COP_CMA)) { cerr(E_DLM);}
    if (token() != TKN_IDN) { cerr(E_IDN);}
    if (!(pi = srchnam(typnsp(typ), buf()))) { cerr(E_NME);}
    if (!token_is(COP_RPA)) { cerr(E_DLM);}
    outcod(psh_i, pi->ofs);
    typ = CT_U4B;
    break;
  default:
    restart(cp);
    typ = postfix_expression();
    break;
  }
  return typ;
}

I4B  LOCALF cast_expression(void)
{  // 僉儍僗僩幃
  I4B typ;
  rSTR cp;

  cp = cpos();
  if (token_is(COP_LPA)) {
    typ = type_name(); if (typ == CT_ERR) { restart(cp); goto _10;}
    if (!token_is(COP_RPA)) { cerr(E_DLM);}
    typ = typcnv(typ, cast_expression());
  } else { _10:
    typ = unary_expression();
  }
  return typ;
}

I4B  LOCALF multiplicative_expression(void)
{ // 忔朄幃
  I4B typ, ltp, rtp;
  rSTR cp;

  typ = cast_expression();
  do {
    cp = cpos();
    switch (token()) {
    case COP_AST:
      ltp = fetch(typ);
      rtp = fetch(cast_expression());
      switch (typ = aricnv(ltp, rtp)) {
      case CT_I4B:
      case CT_U4B: outcod(mul_i); break;
      case CT_I8B:
      case CT_U8B: outcod(mul_l); break;
      case CT_F8B: outcod(mul_d); break;
      }
      break;
    case COP_DIV:
      ltp = fetch(typ);
      rtp = fetch(cast_expression());
      switch (typ = aricnv(ltp, rtp)) {
      case CT_I4B:
      case CT_U4B: outcod(div_i); break;
      case CT_I8B:
      case CT_U8B: outcod(div_l); break;
      case CT_F8B: outcod(div_d); break;
      }
      break;
    case COP_MOD:
      ltp = fetch(typ);
      rtp = fetch(cast_expression());
      if (isflo(ltp) || isflo(rtp)) { cerr(E_OPR);}
      switch (typ = aricnv(ltp, rtp)) {
      case CT_I4B:
      case CT_U4B: outcod(mod_i); break;
      case CT_I8B:
      case CT_U8B: outcod(mod_l); break;
      }
      break;
    default:
      restart(cp);
      break;
    }
  } while (cp != cpos());
  return typ;
}

I4B  LOCALF additive_expression(void)
{ // 壛朄幃
  I4B typ, ltp, rtp;
  rSTR cp;

  typ = multiplicative_expression();
  do {
    cp = cpos();
    switch (token()) {
    case COP_PLS:
      ltp = fetch(typ);
      rtp = fetch(multiplicative_expression());
      if (isptr(ltp) && isint(rtp)) {
        outcod(add_p_i, sizof(deref(ltp))); typ = ltp;
      } else if (isint(ltp) && isptr(rtp)) {
        outcod(add_i_p, sizof(deref(rtp))); typ = rtp;
      } else {
        switch (typ = aricnv(ltp, rtp)) {
        case CT_I4B:
        case CT_U4B: outcod(add_i); break;
        case CT_I8B:
        case CT_U8B: outcod(add_l); break;
        case CT_F8B: outcod(add_d); break;
        }
      }
      break;
    case COP_MNS:
      ltp = fetch(typ);
      rtp = fetch(multiplicative_expression());
      if (isptr(ltp) && isint(rtp)) {
        outcod(sub_p_i, sizof(deref(ltp))); typ = ltp;
      } else if (iscmpptr(ltp, rtp)) {
        outcod(sub_p, sizof(deref(ltp))); typ = CT_I4B;
      } else {
        switch (typ = aricnv(ltp, rtp)) {
        case CT_I4B:
        case CT_U4B: outcod(sub_i); break;
        case CT_I8B:
        case CT_U8B: outcod(sub_l); break;
        case CT_F8B: outcod(sub_d); break;
        }
      }
      break;
    default:
      restart(cp);
      break;
    }
  } while (cp != cpos());
  return typ;
}

I4B  LOCALF shift_expression(void)
{ // 僔僼僩幃
  I4B typ, ltp, rtp;
  rSTR cp;

  typ = additive_expression();
  do {
    cp = cpos();
    switch (token()) {
    case COP_SHL:
      ltp = fetch(typ);
      rtp = fetch(additive_expression());
      if (isflo(ltp) || isflo(rtp)) { cerr(E_OPR);}
      switch (typ = aricnv(ltp, rtp)) {
      case CT_I4B:
      case CT_U4B: outcod(shl_i); break;
      case CT_I8B:
      case CT_U8B: outcod(shl_l); break;
      }
      break;
    case COP_SHR:
      ltp = fetch(typ);
      rtp = fetch(additive_expression());
      if (isflo(ltp) || isflo(rtp)) { cerr(E_OPR);}
      switch (typ = aricnv(ltp, rtp)) {
      case CT_I4B: outcod(shr_i); break;
      case CT_U4B: outcod(shr_u); break;
      case CT_I8B: outcod(shr_l); break;
      case CT_U8B: outcod(shr_q); break;
      }
      break;
    default:
      restart(cp);
      break;
    }
  } while (cp != cpos());
  return typ;
}

I4B  LOCALF relational_expression(void)
{ // 娭學幃
  I4B typ, ltp, rtp;
  rSTR cp;

  typ = shift_expression();
  do {
    cp = cpos();
    switch (token()) {
    case COP_LLT:
      ltp = fetch(typ);
      rtp = fetch(shift_expression());
      if (iscmpptr(ltp, rtp)) {
        outcod(lt_u);
      } else {
        switch (aricnv(ltp, rtp)) {
        case CT_I4B: outcod(lt_i); break;
        case CT_U4B: outcod(lt_u); break;
        case CT_I8B: outcod(lt_l); break;
        case CT_U8B: outcod(lt_q); break;
        case CT_F8B: outcod(lt_d); break;
        }
      }
      typ = CT_I4B;
      break;
    case COP_LGT:
      ltp = fetch(typ);
      rtp = fetch(shift_expression());
      if (iscmpptr(ltp, rtp)) {
        outcod(gt_u);
      } else {
        switch (aricnv(ltp, rtp)) {
        case CT_I4B: outcod(gt_i); break;
        case CT_U4B: outcod(gt_u); break;
        case CT_I8B: outcod(gt_l); break;
        case CT_U8B: outcod(gt_q); break;
        case CT_F8B: outcod(gt_d); break;
        }
      }
      typ = CT_I4B;
      break;
    case COP_LLE:
      ltp = fetch(typ);
      rtp = fetch(shift_expression());
      if (iscmpptr(ltp, rtp)) {
        outcod(le_u);
      } else {
        switch (aricnv(ltp, rtp)) {
        case CT_I4B: outcod(le_i); break;
        case CT_U4B: outcod(le_u); break;
        case CT_I8B: outcod(le_l); break;
        case CT_U8B: outcod(le_q); break;
        case CT_F8B: outcod(le_d); break;
        }
      }
      typ = CT_I4B;
      break;
    case COP_LGE:
      ltp = fetch(typ);
      rtp = fetch(shift_expression());
      if (iscmpptr(ltp, rtp)) {
        outcod(ge_u);
      } else {
        switch (aricnv(ltp, rtp)) {
        case CT_I4B: outcod(ge_i); break;
        case CT_U4B: outcod(ge_u); break;
        case CT_I8B: outcod(ge_l); break;
        case CT_U8B: outcod(ge_q); break;
        case CT_F8B: outcod(ge_d); break;
        }
      }
      typ = CT_I4B;
      break;
    default:
      restart(cp);
      break;
    }
  } while (cp != cpos());
  return typ;
}

I4B  LOCALF equality_expression(void)
{ // 摍抣幃
  I4B typ, ltp, rtp;
  rSTR cp;

  typ = relational_expression();
  do {
    cp = cpos();
    switch (token()) {
    case COP_LEQ:
      ltp = fetch(typ);
      rtp = fetch(relational_expression());
      if (iscmpptr(ltp, rtp) || iscmpfun(ltp, rtp)) {
        outcod(eq_i);
      } else {
        switch (aricnv(ltp, rtp)) {
        case CT_I4B:
        case CT_U4B: outcod(eq_i); break;
        case CT_I8B:
        case CT_U8B: outcod(eq_l); break;
        case CT_F8B: outcod(eq_d); break;
        }
      }
      typ = CT_I4B;
      break;
    case COP_LNE:
      ltp = fetch(typ);
      rtp = fetch(relational_expression());
      if (iscmpptr(ltp, rtp) || iscmpfun(ltp, rtp)) {
        outcod(ne_i);
      } else {
        switch (aricnv(ltp, rtp)) {
        case CT_I4B:
        case CT_U4B: outcod(ne_i); break;
        case CT_I8B:
        case CT_U8B: outcod(ne_l); break;
        case CT_F8B: outcod(ne_d); break;
        }
      }
      typ = CT_I4B;
      break;
    default:
      restart(cp);
      break;
    }
  } while (cp != cpos());
  return typ;
}

I4B  LOCALF and_expression(void)
{ // 價僢僩枅偺AND幃
  I4B typ, ltp, rtp;

  typ = equality_expression();
  while (token_is(COP_BAN)) {
    ltp = fetch(typ);
    rtp = fetch(equality_expression());
    if (isflo(ltp) || isflo(rtp)) { cerr(E_OPR);}
    switch (typ = aricnv(ltp, rtp)) {
    case CT_I4B:
    case CT_U4B: outcod(and_i); break;
    case CT_I8B:
    case CT_U8B: outcod(and_l); break;
    }
  }
  return typ;
}

I4B  LOCALF exclusive_or_expression(void)
{ // 價僢僩枅偺攔懠揑OR幃
  I4B typ, ltp, rtp;

  typ = and_expression();
  while (token_is(COP_BXO)) {
    ltp = fetch(typ);
    rtp = fetch(and_expression());
    if (isflo(ltp) || isflo(rtp)) { cerr(E_OPR);}
    switch (typ = aricnv(ltp, rtp)) {
    case CT_I4B:
    case CT_U4B: outcod(xor_i); break;
    case CT_I8B:
    case CT_U8B: outcod(xor_l); break;
    }
  }
  return typ;
}

I4B  LOCALF inclusive_or_expression(void)
{ // 價僢僩枅偺撪曪揑OR幃
  I4B typ, ltp, rtp;

  typ = exclusive_or_expression();
  while (token_is(COP_BOR)) {
    ltp = fetch(typ);
    rtp = fetch(exclusive_or_expression());
    if (isflo(ltp) || isflo(rtp)) { cerr(E_OPR);}
    switch (typ = aricnv(ltp, rtp)) {
    case CT_I4B:
    case CT_U4B: outcod(or_i); break;
    case CT_I8B:
    case CT_U8B: outcod(or_l); break;
    }
  }
  return typ;
}

I4B  LOCALF logical_and_expression(void)
{ // 榑棟揑AND幃
  I4B n, typ, ln[64];

  typ = inclusive_or_expression();
  for (n = 0; token_is(COP_LAN); n++) {
    if (n >= _countof(ln)) { cerr(E_CAP);}
    nztest(typ);
    outcod(jan_i, 0); ln[n] = codlen();
    nztest(inclusive_or_expression());
    typ = CT_I4B;
  }
  while (--n >= 0) {
    fixcod2(ln[n] - 2, codlen() - ln[n]);
  }
  return typ;
}

I4B  LOCALF logical_or_expression(void)
{ // 榑棟揑OR幃
  I4B n, typ, ln[64];

  typ = logical_and_expression();
  for (n = 0; token_is(COP_LOR); n++) {
    if (n >= _countof(ln)) { cerr(E_CAP);}
    nztest(typ);
    outcod(jor_i, 0); ln[n] = codlen();
    nztest(logical_and_expression());
    typ = CT_I4B;
  }
  while (--n >= 0) {
    fixcod2(ln[n] - 2, codlen() - ln[n]);
  }
  return typ;
}

I4B  LOCALF conditional_expression(void)
{ // 忦審幃
  I4B oc, ln0, ln1, ln2, ltp, rtp;
  HBLK tmp, cod;
  U1B wk[8];

  tmp = CreateTmpBlk(); if (!tmp) { cerr(E_CPL);}
  cod = SelectCodBlk(tmp);
  ltp = logical_or_expression();
  while (token_is(COP_QUE)) {
    nztest(ltp);
    outcod(jeq_i_0, 0); ln0 = codlen();
    ltp = fetch(conditional_expression()); ln1 = codlen();
    outcod(nop_v);
    if (!token_is(COP_CLN)) { cerr(E_DLM);}
    outcod(jmp_v, 0);
    fixcod2(ln0 - 2, ln1 - ln0 + 4);
    rtp = fetch(conditional_expression()); ln2 = codlen();
    outcod(nop_v);
    fixcod2(ln1 + 2, ln2 - ln1 - 3);
    switch (cndcnv(ltp, rtp, &oc)) {
    case 0:  break;
    case 1:  fixcod1(ln1, oc); ltp = rtp; break;
    case 2:  fixcod1(ln2, oc); break;
    default: cerr(E_OPR);
    }
  }
  if (!(isvoi(ltp) || isfun(ltp))) {
    if (isary(ltp)) { ltp = ptrto(elmtyp(ltp));}
    switch (sizof(prom(ltp))) {
    case 4:  outcod(ret_i); break;
    case 8:  outcod(ret_d); break;
    default: cerr(E_NAC);
    }
    outcod(end_v);
    if (iscnsexpr(tmp, SW_CNS)) {
      evalcnsexpr(wk, tmp, SW_CNS);
      setcodlen(0);
      pshcns(ltp = prom(ltp), wk);
    } else if (chkbits(TRN_INI) && !isobj(ltp) && iscnsexpr(tmp, SW_DAT)) {
      evalcnsexpr(wk, tmp, SW_DAT);
      setcodlen(0);
      outcod(psh_i, TPX_DAT | *(rI4B)wk);
      ltp = todat(ltp);
    } else if (chkbits(TRN_INI) && !isobj(ltp) && iscnsexpr(tmp, SW_BSS)) {
      evalcnsexpr(wk, tmp, SW_BSS);
      setcodlen(0);
      outcod(psh_i, TPX_BSS | *(rI4B)wk);
      ltp = tobss(ltp);
    } else {
      setcodlen(codlen() - 2);
    }
  }
  SelectCodBlk(cod);
  outcodblk(tmp);
  DeleteTmpBlk(tmp);
  return ltp;
}

I4B  LOCALF assignment_expression(void)
{ // 戙擖幃
  I4B typ, ltp, rtp;
  rSTR cp;

  typ = conditional_expression();
  do {
    cp = cpos();
    switch (token()) {
    case COP_ASN:
      rtp = fetch(assignment_expression());
      typ = assign(typ, rtp);
      break;
    case COP_PLE:
      outcod(dup_i); ltp = fetch(typ);
      rtp = fetch(assignment_expression());
      if (isptr(ltp) && isint(rtp)) {
        outcod(add_p_i, sizof(deref(ltp)));
      } else {
        switch (ltp = aricnv(ltp, rtp)) {
        case CT_I4B:
        case CT_U4B: outcod(add_i); break;
        case CT_I8B:
        case CT_U8B: outcod(add_l); break;
        case CT_F8B: outcod(add_d); break;
        }
      }
      typ = assign(typ, ltp);
      break;
    case COP_MNE:
      outcod(dup_i); ltp = fetch(typ);
      rtp = fetch(assignment_expression());
      if (isptr(ltp) && isint(rtp)) {
        outcod(sub_p_i, sizof(deref(ltp)));
      } else {
        switch (ltp = aricnv(ltp, rtp)) {
        case CT_I4B:
        case CT_U4B: outcod(sub_i); break;
        case CT_I8B:
        case CT_U8B: outcod(sub_l); break;
        case CT_F8B: outcod(sub_d); break;
        }
      }
      typ = assign(typ, ltp);
      break;
    case COP_MLE:
      outcod(dup_i); ltp = fetch(typ);
      rtp = fetch(assignment_expression());
      switch (ltp = aricnv(ltp, rtp)) {
      case CT_I4B:
      case CT_U4B: outcod(mul_i); break;
      case CT_I8B:
      case CT_U8B: outcod(mul_l); break;
      case CT_F8B: outcod(mul_d); break;
      }
      typ = assign(typ, ltp);
      break;
    case COP_DVE:
      outcod(dup_i); ltp = fetch(typ);
      rtp = fetch(assignment_expression());
      switch (ltp = aricnv(ltp, rtp)) {
      case CT_I4B:
      case CT_U4B: outcod(div_i); break;
      case CT_I8B:
      case CT_U8B: outcod(div_l); break;
      case CT_F8B: outcod(div_d); break;
      }
      typ = assign(typ, ltp);
      break;
    case COP_MOE:
      outcod(dup_i); ltp = fetch(typ);
      rtp = fetch(assignment_expression());
      if (isflo(ltp) || isflo(rtp)) { cerr(E_OPR);}
      switch (ltp = aricnv(ltp, rtp)) {
      case CT_I4B:
      case CT_U4B: outcod(mod_i); break;
      case CT_I8B:
      case CT_U8B: outcod(mod_l); break;
      }
      typ = assign(typ, ltp);
      break;
    case COP_SLE:
      outcod(dup_i); ltp = fetch(typ);
      rtp = fetch(assignment_expression());
      if (isflo(ltp) || isflo(rtp)) { cerr(E_OPR);}
      switch (ltp = aricnv(ltp, rtp)) {
      case CT_I4B:
      case CT_U4B: outcod(shl_i); break;
      case CT_I8B:
      case CT_U8B: outcod(shl_l); break;
      }
      typ = assign(typ, ltp);
      break;
    case COP_SRE:
      outcod(dup_i); ltp = fetch(typ);
      rtp = fetch(assignment_expression());
      if (isflo(ltp) || isflo(rtp)) { cerr(E_OPR);}
      switch (ltp = aricnv(ltp, rtp)) {
      case CT_I4B: outcod(shr_i); break;
      case CT_U4B: outcod(shr_u); break;
      case CT_I8B: outcod(shr_l); break;
      case CT_U8B: outcod(shr_q); break;
      }
      typ = assign(typ, ltp);
      break;
    case COP_BAE:
      outcod(dup_i); ltp = fetch(typ);
      rtp = fetch(assignment_expression());
      if (isflo(ltp) || isflo(rtp)) { cerr(E_OPR);}
      switch (ltp = aricnv(ltp, rtp)) {
      case CT_I4B:
      case CT_U4B: outcod(and_i); break;
      case CT_I8B:
      case CT_U8B: outcod(and_l); break;
      }
      typ = assign(typ, ltp);
      break;
    case COP_BOE:
      outcod(dup_i); ltp = fetch(typ);
      rtp = fetch(assignment_expression());
      if (isflo(ltp) || isflo(rtp)) { cerr(E_OPR);}
      switch (ltp = aricnv(ltp, rtp)) {
      case CT_I4B:
      case CT_U4B: outcod(or_i); break;
      case CT_I8B:
      case CT_U8B: outcod(or_l); break;
      }
      typ = assign(typ, ltp);
      break;
    case COP_BXE:
      outcod(dup_i); ltp = fetch(typ);
      rtp = fetch(assignment_expression());
      if (isflo(ltp) || isflo(rtp)) { cerr(E_OPR);}
      switch (ltp = aricnv(ltp, rtp)) {
      case CT_I4B:
      case CT_U4B: outcod(xor_i); break;
      case CT_I8B:
      case CT_U8B: outcod(xor_l); break;
      }
      typ = assign(typ, ltp);
      break;
    default:
      restart(cp);
      break;
    }
  } while (cp != cpos());
  return typ;
}

I4B  LOCALF expression(void)
{ // 幃
  I4B typ;

  do {
    typ = assignment_expression();
  } while (token_is(COP_CMA) && drop(typ));
  return typ;
}

void LOCALF statement(I4B lbb, I4B lbc, I4B lbr, I4B ret, I4B nsw, pI4B lc, pI4B ld)
{ // 暥
  I4B i, ln0, ln1, typ;
  rSTR cp;
  HBLK tmp, cod;
  U1B wk[8];

 _10: cp = cpos();
  switch (token()) {
  case TKN_IDN:
    if (!token_is(COP_CLN)) goto _20;
    regslab(buf());
    goto _10;
  case CKW_CAS:
    if (!lc) { cerr(E_UNX);}
    typ = constant_expression(wk);
    if (!isint(typ)) { cerr(E_INT);}
    if (!token_is(COP_CLN)) { cerr(E_DLM);}
    outcod(jmp_v, 0); ln0 = codlen();
    fixcod2(*lc - 2, codlen() - *lc);
    outcod(dup_i);
    outcod(psh_i, *(rI4B)wk);
    outcod(eq_i);
    outcod(jeq_i_0, 0); *lc = codlen();
    fixcod2(ln0 - 2, codlen() - ln0);
    goto _10;
  case CKW_DEF:
    if (!ld) { cerr(E_UNX);}
    if (!token_is(COP_CLN)) { cerr(E_DLM);}
    *ld = codlen();
    goto _10;
  default:
    restart(cp); break;
  }
  switch (token()) {
  case CKW_IF_:
    if (!token_is(COP_LPA)) { cerr(E_DLM);}
    nztest(expression());
    if (!token_is(COP_RPA)) { cerr(E_DLM);}
    outcod(jeq_i_0, 0); ln0 = codlen();
    statement(lbb, lbc, lbr, ret, nsw, lc, ld);
    if (token_is(CKW_ELS)) {
      outcod(jmp_v, 0); ln1 = codlen();
      fixcod2(ln0 - 2, codlen() - ln0);
      statement(lbb, lbc, lbr, ret, nsw, lc, ld);
      fixcod2(ln1 - 2, codlen() - ln1);
    } else {
      fixcod2(ln0 - 2, codlen() - ln0);
    }
    break;
  case CKW_SWI:
    if (!token_is(COP_LPA)) { cerr(E_DLM);}
    typ = fetch(expression());
    if (!isint(typ)) { cerr(E_SWI);}
    if (!token_is(COP_RPA)) { cerr(E_DLM);}
    outcod(jmp_v, 0); ln0 = codlen();
    ln1 = -1;
    lbb = regslab(NULL);
    statement(lbb, lbc, lbr, ret, nsw + 1, &ln0, &ln1);
    fixcod2(ln0 - 2, codlen() - ln0);
    if (ln1 != -1) { outcod(jmp_v, ln1 - codlen() - 3);}
    fixlab(lbb);
    drop(typ);
    break;
  case CKW_WHI:
    if (!token_is(COP_LPA)) { cerr(E_DLM);}
    ln0 = codlen();
    lbb = regslab(NULL);
    lbc = regslab(NULL);
    nztest(expression());
    if (!token_is(COP_RPA)) { cerr(E_DLM);}
    outcod(jeq_i_0, 0); ln1 = codlen();
    statement(lbb, lbc, lbr, ret, nsw, lc, ld);
    outcod(jmp_v, ln0 - codlen() - 3);
    fixlab(lbb);
    fixcod2(ln1 - 2, codlen() - ln1);
    break;
  case CKW_DO_:
    ln0 = codlen();
    lbb = regslab(NULL);
    lbc = regslab(NULL);
    statement(lbb, lbc, lbr, ret, nsw, lc, ld);
    if (!token_is(CKW_WHI)) { cerr(E_DLM);}
    if (!token_is(COP_LPA)) { cerr(E_DLM);}
    nztest(expression());
    if (!token_is(COP_RPA)) { cerr(E_DLM);}
    if (!token_is(COP_SEM)) { cerr(E_DLM);}
    outcod(jne_i_0, ln0 - codlen() - 3);
    fixlab(lbb);
    break;
  case CKW_FOR:
    tmp = CreateTmpBlk(); if (!tmp) { cerr(E_CPL);}
    if (!token_is(COP_LPA)) { cerr(E_DLM);}
    if (!token_is(COP_SEM)) {
      drop(expression());
      if (!token_is(COP_SEM)) { cerr(E_DLM);}
    }
    ln0 = codlen();
    if (!token_is(COP_SEM)) {
      typ = expression();
      if (!token_is(COP_SEM)) { cerr(E_DLM);}
    } else {
      outcod(psh_i, 1); typ = CT_I4B;
    }
    nztest(typ);
    outcod(jeq_i_0, 0); ln1 = codlen();
    cod = SelectCodBlk(tmp);
    if (!token_is(COP_RPA)) {
      drop(expression());
      if (!token_is(COP_RPA)) { cerr(E_DLM);}
    }
    SelectCodBlk(cod);
    lbb = regslab(NULL);
    lbc = regslab(NULL);
    statement(lbb, lbc, lbr, ret, nsw, lc, ld);
    fixlab(lbc);
    outcodblk(tmp);
    outcod(jmp_v, ln0 - codlen() - 3);
    fixlab(lbb);
    fixcod2(ln1 - 2, codlen() - ln1);
    DeleteTmpBlk(tmp);
    break;
  case CKW_GOT:
    if (token() != TKN_IDN) { cerr(E_IDN);}
    jmplab(buf());
    if (!token_is(COP_SEM)) { cerr(E_DLM);}
    break;
  case CKW_BRK:
    if (lbb == -1) { cerr(E_UNX);}
    jmplid(lbb);
    if (!token_is(COP_SEM)) { cerr(E_DLM);}
    break;
  case CKW_CNT:
    if (lbc == -1) { cerr(E_UNX);}
    jmplid(lbc);
    if (!token_is(COP_SEM)) { cerr(E_DLM);}
    break;
  case CKW_RET:
    for (i = 0; i < nsw; i++) {
      drop(CT_I4B);
    }
    if (token_is(COP_SEM)) {
      if (!isvoi(ret)) { cerr(E_ASN);}
    } else {
      typ = fetch(expression());
      argprom(ret, typ);
      if (!token_is(COP_SEM)) { cerr(E_DLM);}
    }
    jmplid(lbr);
    break;
  case COP_LBC:
    while (!token_is(COP_RBC)) {
      statement(lbb, lbc, lbr, ret, nsw, lc, ld);
    }
    break;
  case COP_SEM:
    break;
  default: _20:
    restart(cp);
    drop(expression());
    if (!token_is(COP_SEM)) { cerr(E_DLM);}
    break;
  }
}

BOOL LOCALF typedef_declaration(void)
{ // typedef愰尵
  I4B ne, sz, im1, im2, nsp, ltp, rtp;
  rTYPE pt;
  I1B st[LIDN], bf[LIDN];

  if (!token_is(CKW_TDF)) return FALSE;
  im1 = token_is(CKW_IMM);
  if (token_is(CKW_STU)) {
    if (!token_is(COP_LBC)) { cerr(E_DLM);}
    nsp = NSX_STU | newstu();
    ne = sz = 0;
    do {
      im2 = token_is(CKW_IMM);
      ltp = type_specifier(); if (ltp == CT_ERR) { cerr(E_TYP);}
      if (im2) { ltp = toimm(ltp);}
      do {
        rtp = declarator(ltp, bf);
        if (srchnam(nsp, bf)) { cerr(E_DUP);}
        regsnam(nsp, rtp, bf, sz);
        ne++; sz += sizof(rtp);
      } while (token_is(COP_CMA));
      if (!token_is(COP_SEM)) { cerr(E_DLM);}
    } while (!token_is(COP_RBC));
    if (token() != TKN_IDN) { cerr(E_IDN);}
    strcpyi(st, buf());
    pt = regstyp(nsp, 0, ne, sz);
    ltp = typidx(pt);
    if (im1) { ltp = toimm(ltp);}
    regsnam(NSP_GLO, totyp(ltp), st, 0);
  } else {
    ltp = type_specifier(); if (ltp == CT_ERR) { cerr(E_TYP);}
    if (im1) { ltp = toimm(ltp);}
    if (token_is(COP_LPA)) {
      if (token() != COP_AST) { cerr(E_UNX);}
      if (token() != TKN_IDN) { cerr(E_IDN);}
      strcpyi(st, buf());
      if (token() != COP_RPA) { cerr(E_DLM);}
      if (token() != COP_LPA) { cerr(E_DLM);}
      if (!(isvoi(ltp) || issca(ltp))) { cerr(E_SCA);}
      if (srchnam(NSP_GLO, st)) { cerr(E_DUP);}
      nsp = chkbits(TRN_HDR)? NSX_BFN | newbfn(): NSX_CFN | newcfn();
      ne = sz = 0;
      do {
        if (ne == 0 && token_is(CKW_VOI)) break;
        if (ne > 0 && token_is(COP_ELP)) {
          regsnam(nsp, 0, "...", 0); ne++; break;
        }
        im2 = token_is(CKW_IMM);
        rtp = type_specifier(); if (rtp == CT_ERR) { cerr(E_TYP);}
        if (im2) { rtp = toimm(rtp);}
        rtp = declarator(rtp, bf);
        if (!issca(rtp)) { cerr(E_SCA);}
        if (srchnam(nsp, bf)) { cerr(E_DUP);}
        regsnam(nsp, chkbits(TRN_HDR)? rtp: toaut(rtp), bf, -sz);
        ne++; sz += sizof(prom(rtp));
      } while (token_is(COP_CMA));
      if (!token_is(COP_RPA)) { cerr(E_DLM);}
      pt = regstyp(nsp, ltp, ne, sz);
      regsnam(NSP_GLO, totyp(typidx(pt)), st, 0);
    } else {
      do {
        rtp = declarator(ltp, st);
        if (srchnam(NSP_GLO, st)) { cerr(E_DUP);}
        regsnam(NSP_GLO, totyp(rtp), st, 0);
      } while (token_is(COP_CMA));
    }
  }
  if (!token_is(COP_SEM)) { cerr(E_DLM);}
  return TRUE;
}

BOOL LOCALF define_directive(void)
{ // 儅僋儘掕媊晽掕悢愰尵
  I4B typ;
  U1B wk[8];
  I1B st[LIDN];

  if (!token_is(CKW_CNS)) return FALSE;
  if (token() != TKN_IDN) { cerr(E_IDN);}
  strcpyi(st, buf());
  typ = constant_expression(wk);
  if (!isari(typ)) { cerr(E_ARI);}
  glocns(typ, st, wk);
  return TRUE;
}

BOOL LOCALF enum_declaration(void)
{ // 楍嫇掕悢愰尵
  I4B va = 0, typ;
  U1B wk[8];
  I1B st[LIDN];

  if (!token_is(CKW_ENM)) return FALSE;
  if (!token_is(COP_LBC)) { cerr(E_DLM);}
  do {
    if (token_is(COP_RBC)) return TRUE;
    if (token() != TKN_IDN) { cerr(E_IDN);}
    strcpyi(st, buf());
    if (token_is(COP_ASN)) {
      typ = constant_expression(wk);
      if (!isint(typ)) { cerr(E_INT);}
      va = *(rI4B)wk;
    }
    glocns(CT_I4B, st, &va);
    va++;
  } while (token_is(COP_CMA));
  if (!token_is(COP_RBC)) { cerr(E_DLM);}
  return TRUE;
}

BOOL LOCALF variable_declaration(void)
{ // 曄悢愰尵
  I4B aut, imm, typ;
  rSTR cp;

  cp = cpos();
  aut = !!cfn();
  if (token_is(CKW_AUT)) {
    if (!aut) { cerr(E_UNX);}
  } else if (token_is(CKW_STA)) {
    aut = FALSE;
  }
  imm = token_is(CKW_IMM);
  typ = type_specifier(); if (typ == CT_ERR) { restart(cp); return FALSE;}
  if (imm) { typ = toimm(typ);}
  if (aut) { typ = toaut(typ);}
  do {
    init_declarator(typ);
  } while (token_is(COP_CMA));
  if (!token_is(COP_SEM)) { cerr(E_DLM);}
  return TRUE;
}

BOOL LOCALF function_definition(void)
{ // 娭悢愰尵乛娭悢掕媊
  I4B i, ne, sz, imm, nsp, lbr, ltp, rtp;
  rSTR cp;
  rTYPE pt;
  pNAME pi;
  I1B st[LIDN], bf[LIDN];

  cp = cpos();
  imm = token_is(CKW_IMM);
  ltp = type_specifier(); if (ltp == CT_ERR) { restart(cp); return FALSE;}
  if (imm) { ltp = toimm(ltp);}
  if (token() != TKN_IDN) { restart(cp); return FALSE;}
  strcpyi(st, buf());
  if (!token_is(COP_LPA)) { restart(cp); return FALSE;}
  if (!(isvoi(ltp) || issca(ltp))) { cerr(E_SCA);}
  if (!(pi = srchnam(NSP_GLO, st))) {
    nsp = chkbits(TRN_HDR)? NSX_BFN | newbfn(): NSX_CFN | newcfn();
    ne = sz = 0;
    do {
      if (ne == 0 && token_is(CKW_VOI)) break;
      if (ne > 0 && token_is(COP_ELP)) {
        regsnam(nsp, 0, "...", 0); ne++; break;
      }
      imm = token_is(CKW_IMM);
      rtp = type_specifier(); if (rtp == CT_ERR) { cerr(E_TYP);}
      if (imm) { rtp = toimm(rtp);}
      rtp = declarator(rtp, bf);
      if (!issca(rtp)) { cerr(E_SCA);}
      if (srchnam(nsp, bf)) { cerr(E_DUP);}
      regsnam(nsp, chkbits(TRN_HDR)? rtp: toaut(rtp), bf, -sz);
      ne++; sz += sizof(prom(rtp));
    } while (token_is(COP_CMA));
    if (!token_is(COP_RPA)) { cerr(E_DLM);}
    pt = regstyp(nsp, ltp, ne, sz);
    pi = regsnam(NSP_GLO, typidx(pt), st, 0);
  } else {
    if (!iscfn(pi->typ) || pi->ofs != 0) { cerr(E_DUP);}
    pt = typptr(idxof(pi->typ));
    if (ltp != pt->typ) { cerr(E_FNC);}
    nsp = pt->nsp;
    ne = pt->len; sz = 0;
    if (ne == 0) {
      if (token_is(COP_RPA) || (token_is(CKW_VOI) && token_is(COP_RPA))) {} else { cerr(E_FNC);}
    } else {
      for (i = 0; i < ne; i++) {
        if (token_is(COP_ELP)) break;
        imm = token_is(CKW_IMM);
        rtp = type_specifier(); if (rtp == CT_ERR) { cerr(E_TYP);}
        if (imm) { rtp = toimm(rtp);}
        rtp = declarator(rtp, bf);
        if (rtp != tovar(srchord(nsp, i)->typ)) { cerr(E_FNC);}
        if (strcmp(bf, srchord(nsp, i)->nam)) { cerr(E_FNC);}
        sz += sizof(prom(rtp));
        if (i < ne - 1 && !token_is(COP_CMA)) { cerr(E_FNC);}
      }
      if (!token_is(COP_RPA)) { cerr(E_FNC);}
      if (sz != pt->osz) { cerr(E_FNC);}
    }
  }
  if (token_is(COP_SEM)) return TRUE;
  if (chkbits(TRN_HDR|TRN_MAI)) { cerr(E_DLM);}
  if (!token_is(COP_LBC)) { cerr(E_DLM);}
  begincfn(pt, pi);
  while (variable_declaration()) {}
  lbr = regslab(NULL);
  while (!token_is(COP_RBC)) {
    statement(-1, -1, lbr, ltp, 0, NULL, NULL);
  }
  fixlab(lbr);
  switch (sizof0(prom(ltp))) {
  case 0:  outcod(ret_v); break;
  case 4:  outcod(ret_i); break;
  case 8:  outcod(ret_d); break;
  default: cerr(E_NAC);
  }
  fixjmp();
  endcfn(pt, pi);
  return TRUE;
}

void LOCALF translation_unit(void)
{ // 僐儞僷僀儖扨埵
  while (!token_is(TKN_END)) {
    if (typedef_declaration()) continue;
    if (define_directive()) continue;
    if (enum_declaration()) continue;
    if (function_definition()) continue;
    if (variable_declaration()) continue;
    if (token_is(COP_SEM)) continue;
    token(); cerr(E_UNX);
  }
}

BOOL LOCALF translate_header(rSTR st, rSTR fn)
{ // 僿僢僟僼傽僀儖偺僐儞僷僀儖
  I4B er;

  er = errchk(); if (er) { return (BOOL)xerr(er, fn);}
  setbits(TRN_HDR);
  start(st);
  translation_unit();
  resetbits(TRN_HDR);
  return TRUE;
}

BOOL LOCALF translate_source(rSTR st, rSTR fn)
{ // 僜乕僗僐乕僪僼傽僀儖偺僐儞僷僀儖
  I4B er;

  er = errchk(); if (er) { return (BOOL)xerr(er, fn);}
  start(st);
  translation_unit();
  return TRUE;
}

BOOL LOCALF declare_main(rSTR st)
{ // 儊僀儞娭悢愰尵
  I4B er;

  er = errchk(); if (er) { return (BOOL)xerr(er, NULL);}
  setbits(TRN_MAI);
  start(st);
  function_definition();
  resetbits(TRN_MAI);
  return TRUE;
}

BOOL LOCALF isdefined_main(rSTR mai)
{ // 儊僀儞娭悢掕媊偑懚嵼偡傞
  rNAME pi;

  start(mai);
  token_is(CKW_IMM);
  if (type_specifier() == CT_ERR) return FALSE;
  if (token() != TKN_IDN) return FALSE;
  if (!(pi = srchnam(NSP_GLO, buf()))) return FALSE;
  return iscfn(pi->typ) && !!pi->ofs;
}

BOOL WINAPI CompileBCD(rCPLI cp)
{ // 僐儞僷僀儖
  I4B re = FALSE;
  HBLK xb;
  HLEX le, lb;
  HCPL ce, cb;
  HBCD hb = NULL;

  le = CreateParsEnv(&xiC89); if (!le) return FALSE;
  lb = SelectParsEnv(le);
  ce = CreateCmplEnv(DEFCSZ, DEFDSZ); if (!ce) goto _20;
  cb = SelectCmplEnv(ce);
  register_primitive_types();
  if (cp->hfn) {
    xb = LoadTXT(NULL, cp->hfn); if (!xb) goto _10;
  } else {
    xb = cp->hxb;
  }
  if (xb) {
    re = translate_header(Ptr(xb), cp->hfn);
    if (cp->hfn) { UnloadTXT(xb);}
    if (!re) goto _10;
  }
  if (cp->mai) {
    re = declare_main(cp->mai);
    if (!re) goto _10;
    ce->ent = 1;
  }
  if (cp->sfn) {
    xb = LoadTXT(NULL, cp->sfn); if (!xb) goto _10;
  } else {
    xb = cp->sxb;
  }
  if (xb) {
    re = translate_source(Ptr(xb), cp->sfn);
    if (cp->sfn) { UnloadTXT(xb);}
    if (!re) goto _10;
    if (!ce->ent) { ce->ent = ce->ncf;}
  }
  outcod(end_v);
  if (cp->mai) {
    re = isdefined_main(cp->mai);
    if (!re) { ierr(E_ENT); goto _10;}
  }
  OptimizeBCD((pSEGS)ce->cod, cp->opt);
  hb = CreateBCD(cp->app, cp->pro, ce->ent, 0, (rSEGS)ce->cod, (rSEGS)ce->dat, ce->sof, (rIDXS)ce->rel);
  if (!hb) goto _10;
  if (cp->ofn) {
    re = SaveBCD(cp->ofn, hb, cp->tit, cp->dsc);
  } else {
    re = TRUE;
  }
  if (cp->ph && AttachBCD(hb)) {
    *cp->ph = hb;
  } else {
    DeleteBCD(hb);
  }
 _10: SelectCmplEnv(cb); DeleteCmplEnv(ce);
 _20: SelectParsEnv(lb); DeleteParsEnv(le);
  if (!re) { ClearAll(hWRK);}
  return re;
}

//乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗//

U4B  WINAPI BOLCOMVer(void)
{ // 僶乕僕儑儞
  return MODVER;
}

BOOL WINAPI InitBOLCOM(uANY pa)
{ // 奐巒張棟
  register_error_descriptions(&emCOM);
  hWRK = CreatePtrList(32); if (!hWRK) return FALSE;
  PrepPars(&dsC89);
  return TRUE;
}

void WINAPI TermBOLCOM(void)
{ // 廔椆張棟
  DeletePtrList(hWRK);
}

//乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗//
