kolibrios/programs/develop/cmm/tokb.cpp

1 line
281 KiB
C++
Raw Normal View History

#define _TOKB_ #include "tok.h" char badadr[]="Bad outrm value in outaddress();"; char CXandDX[]="CX and DX"; char ECXandEDX[]="ECX and EDX"; char BXandFS[]="BX and FS"; int divexpand=FALSE; int optnumber=FALSE; ITOK itok,itok2,ptok; char *pbuf; SINFO pstr; LISTFLOAT *floatnum=NULL; //ᯨ᮪ float <20><><EFBFBD><EFBFBD><EFBFBD> unsigned int numfloatconst=0; unsigned int maxnumfloatconst; #define STEPFLOATCONST 16 unsigned int ofsfloatlist=0; unsigned char idxregs[5]={ESI,EDI,EBX,EDX,255}; int expandvar(); int speedmul(unsigned long num, int razr); int leamul32(unsigned long num,int reg,int razr); void Float2reg32(int reg,int addop=0,int reg1=idxregs[0],int reg2=idxregs[1]); void NegReg(int razr,int reg); int RshiftReg(int razr,int reg,int sign); void do_e_axmath2(int sign,int razr,int expand); int MulReg(int reg,int razr); void DivMod(int vop,int sign,int razr,int expand); void DivNum2(unsigned long num,int razr,int sign); void DivNum(unsigned long num,int razr,int sign); void ClearDX(int razr,int sign); void doalmath2(int sign); void num2bits(ITOK *gtok,unsigned long num,int razr); void reg2bits(ITOK *gtok,int razr); void cwpointr(ITOK *wtok,char *&wbuf,SINFO *wstr,int *otok,int npointr,int ureg); int CheckAddOnly(); void optnumadd64(unsigned long long num,int r1,int r2,int vop); void CallExternProc(char *name); void getinto_reg(int gtok,ITOK *gstok,char *&gbuf,SINFO *gstr,int razr,int reg); void intinstack(int addop); extern void warningoptnum(); extern void segoperror(); extern void segbyteerror(); extern void regmathoperror(); extern void begmathoperror(); extern void negregerror(); extern void regbyteerror(); extern void begworderror(); extern void regshifterror(); extern void regmatherror(); extern void DevideZero(); extern void wordnotoper(); unsigned long long li[]={0x1,0x2,0x4,0x8,0x10,0x20,0x40,0x80,0x100,0x200,0x400, 0x800,0x1000,0x2000,0x4000,0x8000,0x10000,0x20000,0x40000,0x80000,0x100000, 0x200000,0x400000,0x800000,0x1000000,0x2000000,0x4000000,0x8000000,0x10000000, 0x20000000,0x40000000,0x80000000,0x100000000LL,0x200000000LL,0x400000000LL ,0x800000000LL,0x1000000000LL,0x2000000000LL,0x4000000000LL,0x8000000000LL ,0x10000000000LL,0x20000000000LL,0x40000000000LL,0x80000000000LL ,0x100000000000LL,0x200000000000LL,0x400000000000LL,0x800000000000LL ,0x1000000000000LL,0x2000000000000LL,0x4000000000000LL,0x8000000000000LL ,0x10000000000000LL,0x20000000000000LL,0x40000000000000LL,0x80000000000000LL ,0x100000000000000LL,0x200000000000000LL,0x400000000000000LL,0x800000000000000LL ,0x1000000000000000LL,0x2000000000000000LL,0x4000000000000000LL,0x8000000000000000LL}; unsigned long leanum[24]={3,5,9,15,25,27,45,81,75,125,135,225,243,405,729, 375,675,1215,2187,625,1125,2025,3645,6561}; unsigned int numleamul[24][4]={ {3,0,0,0},{5,0,0,0},{9,0,0,0},{3,5,0,0},{5,5,0,0},{3,9,0,0},{5,9,0,0}, {9,9,0,0},{5,5,3,0},{5,5,5,0},{9,5,3,0},{9,5,5,0},{9,9,3,0},{9,9,5,0}, {9,9,9,0},{5,5,5,3},{5,5,9,3},{9,9,5,3},{9,9,9,3},{5,5,5,5},{9,5,5,5}, {9,9,5,5},{9,9,9,5},{9,9,9,9}}; int RmEqualReg(int reg,int rm,int sib) { int rm0; int reg1=-1,reg2=-1; rm0=rm&0x7; if(sib==CODE16){ switch(rm0){ case 0: reg1=BX; reg2=SI; break; case 1: reg1=BX; reg2=DI; break; case 2: reg1=BP; reg2=SI; break; case 3: reg1=BP; reg2=DI; break; case 4: reg1=SI; break; case 5: reg1=DI; break; case 6: if((rm&0xC0)!=0)reg1=BP; break; case 7: reg1=BX; break; } } else{ if(rm0==4){ reg1=sib&7; reg2=(sib>>3)&7; if(reg1==5&&(rm&0xc0)==0)reg1=-1; if(reg2==4)reg2=-1; } else{ reg1=rm0; if(reg1==5&&(rm&0xc0)==0)reg1=-1; } } if(reg==reg1||reg==reg2)return TRUE; return FALSE; } void startmul(int razr) { if(razr==r8)outword(0xE08A); //mov ah,al else{ op66(razr); outword(0xD08B); //mov dx,ax warningreg(regs[razr/2-1][2]); } } void lshiftmul(int num,int razr,int reg=AX) { if(razr==r8){ if(num==1)ou