CoolFace
Datasetpublic

hschumann2/TempleOS-Source-Code

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes838downloads
UAsm.txt684 linesDownload Raw Back to Compiler
1 2I64 InstEntriesCompare(CInst *tmpins1,CInst *tmpins2)3{4  I64 i1,i2,j=0,res=0,oc_cnt1=tmpins1->opcode_cnt,oc_cnt2=tmpins2->opcode_cnt;5  if (tmpins1->flags&IEF_STI_LIKE)6    oc_cnt1--;7  if (tmpins2->flags&IEF_STI_LIKE)8    oc_cnt2--;9  while (TRUE) {10    if (j<oc_cnt1 && j<oc_cnt2) {11      if (res=tmpins1->opcode[j]-tmpins2->opcode[j])12        return res;13      j++;14    } else {15      if (res=oc_cnt1-oc_cnt2)16        return res;17 18      if (tmpins1->flags&IEF_STI_LIKE && tmpins2->flags&IEF_STI_LIKE)19        return tmpins1->opcode[j]-tmpins2->opcode[j];20 21      if (res=tmpins1->flags&IEF_STI_LIKE - tmpins2->flags&IEF_STI_LIKE)22        return res;23 24      if (res=tmpins1->slash_val-tmpins2->slash_val)25        return res;26 27      if (res=tmpins1->flags&IEF_OP_SIZE32 - tmpins2->flags&IEF_OP_SIZE32)28        return res;29 30      i1=Bt(&uasm.ins64_arg_mask,tmpins1->arg1) ||31            Bt(&uasm.ins64_arg_mask,tmpins1->arg2);32      i2=Bt(&uasm.ins64_arg_mask,tmpins2->arg1) ||33            Bt(&uasm.ins64_arg_mask,tmpins2->arg2);34      if (res=i1-i2)35        return res;36 37      if (res=tmpins1->flags&IEF_48_REX - tmpins2->flags&IEF_48_REX)38        return res;39 40      i1=tmpins1->arg2==ARGT_IMM64 || tmpins1->arg2==ARGT_UIMM64;41      i2=tmpins2->arg2==ARGT_IMM64 || tmpins2->arg2==ARGT_UIMM64;42      return i1-i2;43    }44  }45}46 47/*48U0 DumpUAsmIns(CInst *tmpins)49{50  CHashOpcode *tmpo=tmpins(U8 *)-tmpins->ins_entry_num*sizeof(CInst)51  -offset(CHashOpcode.ins);52  "%10s:%02d,%02d SV:%02d\n",tmpo->str,53        tmpins->arg1,tmpins->arg2,tmpins->slash_val;54}55U0 DumpUAsmTables()56{57  I64 k;58  "16/32 Bit Table\n";59  for (k=0;k<uasm.table_16_32_entries;k++)60    DumpUAsmIns(uasm.table_16_32[k]);61  "\n\n\n\n64 Bit Table\n";62  for (k=0;k<uasm.table_64_entries;k++)63    DumpUAsmIns(uasm.table_64[k]);64}65*/66 67CInst *InstEntryFind(U8 *rip,I64 opsize,I64 seg_size)68{//Binary Search69  I64 i,j,n,m,k,arg1,arg2,o1,o2,oc_cnt;70  CInst *tmpins,**table;71  i=0;72  if (seg_size==64) {73    table=uasm.table_64;74    j=uasm.table_64_entries-1;75  } else {76    table=uasm.table_16_32;77    j=uasm.table_16_32_entries-1;78  }79  while (TRUE) {80    k=(i+j)>>1;  //binary search81    tmpins=table[k];82//DumpUAsmIns(tmpins);83    m=0;84    n=0;85    while (TRUE) { //ief_compare_start86      arg1=tmpins->arg1;87      arg2=tmpins->arg2;88      oc_cnt=tmpins->opcode_cnt;89      if (tmpins->flags&IEF_STI_LIKE)90        oc_cnt--;91      if (n<oc_cnt) {92        o1=rip[n];93        if (n==tmpins->opcode_cnt-1 && tmpins->flags & IEF_PLUS_OPCODE)94          o1&=-8;95        o2=tmpins->opcode[n++];96        if (m=o1-o2)97          goto ief_compare_done;98      } else99        switch [tmpins->uasm_slash_val] {100          case 0...7:101            if (!(m=rip[n]>>3&7-tmpins->slash_val)) {102              if ((Bt(&uasm.mem_arg_mask,arg1) ||103                    Bt(&uasm.mem_arg_mask,arg2)) &&104                    rip[n]&0xC0==0xC0) {105                m=1;106                goto ief_compare_done;107              }108              if (opsize==16) {109                if (tmpins->flags & IEF_OP_SIZE32) {110                  m=-1;111                  goto ief_compare_done;112                }113              } else {114                if (tmpins->flags & IEF_OP_SIZE16) {115                  m=1;116                  goto ief_compare_done;117                }118              }119              if (opsize==64||arg1==ARGT_M64||arg2==ARGT_M64) {120                if (!Bt(&uasm.ins64_arg_mask,arg1)&&121                      !Bt(&uasm.ins64_arg_mask,arg2)&&122                      !(tmpins->flags&IEF_48_REX))123                  m=1;124              } else {125                if (Bt(&uasm.ins64_arg_mask,arg1)||126                      Bt(&uasm.ins64_arg_mask,arg2) ||127                      tmpins->flags&IEF_48_REX)128                  m=-1;129              }130            } else if ((Bt(&uasm.mem_arg_mask,arg1)||131                  Bt(&uasm.mem_arg_mask,arg2)) &&132                  rip[n]&0xC0==0xC0)133              m=1;134            goto ief_compare_done;135          case SV_I_REG:136            m=rip[n]>>3-tmpins->opcode[tmpins->opcode_cnt-1]>>3;137            goto ief_compare_done;138          case SV_STI_LIKE:139            if (!(m=rip[n]>>3-tmpins->opcode[tmpins->opcode_cnt-1]>>3))140              m=rip[n]-tmpins->opcode[tmpins->opcode_cnt-1];141            goto ief_compare_done;142          case SV_R_REG:143          case SV_NONE:144            m=0;145            if (opsize==16) {146              if (tmpins->flags & IEF_OP_SIZE32) {147                m=-1;148                goto ief_compare_done;149              }150            } else {151              if (tmpins->flags & IEF_OP_SIZE16) {152                m=1;153                goto ief_compare_done;154              }155            }156            if (opsize==64 || arg1==ARGT_M64 || arg2==ARGT_M64) {157              if (!Bt(&uasm.ins64_arg_mask,arg1) &&158                    !Bt(&uasm.ins64_arg_mask,arg2) &&159                    !(tmpins->flags&IEF_48_REX)&& !(arg2==ARGT_NONE &&160                    (ARGT_UIMM8<=arg1<=ARGT_UIMM64 ||161                    ARGT_IMM8<=arg1<=ARGT_IMM64)))162                m=1;163              else if (tmpins->arg2==ARGT_IMM64 || tmpins->arg2==ARGT_UIMM64) {164                if (arg2!=ARGT_IMM64&&arg2!=ARGT_UIMM64)165                  m=1;166              } else if (arg2==ARGT_IMM64||arg2==ARGT_UIMM64)167                m=-1;168            } else {169              if (Bt(&uasm.ins64_arg_mask,arg1) ||170                    Bt(&uasm.ins64_arg_mask,arg2) ||171                    tmpins->flags&IEF_48_REX)172                m=-1;173            }174            goto ief_compare_done;175        }176    }177ief_compare_done:178    if (m>0) {179      if (k==i) {180        k=j;181        break;182      } else183        i=k;184    } else if (m<0) {185      if (k-i<=1) {186        k=i;187        break;188      } else189        j=k;190    } else191      break;192  }193  return table[k];194}195 196U0 UAsmHashLoad()197{198  CHashOpcode *tmph;199  CInst *tmpins;200  I64 i,j1,j2,k;201 202  uasm.ins64_arg_mask=0x0880888880+1<<ARGT_ST0+1<<ARGT_STI;203  uasm.signed_arg_mask=1<<ARGT_REL8+1<<ARGT_REL16+1<<ARGT_REL32+204        1<<ARGT_IMM8+1<<ARGT_IMM16+1<<ARGT_IMM32+1<<ARGT_IMM64;205  uasm.mem_arg_mask=1<<ARGT_M8+1<<ARGT_M16+1<<ARGT_M32+1<<ARGT_M64;206 207  uasm.table_16_32_entries=uasm.table_64_entries=0;208  for (i=0;i<=cmp.asm_hash->mask;i++) {209    tmph=cmp.asm_hash->body[i];210    while (tmph) {211      if (tmph->type==HTT_OPCODE && !(tmph->oc_flags&OCF_ALIAS)) {212        tmpins=&tmph->ins;213        for (k=0;k<tmph->inst_entry_cnt;k++) {214          uasm.table_16_32_entries++;215          if (!(tmpins->flags&IEF_NOT_IN_64_BIT))216            uasm.table_64_entries++;217          tmpins++;218        }219      }220      tmph=tmph->next;221    }222  }223 224  j1=j2=0;225  uasm.table_16_32=MAlloc(uasm.table_16_32_entries*sizeof(U8 *));226  uasm.table_64   =MAlloc(uasm.table_64_entries   *sizeof(U8 *));227  for (i=0;i<=cmp.asm_hash->mask;i++) {228    tmph=cmp.asm_hash->body[i];229    while (tmph) {230      if (tmph->type==HTT_OPCODE && !(tmph->oc_flags&OCF_ALIAS)) {231        tmpins=&tmph->ins;232        for (k=0;k<tmph->inst_entry_cnt;k++) {233          uasm.table_16_32[j1++]=tmpins;234          if (!(tmpins->flags&IEF_NOT_IN_64_BIT))235            uasm.table_64[j2++]=tmpins;236          tmpins++;237        }238      }239      tmph=tmph->next;240    }241  }242  QSortI64(uasm.table_16_32,uasm.table_16_32_entries,&InstEntriesCompare);243  QSortI64(uasm.table_64   ,uasm.table_64_entries   ,&InstEntriesCompare);244}245 246U0 Ui(U8 *buf,U8 **_rip,I64 seg_size=64,I64 *_jmp_dst=NULL,Bool just_ins=FALSE)247{//Unassembles one inst248  I64 i,disp,imm,opsize,opadd,249        arg1,arg2,reloced_arg1,reloced_arg2,250        arg1_size=0,arg2_size=0,reloced_arg1_size,reloced_arg2_size,251        ModrM=-1,SIB=-1,scale,r1,r2,252        Mod=-1,RM1=-1,RM2=-1,REX=-1,REX_r=0,REX_x=0,REX_b=0;253  Bool cont;254  CInst *tmpins,*tmpins2;255  CHashOpcode *tmpo;256  U8 *rip=*_rip,*ptr,*reloced_arg1_st,*reloced_arg2_st,257        *bin_data_area1,*bin_data_area2,258        line1[512],line2[512],buf2[512],arg1_st[512],259        arg2_st[512],seg_overrides[32];260 261  if (_jmp_dst) *_jmp_dst=-1;262  if (seg_size==16) {263    opsize=16;264    opadd=16;265  } else if (seg_size==32) {266    opsize=32;267    opadd=32;268  } else {269    opsize=32;270    opadd=64;271  }272  *arg1_st=0;273  *arg2_st=0;274  if (!IsRaw && PutSrcLink(rip,1,line1))275    CatPrint(line1,"\n");276  else277    *line1=0;278 279  StrPrint(line1+StrLen(line1),"%24tp ",rip);280  bin_data_area1=line1+StrLen(line1);281  for (i=0;i<6;i++)282    CatPrint(line1,"%02X",rip[i]);283  CatPrint(line1," ");284 285  StrPrint(line2,"%24tp ",rip+6);286  bin_data_area2=line2+StrLen(line2);287  for (i=6;i<12;i++)288    CatPrint(line2,"%02X",rip[i]);289 290  *seg_overrides=0;291  cont=TRUE;292  while (TRUE) {293    switch (*rip) {294      case 0x2E: if (StrLen(seg_overrides)<24)295          CatPrint(seg_overrides,"CS:"); break;296      case 0x36: if (StrLen(seg_overrides)<24)297          CatPrint(seg_overrides,"SS:"); break;298      case 0x3E: if (StrLen(seg_overrides)<24)299          CatPrint(seg_overrides,"DS:"); break;300      case 0x26: if (StrLen(seg_overrides)<24)301          CatPrint(seg_overrides,"ES:"); break;302      case 0x64: if (StrLen(seg_overrides)<24)303          CatPrint(seg_overrides,"FS:"); break;304      case 0x65: if (StrLen(seg_overrides)<24)305          CatPrint(seg_overrides,"GS:"); break;306      case OC_OP_SIZE_PREFIX:307        if (opsize==16)308          opsize=32;309        else310          opsize=16;311        break;312      case OC_ADDR_SIZE_PREFIX:313        if (opadd==16)314          opadd=32;315        else316          opadd=16;317        break;318      case 0x40...0x4F:319        if (seg_size==64) {320          REX=*rip;321          if (REX>=0x48)322            opsize=64;323          REX_b=Bt(&REX,0)<<3;324          REX_x=Bt(&REX,1)<<3;325          REX_r=Bt(&REX,2)<<3;326          break;327        } //Fall thru if !64328      default:329        cont=FALSE;330    }331    if (cont)332      rip++;333    else334      break;335  }336 337  tmpins=InstEntryFind(rip,opsize,seg_size);338  if (opsize==32 && seg_size==64) {339    tmpins2=InstEntryFind(rip,64,seg_size);340    if (tmpins2!=tmpins && tmpins2->flags&IEF_REX_ONLY_R8_R15 ||341          tmpins2->flags&IEF_REX_XOR_LIKE&& rip[1]>>3&7==rip[1]&7)342      tmpins=tmpins2;343  }344 345  rip+=tmpins->opcode_cnt;346  tmpo=tmpins(U8 *)-tmpins->ins_entry_num*sizeof(CInst)347  -offset(CHashOpcode.ins);348  if (just_ins)349    *line1=0;350  CatPrint(line1,tmpo->str);351 352  arg1=tmpins->arg1;353  arg2=tmpins->arg2;354 355  if (arg1_size=tmpins->size1) {356    if (Bt(&uasm.signed_arg_mask,arg1))357      CatPrint(arg1_st,"I%d ",arg1_size);358    else359      CatPrint(arg1_st,"U%d ",arg1_size);360  }361 362  if (arg2_size=tmpins->size2) {363    if (Bt(&uasm.signed_arg_mask,arg2))364      CatPrint(arg2_st,"I%d ",arg2_size);365    else366      CatPrint(arg2_st,"U%d ",arg2_size);367  }368 369  if (tmpins->flags & IEF_PLUS_OPCODE) {370    rip--;371    RM1=*rip++ - tmpins->opcode[tmpins->opcode_cnt-1]+REX_b;372    ptr=NULL;373    if (ARGT_R8<=arg1<=ARGT_R64) {374      if (arg1_size==8) {375        if (REX!=-1)376          ptr="ST_U8_REX_REGS";377        else378          ptr="ST_U8_REGS";379      } else if (arg1_size==16)380        ptr="ST_U16_REGS";381      else if (arg1_size==32)382        ptr="ST_U32_REGS";383      else if (arg1_size==64)384        ptr="ST_U64_REGS";385      if (ptr)386        CatPrint(arg1_st,"%Z",RM1,ptr);387    } else {388      if (arg2_size==8) {389        if (REX!=-1)390          ptr="ST_U8_REX_REGS";391        else392          ptr="ST_U8_REGS";393      } else if (arg2_size==16)394        ptr="ST_U16_REGS";395      else if (arg2_size==32)396        ptr="ST_U32_REGS";397      else if (arg2_size==64)398        ptr="ST_U64_REGS";399      if (ptr)400        CatPrint(arg2_st,"%Z",RM1,ptr);401    }402  }403 404  if (ARGT_RM8<=arg1<=ARGT_RM64 || ARGT_M8<=arg1<=ARGT_M64 ||405        ARGT_RM8<=arg2<=ARGT_RM64 || ARGT_M8<=arg2<=ARGT_M64) {406    if (ARGT_RM8<=arg2<=ARGT_RM64 || ARGT_M8<=arg2<=ARGT_M64) {407      reloced_arg1=arg2;408      reloced_arg2=arg1;409      reloced_arg1_size=arg2_size;410      reloced_arg2_size=arg1_size;411      reloced_arg1_st=arg2_st;412      reloced_arg2_st=arg1_st;413    } else {414      reloced_arg1=arg1;415      reloced_arg2=arg2;416      reloced_arg1_size=arg1_size;417      reloced_arg2_size=arg2_size;418      reloced_arg1_st=arg1_st;419      reloced_arg2_st=arg2_st;420    }421 422    CatPrint(reloced_arg1_st,seg_overrides);423    ModrM=*rip++;424    Mod=ModrM>>6 & 3;425    RM1=ModrM & 7+REX_b;426    RM2=ModrM>>3 & 7+REX_r;427    if (Mod<3 && RM1&7==4)428      SIB=*rip++;429    if (Mod==1) {430      disp=*rip(U8 *)++;431      CatPrint(reloced_arg1_st,"%02X",disp);432    } else if (Mod==2) {433      disp=*rip(U32 *)++;434      CatPrint(reloced_arg1_st,"%08X",disp);435    }436    if (tmpins->slash_val<8)437      RM2=-1;438    else {439      ptr=NULL;440      if (reloced_arg2==ARGT_SREG) {441        if (RM2<=5)442          ptr="ST_SEG_REGS";443      } else if (!(ARGT_IMM8<=reloced_arg2<=ARGT_IMM64) &&444            !(ARGT_UIMM8<=reloced_arg2<=ARGT_UIMM64)) {445        if (reloced_arg2_size==8) {446          if (REX!=-1)447            ptr="ST_U8_REX_REGS";448          else449            ptr="ST_U8_REGS";450        } else if (reloced_arg2_size==16)451          ptr="ST_U16_REGS";452        else if (reloced_arg2_size==32)453          ptr="ST_U32_REGS";454        else if (reloced_arg2_size==64)455          ptr="ST_U64_REGS";456      }457      if (ptr)458        CatPrint(reloced_arg2_st,"%Z",RM2,ptr);459    }460    if (RM1&7==5 && !Mod) {461      disp=*rip(I32 *)++;462      if (seg_size==64) {463        disp+=rip;464        if (reloced_arg2==ARGT_IMM8 || reloced_arg2==ARGT_UIMM8)465          disp++;466        else if (reloced_arg2==ARGT_IMM16 || reloced_arg2==ARGT_UIMM16)467          disp+=2;468        else if (reloced_arg2==ARGT_IMM32 || reloced_arg2==ARGT_UIMM32)469          disp+=4;470        else if (reloced_arg2==ARGT_IMM64 || reloced_arg2==ARGT_UIMM64)471          disp+=8;472      }473      CatPrint(reloced_arg1_st,"[%X]",disp);474      RM1=-1;475    } else {476      if (Mod<3) {477        if (RM1&7==4) {478          RM1=-1;479          r1=SIB & 7+REX_b;480          r2=SIB>>3 & 7+REX_x;481          scale=SIB>>6 &3;482          if (scale==3)483            scale=8;484          else if (scale==2)485            scale=4;486          else if (scale==1)487            scale=2;488          else489            scale=1;490          if (seg_size==64)491            ptr="ST_U64_REGS";492          else493            ptr="ST_U32_REGS";494          if (r1==REG_RBP && !Mod) {495            disp=*rip(U32 *)++;496            CatPrint(reloced_arg1_st,"%08X[%Z*%d]",disp,r2,ptr,scale);497          } else if (r2==4)498            CatPrint(reloced_arg1_st,"[%Z]",r1,ptr);499          else500            CatPrint(reloced_arg1_st,"[%Z+%Z*%d]",r1,ptr,r2,ptr,scale);501        } else {502          if (opadd==16)503            ptr="ST_U16_REGS";504          else if (opadd==32)505            ptr="ST_U32_REGS";506          else507            ptr="ST_U64_REGS";508          CatPrint(reloced_arg1_st,"[%Z]",RM1,ptr);509        }510      } else {511        ptr=NULL;512        if (reloced_arg1_size==8) {513          if (REX!=-1)514            ptr="ST_U8_REX_REGS";515          else516            ptr="ST_U8_REGS";517        } else if (reloced_arg1_size==16)518          ptr="ST_U16_REGS";519        else if (reloced_arg1_size==32)520          ptr="ST_U32_REGS";521        else if (reloced_arg1_size==64)522          ptr="ST_U64_REGS";523        if (ptr)524          CatPrint(reloced_arg1_st,DefineSub(RM1,ptr));525      }526    }527  }528 529  switch (arg1) {530    case ARGT_IMM8:531    case ARGT_UIMM8:532      imm=*rip(U8 *)++;533      CatPrint(arg1_st,"%02X",imm);534      if (tmpins->opcode[0]==0xCD && (ptr=DefineSub(imm,"ST_INT_NAMES")))535        CatPrint(arg1_st," %s",ptr);536      break;537    case ARGT_IMM16:538    case ARGT_UIMM16:539      CatPrint(arg1_st,"%04X",*rip(U16 *)++);540      break;541    case ARGT_IMM32:542    case ARGT_UIMM32:543      CatPrint(arg1_st,"%08X",*rip(U32 *)++);544      break;545    case ARGT_IMM64:546    case ARGT_UIMM64:547      CatPrint(arg1_st,"%016X",*rip(I64 *)++);548      break;549    start:550      case ARGT_REL8:551        disp=*rip(I8 *)++;552        break;553      case ARGT_REL16:554        disp=*rip(I16 *)++;555        break;556      case ARGT_REL32:557        disp=*rip(I32 *)++;558        break;559    end:560      disp+=rip;561      if (IsDbgMode)562        CatPrint(arg1_st,"%p ",disp);563      else if (PutSrcLink(disp,512,buf2))564        CatPrint(arg1_st,"%s ",buf2);565      else566        CatPrint(arg1_st,"%P ",disp);567      if (_jmp_dst) *_jmp_dst=disp;568      break;569    case ARGT_MOFFS8...ARGT_MOFFS64:570      CatPrint(arg1_st,seg_overrides);571      if (arg1_size==8)572        disp=*rip(U8 *)++;573      else if (opadd==16)574        disp=*rip(U16 *)++;575      else576        disp=*rip(U32 *)++;577      CatPrint(arg1_st,"[%X]",disp);578      break;579    case ARGT_AL ... ARGT_DX:580    case ARGT_SS ... ARGT_ST0:581      CatPrint(arg1_st,"%z",arg1-ARGT_AL,582            "AL\0AX\0EAX\0RAX\0CL\0DX\0 \0 \0SS\0DS\0ES\0FS\0GS\0CS\0ST0\0");583      break;584    case ARGT_STI:585      rip--;586      CatPrint(arg1_st,"%Z",*rip++ - tmpins->opcode[tmpins->opcode_cnt-1],587            "ST_FSTK_REGS");588      break;589  }590 591  switch (arg2) {592    case ARGT_IMM8:593    case ARGT_UIMM8:594      CatPrint(arg2_st,"%02X",*rip(U8 *)++);595      break;596    case ARGT_IMM16:597    case ARGT_UIMM16:598      CatPrint(arg2_st,"%04X",*rip(U16 *)++);599      break;600    case ARGT_IMM32:601    case ARGT_UIMM32:602      CatPrint(arg2_st,"%08X",*rip(U32 *)++);603      break;604    case ARGT_IMM64:605    case ARGT_UIMM64:606      CatPrint(arg2_st,"%016X",*rip(I64 *)++);607      break;608    case ARGT_MOFFS8...ARGT_MOFFS64:609      CatPrint(arg2_st,seg_overrides);610      if (arg2_size==8)611        disp=*rip(U8 *)++;612      else if (opadd==16)613        disp=*rip(U16 *)++;614      else615        disp=*rip(U32 *)++;616      CatPrint(arg2_st,"[%X]",disp);617      break;618    case ARGT_AL ... ARGT_DX:619    case ARGT_SS ... ARGT_ST0:620      CatPrint(arg2_st,"%z",arg2-ARGT_AL,621            "AL\0AX\0EAX\0RAX\0CL\0DX\0 \0 \0SS\0DS\0ES\0FS\0GS\0CS\0ST0\0");622      break;623    case ARGT_STI:624      rip--;625      CatPrint(arg2_st,"%Z",*rip++ -tmpins->opcode[tmpins->opcode_cnt-1],626            "ST_FSTK_REGS");627      break;628  }629  if (tmpins->flags&IEF_ENDING_ZERO)630    rip++;631 632  if (*arg1_st)633    CatPrint(line1,"\t%s",arg1_st);634  if (*arg2_st)635    CatPrint(line1,",%s",arg2_st);636  CatPrint(line1,"\n");637  CatPrint(line2,"\n");638  if (!just_ins) {639    for (i=rip-(*_rip)(I64);i<6;i++) {640      bin_data_area1[i<<1]=CH_SPACE;641      bin_data_area1[i<<1+1]=CH_SPACE;642    }643    for (i=rip-(*_rip)(I64);i<12;i++) {644      bin_data_area2[(i-6)<<1]=CH_SPACE;645      bin_data_area2[(i-6)<<1+1]=CH_SPACE;646    }647  }648  StrCpy(buf,line1);649  if (!just_ins && rip-(*_rip)(I64)>6)650    CatPrint(buf,line2);651  *_rip=rip;652}653 654U8 *U(U8 *rip,I64 cnt=20,I64 seg_size=64)655{//Unassembles a num of insts.656  I64 i;657  U8 buf[1024];658  if (seg_size==16)659    PrintWarn("16-bit unassembly is not well supported.\n");660  "$HL,1$";661  for (i=0;i<cnt;i++) {662    Ui(buf,&rip,seg_size);663    "%s",buf;664  }665  "$HL,0$";666  return rip;667}668 669I64 Un(U8 *rip,I64 cnt=0x80,I64 seg_size=64)670{//Unassembles a num of bytes671  I64 i=0;672  U8 buf[1024],*end_rip=rip(I64)+cnt;673  if (seg_size==16)674    PrintWarn("16-bit unassembly is not well supported.\n");675  "$HL,1$";676  while (rip<end_rip) {677    Ui(buf,&rip,seg_size);678    "%s",buf;679    i++;680  }681  "$HL,0$";682  return i;683}684