Rev 6618 | Rev 7626 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6618 | Rev 7545 | ||
---|---|---|---|
1 | #define _TOKC_ |
1 | #define _TOKC_ |
2 | 2 | ||
3 | #include |
3 | #include |
4 | #include |
4 | #include |
5 | #include "tok.h" |
5 | #include "tok.h" |
6 | 6 | ||
7 | void GetFileTime(int fd,struct ftime *buf); |
7 | void GetFileTime(int fd,struct ftime *buf); |
8 | 8 | ||
9 | #define MAXIF 32 |
9 | #define MAXIF 32 |
10 | 10 | ||
11 | //idrec *crec=NULL; |
11 | //idrec *crec=NULL; |
12 | 12 | ||
13 | char invaliddecrem[]="invalid token to be decremented"; |
13 | char invaliddecrem[]="invalid token to be decremented"; |
14 | char mesLOOPNZ[]="LOOPNZ"; |
14 | char mesLOOPNZ[]="LOOPNZ"; |
15 | char mesIF[]="IF"; |
15 | char mesIF[]="IF"; |
16 | char mesELSE[]="ELSE"; |
16 | char mesELSE[]="ELSE"; |
17 | char mesWHILE[]="WHILE"; |
17 | char mesWHILE[]="WHILE"; |
18 | char mesFOR[]="FOR"; |
18 | char mesFOR[]="FOR"; |
19 | char mesRETURN[]="RETURN"; |
19 | char mesRETURN[]="RETURN"; |
20 | int tok,tok2; /* token holders current, next */ |
20 | int tok,tok2; /* token holders current, next */ |
21 | unsigned char string[STRLEN],string2[STRLEN+20], |
21 | unsigned char string[STRLEN],string2[STRLEN+20], |
22 | string3[STRLEN]; //ñîäåðæèò íå ïðåîáðàçîâàííóþ ñòðîêó |
22 | string3[STRLEN]; //ñîäåðæèò íå ïðåîáðàçîâàííóþ ñòðîêó |
23 | unsigned int posts=0; /* number of post entrys */ |
23 | unsigned int posts=0; /* number of post entrys */ |
24 | postinfo *postbuf; |
24 | postinfo *postbuf; |
25 | unsigned int maxposts=MAXPOSTS; |
25 | unsigned int maxposts=MAXPOSTS; |
26 | unsigned int secondcallnum=1; /* # of different second calls and labels */ |
26 | unsigned int secondcallnum=1; /* # of different second calls and labels */ |
27 | unsigned int externnum=0; |
27 | unsigned int externnum=0; |
28 | unsigned long postsize=0; /* total size of all post vars */ |
28 | unsigned long postsize=0; /* total size of all post vars */ |
29 | unsigned int poststrptr=0; /* post string index in output */ |
29 | unsigned int poststrptr=0; /* post string index in output */ |
30 | unsigned int outptrsize=MAXDATA; //ðàçìåð âûõîäíîãî áóôåðà äëÿ êîäà |
30 | unsigned int outptrsize=MAXDATA; //ðàçìåð âûõîäíîãî áóôåðà äëÿ êîäà |
31 | unsigned int outdatasize=MAXDATA; //ðàçìåð âûõîäíîãî áóôåðà äëÿ äàííûõ |
31 | unsigned int outdatasize=MAXDATA; //ðàçìåð âûõîäíîãî áóôåðà äëÿ äàííûõ |
32 | long runfilesize; |
32 | long runfilesize; |
33 | int error=0; /* current error number holder */ |
33 | int error=0; /* current error number holder */ |
34 | unsigned char dos1=0,dos2=0; /* DOS version required for program execution */ |
34 | unsigned char dos1=0,dos2=0; /* DOS version required for program execution */ |
35 | unsigned char cpu=0; /* CPU required, 2 for 80286, 3 for 80386, ... */ |
35 | unsigned char cpu=0; /* CPU required, 2 for 80286, 3 for 80386, ... */ |
36 | unsigned int paramsize=0; /* byte size of all procedure parameters */ |
36 | unsigned int paramsize=0; /* byte size of all procedure parameters */ |
37 | unsigned int localsize=0; /* byte size of all procedure local variables */ |
37 | unsigned int localsize=0; /* byte size of all procedure local variables */ |
38 | unsigned int procedure_start=0; /* address of start of procedure */ |
38 | unsigned int procedure_start=0; /* address of start of procedure */ |
39 | unsigned int current_proc_type; /* current procedure type */ |
39 | unsigned int current_proc_type; /* current procedure type */ |
40 | int returntype; /* return type, (void, byte, word, ...) */ |
40 | int returntype; /* return type, (void, byte, word, ...) */ |
41 | unsigned char warning; |
41 | unsigned char warning; |
42 | /*+++++++++++++++++++++++ Óñòàíîâêè ïî óìîë÷àíèþ +++++++++++++++++++++++*/ |
42 | /*+++++++++++++++++++++++ Óñòàíîâêè ïî óìîë÷àíèþ +++++++++++++++++++++++*/ |
43 | unsigned char am32 = FALSE; // ðåæèì 32 áèòíîé àäðåñàöèè |
43 | unsigned char am32 = FALSE; // ðåæèì 32 áèòíîé àäðåñàöèè |
44 | unsigned char comfile = file_com; // output file format |
44 | unsigned char comfile = file_com; // output file format |
45 | unsigned char optimizespeed = 1; // optimize for size or speed flag |
45 | unsigned char optimizespeed = 1; // optimize for size or speed flag |
46 | unsigned char alignword = 1; // flag whether or not to align words |
46 | unsigned char alignword = 1; // flag whether or not to align words |
47 | unsigned char aligner = 0; // value used to align words |
47 | unsigned char aligner = 0; // value used to align words |
48 | unsigned char header = 1; // output SPHINX C-- Ver1 Ver2 header |
48 | unsigned char header = 1; // output SPHINX C-- Ver1 Ver2 header |
49 | unsigned char chip = 0; // CPU optimization (286,386,486,...) |
49 | unsigned char chip = 0; // CPU optimization (286,386,486,...) |
50 | unsigned char killctrlc = 0; // add disable CTRL-C code in header |
50 | unsigned char killctrlc = 0; // add disable CTRL-C code in header |
51 | unsigned int stacksize = 2048; // stack size (2048 default) |
51 | unsigned int stacksize = 2048; // stack size (2048 default) |
52 | unsigned char splitdata=FALSE; //îòäåëèòü äàííûå îò êîäà |
52 | unsigned char splitdata=FALSE; //îòäåëèòü äàííûå îò êîäà |
53 | unsigned char AlignCycle=FALSE; //âûðàâíèâàòü íà÷àëà öèêëîâ |
53 | unsigned char AlignCycle=FALSE; //âûðàâíèâàòü íà÷àëà öèêëîâ |
54 | /*+++++++++++++++++++ end of flexable compiler options ++++++++++++++++++++*/ |
54 | /*+++++++++++++++++++ end of flexable compiler options ++++++++++++++++++++*/ |
55 | unsigned char notdoneprestuff = TRUE; // flag if initial stuff has been entered |
55 | unsigned char notdoneprestuff = TRUE; // flag if initial stuff has been entered |
56 | unsigned int datasize=0,alignersize=0; /* size of data and other */ |
56 | unsigned int datasize=0,alignersize=0; /* size of data and other */ |
57 | unsigned int outptr=0x100,outptrdata=0x100; /* ptr to output */ |
57 | unsigned int outptr=0x100,outptrdata=0x100; /* ptr to output */ |
58 | unsigned char *output; |
58 | unsigned char *output; |
59 | unsigned char *outputdata=NULL; |
59 | unsigned char *outputdata=NULL; |
60 | unsigned int linenumber=0; |
60 | unsigned int linenumber=0; |
61 | unsigned char dynamic_flag=0; //ôëàã îáðàáîòêè äèíàìè÷åñêèõ ýëåìåíòîâ |
61 | unsigned char dynamic_flag=0; //ôëàã îáðàáîòêè äèíàìè÷åñêèõ ýëåìåíòîâ |
62 | 62 | ||
63 | unsigned char *input; /* dynamic input buffer */ |
63 | unsigned char *input; /* dynamic input buffer */ |
64 | unsigned int endinptr; /* end index of input array */ |
64 | unsigned int endinptr; /* end index of input array */ |
65 | unsigned int inptr; /* index in input buffer */ |
65 | unsigned int inptr; /* index in input buffer */ |
66 | unsigned char cha; /* pipe byte for token production */ |
66 | unsigned char cha; /* pipe byte for token production */ |
67 | char endoffile; /* end of input file flag */ |
67 | char endoffile; /* end of input file flag */ |
68 | unsigned char insertmode=FALSE; |
68 | unsigned char insertmode=FALSE; |
69 | unsigned int numblocks=0; //íîìåð âëîæåííîãî áëîêà |
69 | unsigned int numblocks=0; //íîìåð âëîæåííîãî áëîêà |
70 | treelocalrec *tlr=NULL; //öåïî÷êà ëîêàëüíûõ áëîêîâ |
70 | treelocalrec *tlr=NULL; //öåïî÷êà ëîêàëüíûõ áëîêîâ |
71 | treelocalrec *btlr=NULL; //öåïî÷êà èñïîëüçîâàíûõ ëîêàëüíûõ áëîêîâ |
71 | treelocalrec *btlr=NULL; //öåïî÷êà èñïîëüçîâàíûõ ëîêàëüíûõ áëîêîâ |
72 | RETLIST *listreturn=NULL; |
72 | RETLIST *listreturn=NULL; |
73 | unsigned int numreturn=0; |
73 | unsigned int numreturn=0; |
74 | idrec *staticlist; |
74 | idrec *staticlist; |
75 | unsigned char stat_reg[8]; //òàáëèöà çàíÿòîñòè ðåãèñòðîâ |
75 | unsigned char stat_reg[8]; //òàáëèöà çàíÿòîñòè ðåãèñòðîâ |
76 | 76 | ||
77 | int sizestack=0; //ðàçìåð íå êîìïåíñèðîâàííûõ ïàðàìåòðîâ ôóíêöèé |
77 | int sizestack=0; //ðàçìåð íå êîìïåíñèðîâàííûõ ïàðàìåòðîâ ôóíêöèé |
78 | unsigned char addstack=TRUE; |
78 | unsigned char addstack=TRUE; |
79 | 79 | ||
80 | extern char shorterr[]; |
80 | extern char shorterr[]; |
81 | extern unsigned long long li[]; |
81 | extern unsigned long long li[]; |
82 | 82 | ||
83 | /*-----------------01.05.98 19:22------------------- |
83 | /*-----------------01.05.98 19:22------------------- |
84 | äîïîëíèòåëüíûå ïåðåìåííûå äëÿ ðåàëèçàöèè BREAK CONTINUE |
84 | äîïîëíèòåëüíûå ïåðåìåííûå äëÿ ðåàëèçàöèè BREAK CONTINUE |
85 | --------------------------------------------------*/ |
85 | --------------------------------------------------*/ |
86 | #define MAXIN 100 //ìàêñèìàëüíàÿ âëîæåíîñòü öèêëîâ |
86 | #define MAXIN 100 //ìàêñèìàëüíàÿ âëîæåíîñòü öèêëîâ |
87 | unsigned int numbr=0; //ñ÷åò÷èê îáùåãî ÷èñëà öèêëîâ LOOP DO-WHILE... |
87 | unsigned int numbr=0; //ñ÷åò÷èê îáùåãî ÷èñëà öèêëîâ LOOP DO-WHILE... |
88 | unsigned int listbr[MAXIN]; //òàáëèöà íîìåðîâ öèêëîâ |
88 | unsigned int listbr[MAXIN]; //òàáëèöà íîìåðîâ öèêëîâ |
89 | unsigned int usebr[MAXIN]; //èñïîëüçîâàíî break |
89 | unsigned int usebr[MAXIN]; //èñïîëüçîâàíî break |
90 | unsigned int useco[MAXIN]; //èñïîëüçîâàíî continue |
90 | unsigned int useco[MAXIN]; //èñïîëüçîâàíî continue |
91 | unsigned int curbr=0,curco=0; //òåêóùàÿâëîæåíîñòü öèêëîâ |
91 | unsigned int curbr=0,curco=0; //òåêóùàÿâëîæåíîñòü öèêëîâ |
92 | unsigned int startStartup=0x100; |
92 | unsigned int startStartup=0x100; |
93 | unsigned int endStartup=0; |
93 | unsigned int endStartup=0; |
94 | unsigned char useStartup=FALSE; |
94 | unsigned char useStartup=FALSE; |
95 | unsigned char notpost=FALSE; |
95 | unsigned char notpost=FALSE; |
96 | int retproc; |
96 | int retproc; |
97 | int lastcommand; //ïîñëåäíèé îïåðàòîð â áëîêå |
97 | int lastcommand; //ïîñëåäíèé îïåðàòîð â áëîêå |
98 | unsigned char FastCallApi=TRUE; //ðàçðåøèòü áûñòðûé âûçîâ API ïðîöåäóð |
98 | unsigned char FastCallApi=TRUE; //ðàçðåøèòü áûñòðûé âûçîâ API ïðîöåäóð |
99 | unsigned char FixUp=FALSE; //Äåëàòü ëè òàáëèöó ïåðåìåùåíèé |
99 | unsigned char FixUp=FALSE; //Äåëàòü ëè òàáëèöó ïåðåìåùåíèé |
100 | unsigned char AlignProc=FALSE; |
100 | unsigned char AlignProc=FALSE; |
101 | //------- ðàáîòà ñ union --------------------------------------------- |
101 | //------- ðàáîòà ñ union --------------------------------------------- |
102 | char param[256]; //áóôåð äëÿ ïàðàìåòðîâ ïðîöåäóðû |
102 | char param[256]; //áóôåð äëÿ ïàðàìåòðîâ ïðîöåäóðû |
103 | char *BackTextBlock; //áóôåð äëÿ ïåðåíåñåííîãî òåêñòà |
103 | char *BackTextBlock; //áóôåð äëÿ ïåðåíåñåííîãî òåêñòà |
104 | int SizeBackBuf=0,MaxSizeBackBuf; |
104 | int SizeBackBuf=0,MaxSizeBackBuf; |
105 | struct FILEINFO *startfileinfo=NULL; |
105 | struct FILEINFO *startfileinfo=NULL; |
106 | unsigned int totalmodule=0; |
106 | unsigned int totalmodule=0; |
107 | unsigned int currentfileinfo; |
107 | unsigned int currentfileinfo; |
108 | unsigned char setzeroflag; //îïåðàöèÿ ìåíÿåò zero flag |
108 | unsigned char setzeroflag; //îïåðàöèÿ ìåíÿåò zero flag |
109 | unsigned char notunreach=FALSE; |
109 | unsigned char notunreach=FALSE; |
110 | unsigned int initBP=0; |
110 | unsigned int initBP=0; |
111 | int inlineflag=0; // flag for disabling entry and exit codes production |
111 | int inlineflag=0; // flag for disabling entry and exit codes production |
112 | unsigned char fstatic=FALSE; |
112 | unsigned char fstatic=FALSE; |
113 | 113 | ||
114 | unsigned long addESP=0; //äîáàâêà ñòåêà |
114 | unsigned long addESP=0; //äîáàâêà ñòåêà |
115 | unsigned char blockproc=FALSE; //èäåòðàçáîðêà áëîêà ôóíêöèè |
115 | unsigned char blockproc=FALSE; //èäåòðàçáîðêà áëîêà ôóíêöèè |
116 | 116 | ||
117 | unsigned int updatelocalvar(char *str,int tok,unsigned int num); |
117 | unsigned int updatelocalvar(char *str,int tok,unsigned int num); |
118 | void setuprm(); |
118 | void setuprm(); |
119 | void doloop(unsigned int typeb); /* both short and long loops */ |
119 | void doloop(unsigned int typeb); /* both short and long loops */ |
120 | void doBREAK(unsigned char typeb); |
120 | void doBREAK(unsigned char typeb); |
121 | void doCONTINUE(unsigned char typeb); |
121 | void doCONTINUE(unsigned char typeb); |
122 | void dowhile(unsigned int typeb); |
122 | void dowhile(unsigned int typeb); |
123 | void MakeContinue(unsigned char typeb); |
123 | void MakeContinue(unsigned char typeb); |
124 | void dofor(unsigned int typeb); |
124 | void dofor(unsigned int typeb); |
125 | void dodo(); |
125 | void dodo(); |
126 | void globalvar(); /* both initialized and unitialized combined */ |
126 | void globalvar(); /* both initialized and unitialized combined */ |
127 | void doswitch(); |
127 | void doswitch(); |
128 | void CalcRegPar(int reg,int def,char *&ofsstr); |
128 | void CalcRegPar(int reg,int def,char *&ofsstr); |
129 | void JXorJMP(); |
129 | void JXorJMP(); |
130 | int loadinputfile(char *inpfile); |
130 | int loadinputfile(char *inpfile); |
131 | int SaveStartUp(int size,char *var_name); |
131 | int SaveStartUp(int size,char *var_name); |
132 | void LoadData(unsigned int size,int filehandle); |
132 | void LoadData(unsigned int size,int filehandle); |
133 | void SetNewTok(int type,int typev); |
133 | void SetNewTok(int type,int typev); |
134 | void doreturn(int type=tokens); /* do return(...); */ |
134 | void doreturn(int type=tokens); /* do return(...); */ |
135 | void notnegit(int notneg); |
135 | void notnegit(int notneg); |
136 | void insertcode(); // force code procedure at specified location |
136 | void insertcode(); // force code procedure at specified location |
137 | void interruptproc(); |
137 | void interruptproc(); |
138 | void dobigif(); |
138 | void dobigif(); |
139 | void doif(void); |
139 | void doif(void); |
140 | void doasmblock(); |
140 | void doasmblock(); |
141 | void declareextern(); |
141 | void declareextern(); |
142 | unsigned long dounion(int,int); |
142 | unsigned long dounion(int,int); |
143 | void RunBackText(); |
143 | void RunBackText(); |
144 | int FindDublString(int segm,unsigned int len,int term); |
144 | int FindDublString(int segm,unsigned int len,int term); |
145 | void *liststring=NULL; //öåïî÷êà èíôîðìàöèîííûõ áëîêîâ î ñòðîêàõ |
145 | void *liststring=NULL; //öåïî÷êà èíôîðìàöèîííûõ áëîêîâ î ñòðîêàõ |
146 | void GetNameLabel(int type,int num); |
146 | void GetNameLabel(int type,int num); |
147 | void CheckPosts(); |
147 | void CheckPosts(); |
148 | SAVEPAR *SRparam(int save,SAVEPAR *par); //save or restore global param compiler |
148 | SAVEPAR *SRparam(int save,SAVEPAR *par); //save or restore global param compiler |
149 | void AddRetList(int pos,int line,int type); |
149 | void AddRetList(int pos,int line,int type); |
150 | void CheckRealizable(); |
150 | void CheckRealizable(); |
151 | void declare_procedure(int oflag,int orm,int npointr); |
151 | void declare_procedure(int oflag,int orm,int npointr); |
152 | void labelindata(); |
152 | void labelindata(); |
153 | void AddRegistr(int razr,int reg); |
153 | void AddRegistr(int razr,int reg); |
154 | void ClearRegister(); |
154 | void ClearRegister(); |
155 | int GetRegister(int mode=0); |
155 | int GetRegister(int mode=0); |
156 | void RegAddNum(int reg); |
156 | void RegAddNum(int reg); |
157 | void dowhilefast(unsigned int typeb); |
157 | void dowhilefast(unsigned int typeb); |
158 | int getrazr(int type); |
158 | int getrazr(int type); |
159 | void RestoreSaveReg(); |
159 | void RestoreSaveReg(); |
160 | void killlocals(/*int endp=TRUE*/); |
160 | void killlocals(/*int endp=TRUE*/); |
161 | void leaveproc(); |
161 | void leaveproc(); |
162 | int IsSaveReg(); |
162 | int IsSaveReg(); |
163 | void CorrectParamVar(); |
163 | void CorrectParamVar(); |
164 | 164 | ||
165 | extern void ManyLogicCompare(); |
165 | extern void ManyLogicCompare(); |
166 | extern void maxdataerror(); |
166 | extern void maxdataerror(); |
167 | extern void CompareOr(); |
167 | extern void CompareOr(); |
168 | extern void dynamiclabelerror(); |
168 | extern void dynamiclabelerror(); |
169 | extern void retvoid(); |
169 | extern void retvoid(); |
170 | extern int numberbreak; |
170 | extern int numberbreak; |
171 | 171 | ||
172 | SAVEREG savereg; |
172 | SAVEREG savereg; |
173 | SAVEREG *psavereg=&savereg; |
173 | SAVEREG *psavereg=&savereg; |
174 | 174 | ||
175 | int loadfile(char *filename,int firstflag) |
175 | int loadfile(char *filename,int firstflag) |
176 | { |
176 | { |
177 | int hold; |
177 | int hold; |
178 | 178 | ||
179 | for(int i=0;i<=numfindpath;i++){ |
179 | for(int i=0;i<=numfindpath;i++){ |
180 | sprintf((char *)string2,"%s%s",findpath[(firstflag==0?i:numfindpath-i)],filename); |
180 | sprintf((char *)string2,"%s%s",findpath[(firstflag==0?i:numfindpath-i)],filename); |
- | 181 | #ifndef _WIN32_ |
|
- | 182 | for(char* p=(char *)string2; *p; ++p) if(*p=='\\') *p='/'; |
|
- | 183 | #endif |
|
181 | if((hold=loadinputfile((char *)string2))!=-2)break; |
184 | if((hold=loadinputfile((char *)string2))!=-2)break; |
182 | if(firstflag==2||(firstflag==0&&(i+1)==numfindpath))break; |
185 | if(firstflag==2||(firstflag==0&&(i+1)==numfindpath))break; |
183 | } |
186 | } |
184 | if(hold==-2){ |
187 | if(hold==-2){ |
185 | unableopenfile(filename); //ñîîáùåíèå î îøèáêå |
188 | unableopenfile(filename); //ñîîáùåíèå î îøèáêå |
186 | exit(e_cannotopeninput); //çàâåðøèòü ðàáîòó åñëè íå ñìîãëè çàãðóçèòü ôàéë |
189 | exit(e_cannotopeninput); //çàâåðøèòü ðàáîòó åñëè íå ñìîãëè çàãðóçèòü ôàéë |
187 | } |
190 | } |
188 | return hold; |
191 | return hold; |
189 | } |
192 | } |
190 | 193 | ||
191 | void compilefile(char *filename,int firstflag) |
194 | void compilefile(char *filename,int firstflag) |
192 | { |
195 | { |
193 | int hold; |
196 | int hold; |
194 | 197 | ||
195 | hold=loadfile(filename,firstflag); |
198 | hold=loadfile(filename,firstflag); |
196 | if(hold==1||hold==-1)return; |
199 | if(hold==1||hold==-1)return; |
197 | if(strcmp(filename,"startup.h--")==0)startupfile=currentfileinfo; |
200 | if(strcmp(filename,"startup.h--")==0)startupfile=currentfileinfo; |
198 | 201 | ||
199 | inptr=0; |
202 | inptr=0; |
200 | endoffile=0; |
203 | endoffile=0; |
201 | startline=(char*)input; |
204 | startline=(char*)input; |
202 | endinput=startline+endinptr; |
205 | endinput=startline+endinptr; |
203 | warning=gwarning; |
206 | warning=gwarning; |
204 | nextchar(); |
207 | nextchar(); |
205 | cha2=cha; //ñèìâîë èç áóôåðà |
208 | cha2=cha; //ñèìâîë èç áóôåðà |
206 | inptr2=inptr; //çàïîìí óêàçàòåëü íà ñëåä ñèìâîë |
209 | inptr2=inptr; //çàïîìí óêàçàòåëü íà ñëåä ñèìâîë |
207 | linenum2=1; //íîìåð ñòðîêè |
210 | linenum2=1; //íîìåð ñòðîêè |
208 | { //ïðîâåðêà íà ôàéë ðåñóðñîâ è åãî îáðàáîòêà |
211 | { //ïðîâåðêà íà ôàéë ðåñóðñîâ è åãî îáðàáîòêà |
209 | char *a; |
212 | char *a; |
210 | if((a=strrchr(filename,'.'))!=NULL){ |
213 | if((a=strrchr(filename,'.'))!=NULL){ |
211 | if(stricmp(a,".rc")==0){ |
214 | if(stricmp(a,".rc")==0){ |
212 | input_res(); |
215 | input_res(); |
213 | free(input); |
216 | free(input); |
214 | return; |
217 | return; |
215 | } |
218 | } |
216 | } |
219 | } |
217 | } |
220 | } |
218 | 221 | ||
219 | nexttok(); //îïð òèï ïåðâîãî è âòîðîãî òîêåíà |
222 | nexttok(); //îïð òèï ïåðâîãî è âòîðîãî òîêåíà |
220 | while(tok!=tk_eof){ //öèêë ïîêà íå êîí÷èòñÿ ôàéë |
223 | while(tok!=tk_eof){ //öèêë ïîêà íå êîí÷èòñÿ ôàéë |
221 | while(tok==tk_question){ |
224 | while(tok==tk_question){ |
222 | directive();//îáðàáîòêà äèðåêòèâ |
225 | directive();//îáðàáîòêà äèðåêòèâ |
223 | if(tok==tk_semicolon)nexttok(); |
226 | if(tok==tk_semicolon)nexttok(); |
224 | } |
227 | } |
225 | usedirectiv=FALSE; |
228 | usedirectiv=FALSE; |
226 | if(notdoneprestuff==TRUE)doprestuff();//startup |
229 | if(notdoneprestuff==TRUE)doprestuff();//startup |
227 | switch(tok){ |
230 | switch(tok){ |
228 | case tk_ID: |
231 | case tk_ID: |
229 | case tk_id: |
232 | case tk_id: |
230 | if(FindTeg(TRUE)!=NULL){ |
233 | if(FindTeg(TRUE)!=NULL){ |
231 | InitStruct(); |
234 | InitStruct(); |
232 | break; |
235 | break; |
233 | } |
236 | } |
234 | if(tok2==tk_colon){ |
237 | if(tok2==tk_colon){ |
235 | labelindata(); |
238 | labelindata(); |
236 | break; |
239 | break; |
237 | } |
240 | } |
238 | case tk_far: |
241 | case tk_far: |
239 | case tk_cdecl: |
242 | case tk_cdecl: |
240 | case tk_pascal: |
243 | case tk_pascal: |
241 | case tk_stdcall: |
244 | case tk_stdcall: |
242 | case tk_fastcall: |
245 | case tk_fastcall: |
243 | case tk_declare: |
246 | case tk_declare: |
244 | case tk_undefproc: |
247 | case tk_undefproc: |
245 | case tk_float: |
248 | case tk_float: |
246 | case tk_long: |
249 | case tk_long: |
247 | case tk_dword: |
250 | case tk_dword: |
248 | case tk_word: |
251 | case tk_word: |
249 | case tk_byte: |
252 | case tk_byte: |
250 | case tk_char: |
253 | case tk_char: |
251 | case tk_int: |
254 | case tk_int: |
252 | case tk_void: |
255 | case tk_void: |
253 | case tk_export: |
256 | case tk_export: |
254 | case tk_qword: |
257 | case tk_qword: |
255 | case tk_double: |
258 | case tk_double: |
256 | case tk_fpust: |
259 | case tk_fpust: |
257 | if((hold=testInitVar())==FALSE)define_procedure(); |
260 | if((hold=testInitVar())==FALSE)define_procedure(); |
258 | else if(hold==TRUE)globalvar(); |
261 | else if(hold==TRUE)globalvar(); |
259 | break; |
262 | break; |
260 | case tk_struct: InitStruct(); break; |
263 | case tk_struct: InitStruct(); break; |
261 | case tk_interrupt: interruptproc(); break; |
264 | case tk_interrupt: interruptproc(); break; |
262 | case tk_at: insertcode(); break; //âñòàâêà ðåãèñòðîâîé ïðîöåäóðû |
265 | case tk_at: insertcode(); break; //âñòàâêà ðåãèñòðîâîé ïðîöåäóðû |
263 | case tk_colon: |
266 | case tk_colon: |
264 | nexttok(); |
267 | nexttok(); |
265 | dynamic_flag=2; |
268 | dynamic_flag=2; |
266 | break;// îïð äèíàìè÷åñêîé ïðîöåäóðû |
269 | break;// îïð äèíàìè÷åñêîé ïðîöåäóðû |
267 | case tk_inline: |
270 | case tk_inline: |
268 | if(testInitVar()){ |
271 | if(testInitVar()){ |
269 | preerror("Bad header dynamic function"); |
272 | preerror("Bad header dynamic function"); |
270 | nexttok(); |
273 | nexttok(); |
271 | } |
274 | } |
272 | dynamic_proc(); |
275 | dynamic_proc(); |
273 | break; |
276 | break; |
274 | case tk_static: |
277 | case tk_static: |
275 | fstatic=2; |
278 | fstatic=2; |
276 | nexttok(); |
279 | nexttok(); |
277 | break; |
280 | break; |
278 | case tk_enum: doenum(); break; |
281 | case tk_enum: doenum(); break; |
279 | case tk_from: nexttok(); dofrom(); nextseminext(); break; |
282 | case tk_from: nexttok(); dofrom(); nextseminext(); break; |
280 | case tk_extract: nexttok(); doextract(); seminext(); break; |
283 | case tk_extract: nexttok(); doextract(); seminext(); break; |
281 | case tk_loop: |
284 | case tk_loop: |
282 | case tk_while: |
285 | case tk_while: |
283 | case tk_do: |
286 | case tk_do: |
284 | case tk_else: |
287 | case tk_else: |
285 | case tk_ELSE: |
288 | case tk_ELSE: |
286 | case tk_if: |
289 | case tk_if: |
287 | case tk_IF: |
290 | case tk_IF: |
288 | case tk_interruptproc: |
291 | case tk_interruptproc: |
289 | case tk_proc: |
292 | case tk_proc: |
290 | case tk_charvar: |
293 | case tk_charvar: |
291 | case tk_intvar: |
294 | case tk_intvar: |
292 | case tk_bytevar: |
295 | case tk_bytevar: |
293 | case tk_longvar: |
296 | case tk_longvar: |
294 | case tk_dwordvar: |
297 | case tk_dwordvar: |
295 | case tk_floatvar: |
298 | case tk_floatvar: |
296 | case tk_qwordvar: |
299 | case tk_qwordvar: |
297 | case tk_doublevar: |
300 | case tk_doublevar: |
298 | case tk_wordvar: idalreadydefined(); break; |
301 | case tk_wordvar: idalreadydefined(); break; |
299 | case tk_reg32: |
302 | case tk_reg32: |
300 | case tk_debugreg: |
303 | case tk_debugreg: |
301 | case tk_controlreg: |
304 | case tk_controlreg: |
302 | case tk_testreg: |
305 | case tk_testreg: |
303 | case tk_reg: |
306 | case tk_reg: |
304 | case tk_seg: |
307 | case tk_seg: |
305 | case tk_beg: |
308 | case tk_beg: |
306 | case tk_reg64: |
309 | case tk_reg64: |
307 | preerror("register name cannot be used as an identifier"); |
310 | preerror("register name cannot be used as an identifier"); |
308 | nexttok(); |
311 | nexttok(); |
309 | case tk_eof: break; |
312 | case tk_eof: break; |
310 | case tk_locallabel: internalerror("local label token found outside function block."); break; |
313 | case tk_locallabel: internalerror("local label token found outside function block."); break; |
311 | case tk_extern: declareextern(); break; |
314 | case tk_extern: declareextern(); break; |
312 | case tk_union: dynamic_flag=0; dounion(TRUE,fstatic==0?0:f_static); break; |
315 | case tk_union: dynamic_flag=0; dounion(TRUE,fstatic==0?0:f_static); break; |
313 | case tk_semicolon: nexttok(); break; |
316 | case tk_semicolon: nexttok(); break; |
314 | case tk_asm: |
317 | case tk_asm: |
315 | if(tok2==tk_openbrace)doasmblock(); |
318 | if(tok2==tk_openbrace)doasmblock(); |
316 | else doasm(); |
319 | else doasm(); |
317 | break; |
320 | break; |
318 | case tk_idasm: doasm(TRUE); break; |
321 | case tk_idasm: doasm(TRUE); break; |
319 | case tk_dollar: doasm(FALSE); break; |
322 | case tk_dollar: doasm(FALSE); break; |
320 | default: unuseableinput(); |
323 | default: unuseableinput(); |
321 | /* while(itok.type==tp_stopper&&tok!=tk_eof)*/nexttok(); |
324 | /* while(itok.type==tp_stopper&&tok!=tk_eof)*/nexttok(); |
322 | break; |
325 | break; |
323 | } |
326 | } |
324 | if(fstatic)fstatic--; |
327 | if(fstatic)fstatic--; |
325 | else if(dynamic_flag)dynamic_flag--; |
328 | else if(dynamic_flag)dynamic_flag--; |
326 | } |
329 | } |
327 | (startfileinfo+currentfileinfo)->stlist=staticlist; |
330 | (startfileinfo+currentfileinfo)->stlist=staticlist; |
328 | free(input); |
331 | free(input); |
329 | } |
332 | } |
330 | 333 | ||
331 | /* ------------------- output procedures start ------------------- */ |
334 | /* ------------------- output procedures start ------------------- */ |
332 | int CheckCodeSize() |
335 | int CheckCodeSize() |
333 | //ïðîâåðêà ðàçìåðà áóôåðà äëÿ êîäà |
336 | //ïðîâåðêà ðàçìåðà áóôåðà äëÿ êîäà |
334 | { |
337 | { |
335 | if(!am32){ |
338 | if(!am32){ |
336 | maxoutputerror(); |
339 | maxoutputerror(); |
337 | return FALSE; |
340 | return FALSE; |
338 | } |
341 | } |
339 | outptrsize+=MAXDATA; |
342 | outptrsize+=MAXDATA; |
340 | output=(unsigned char *)REALLOC(output,outptrsize); |
343 | output=(unsigned char *)REALLOC(output,outptrsize); |
341 | if(splitdata==FALSE)outputdata=output; |
344 | if(splitdata==FALSE)outputdata=output; |
342 | return TRUE; |
345 | return TRUE; |
343 | } |
346 | } |
344 | 347 | ||
345 | int CheckDataSize() |
348 | int CheckDataSize() |
346 | //ïðîâåðêà ðàçìåðà áóôåðà äëÿ êîäà |
349 | //ïðîâåðêà ðàçìåðà áóôåðà äëÿ êîäà |
347 | { |
350 | { |
348 | if(!am32){ |
351 | if(!am32){ |
349 | maxoutputerror(); |
352 | maxoutputerror(); |
350 | return FALSE; |
353 | return FALSE; |
351 | } |
354 | } |
352 | outdatasize+=MAXDATA; |
355 | outdatasize+=MAXDATA; |
353 | outputdata=(unsigned char *)REALLOC(outputdata,outdatasize); |
356 | outputdata=(unsigned char *)REALLOC(outputdata,outdatasize); |
354 | return TRUE; |
357 | return TRUE; |
355 | } |
358 | } |
356 | 359 | ||
357 | void op(int byte) |
360 | void op(int byte) |
358 | { |
361 | { |
359 | if(outptr>=outptrsize&&CheckCodeSize()==FALSE)return; |
362 | if(outptr>=outptrsize&&CheckCodeSize()==FALSE)return; |
360 | output[outptr++]=(unsigned char)byte; |
363 | output[outptr++]=(unsigned char)byte; |
361 | if(splitdata==FALSE)outptrdata=outptr; |
364 | if(splitdata==FALSE)outptrdata=outptr; |
362 | retproc=FALSE; |
365 | retproc=FALSE; |
363 | } |
366 | } |
364 | 367 | ||
365 | void opd(int byte) |
368 | void opd(int byte) |
366 | { |
369 | { |
367 | if(splitdata==FALSE){ |
370 | if(splitdata==FALSE){ |
368 | if(outptr>=outptrsize&&CheckCodeSize()==FALSE)return; |
371 | if(outptr>=outptrsize&&CheckCodeSize()==FALSE)return; |
369 | output[outptr++]=(unsigned char)byte; |
372 | output[outptr++]=(unsigned char)byte; |
370 | outptrdata=outptr; |
373 | outptrdata=outptr; |
371 | } |
374 | } |
372 | else{ |
375 | else{ |
373 | if(outptrdata>=outdatasize&&CheckDataSize()==FALSE)return; |
376 | if(outptrdata>=outdatasize&&CheckDataSize()==FALSE)return; |
374 | outputdata[outptrdata++]=(unsigned char)byte; |
377 | outputdata[outptrdata++]=(unsigned char)byte; |
375 | } |
378 | } |
376 | } |
379 | } |
377 | 380 | ||
378 | void CorrectOfsBit(int bitofs) |
381 | void CorrectOfsBit(int bitofs) |
379 | { |
382 | { |
380 | bitofs=(bitofs+7)/8; |
383 | bitofs=(bitofs+7)/8; |
381 | if(splitdata)outptrdata+=bitofs; |
384 | if(splitdata)outptrdata+=bitofs; |
382 | else{ |
385 | else{ |
383 | outptr+=bitofs; |
386 | outptr+=bitofs; |
384 | outptrdata=outptr; |
387 | outptrdata=outptr; |
385 | } |
388 | } |
386 | } |
389 | } |
387 | 390 | ||
388 | long GetBitMask(int ofs,int size) |
391 | long GetBitMask(int ofs,int size) |
389 | { |
392 | { |
390 | return (~((li[size]-1)< |
393 | return (~((li[size]-1)< |
391 | } |
394 | } |
392 | 395 | ||
393 | void opb(unsigned long num,unsigned int ofs,unsigned int size) |
396 | void opb(unsigned long num,unsigned int ofs,unsigned int size) |
394 | { |
397 | { |
395 | int s; |
398 | int s; |
396 | //ïðîâåðèòü âûõîä çà ãðàíèöû áëîêà ïàìÿòè |
399 | //ïðîâåðèòü âûõîä çà ãðàíèöû áëîêà ïàìÿòè |
397 | s=(ofs+size+7)/8; |
400 | s=(ofs+size+7)/8; |
398 | if(splitdata==FALSE){ |
401 | if(splitdata==FALSE){ |
399 | if((outptr+s+8)>=outptrsize&&CheckCodeSize()==FALSE)return; |
402 | if((outptr+s+8)>=outptrsize&&CheckCodeSize()==FALSE)return; |
400 | } |
403 | } |
401 | else{ |
404 | else{ |
402 | if((outptrdata+s+8)>=outdatasize&&CheckDataSize()==FALSE)return; |
405 | if((outptrdata+s+8)>=outdatasize&&CheckDataSize()==FALSE)return; |
403 | } |
406 | } |
404 | if(size!=32)num=num&(li[size]-1); |
407 | if(size!=32)num=num&(li[size]-1); |
405 | s=outptrdata+ofs/8; |
408 | s=outptrdata+ofs/8; |
406 | ofs=ofs%8; |
409 | ofs=ofs%8; |
407 | *(long *)&outputdata[s]&=GetBitMask(ofs,size); |
410 | *(long *)&outputdata[s]&=GetBitMask(ofs,size); |
408 | *(long *)&outputdata[s]|=(num< |
411 | *(long *)&outputdata[s]|=(num< |
409 | // printf("ofs=%Xh mask=%X value=%X\n",s,GetBitMask(ofs,size),(num< |
412 | // printf("ofs=%Xh mask=%X value=%X\n",s,GetBitMask(ofs,size),(num< |
410 | if((ofs+size)>32){ |
413 | if((ofs+size)>32){ |
411 | *(long *)&outputdata[s+4]&=GetBitMask(0,ofs+size-32); |
414 | *(long *)&outputdata[s+4]&=GetBitMask(0,ofs+size-32); |
412 | *(long *)&outputdata[s+4]|=(num>>(64-ofs-size)); |
415 | *(long *)&outputdata[s+4]|=(num>>(64-ofs-size)); |
413 | // printf("continue ofs=%Xh mask=%X value=%X\n",s+4,GetBitMask(0,ofs+size-32),num>>(64-ofs-size)); |
416 | // printf("continue ofs=%Xh mask=%X value=%X\n",s+4,GetBitMask(0,ofs+size-32),num>>(64-ofs-size)); |
414 | } |
417 | } |
415 | } |
418 | } |
416 | 419 | ||
417 | void outword(unsigned int num) |
420 | void outword(unsigned int num) |
418 | { |
421 | { |
419 | op(num); |
422 | op(num); |
420 | op(num/256); |
423 | op(num/256); |
421 | } |
424 | } |
422 | 425 | ||
423 | void outwordd(unsigned int num) |
426 | void outwordd(unsigned int num) |
424 | { |
427 | { |
425 | opd(num); |
428 | opd(num); |
426 | opd(num/256); |
429 | opd(num/256); |
427 | } |
430 | } |
428 | 431 | ||
429 | void outdword(unsigned long num) |
432 | void outdword(unsigned long num) |
430 | { |
433 | { |
431 | outword((unsigned int)(num&0xFFFFL)); |
434 | outword((unsigned int)(num&0xFFFFL)); |
432 | outword((unsigned int)(num/0x10000L)); |
435 | outword((unsigned int)(num/0x10000L)); |
433 | } |
436 | } |
434 | 437 | ||
435 | void outdwordd(unsigned long num) |
438 | void outdwordd(unsigned long num) |
436 | { |
439 | { |
437 | outwordd((unsigned int)(num&0xFFFFL)); |
440 | outwordd((unsigned int)(num&0xFFFFL)); |
438 | outwordd((unsigned int)(num/0x10000L)); |
441 | outwordd((unsigned int)(num/0x10000L)); |
439 | } |
442 | } |
440 | 443 | ||
441 | void outqword(unsigned long long num) |
444 | void outqword(unsigned long long num) |
442 | { |
445 | { |
443 | outdword((unsigned long)(num&0xFFFFFFFFL)); |
446 | outdword((unsigned long)(num&0xFFFFFFFFL)); |
444 | outdword((unsigned long)(num/0x100000000LL)); |
447 | outdword((unsigned long)(num/0x100000000LL)); |
445 | } |
448 | } |
446 | 449 | ||
447 | void outqwordd(unsigned long long num) |
450 | void outqwordd(unsigned long long num) |
448 | { |
451 | { |
449 | outdwordd((unsigned long)(num&0xFFFFFFFFL)); |
452 | outdwordd((unsigned long)(num&0xFFFFFFFFL)); |
450 | outdwordd((unsigned long)(num/0x100000000LL)); |
453 | outdwordd((unsigned long)(num/0x100000000LL)); |
451 | } |
454 | } |
452 | 455 | ||
453 | void doasmblock() |
456 | void doasmblock() |
454 | { |
457 | { |
455 | nexttok(); |
458 | nexttok(); |
456 | useasm=TRUE; |
459 | useasm=TRUE; |
457 | expecting(tk_openbrace); |
460 | expecting(tk_openbrace); |
458 | for(;;){ |
461 | for(;;){ |
459 | if(tok==tk_closebrace)break; |
462 | if(tok==tk_closebrace)break; |
460 | if(tok==tk_eof){ |
463 | if(tok==tk_eof){ |
461 | unexpectedeof(); |
464 | unexpectedeof(); |
462 | break; |
465 | break; |
463 | } |
466 | } |
464 | lastcommand=tok; |
467 | lastcommand=tok; |
465 | if(dbg)AddLine(); |
468 | if(dbg)AddLine(); |
466 | doasm(TRUE); |
469 | doasm(TRUE); |
467 | } |
470 | } |
468 | useasm=FALSE; |
471 | useasm=FALSE; |
469 | nexttok(); |
472 | nexttok(); |
470 | } |
473 | } |
471 | 474 | ||
472 | void doblock() |
475 | void doblock() |
473 | { |
476 | { |
474 | expecting(tk_openbrace); |
477 | expecting(tk_openbrace); |
475 | doblock2(); |
478 | doblock2(); |
476 | /* for(;;){ |
479 | /* for(;;){ |
477 | if(tok==tk_closebrace)break; |
480 | if(tok==tk_closebrace)break; |
478 | if(tok==tk_eof){ |
481 | if(tok==tk_eof){ |
479 | unexpectedeof(); |
482 | unexpectedeof(); |
480 | break; |
483 | break; |
481 | } |
484 | } |
482 | docommand(); |
485 | docommand(); |
483 | } |
486 | } |
484 | RestoreStack();*/ |
487 | RestoreStack();*/ |
485 | } |
488 | } |
486 | 489 | ||
487 | void doblock2() |
490 | void doblock2() |
488 | { |
491 | { |
489 | for(;;){ |
492 | for(;;){ |
490 | if(tok==tk_closebrace)break; |
493 | if(tok==tk_closebrace)break; |
491 | if(tok==tk_eof){ |
494 | if(tok==tk_eof){ |
492 | unexpectedeof(); |
495 | unexpectedeof(); |
493 | break; |
496 | break; |
494 | } |
497 | } |
495 | docommand(); |
498 | docommand(); |
496 | } |
499 | } |
497 | if(numblocks==1&&addstack&&sizestack&&localsize&&am32&&ESPloc&&IsSaveReg()==FALSE){ |
500 | if(numblocks==1&&addstack&&sizestack&&localsize&&am32&&ESPloc&&IsSaveReg()==FALSE){ |
498 | localsize+=sizestack; |
501 | localsize+=sizestack; |
499 | sizestack=0; |
502 | sizestack=0; |
500 | } |
503 | } |
501 | else RestoreStack(); |
504 | else RestoreStack(); |
502 | } |
505 | } |
503 | 506 | ||
504 | void gotodo() |
507 | void gotodo() |
505 | { |
508 | { |
506 | nexttok(); |
509 | nexttok(); |
507 | if(gotol(0))nexttok(); |
510 | if(gotol(0))nexttok(); |
508 | seminext(); |
511 | seminext(); |
509 | } |
512 | } |
510 | 513 | ||
511 | void GOTOdo() |
514 | void GOTOdo() |
512 | { |
515 | { |
513 | nexttok(); |
516 | nexttok(); |
514 | if(GOTO())nexttok(); |
517 | if(GOTO())nexttok(); |
515 | seminext(); |
518 | seminext(); |
516 | } |
519 | } |
517 | 520 | ||
518 | void docommand() /* do a single command */ |
521 | void docommand() /* do a single command */ |
519 | { |
522 | { |
520 | unsigned int useflag; |
523 | unsigned int useflag; |
521 | useflag=0; |
524 | useflag=0; |
522 | if(dbg)AddLine(); |
525 | if(dbg)AddLine(); |
523 | //loops: |
526 | //loops: |
524 | lastcommand=tok; |
527 | lastcommand=tok; |
525 | // printf("tok=%d %s\n",tok,itok.name); |
528 | // printf("tok=%d %s\n",tok,itok.name); |
526 | switch(tok){ |
529 | switch(tok){ |
527 | case tk_ID: useflag++; |
530 | case tk_ID: useflag++; |
528 | case tk_id: |
531 | case tk_id: |
529 | if((useflag=doid((char)useflag,tk_void))!=tokens){ |
532 | if((useflag=doid((char)useflag,tk_void))!=tokens){ |
530 | nextseminext(); |
533 | nextseminext(); |
531 | if(useflag==tk_fpust)preerror("function returned parametr in FPU stack"); |
534 | if(useflag==tk_fpust)preerror("function returned parametr in FPU stack"); |
532 | } |
535 | } |
533 | else if(tok!=tk_closebrace)docommand(); |
536 | else if(tok!=tk_closebrace)docommand(); |
534 | break; |
537 | break; |
535 | case tk_apiproc: |
538 | case tk_apiproc: |
536 | case tk_undefproc: |
539 | case tk_undefproc: |
537 | case tk_declare: |
540 | case tk_declare: |
538 | if(doanyundefproc()!=tokens)nextseminext(); |
541 | if(doanyundefproc()!=tokens)nextseminext(); |
539 | else if(tok!=tk_closebrace)docommand(); |
542 | else if(tok!=tk_closebrace)docommand(); |
540 | break; |
543 | break; |
541 | case tk_proc: |
544 | case tk_proc: |
542 | doanyproc(); |
545 | doanyproc(); |
543 | nextseminext(); |
546 | nextseminext(); |
544 | break; |
547 | break; |
545 | case tk_interruptproc: |
548 | case tk_interruptproc: |
546 | outword(0x0E9C); //pushf //push cs |
549 | outword(0x0E9C); //pushf //push cs |
547 | useflag=itok.post; |
550 | useflag=itok.post; |
548 | callloc(itok.number); |
551 | callloc(itok.number); |
549 | nexttok(); |
552 | nexttok(); |
550 | expecting(tk_openbracket); |
553 | expecting(tk_openbracket); |
551 | expecting(tk_closebracket); |
554 | expecting(tk_closebracket); |
552 | #ifdef OPTVARCONST |
555 | #ifdef OPTVARCONST |
553 | FreeGlobalConst(); |
556 | FreeGlobalConst(); |
554 | #endif |
557 | #endif |
555 | seminext(); |
558 | seminext(); |
556 | clearregstat(useflag); |
559 | clearregstat(useflag); |
557 | break; |
560 | break; |
558 | case tk_bits: |
561 | case tk_bits: |
559 | dobits(); |
562 | dobits(); |
560 | break; |
563 | break; |
561 | case tk_charvar: useflag=1; |
564 | case tk_charvar: useflag=1; |
562 | case tk_bytevar: |
565 | case tk_bytevar: |
563 | dobytevar(useflag); |
566 | dobytevar(useflag); |
564 | break; |
567 | break; |
565 | case tk_intvar: useflag=1; |
568 | case tk_intvar: useflag=1; |
566 | case tk_wordvar: |
569 | case tk_wordvar: |
567 | do_d_wordvar(useflag,r16); |
570 | do_d_wordvar(useflag,r16); |
568 | break; |
571 | break; |
569 | case tk_longvar: useflag=1; |
572 | case tk_longvar: useflag=1; |
570 | case tk_dwordvar: |
573 | case tk_dwordvar: |
571 | do_d_wordvar(useflag,r32); |
574 | do_d_wordvar(useflag,r32); |
572 | break; |
575 | break; |
573 | case tk_doublevar: |
576 | case tk_doublevar: |
574 | useflag=4; |
577 | useflag=4; |
575 | case tk_floatvar: |
578 | case tk_floatvar: |
576 | dofloatvar(useflag,tk_floatvar,tk_semicolon); |
579 | dofloatvar(useflag,tk_floatvar,tk_semicolon); |
577 | break; |
580 | break; |
578 | case tk_qwordvar: |
581 | case tk_qwordvar: |
579 | doqwordvar(); |
582 | doqwordvar(); |
580 | break; |
583 | break; |
581 | case tk_fpust: |
584 | case tk_fpust: |
582 | dofloatstack(itok.number); |
585 | dofloatstack(itok.number); |
583 | break; |
586 | break; |
584 | case tk_structvar: |
587 | case tk_structvar: |
585 | dostruct(); |
588 | dostruct(); |
586 | break; |
589 | break; |
587 | case tk_pointer: |
590 | case tk_pointer: |
588 | dopointer(); |
591 | dopointer(); |
589 | break; |
592 | break; |
590 | case tk_mult: |
593 | case tk_mult: |
591 | dovalpointer(); |
594 | dovalpointer(); |
592 | break; |
595 | break; |
593 | case tk_RETURN: |
596 | case tk_RETURN: |
594 | case tk_return: |
597 | case tk_return: |
595 | RestoreStack(); |
598 | RestoreStack(); |
596 | #ifdef OPTVARCONST |
599 | #ifdef OPTVARCONST |
597 | ClearLVIC(); |
600 | ClearLVIC(); |
598 | #endif |
601 | #endif |
599 | doreturn(tok); |
602 | doreturn(tok); |
600 | CheckRealizable(); |
603 | CheckRealizable(); |
601 | break; |
604 | break; |
602 | case tk_at: |
605 | case tk_at: |
603 | nexttok(); |
606 | nexttok(); |
604 | if(tok2==tk_colon){ |
607 | if(tok2==tk_colon){ |
605 | LLabel(); |
608 | LLabel(); |
606 | if(tok!=tk_closebrace)docommand(); |
609 | if(tok!=tk_closebrace)docommand(); |
607 | } |
610 | } |
608 | else if(macros(tk_void)!=0)nextseminext(); |
611 | else if(macros(tk_void)!=0)nextseminext(); |
609 | break; |
612 | break; |
610 | case tk_if: RestoreStack(); doif(); break; |
613 | case tk_if: RestoreStack(); doif(); break; |
611 | case tk_IF: RestoreStack(); dobigif(); break; |
614 | case tk_IF: RestoreStack(); dobigif(); break; |
612 | case tk_loopnz: |
615 | case tk_loopnz: |
613 | case tk_LOOPNZ: |
616 | case tk_LOOPNZ: |
614 | case tk_loop: RestoreStack(); doloop(tok); break; |
617 | case tk_loop: RestoreStack(); doloop(tok); break; |
615 | case tk_while: |
618 | case tk_while: |
616 | case tk_WHILE: RestoreStack(); dowhilefast(tok); break; |
619 | case tk_WHILE: RestoreStack(); dowhilefast(tok); break; |
617 | case tk_do: RestoreStack(); dodo(); break; |
620 | case tk_do: RestoreStack(); dodo(); break; |
618 | case tk_for: |
621 | case tk_for: |
619 | case tk_FOR: RestoreStack(); dofor(tok); break; |
622 | case tk_FOR: RestoreStack(); dofor(tok); break; |
620 | case tk_reg32: doreg_32((unsigned int)itok.number,r32); break; |
623 | case tk_reg32: doreg_32((unsigned int)itok.number,r32); break; |
621 | case tk_reg: doreg_32((unsigned int)itok.number,r16); break; |
624 | case tk_reg: doreg_32((unsigned int)itok.number,r16); break; |
622 | case tk_beg: dobeg((unsigned int)itok.number); break; |
625 | case tk_beg: dobeg((unsigned int)itok.number); break; |
623 | case tk_reg64: doreg64(itok.number); break; |
626 | case tk_reg64: doreg64(itok.number); break; |
624 | case tk_seg: doseg((unsigned int)itok.number); break; |
627 | case tk_seg: doseg((unsigned int)itok.number); break; |
625 | case tk_openbrace: |
628 | case tk_openbrace: |
626 | startblock(); |
629 | startblock(); |
627 | doblock(); |
630 | doblock(); |
628 | nexttok(); |
631 | nexttok(); |
629 | endblock(); |
632 | endblock(); |
630 | break; |
633 | break; |
631 | case tk_from: nexttok(); dofrom(); nextseminext(); break; |
634 | case tk_from: nexttok(); dofrom(); nextseminext(); break; |
632 | case tk_extract: nexttok(); doextract(); seminext(); break; |
635 | case tk_extract: nexttok(); doextract(); seminext(); break; |
633 | case tk_minus: useflag=8; |
636 | case tk_minus: useflag=8; |
634 | case tk_not: |
637 | case tk_not: |
635 | notnegit(useflag); |
638 | notnegit(useflag); |
636 | nextseminext(); |
639 | nextseminext(); |
637 | break; |
640 | break; |
638 | case tk_locallabel: RestoreStack(); define_locallabel(); break; |
641 | case tk_locallabel: RestoreStack(); define_locallabel(); break; |
639 | case tk_camma: |
642 | case tk_camma: |
640 | case tk_semicolon: nexttok(); break; |
643 | case tk_semicolon: nexttok(); break; |
641 | case tk_else: |
644 | case tk_else: |
642 | preerror("else without preceeding if or IF"); |
645 | preerror("else without preceeding if or IF"); |
643 | nexttok(); |
646 | nexttok(); |
644 | break; |
647 | break; |
645 | case tk_ELSE: |
648 | case tk_ELSE: |
646 | preerror("ELSE without preceeding IF or if"); |
649 | preerror("ELSE without preceeding IF or if"); |
647 | nexttok(); |
650 | nexttok(); |
648 | break; |
651 | break; |
649 | case tk_eof: unexpectedeof(); break; |
652 | case tk_eof: unexpectedeof(); break; |
650 | case tk_void: |
653 | case tk_void: |
651 | case tk_long: |
654 | case tk_long: |
652 | case tk_dword: |
655 | case tk_dword: |
653 | case tk_word: |
656 | case tk_word: |
654 | case tk_byte: |
657 | case tk_byte: |
655 | case tk_int: |
658 | case tk_int: |
656 | case tk_char: |
659 | case tk_char: |
657 | preerror("cannot declare variables within function { } block"); |
660 | preerror("cannot declare variables within function { } block"); |
658 | nexttok(); |
661 | nexttok(); |
659 | break; |
662 | break; |
660 | case tk_GOTO: |
663 | case tk_GOTO: |
661 | RestoreStack(); |
664 | RestoreStack(); |
662 | GOTOdo(); |
665 | GOTOdo(); |
663 | CheckRealizable(); |
666 | CheckRealizable(); |
664 | break; |
667 | break; |
665 | case tk_goto: |
668 | case tk_goto: |
666 | RestoreStack(); |
669 | RestoreStack(); |
667 | gotodo(); |
670 | gotodo(); |
668 | CheckRealizable(); |
671 | CheckRealizable(); |
669 | break; |
672 | break; |
670 | case tk_BREAK: |
673 | case tk_BREAK: |
671 | RestoreStack(); |
674 | RestoreStack(); |
672 | doBREAK(BREAK_SHORT); |
675 | doBREAK(BREAK_SHORT); |
673 | CheckRealizable(); |
676 | CheckRealizable(); |
674 | break; |
677 | break; |
675 | case tk_break: |
678 | case tk_break: |
676 | RestoreStack(); |
679 | RestoreStack(); |
677 | doBREAK((unsigned char)(am32==FALSE?BREAK_NEAR:BREAK_32)); |
680 | doBREAK((unsigned char)(am32==FALSE?BREAK_NEAR:BREAK_32)); |
678 | CheckRealizable(); |
681 | CheckRealizable(); |
679 | break; |
682 | break; |
680 | case tk_CONTINUE: |
683 | case tk_CONTINUE: |
681 | RestoreStack(); |
684 | RestoreStack(); |
682 | doCONTINUE(CONTINUE_SHORT); |
685 | doCONTINUE(CONTINUE_SHORT); |
683 | CheckRealizable(); |
686 | CheckRealizable(); |
684 | break; |
687 | break; |
685 | case tk_continue: |
688 | case tk_continue: |
686 | RestoreStack(); |
689 | RestoreStack(); |
687 | doCONTINUE((unsigned char)(am32==FALSE?CONTINUE_NEAR:CONTINUE_32)); |
690 | doCONTINUE((unsigned char)(am32==FALSE?CONTINUE_NEAR:CONTINUE_32)); |
688 | CheckRealizable(); |
691 | CheckRealizable(); |
689 | break; |
692 | break; |
690 | case tk_asm: |
693 | case tk_asm: |
691 | if(tok2==tk_openbrace)doasmblock(); |
694 | if(tok2==tk_openbrace)doasmblock(); |
692 | else doasm(); |
695 | else doasm(); |
693 | break; |
696 | break; |
694 | case tk_idasm: |
697 | case tk_idasm: |
695 | useflag=TRUE; |
698 | useflag=TRUE; |
696 | case tk_dollar: |
699 | case tk_dollar: |
697 | doasm(useflag); |
700 | doasm(useflag); |
698 | break; |
701 | break; |
699 | case tk_SWITCH: |
702 | case tk_SWITCH: |
700 | case tk_switch: RestoreStack(); doswitch(); break; |
703 | case tk_switch: RestoreStack(); doswitch(); break; |
701 | case tk_delete: dodelete(); break; |
704 | case tk_delete: dodelete(); break; |
702 | case tk_new: donew(); seminext(); break; |
705 | case tk_new: donew(); seminext(); break; |
703 | case tk_question: |
706 | case tk_question: |
704 | // calcnumber=FALSE; |
707 | // calcnumber=FALSE; |
705 | while(tok==tk_question)directive(); |
708 | while(tok==tk_question)directive(); |
706 | break; |
709 | break; |
707 | /* case tk_openbracket: |
710 | /* case tk_openbracket: |
708 | nexttok(); |
711 | nexttok(); |
709 | nexttok(); |
712 | nexttok(); |
710 | expectingoperand(tk_closebracket); |
713 | expectingoperand(tk_closebracket); |
711 | goto loops;*/ |
714 | goto loops;*/ |
712 | default: unuseableinput(); break; |
715 | default: unuseableinput(); break; |
713 | } |
716 | } |
714 | notunreach=FALSE; |
717 | notunreach=FALSE; |
715 | } |
718 | } |
716 | 719 | ||
717 | void doBREAK(unsigned char typeb) |
720 | void doBREAK(unsigned char typeb) |
718 | { |
721 | { |
719 | if(curbr==0)preerror("'BREAK' or 'break' use only in loop, do-while.."); |
722 | if(curbr==0)preerror("'BREAK' or 'break' use only in loop, do-while.."); |
720 | else MakeBreak(typeb); |
723 | else MakeBreak(typeb); |
721 | nextseminext(); |
724 | nextseminext(); |
722 | } |
725 | } |
723 | 726 | ||
724 | void doCONTINUE(unsigned char typeb) |
727 | void doCONTINUE(unsigned char typeb) |
725 | { |
728 | { |
726 | if(curco==0)preerror("'CONTINUE' or 'continue' use only in loop, do-while.."); |
729 | if(curco==0)preerror("'CONTINUE' or 'continue' use only in loop, do-while.."); |
727 | else MakeContinue(typeb); |
730 | else MakeContinue(typeb); |
728 | nextseminext(); |
731 | nextseminext(); |
729 | } |
732 | } |
730 | 733 | ||
731 | void MakeBreak(unsigned char typeb) |
734 | void MakeBreak(unsigned char typeb) |
732 | { |
735 | { |
733 | unsigned int nbr=0; |
736 | unsigned int nbr=0; |
734 | if(tok2==tk_number){ |
737 | if(tok2==tk_number){ |
735 | nexttok(); |
738 | nexttok(); |
736 | nbr=itok.number; |
739 | nbr=itok.number; |
737 | if(nbr>=curbr)preerror("'BREAK' or 'break' on incorrect number skip cycle"); |
740 | if(nbr>=curbr)preerror("'BREAK' or 'break' on incorrect number skip cycle"); |
738 | } |
741 | } |
739 | numberbreak=nbr; |
742 | numberbreak=nbr; |
740 | nbr=curbr-1-nbr; |
743 | nbr=curbr-1-nbr; |
741 | if(usebr[nbr]==0){ |
744 | if(usebr[nbr]==0){ |
742 | GetNameLabel(tk_break,nbr); |
745 | GetNameLabel(tk_break,nbr); |
743 | addlocalvar((char *)string2,tk_locallabel,secondcallnum,TRUE); |
746 | addlocalvar((char *)string2,tk_locallabel,secondcallnum,TRUE); |
744 | usebr[nbr]=secondcallnum; |
747 | usebr[nbr]=secondcallnum; |
745 | secondcallnum++; |
748 | secondcallnum++; |
746 | } |
749 | } |
747 | addacall(usebr[nbr],typeb); |
750 | addacall(usebr[nbr],typeb); |
748 | if(typeb==BREAK_SHORT)outword(0x00EB); // JMP SHORT |
751 | if(typeb==BREAK_SHORT)outword(0x00EB); // JMP SHORT |
749 | else jumploc0(); |
752 | else jumploc0(); |
750 | } |
753 | } |
751 | 754 | ||
752 | void MakeContinue(unsigned char typeb) |
755 | void MakeContinue(unsigned char typeb) |
753 | { |
756 | { |
754 | unsigned int nbr=0; |
757 | unsigned int nbr=0; |
755 | if(tok2==tk_number){ |
758 | if(tok2==tk_number){ |
756 | nexttok(); |
759 | nexttok(); |
757 | nbr=itok.number; |
760 | nbr=itok.number; |
758 | if(nbr>=curco)preerror("'CONTINUE' or 'continue' on incorrect number skip cycle"); |
761 | if(nbr>=curco)preerror("'CONTINUE' or 'continue' on incorrect number skip cycle"); |
759 | } |
762 | } |
760 | nbr=curco-1-nbr; |
763 | nbr=curco-1-nbr; |
761 | if(useco[nbr]==0){ |
764 | if(useco[nbr]==0){ |
762 | GetNameLabel(tk_continue,nbr); |
765 | GetNameLabel(tk_continue,nbr); |
763 | // printf("%s nbr=%d\n",(char *)string2,nbr); |
766 | // printf("%s nbr=%d\n",(char *)string2,nbr); |
764 | addlocalvar((char *)string2,tk_locallabel,secondcallnum,TRUE); |
767 | addlocalvar((char *)string2,tk_locallabel,secondcallnum,TRUE); |
765 | useco[nbr]=secondcallnum; |
768 | useco[nbr]=secondcallnum; |
766 | secondcallnum++; |
769 | secondcallnum++; |
767 | } |
770 | } |
768 | addacall(useco[nbr],typeb); |
771 | addacall(useco[nbr],typeb); |
769 | if(typeb==CONTINUE_SHORT)outword(0x00EB); // JMP SHORT |
772 | if(typeb==CONTINUE_SHORT)outword(0x00EB); // JMP SHORT |
770 | else jumploc0(); |
773 | else jumploc0(); |
771 | } |
774 | } |
772 | 775 | ||
773 | int CheckExitProc() |
776 | int CheckExitProc() |
774 | { |
777 | { |
775 | if(strcmp(itok.name,"EXIT")==0||strcmp(itok.name,"ABORT")==0)return TRUE; |
778 | if(strcmp(itok.name,"EXIT")==0||strcmp(itok.name,"ABORT")==0)return TRUE; |
776 | return FALSE; |
779 | return FALSE; |
777 | } |
780 | } |
778 | 781 | ||
779 | void LLabel() |
782 | void LLabel() |
780 | { |
783 | { |
781 | localrec *ptr; |
784 | localrec *ptr; |
782 | #ifdef OPTVARCONST |
785 | #ifdef OPTVARCONST |
783 | ClearLVIC(); |
786 | ClearLVIC(); |
784 | #endif |
787 | #endif |
785 | RestoreStack(); |
788 | RestoreStack(); |
786 | clearregstat(); |
789 | clearregstat(); |
787 | switch(tok){ |
790 | switch(tok){ |
788 | case tk_id: |
791 | case tk_id: |
789 | case tk_ID: |
792 | case tk_ID: |
790 | FindOff((unsigned char *)itok.name,CS); |
793 | FindOff((unsigned char *)itok.name,CS); |
791 | ptr=addlocalvar(itok.name,tk_number,outptr,TRUE); |
794 | ptr=addlocalvar(itok.name,tk_number,outptr,TRUE); |
792 | if(FixUp)ptr->rec.flag=f_reloc; |
795 | if(FixUp)ptr->rec.flag=f_reloc; |
793 | break; |
796 | break; |
794 | case tk_undefproc: |
797 | case tk_undefproc: |
795 | ptr=addlocalvar(itok.name,tk_number,outptr,TRUE);//äîáàâèòü â ëîêàëüíûé ñïèñîê |
798 | ptr=addlocalvar(itok.name,tk_number,outptr,TRUE);//äîáàâèòü â ëîêàëüíûé ñïèñîê |
796 | if(FixUp)ptr->rec.flag=f_reloc; |
799 | if(FixUp)ptr->rec.flag=f_reloc; |
797 | updatecall((unsigned int)itok.number,outptr,procedure_start);//îáðàáîòàòü ðàííèå îáðàùåíèÿ |
800 | updatecall((unsigned int)itok.number,outptr,procedure_start);//îáðàáîòàòü ðàííèå îáðàùåíèÿ |
798 | break; |
801 | break; |
799 | default: |
802 | default: |
800 | preerror("error declaretion local label"); |
803 | preerror("error declaretion local label"); |
801 | break; |
804 | break; |
802 | } |
805 | } |
803 | nexttok(); |
806 | nexttok(); |
804 | nexttok(); |
807 | nexttok(); |
805 | } |
808 | } |
806 | 809 | ||
807 | void AddApiToPost(unsigned int num) |
810 | void AddApiToPost(unsigned int num) |
808 | { |
811 | { |
809 | CheckPosts(); |
812 | CheckPosts(); |
810 | (postbuf+posts)->type=CALL_32I; |
813 | (postbuf+posts)->type=CALL_32I; |
811 | (postbuf+posts)->loc=outptr; |
814 | (postbuf+posts)->loc=outptr; |
812 | (postbuf+posts)->num=num; |
815 | (postbuf+posts)->num=num; |
813 | posts++; |
816 | posts++; |
814 | outdword(0); |
817 | outdword(0); |
815 | } |
818 | } |
816 | 819 | ||
817 | /* ---------------------- Procedure Calling Starts -------------------- */ |
820 | /* ---------------------- Procedure Calling Starts -------------------- */ |
818 | 821 | ||
819 | int doanyundefproc(int jumpsend) |
822 | int doanyundefproc(int jumpsend) |
820 | { |
823 | { |
821 | unsigned int cnum,snum; |
824 | unsigned int cnum,snum; |
822 | int returnvalue; |
825 | int returnvalue; |
823 | int regs; |
826 | int regs; |
824 | char fname[IDLENGTH]; |
827 | char fname[IDLENGTH]; |
825 | if(tok2==tk_colon){ // if a label |
828 | if(tok2==tk_colon){ // if a label |
826 | #ifdef OPTVARCONST |
829 | #ifdef OPTVARCONST |
827 | ClearLVIC(); |
830 | ClearLVIC(); |
828 | #endif |
831 | #endif |
829 | RestoreStack(); |
832 | RestoreStack(); |
830 | clearregstat(); |
833 | clearregstat(); |
831 | if(CidOrID()==tk_ID){//local label that has been used, but not placed |
834 | if(CidOrID()==tk_ID){//local label that has been used, but not placed |
832 | localrec *ptr=addlocalvar(itok.name,tk_number,outptr,TRUE); |
835 | localrec *ptr=addlocalvar(itok.name,tk_number,outptr,TRUE); |
833 | if(FixUp)ptr->rec.flag=f_reloc; |
836 | if(FixUp)ptr->rec.flag=f_reloc; |
834 | updatecall((unsigned int)itok.number,outptr,procedure_start);//îáðàáîòàòü ðàííèå îáðàùåíèÿ |
837 | updatecall((unsigned int)itok.number,outptr,procedure_start);//îáðàáîòàòü ðàííèå îáðàùåíèÿ |
835 | } |
838 | } |
836 | else{ //ãëîáàëüíàÿ ìåòêà |
839 | else{ //ãëîáàëüíàÿ ìåòêà |
837 | tok=tk_proc; |
840 | tok=tk_proc; |
838 | itok.number=outptr; |
841 | itok.number=outptr; |
839 | string[0]=0; |
842 | string[0]=0; |
840 | updatecall((unsigned int)updatetree(),(unsigned int)itok.number,0); |
843 | updatecall((unsigned int)updatetree(),(unsigned int)itok.number,0); |
841 | } |
844 | } |
842 | nexttok(); // move past id |
845 | nexttok(); // move past id |
843 | nexttok(); // move past : |
846 | nexttok(); // move past : |
844 | return(tokens); |
847 | return(tokens); |
845 | } |
848 | } |
846 | if(tok2==tk_openbracket){ |
849 | if(tok2==tk_openbracket){ |
847 | strcpy(fname,itok.name); |
850 | strcpy(fname,itok.name); |
848 | if(tok==tk_declare){ //ñìåíèòü ñòàòóñ ïðîöåäóðû ñ îáúÿâëåíîé íà íåèçâåñòíóþ |
851 | if(tok==tk_declare){ //ñìåíèòü ñòàòóñ ïðîöåäóðû ñ îáúÿâëåíîé íà íåèçâåñòíóþ |
849 | tok=tk_undefproc; |
852 | tok=tk_undefproc; |
850 | updatetree(); |
853 | updatetree(); |
851 | if(itok.flag&f_classproc)AddUndefClassProc(); |
854 | if(itok.flag&f_classproc)AddUndefClassProc(); |
852 | } |
855 | } |
853 | cnum=(unsigned int)itok.number; |
856 | cnum=(unsigned int)itok.number; |
854 | regs=itok.post; |
857 | regs=itok.post; |
855 | returnvalue=itok.rm; |
858 | returnvalue=itok.rm; |
856 | unsigned int tproc=itok.flag; |
859 | unsigned int tproc=itok.flag; |
857 | unsigned char apiproc=FALSE; |
860 | unsigned char apiproc=FALSE; |
858 | unsigned int oaddESP=addESP; |
861 | unsigned int oaddESP=addESP; |
859 | int sizestack=-1; |
862 | int sizestack=-1; |
860 | if(tok==tk_apiproc){ |
863 | if(tok==tk_apiproc){ |
861 | apiproc=TRUE; |
864 | apiproc=TRUE; |
862 | sizestack=itok.size; //ðàçìåð ñòåêà ïîä ïàðàìåòðû |
865 | sizestack=itok.size; //ðàçìåð ñòåêà ïîä ïàðàìåòðû |
863 | } |
866 | } |
864 | #ifdef OPTVARCONST |
867 | #ifdef OPTVARCONST |
865 | if(tproc&f_useidx)ClearLVIC(); |
868 | if(tproc&f_useidx)ClearLVIC(); |
866 | else FreeGlobalConst(); |
869 | else FreeGlobalConst(); |
867 | #endif |
870 | #endif |
868 | int exitproc=CheckExitProc(); |
871 | int exitproc=CheckExitProc(); |
869 | snum=initparamproc(); |
872 | snum=initparamproc(); |
870 | if(sizestack!=-1){ |
873 | if(sizestack!=-1){ |
871 | if(snum>(unsigned int)sizestack)extraparam(fname); |
874 | if(snum>(unsigned int)sizestack)extraparam(fname); |
872 | else if(snum<(unsigned int)sizestack)missingpar(fname); |
875 | else if(snum<(unsigned int)sizestack)missingpar(fname); |
873 | } |
876 | } |
874 | if((tproc&f_typeproc)!=tp_cdecl){ |
877 | if((tproc&f_typeproc)!=tp_cdecl){ |
875 | snum=0; |
878 | snum=0; |
876 | addESP=oaddESP; |
879 | addESP=oaddESP; |
877 | } |
880 | } |
878 | if(FastCallApi==TRUE&&apiproc!=FALSE){ |
881 | if(FastCallApi==TRUE&&apiproc!=FALSE){ |
879 | if(jumpsend)outword(0x25ff); |
882 | if(jumpsend)outword(0x25ff); |
880 | else outword(0x15FF); |
883 | else outword(0x15FF); |
881 | AddApiToPost(cnum); |
884 | AddApiToPost(cnum); |
882 | } |
885 | } |
883 | else{ |
886 | else{ |
884 | addacall(cnum,(unsigned char)((tproc&f_extern)!=0?CALL_EXT:(am32!=FALSE?CALL_32:CALL_NEAR))); |
887 | addacall(cnum,(unsigned char)((tproc&f_extern)!=0?CALL_EXT:(am32!=FALSE?CALL_32:CALL_NEAR))); |
885 | if(jumpsend)jumploc0(); |
888 | if(jumpsend)jumploc0(); |
886 | else callloc0(); /* produce CALL [#] */ |
889 | else callloc0(); /* produce CALL [#] */ |
887 | } |
890 | } |
888 | clearregstat(regs); |
891 | clearregstat(regs); |
889 | if(snum!=0&&jumpsend==FALSE)CorrectStack(snum); |
892 | if(snum!=0&&jumpsend==FALSE)CorrectStack(snum); |
890 | retproc=exitproc; |
893 | retproc=exitproc; |
891 | return(returnvalue); |
894 | return(returnvalue); |
892 | } |
895 | } |
893 | thisundefined(itok.name); |
896 | thisundefined(itok.name); |
894 | nexttok(); |
897 | nexttok(); |
895 | return(tk_long); |
898 | return(tk_long); |
896 | } |
899 | } |
897 | 900 | ||
898 | void CorrectStack(unsigned int num) |
901 | void CorrectStack(unsigned int num) |
899 | { |
902 | { |
900 | if(addstack){ |
903 | if(addstack){ |
901 | sizestack+=num; |
904 | sizestack+=num; |
902 | // printf("%s(%d)> Add %d bytes stacks.\n",startfileinfo==NULL?"":(startfileinfo+currentfileinfo)->filename,linenumber,num); |
905 | // printf("%s(%d)> Add %d bytes stacks.\n",startfileinfo==NULL?"":(startfileinfo+currentfileinfo)->filename,linenumber,num); |
903 | } |
906 | } |
904 | else{ |
907 | else{ |
905 | if(short_ok(num)){ |
908 | if(short_ok(num)){ |
906 | outword(0xC483); |
909 | outword(0xC483); |
907 | op(num); |
910 | op(num); |
908 | } |
911 | } |
909 | else{ |
912 | else{ |
910 | outword(0xC481); |
913 | outword(0xC481); |
911 | if(am32==FALSE)outword(num); |
914 | if(am32==FALSE)outword(num); |
912 | else outdword(num); |
915 | else outdword(num); |
913 | } |
916 | } |
914 | addESP-=num; |
917 | addESP-=num; |
915 | } |
918 | } |
916 | } |
919 | } |
917 | 920 | ||
918 | unsigned int initparamproc() |
921 | unsigned int initparamproc() |
919 | { |
922 | { |
920 | unsigned int typep=itok.flag,snum=0; |
923 | unsigned int typep=itok.flag,snum=0; |
921 | ITOK ostructadr=structadr; |
924 | ITOK ostructadr=structadr; |
922 | strcpy(param,(char *)string); |
925 | strcpy(param,(char *)string); |
923 | nexttok(); |
926 | nexttok(); |
924 | switch(typep&f_typeproc){ |
927 | switch(typep&f_typeproc){ |
925 | case tp_cdecl: |
928 | case tp_cdecl: |
926 | case tp_stdcall: |
929 | case tp_stdcall: |
927 | snum=swapparam(); |
930 | snum=swapparam(); |
928 | break; |
931 | break; |
929 | case tp_pascal: |
932 | case tp_pascal: |
930 | doparams(); |
933 | doparams(); |
931 | break; |
934 | break; |
932 | case tp_fastcall: |
935 | case tp_fastcall: |
933 | doregparams(); |
936 | doregparams(); |
934 | break; |
937 | break; |
935 | } |
938 | } |
936 | // if(crec)printf("after doparams num=%08X\n",crec->recnumber); |
939 | // if(crec)printf("after doparams num=%08X\n",crec->recnumber); |
937 | if((typep&f_classproc)&&(!(typep&f_static))){ |
940 | if((typep&f_classproc)&&(!(typep&f_static))){ |
938 | if((current_proc_type&f_static)&&structadr.sib==THIS_PARAM )return snum; |
941 | if((current_proc_type&f_static)&&structadr.sib==THIS_PARAM )return snum; |
939 | structadr=ostructadr; |
942 | structadr=ostructadr; |
940 | if(structadr.sib==THIS_PARAM){ |
943 | if(structadr.sib==THIS_PARAM){ |
941 | if(structadr.number==0){ |
944 | if(structadr.number==0){ |
942 | op(0xff); |
945 | op(0xff); |
943 | if(ESPloc&&am32){ |
946 | if(ESPloc&&am32){ |
944 | int num; |
947 | int num; |
945 | num=localsize+addESP+4; |
948 | num=localsize+addESP+4; |
946 | if(short_ok(num,TRUE)){ |
949 | if(short_ok(num,TRUE)){ |
947 | outword(0x2474); |
950 | outword(0x2474); |
948 | op(num); |
951 | op(num); |
949 | } |
952 | } |
950 | else{ |
953 | else{ |
951 | outword(0x24B4); |
954 | outword(0x24B4); |
952 | outdword(num); |
955 | outdword(num); |
953 | } |
956 | } |
954 | } |
957 | } |
955 | else outword(am32==FALSE?0x0476:0x0875);//push[ebp+4] |
958 | else outword(am32==FALSE?0x0476:0x0875);//push[ebp+4] |
956 | } |
959 | } |
957 | else{ |
960 | else{ |
958 | int reg=GetRegister(1); |
961 | int reg=GetRegister(1); |
959 | op(0x8B); |
962 | op(0x8B); |
960 | if(ESPloc&&am32){ |
963 | if(ESPloc&&am32){ |
961 | int num; |
964 | int num; |
962 | num=localsize+addESP+4; |
965 | num=localsize+addESP+4; |
963 | if(short_ok(num,TRUE)){ |
966 | if(short_ok(num,TRUE)){ |
964 | op(4+reg*8+64); |
967 | op(4+reg*8+64); |
965 | op(0x24); |
968 | op(0x24); |
966 | op(num); |
969 | op(num); |
967 | } |
970 | } |
968 | else{ |
971 | else{ |
969 | op(4+reg*8+128); |
972 | op(4+reg*8+128); |
970 | op(0x24); |
973 | op(0x24); |
971 | outdword(num); |
974 | outdword(num); |
972 | } |
975 | } |
973 | } |
976 | } |
974 | else{ |
977 | else{ |
975 | op((am32==FALSE?6:5)+reg*8+64); |
978 | op((am32==FALSE?6:5)+reg*8+64); |
976 | op((am32==FALSE?4:8));//mov ESI,[ebp+4] |
979 | op((am32==FALSE?4:8));//mov ESI,[ebp+4] |
977 | } |
980 | } |
978 | RegAddNum(reg); |
981 | RegAddNum(reg); |
979 | op(0x50+reg); //push reg |
982 | op(0x50+reg); //push reg |
980 | warningreg(regs[am32][reg]); |
983 | warningreg(regs[am32][reg]); |
981 | } |
984 | } |
982 | } |
985 | } |
983 | else if(structadr.sib==THIS_REG){ |
986 | else if(structadr.sib==THIS_REG){ |
984 | if(structadr.number/*size*/!=0){ |
987 | if(structadr.number/*size*/!=0){ |
985 | int reg=GetRegister(1); |
988 | int reg=GetRegister(1); |
986 | if(reg==structadr.rm)RegAddNum(reg); |
989 | if(reg==structadr.rm)RegAddNum(reg); |
987 | else{ |
990 | else{ |
988 | if(am32==FALSE){ |
991 | if(am32==FALSE){ |
989 | switch(structadr.rm){ |
992 | switch(structadr.rm){ |
990 | case BX: |
993 | case BX: |
991 | structadr.rm=7; |
994 | structadr.rm=7; |
992 | break; |
995 | break; |
993 | case DI: |
996 | case DI: |
994 | structadr.rm=5; |
997 | structadr.rm=5; |
995 | break; |
998 | break; |
996 | case SI: |
999 | case SI: |
997 | structadr.rm=4; |
1000 | structadr.rm=4; |
998 | break; |
1001 | break; |
999 | case BP: |
1002 | case BP: |
1000 | structadr.rm=6; |
1003 | structadr.rm=6; |
1001 | break; |
1004 | break; |
1002 | default: |
1005 | default: |
1003 | regBXDISIBPexpected(); |
1006 | regBXDISIBPexpected(); |
1004 | } |
1007 | } |
1005 | structadr.sib=CODE16; |
1008 | structadr.sib=CODE16; |
1006 | } |
1009 | } |
1007 | else structadr.sib=CODE32; |
1010 | else structadr.sib=CODE32; |
1008 | structadr.rm|=(structadr.number<128?rm_mod01:rm_mod10); |
1011 | structadr.rm|=(structadr.number<128?rm_mod01:rm_mod10); |
1009 | op(0x8d); //lea reg [reg2+num] |
1012 | op(0x8d); //lea reg [reg2+num] |
1010 | op(structadr.rm+reg*8); |
1013 | op(structadr.rm+reg*8); |
1011 | outaddress(&structadr); |
1014 | outaddress(&structadr); |
1012 | } |
1015 | } |
1013 | op(0x50+reg); |
1016 | op(0x50+reg); |
1014 | warningreg(regs[am32][reg]); |
1017 | warningreg(regs[am32][reg]); |
1015 | } |
1018 | } |
1016 | else op(0x50+structadr.rm); |
1019 | else op(0x50+structadr.rm); |
1017 | } |
1020 | } |
1018 | else if(structadr.sib==THIS_NEW){ |
1021 | else if(structadr.sib==THIS_NEW){ |
1019 | RunNew(structadr.number); |
1022 | RunNew(structadr.number); |
1020 | op(0x50); |
1023 | op(0x50); |
1021 | } |
1024 | } |
1022 | else if(structadr.sib==THIS_ZEROSIZE){ |
1025 | else if(structadr.sib==THIS_ZEROSIZE){ |
1023 | outword(0x6a); //push 0 |
1026 | outword(0x6a); //push 0 |
1024 | } |
1027 | } |
1025 | else{ |
1028 | else{ |
1026 | // printf("post=%d\n",structadr.post); |
1029 | // printf("post=%d\n",structadr.post); |
1027 | if(structadr.post==LOCAL){ |
1030 | if(structadr.post==LOCAL){ |
1028 | int reg=GetRegister(1); |
1031 | int reg=GetRegister(1); |
1029 | structadr.post=0; |
1032 | structadr.post=0; |
1030 | outseg(&structadr,2); |
1033 | outseg(&structadr,2); |
1031 | op(0x8d); |
1034 | op(0x8d); |
1032 | op(structadr.rm+reg*8); |
1035 | op(structadr.rm+reg*8); |
1033 | outaddress(&structadr); |
1036 | outaddress(&structadr); |
1034 | op(0x50+reg); |
1037 | op(0x50+reg); |
1035 | warningreg(regs[am32][reg]); |
1038 | warningreg(regs[am32][reg]); |
1036 | } |
1039 | } |
1037 | else{ |
1040 | else{ |
1038 | if(strinf.bufstr){ |
1041 | if(strinf.bufstr){ |
1039 | int reg=GetRegister(1); |
1042 | int reg=GetRegister(1); |
1040 | int newreg; |
1043 | int newreg; |
1041 | if((newreg=CheckIDXReg(strinf.bufstr,strinf.size,reg))!=NOINREG){ |
1044 | if((newreg=CheckIDXReg(strinf.bufstr,strinf.size,reg))!=NOINREG){ |
1042 | if(newreg!=SKIPREG){ |
1045 | if(newreg!=SKIPREG){ |
1043 | if(am32==FALSE&&newreg!=BX&&newreg!=DI&&newreg!=SI&&newreg!=BP)goto noopt; |
1046 | if(am32==FALSE&&newreg!=BX&&newreg!=DI&&newreg!=SI&&newreg!=BP)goto noopt; |
1044 | waralreadinitreg(regs[am32][reg],regs[am32][newreg]); |
1047 | waralreadinitreg(regs[am32][reg],regs[am32][newreg]); |
1045 | reg=newreg; |
1048 | reg=newreg; |
1046 | } |
1049 | } |
1047 | free(strinf.bufstr); |
1050 | free(strinf.bufstr); |
1048 | goto cont1; |
1051 | goto cont1; |
1049 | } |
1052 | } |
1050 | noopt: |
1053 | noopt: |
1051 | if(newreg=CheckMassiv(strinf.bufstr,strinf.size,reg)!=-1)reg=newreg; |
1054 | if(newreg=CheckMassiv(strinf.bufstr,strinf.size,reg)!=-1)reg=newreg; |
1052 | cont1: |
1055 | cont1: |
1053 | strinf.bufstr=NULL; |
1056 | strinf.bufstr=NULL; |
1054 | RegAddNum(reg); |
1057 | RegAddNum(reg); |
1055 | op(0x50+reg); |
1058 | op(0x50+reg); |
1056 | } |
1059 | } |
1057 | else{ |
1060 | else{ |
1058 | op(0x68); |
1061 | op(0x68); |
1059 | if(structadr.post/*&&structadr.post!=USED_DIN_VAR*/)setwordpost(&structadr); |
1062 | if(structadr.post/*&&structadr.post!=USED_DIN_VAR*/)setwordpost(&structadr); |
1060 | else if(FixUp)AddReloc(); |
1063 | else if(FixUp)AddReloc(); |
1061 | if(am32==FALSE)outword((unsigned int)structadr.number); |
1064 | if(am32==FALSE)outword((unsigned int)structadr.number); |
1062 | else outdword(structadr.number); |
1065 | else outdword(structadr.number); |
1063 | } |
1066 | } |
1064 | } |
1067 | } |
1065 | } |
1068 | } |
1066 | snum+=(am32==FALSE?2:4); |
1069 | snum+=(am32==FALSE?2:4); |
1067 | addESP+=(am32==FALSE?2:4); |
1070 | addESP+=(am32==FALSE?2:4); |
1068 | } |
1071 | } |
1069 | if(typep&f_far)op(0x0e); //push cs |
1072 | if(typep&f_far)op(0x0e); //push cs |
1070 | return snum; |
1073 | return snum; |
1071 | } |
1074 | } |
1072 | 1075 | ||
1073 | int doanyproc(int jumpsend) |
1076 | int doanyproc(int jumpsend) |
1074 | { |
1077 | { |
1075 | unsigned int cloc,snum; |
1078 | unsigned int cloc,snum; |
1076 | int returnvalue,dynamicindex; |
1079 | int returnvalue,dynamicindex; |
1077 | int regs; |
1080 | int regs; |
1078 | if(tok2==tk_colon){ |
1081 | if(tok2==tk_colon){ |
1079 | preerror("dublication global label"); |
1082 | preerror("dublication global label"); |
1080 | nexttok(); |
1083 | nexttok(); |
1081 | return 0; |
1084 | return 0; |
1082 | } |
1085 | } |
1083 | cloc=(unsigned int)itok.number; /* get address or handle */ |
1086 | cloc=(unsigned int)itok.number; /* get address or handle */ |
1084 | returnvalue=itok.rm; |
1087 | returnvalue=itok.rm; |
1085 | regs=itok.post; |
1088 | regs=itok.post; |
1086 | // printf("regs=%08X name=%s\n",regs,itok.name); |
1089 | // printf("regs=%08X name=%s\n",regs,itok.name); |
1087 | int flag=itok.flag; |
1090 | int flag=itok.flag; |
1088 | if(itok.npointr)dopointerproc(); |
1091 | if(itok.npointr)dopointerproc(); |
1089 | else{ |
1092 | else{ |
1090 | if((itok.flag&f_inline)!=0&&(useinline==TRUE||(useinline==2&&optimizespeed))){ |
1093 | if((itok.flag&f_inline)!=0&&(useinline==TRUE||(useinline==2&&optimizespeed))){ |
1091 | if(macros(tk_void)!=0)return(returnvalue); |
1094 | if(macros(tk_void)!=0)return(returnvalue); |
1092 | } |
1095 | } |
1093 | dynamicindex=itok.segm; |
1096 | dynamicindex=itok.segm; |
1094 | 1097 | ||
1095 | // printf("%s %08X seg=%d\n",rec->recid/*itok.name*/,itok.flag,itok.segm); |
1098 | // printf("%s %08X seg=%d\n",rec->recid/*itok.name*/,itok.flag,itok.segm); |
1096 | if(itok.segm==DYNAMIC){ |
1099 | if(itok.segm==DYNAMIC){ |
1097 | itok.segm=DYNAMIC_USED; |
1100 | itok.segm=DYNAMIC_USED; |
1098 | updatetree(); |
1101 | updatetree(); |
1099 | } |
1102 | } |
1100 | unsigned int oaddESP=addESP; |
1103 | unsigned int oaddESP=addESP; |
1101 | snum=initparamproc(); |
1104 | snum=initparamproc(); |
1102 | if((flag&f_typeproc)!=tp_cdecl){ |
1105 | if((flag&f_typeproc)!=tp_cdecl){ |
1103 | snum=0; |
1106 | snum=0; |
1104 | addESP=oaddESP; |
1107 | addESP=oaddESP; |
1105 | } |
1108 | } |
1106 | if(dynamicindex |
1109 | if(dynamicindex |
1107 | addacall(cloc,(unsigned char)(am32!=FALSE?CALL_32:CALL_NEAR)); |
1110 | addacall(cloc,(unsigned char)(am32!=FALSE?CALL_32:CALL_NEAR)); |
1108 | if(jumpsend)jumploc0(); |
1111 | if(jumpsend)jumploc0(); |
1109 | else{ |
1112 | else{ |
1110 | callloc0(); |
1113 | callloc0(); |
1111 | if(snum!=0)CorrectStack(snum); |
1114 | if(snum!=0)CorrectStack(snum); |
1112 | } |
1115 | } |
1113 | } |
1116 | } |
1114 | else{ |
1117 | else{ |
1115 | if(jumpsend)jumploc(cloc); |
1118 | if(jumpsend)jumploc(cloc); |
1116 | else{ |
1119 | else{ |
1117 | callloc(cloc); |
1120 | callloc(cloc); |
1118 | if(snum!=0)CorrectStack(snum); |
1121 | if(snum!=0)CorrectStack(snum); |
1119 | } |
1122 | } |
1120 | } |
1123 | } |
1121 | } |
1124 | } |
1122 | #ifdef OPTVARCONST |
1125 | #ifdef OPTVARCONST |
1123 | if(flag&f_useidx)ClearLVIC(); |
1126 | if(flag&f_useidx)ClearLVIC(); |
1124 | else FreeGlobalConst(); |
1127 | else FreeGlobalConst(); |
1125 | #endif |
1128 | #endif |
1126 | clearregstat(regs); |
1129 | clearregstat(regs); |
1127 | return(returnvalue); |
1130 | return(returnvalue); |
1128 | } |
1131 | } |
1129 | 1132 | ||
1130 | int doid(char uppercase,int expectedreturn) |
1133 | int doid(char uppercase,int expectedreturn) |
1131 | { |
1134 | { |
1132 | int cnum; |
1135 | int cnum; |
1133 | if(tok2==tk_colon){ // if a label |
1136 | if(tok2==tk_colon){ // if a label |
1134 | #ifdef OPTVARCONST |
1137 | #ifdef OPTVARCONST |
1135 | ClearLVIC(); |
1138 | ClearLVIC(); |
1136 | #endif |
1139 | #endif |
1137 | RestoreStack(); |
1140 | RestoreStack(); |
1138 | clearregstat(); |
1141 | clearregstat(); |
1139 | cnum=FindOff((unsigned char *)itok.name,CS); |
1142 | cnum=FindOff((unsigned char *)itok.name,CS); |
1140 | if(uppercase){ |
1143 | if(uppercase){ |
1141 | localrec *ptr=addlocalvar(itok.name,tk_number,outptr,TRUE); |
1144 | localrec *ptr=addlocalvar(itok.name,tk_number,outptr,TRUE); |
1142 | if(FixUp)ptr->rec.flag=f_reloc; |
1145 | if(FixUp)ptr->rec.flag=f_reloc; |
1143 | } |
1146 | } |
1144 | else{ |
1147 | else{ |
1145 | tok=tk_proc; |
1148 | tok=tk_proc; |
1146 | itok.rm=tk_void; |
1149 | itok.rm=tk_void; |
1147 | itok.number=outptr; |
1150 | itok.number=outptr; |
1148 | itok.segm=NOT_DYNAMIC; |
1151 | itok.segm=NOT_DYNAMIC; |
1149 | itok.flag=0; |
1152 | itok.flag=0; |
1150 | string[0]=0; |
1153 | string[0]=0; |
1151 | itok.type=tp_ucnovn; |
1154 | itok.type=tp_ucnovn; |
1152 | addtotree(itok.name); |
1155 | addtotree(itok.name); |
1153 | itok.rec->count=cnum; |
1156 | itok.rec->count=cnum; |
1154 | } |
1157 | } |
1155 | nexttok(); // move past id |
1158 | nexttok(); // move past id |
1156 | nexttok(); // move past : |
1159 | nexttok(); // move past : |
1157 | return(tokens); |
1160 | return(tokens); |
1158 | } |
1161 | } |
1159 | if(tok2==tk_openbracket){ |
1162 | if(tok2==tk_openbracket){ |
1160 | if((cnum=CheckMacros())!=tokens)return cnum; |
1163 | if((cnum=CheckMacros())!=tokens)return cnum; |
1161 | tobedefined(am32==FALSE?CALL_NEAR:CALL_32,expectedreturn); |
1164 | tobedefined(am32==FALSE?CALL_NEAR:CALL_32,expectedreturn); |
1162 | cnum=posts-1; |
1165 | cnum=posts-1; |
1163 | param[0]=0; |
1166 | param[0]=0; |
1164 | int flag=itok.flag; |
1167 | int flag=itok.flag; |
1165 | int exitproc=CheckExitProc(); |
1168 | int exitproc=CheckExitProc(); |
1166 | unsigned int oaddESP=addESP; |
1169 | unsigned int oaddESP=addESP; |
1167 | if(itok.flag==tp_stdcall){ |
1170 | if(itok.flag==tp_stdcall){ |
1168 | nexttok(); |
1171 | nexttok(); |
1169 | swapparam(); |
1172 | swapparam(); |
1170 | } |
1173 | } |
1171 | else{ |
1174 | else{ |
1172 | nexttok(); |
1175 | nexttok(); |
1173 | if(uppercase)doregparams(); |
1176 | if(uppercase)doregparams(); |
1174 | else doparams(); |
1177 | else doparams(); |
1175 | } |
1178 | } |
1176 | (postbuf+cnum)->loc=outptr+1; |
1179 | (postbuf+cnum)->loc=outptr+1; |
1177 | callloc0(); /* produce CALL [#] */ |
1180 | callloc0(); /* produce CALL [#] */ |
1178 | clearregstat(); |
1181 | clearregstat(); |
1179 | addESP=oaddESP; |
1182 | addESP=oaddESP; |
1180 | #ifdef OPTVARCONST |
1183 | #ifdef OPTVARCONST |
1181 | if(flag&f_useidx)ClearLVIC(); |
1184 | if(flag&f_useidx)ClearLVIC(); |
1182 | else FreeGlobalConst(); |
1185 | else FreeGlobalConst(); |
1183 | #endif |
1186 | #endif |
1184 | retproc=exitproc; |
1187 | retproc=exitproc; |
1185 | return(expectedreturn); |
1188 | return(expectedreturn); |
1186 | } |
1189 | } |
1187 | thisundefined(itok.name); |
1190 | thisundefined(itok.name); |
1188 | return(tk_long); |
1191 | return(tk_long); |
1189 | } |
1192 | } |
1190 | 1193 | ||
1191 | int typesize(int vartype) // âîçâðàùàåò ðàçìåð â áàéòàõ êîäà âîçâðàòà |
1194 | int typesize(int vartype) // âîçâðàùàåò ðàçìåð â áàéòàõ êîäà âîçâðàòà |
1192 | { |
1195 | { |
1193 | switch(vartype){ |
1196 | switch(vartype){ |
1194 | case tk_char: |
1197 | case tk_char: |
1195 | case tk_byte: return(1); |
1198 | case tk_byte: return(1); |
1196 | case tk_int: |
1199 | case tk_int: |
1197 | case tk_word: return(2); |
1200 | case tk_word: return(2); |
1198 | case tk_float: |
1201 | case tk_float: |
1199 | case tk_dword: |
1202 | case tk_dword: |
1200 | case tk_long: return(4); |
1203 | case tk_long: return(4); |
1201 | case tk_double: |
1204 | case tk_double: |
1202 | case tk_qword: return 8; |
1205 | case tk_qword: return 8; |
1203 | } |
1206 | } |
1204 | return(0); |
1207 | return(0); |
1205 | } |
1208 | } |
1206 | 1209 | ||
1207 | void FpuSt2Number() |
1210 | void FpuSt2Number() |
1208 | { |
1211 | { |
1209 | op66(r32); //push EAX |
1212 | op66(r32); //push EAX |
1210 | op(0x50); |
1213 | op(0x50); |
1211 | CheckInitBP(); |
1214 | CheckInitBP(); |
1212 | fistp_stack(); |
1215 | fistp_stack(); |
1213 | RestoreBP(); |
1216 | RestoreBP(); |
1214 | fwait3(); |
1217 | fwait3(); |
1215 | op66(r32); |
1218 | op66(r32); |
1216 | op(0x58); //pop EAX |
1219 | op(0x58); //pop EAX |
1217 | if(cpu<3)cpu=3; |
1220 | if(cpu<3)cpu=3; |
1218 | } |
1221 | } |
1219 | 1222 | ||
1220 | void FpuSt2QNumber() |
1223 | void FpuSt2QNumber() |
1221 | { |
1224 | { |
1222 | op66(r32); //push EAX |
1225 | op66(r32); //push EAX |
1223 | op(0x50); |
1226 | op(0x50); |
1224 | op66(r32); //push EAX |
1227 | op66(r32); //push EAX |
1225 | op(0x50); |
1228 | op(0x50); |
1226 | CheckInitBP(); |
1229 | CheckInitBP(); |
1227 | fistp_stack(4); |
1230 | fistp_stack(4); |
1228 | RestoreBP(); |
1231 | RestoreBP(); |
1229 | fwait3(); |
1232 | fwait3(); |
1230 | op66(r32); |
1233 | op66(r32); |
1231 | op(0x58+EDX); //pop EAX |
1234 | op(0x58+EDX); //pop EAX |
1232 | op66(r32); |
1235 | op66(r32); |
1233 | op(0x58); //pop EAX |
1236 | op(0x58); //pop EAX |
1234 | if(cpu<3)cpu=3; |
1237 | if(cpu<3)cpu=3; |
1235 | } |
1238 | } |
1236 | 1239 | ||
1237 | void fwait3_4() |
1240 | void fwait3_4() |
1238 | { |
1241 | { |
1239 | if(chip<4)op(0x9B); |
1242 | if(chip<4)op(0x9B); |
1240 | } |
1243 | } |
1241 | 1244 | ||
1242 | void convert_returnvalue(int expectedreturn,int actualreturn) |
1245 | void convert_returnvalue(int expectedreturn,int actualreturn) |
1243 | { |
1246 | { |
1244 | if(expectedreturn==tk_void)return; //17.09.05 17:52 |
1247 | if(expectedreturn==tk_void)return; //17.09.05 17:52 |
1245 | if(actualreturn==tk_void/*||expectedreturn==tk_void*/){ |
1248 | if(actualreturn==tk_void/*||expectedreturn==tk_void*/){ |
1246 | retvoid(); |
1249 | retvoid(); |
1247 | return; |
1250 | return; |
1248 | } |
1251 | } |
1249 | switch(expectedreturn){ |
1252 | switch(expectedreturn){ |
1250 | case tk_byte: |
1253 | case tk_byte: |
1251 | case tk_char: |
1254 | case tk_char: |
1252 | case tk_word: |
1255 | case tk_word: |
1253 | case tk_int: |
1256 | case tk_int: |
1254 | if(actualreturn==tk_float||actualreturn==tk_double){ |
1257 | if(actualreturn==tk_float||actualreturn==tk_double){ |
1255 | op66(r32); |
1258 | op66(r32); |
1256 | op(0x50); |
1259 | op(0x50); |
1257 | FloatToNumer(actualreturn==tk_float?0:4); |
1260 | FloatToNumer(actualreturn==tk_float?0:4); |
1258 | } |
1261 | } |
1259 | else if(actualreturn==tk_fpust)FpuSt2Number(); |
1262 | else if(actualreturn==tk_fpust)FpuSt2Number(); |
1260 | else if(expectedreturn==tk_word||expectedreturn==tk_int){ |
1263 | else if(expectedreturn==tk_word||expectedreturn==tk_int){ |
1261 | if(actualreturn==tk_char)cbw(); |
1264 | if(actualreturn==tk_char)cbw(); |
1262 | else if(actualreturn==tk_byte)xorAHAH(); |
1265 | else if(actualreturn==tk_byte)xorAHAH(); |
1263 | } |
1266 | } |
1264 | break; |
1267 | break; |
1265 | case tk_long: |
1268 | case tk_long: |
1266 | case tk_dword: |
1269 | case tk_dword: |
1267 | switch(actualreturn){ |
1270 | switch(actualreturn){ |
1268 | case tk_char: |
1271 | case tk_char: |
1269 | op66(r32); |
1272 | op66(r32); |
1270 | op(0x0F); outword(0xC0BE); //MOVSX EAX,AL |
1273 | op(0x0F); outword(0xC0BE); //MOVSX EAX,AL |
1271 | break; |
1274 | break; |
1272 | case tk_byte: /* MOVZX EAX,AL */ |
1275 | case tk_byte: /* MOVZX EAX,AL */ |
1273 | op66(r32); |
1276 | op66(r32); |
1274 | op(0x0F); outword(0xC0B6); |
1277 | op(0x0F); outword(0xC0B6); |
1275 | break; |
1278 | break; |
1276 | case tk_word: /* MOVZX EAX,AX */ |
1279 | case tk_word: /* MOVZX EAX,AX */ |
1277 | op66(r32); |
1280 | op66(r32); |
1278 | op(0x0F); outword(0xC0B7); |
1281 | op(0x0F); outword(0xC0B7); |
1279 | break; |
1282 | break; |
1280 | case tk_int: /* MOVSX EAX,AX */ |
1283 | case tk_int: /* MOVSX EAX,AX */ |
1281 | op66(r32); |
1284 | op66(r32); |
1282 | op(0x0F); outword(0xC0BF); |
1285 | op(0x0F); outword(0xC0BF); |
1283 | break; |
1286 | break; |
1284 | case tk_double: |
1287 | case tk_double: |
1285 | case tk_fpust: |
1288 | case tk_fpust: |
1286 | FpuSt2Number(); |
1289 | FpuSt2Number(); |
1287 | break; |
1290 | break; |
1288 | // case tk_double: |
1291 | // case tk_double: |
1289 | case tk_float: |
1292 | case tk_float: |
1290 | op66(r32); |
1293 | op66(r32); |
1291 | op(0x50); |
1294 | op(0x50); |
1292 | FloatToNumer(/*actualreturn==tk_float?0:4*/); |
1295 | FloatToNumer(/*actualreturn==tk_float?0:4*/); |
1293 | break; |
1296 | break; |
1294 | } |
1297 | } |
1295 | if(cpu<3)cpu=3; |
1298 | if(cpu<3)cpu=3; |
1296 | break; |
1299 | break; |
1297 | case tk_qword: |
1300 | case tk_qword: |
1298 | switch(actualreturn){ |
1301 | switch(actualreturn){ |
1299 | case tk_char: |
1302 | case tk_char: |
1300 | op66(r32); |
1303 | op66(r32); |
1301 | op(0x0F); outword(0xC0BE); //MOVSX EAX,AL |
1304 | op(0x0F); outword(0xC0BE); //MOVSX EAX,AL |
1302 | cwdq(r32); |
1305 | cwdq(r32); |
1303 | break; |
1306 | break; |
1304 | case tk_byte: /* MOVZX EAX,AL */ |
1307 | case tk_byte: /* MOVZX EAX,AL */ |
1305 | op66(r32); |
1308 | op66(r32); |
1306 | op(0x0F); outword(0xC0B6); |
1309 | op(0x0F); outword(0xC0B6); |
1307 | ZeroReg(EDX,r32); |
1310 | ZeroReg(EDX,r32); |
1308 | break; |
1311 | break; |
1309 | case tk_word: /* MOVZX EAX,AX */ |
1312 | case tk_word: /* MOVZX EAX,AX */ |
1310 | op66(r32); |
1313 | op66(r32); |
1311 | op(0x0F); outword(0xC0B7); |
1314 | op(0x0F); outword(0xC0B7); |
1312 | case tk_dword: |
1315 | case tk_dword: |
1313 | ZeroReg(EDX,r32); |
1316 | ZeroReg(EDX,r32); |
1314 | break; |
1317 | break; |
1315 | case tk_int: /* MOVSX EAX,AX */ |
1318 | case tk_int: /* MOVSX EAX,AX */ |
1316 | op66(r32); |
1319 | op66(r32); |
1317 | op(0x0F); outword(0xC0BF); |
1320 | op(0x0F); outword(0xC0BF); |
1318 | case tk_long: |
1321 | case tk_long: |
1319 | cwdq(r32); |
1322 | cwdq(r32); |
1320 | break; |
1323 | break; |
1321 | case tk_fpust: |
1324 | case tk_fpust: |
1322 | case tk_double: |
1325 | case tk_double: |
1323 | FpuSt2QNumber(); |
1326 | FpuSt2QNumber(); |
1324 | break; |
1327 | break; |
1325 | case tk_float: |
1328 | case tk_float: |
1326 | op66(r32); |
1329 | op66(r32); |
1327 | op(0x50); |
1330 | op(0x50); |
1328 | FloatToNumer(actualreturn==tk_float?0:4); |
1331 | FloatToNumer(actualreturn==tk_float?0:4); |
1329 | cwdq(r32); |
1332 | cwdq(r32); |
1330 | break; |
1333 | break; |
1331 | } |
1334 | } |
1332 | if(cpu<3)cpu=3; |
1335 | if(cpu<3)cpu=3; |
1333 | break; |
1336 | break; |
1334 | case tk_fpust: |
1337 | case tk_fpust: |
1335 | if(tok2==tk_semicolon)break; |
1338 | if(tok2==tk_semicolon)break; |
1336 | switch(actualreturn){ |
1339 | switch(actualreturn){ |
1337 | case tk_char: |
1340 | case tk_char: |
1338 | CheckInitBP(); |
1341 | CheckInitBP(); |
1339 | cbw(); |
1342 | cbw(); |
1340 | op66(r32); |
1343 | op66(r32); |
1341 | outword(0xDF50); //push EAX |
1344 | outword(0xDF50); //push EAX |
1342 | goto endfxld; //fild ss[bp-4]/[esp] |
1345 | goto endfxld; //fild ss[bp-4]/[esp] |
1343 | case tk_byte: |
1346 | case tk_byte: |
1344 | CheckInitBP(); |
1347 | CheckInitBP(); |
1345 | xorAHAH(); |
1348 | xorAHAH(); |
1346 | op66(r32); |
1349 | op66(r32); |
1347 | outword(0xDF50); //push EAX |
1350 | outword(0xDF50); //push EAX |
1348 | goto endfxld; //fild ss[bp-4]/[esp] |
1351 | goto endfxld; //fild ss[bp-4]/[esp] |
1349 | case tk_word: |
1352 | case tk_word: |
1350 | CheckInitBP(); |
1353 | CheckInitBP(); |
1351 | op66(r16); |
1354 | op66(r16); |
1352 | outword(0x6A); //push 0 |
1355 | outword(0x6A); //push 0 |
1353 | op66(r16); |
1356 | op66(r16); |
1354 | outword(0xDB50); //push AX |
1357 | outword(0xDB50); //push AX |
1355 | goto endfxld; //fild ss[bp-4]/[esp] |
1358 | goto endfxld; //fild ss[bp-4]/[esp] |
1356 | case tk_int: |
1359 | case tk_int: |
1357 | CheckInitBP(); |
1360 | CheckInitBP(); |
1358 | op66(r32); |
1361 | op66(r32); |
1359 | outword(0xDF50); //push eax |
1362 | outword(0xDF50); //push eax |
1360 | goto endfxld; //fild ss[bp-4]/[esp] |
1363 | goto endfxld; //fild ss[bp-4]/[esp] |
1361 | case tk_dword: |
1364 | case tk_dword: |
1362 | CheckInitBP(); |
1365 | CheckInitBP(); |
1363 | op66(r32); //push 0L |
1366 | op66(r32); //push 0L |
1364 | outword(0x6A); |
1367 | outword(0x6A); |
1365 | op66(r32); |
1368 | op66(r32); |
1366 | op(0x50); //push EAX |
1369 | op(0x50); //push EAX |
1367 | fildq_stack(); |
1370 | fildq_stack(); |
1368 | RestoreBP(); |
1371 | RestoreBP(); |
1369 | op66(r32); |
1372 | op66(r32); |
1370 | op(0x58); //pop eax |
1373 | op(0x58); //pop eax |
1371 | op66(r32); |
1374 | op66(r32); |
1372 | op(0x58); //pop eax |
1375 | op(0x58); //pop eax |
1373 | break; |
1376 | break; |
1374 | case tk_long: |
1377 | case tk_long: |
1375 | CheckInitBP(); |
1378 | CheckInitBP(); |
1376 | op66(r32); |
1379 | op66(r32); |
1377 | outword(0xDB50); //push EAX |
1380 | outword(0xDB50); //push EAX |
1378 | goto endfxld; //fild ss[bp-4]/[esp] |
1381 | goto endfxld; //fild ss[bp-4]/[esp] |
1379 | case tk_float: |
1382 | case tk_float: |
1380 | CheckInitBP(); |
1383 | CheckInitBP(); |
1381 | op66(r32); |
1384 | op66(r32); |
1382 | outword(0xd950); //push EAX |
1385 | outword(0xd950); //push EAX |
1383 | endfxld: |
1386 | endfxld: |
1384 | fld_stack(4+localsize); |
1387 | fld_stack(4+localsize); |
1385 | RestoreBP(); |
1388 | RestoreBP(); |
1386 | op66(r32); |
1389 | op66(r32); |
1387 | op(0x58); //pop eax |
1390 | op(0x58); //pop eax |
1388 | break; |
1391 | break; |
1389 | case tk_qword: |
1392 | case tk_qword: |
1390 | // case tk_double: |
1393 | // case tk_double: |
1391 | CheckInitBP(); |
1394 | CheckInitBP(); |
1392 | op66(r32); |
1395 | op66(r32); |
1393 | op(0x50+EDX); //push EDX |
1396 | op(0x50+EDX); //push EDX |
1394 | op66(r32); |
1397 | op66(r32); |
1395 | op(0x50); //push EAX |
1398 | op(0x50); //push EAX |
1396 | /* if(actualreturn==tk_double){ |
1399 | /* if(actualreturn==tk_double){ |
1397 | op(0xDD); |
1400 | op(0xDD); |
1398 | fld_stack(8+localsize); |
1401 | fld_stack(8+localsize); |
1399 | } |
1402 | } |
1400 | else*/ fildq_stack(); |
1403 | else*/ fildq_stack(); |
1401 | RestoreBP(); |
1404 | RestoreBP(); |
1402 | op66(r32); |
1405 | op66(r32); |
1403 | op(0x58); //pop eax |
1406 | op(0x58); //pop eax |
1404 | op66(r32); |
1407 | op66(r32); |
1405 | op(0x58); //pop eax |
1408 | op(0x58); //pop eax |
1406 | break; |
1409 | break; |
1407 | } |
1410 | } |
1408 | if(cpu<3)cpu=3; |
1411 | if(cpu<3)cpu=3; |
1409 | break; |
1412 | break; |
1410 | default: |
1413 | default: |
1411 | // printf("expectedreturn=%d %s %d\n",expectedreturn,(startfileinfo+currentfileinfo)->filename,linenumber); |
1414 | // printf("expectedreturn=%d %s %d\n",expectedreturn,(startfileinfo+currentfileinfo)->filename,linenumber); |
1412 | break; |
1415 | break; |
1413 | } |
1416 | } |
1414 | } |
1417 | } |
1415 | 1418 | ||
1416 | int procdo(int expectedreturn) |
1419 | int procdo(int expectedreturn) |
1417 | { |
1420 | { |
1418 | int actualreturn; |
1421 | int actualreturn; |
1419 | char idflag=0; |
1422 | char idflag=0; |
1420 | switch(tok){ |
1423 | switch(tok){ |
1421 | case tk_ID: idflag++; |
1424 | case tk_ID: idflag++; |
1422 | case tk_id: |
1425 | case tk_id: |
1423 | actualreturn=doid(idflag,expectedreturn); |
1426 | actualreturn=doid(idflag,expectedreturn); |
1424 | break; |
1427 | break; |
1425 | case tk_proc: |
1428 | case tk_proc: |
1426 | actualreturn=doanyproc(); |
1429 | actualreturn=doanyproc(); |
1427 | break; |
1430 | break; |
1428 | case tk_apiproc: |
1431 | case tk_apiproc: |
1429 | case tk_undefproc: |
1432 | case tk_undefproc: |
1430 | case tk_declare: |
1433 | case tk_declare: |
1431 | // if((actualreturn=doanyundefproc())==tk_void)actualreturn=expectedreturn; |
1434 | // if((actualreturn=doanyundefproc())==tk_void)actualreturn=expectedreturn; |
1432 | actualreturn=doanyundefproc(); //17.09.05 17:56 |
1435 | actualreturn=doanyundefproc(); //17.09.05 17:56 |
1433 | break; |
1436 | break; |
1434 | default: internalerror("Bad tok in procdo();"); break; |
1437 | default: internalerror("Bad tok in procdo();"); break; |
1435 | } |
1438 | } |
1436 | convert_returnvalue(expectedreturn,actualreturn); |
1439 | convert_returnvalue(expectedreturn,actualreturn); |
1437 | return actualreturn; |
1440 | return actualreturn; |
1438 | } |
1441 | } |
1439 | 1442 | ||
1440 | /* +++++++++++++++++++++++ loops and ifs start ++++++++++++++++++++++++ */ |
1443 | /* +++++++++++++++++++++++ loops and ifs start ++++++++++++++++++++++++ */ |
1441 | 1444 | ||
1442 | void endcmpfloat() |
1445 | void endcmpfloat() |
1443 | { |
1446 | { |
1444 | fwait3(); |
1447 | fwait3(); |
1445 | outword(0xE0DF);//fstsw ax |
1448 | outword(0xE0DF);//fstsw ax |
1446 | op(0x9E); |
1449 | op(0x9E); |
1447 | RestoreBP(); |
1450 | RestoreBP(); |
1448 | } |
1451 | } |
1449 | 1452 | ||
1450 | int outcmp(int swapped,int ctok,ITOK *cstok,char *&cbuf,SINFO *cstr,int ctok2,ITOK *cstok2,char *&cbuf2,SINFO *cstr2,int typet) |
1453 | int outcmp(int swapped,int ctok,ITOK *cstok,char *&cbuf,SINFO *cstr,int ctok2,ITOK *cstok2,char *&cbuf2,SINFO *cstr2,int typet) |
1451 | { |
1454 | { |
1452 | unsigned char err=0; |
1455 | unsigned char err=0; |
1453 | int typef=0; |
1456 | int typef=0; |
1454 | int vop=0; |
1457 | int vop=0; |
1455 | long long lnumber; |
1458 | long long lnumber; |
1456 | unsigned int ofs; |
1459 | unsigned int ofs; |
1457 | int i,reg,reg1; |
1460 | int i,reg,reg1; |
1458 | if(typet |
1461 | if(typet |
1459 | switch(ctok){ |
1462 | switch(ctok){ |
1460 | case tk_reg64: |
1463 | case tk_reg64: |
1461 | reg=cstok->number/256; |
1464 | reg=cstok->number/256; |
1462 | switch(ctok2){ |
1465 | switch(ctok2){ |
1463 | case tk_reg64: |
1466 | case tk_reg64: |
1464 | reg1=cstok2->number/256; |
1467 | reg1=cstok2->number/256; |
1465 | for(i=0;i<2;i++){ |
1468 | for(i=0;i<2;i++){ |
1466 | op66(r32); |
1469 | op66(r32); |
1467 | op(0x39); //cmp reg,reg |
1470 | op(0x39); //cmp reg,reg |
1468 | op(0xC0+reg+reg1*8); |
1471 | op(0xC0+reg+reg1*8); |
1469 | if(i==1)break; |
1472 | if(i==1)break; |
1470 | outword(0x75); |
1473 | outword(0x75); |
1471 | ofs=outptr; |
1474 | ofs=outptr; |
1472 | reg=cstok->number&255; |
1475 | reg=cstok->number&255; |
1473 | reg1=cstok2->number&255; |
1476 | reg1=cstok2->number&255; |
1474 | } |
1477 | } |
1475 | output[ofs-1]=outptr-ofs; |
1478 | output[ofs-1]=outptr-ofs; |
1476 | break; |
1479 | break; |
1477 | case tk_number: |
1480 | case tk_number: |
1478 | case tk_postnumber: |
1481 | case tk_postnumber: |
1479 | case tk_undefofs: |
1482 | case tk_undefofs: |
1480 | lnumber=cstok2->lnumber>>32; |
1483 | lnumber=cstok2->lnumber>>32; |
1481 | for(i=0;i<2;i++){ |
1484 | for(i=0;i<2;i++){ |
1482 | op66(r32); |
1485 | op66(r32); |
1483 | //ïðîâåðêà íà âîçìîæíîñòü áîëåå êîðîòêîãî êîäà |
1486 | //ïðîâåðêà íà âîçìîæíîñòü áîëåå êîðîòêîãî êîäà |
1484 | if((cstok2->flag&f_reloc)==0&&ctok2!=tk_postnumber&&ctok2!=tk_undefofs&& |
1487 | if((cstok2->flag&f_reloc)==0&&ctok2!=tk_postnumber&&ctok2!=tk_undefofs&& |
1485 | short_ok(lnumber,TRUE)){ |
1488 | short_ok(lnumber,TRUE)){ |
1486 | if(!lnumber){ |
1489 | if(!lnumber){ |
1487 | op(0x85); //test reg,reg |
1490 | op(0x85); //test reg,reg |
1488 | op(0xc0+reg*9); |
1491 | op(0xc0+reg*9); |
1489 | } |
1492 | } |
1490 | else{ |
1493 | else{ |
1491 | op(0x83); //cmp reg, |
1494 | op(0x83); //cmp reg, |
1492 | op(0xF8+reg); |
1495 | op(0xF8+reg); |
1493 | op(lnumber); |
1496 | op(lnumber); |
1494 | } |
1497 | } |
1495 | } |
1498 | } |
1496 | else{ |
1499 | else{ |
1497 | if(reg==AX)op(0x3D); |
1500 | if(reg==AX)op(0x3D); |
1498 | else{ |
1501 | else{ |
1499 | op(0x81); |
1502 | op(0x81); |
1500 | op(0xF8+reg); |
1503 | op(0xF8+reg); |
1501 | } |
1504 | } |
1502 | if(i==1){ |
1505 | if(i==1){ |
1503 | if(ctok2==tk_postnumber)(cstok2->flag&f_extern)==0?setwordpost(cstok2):setwordext(&cstok2->number); |
1506 | if(ctok2==tk_postnumber)(cstok2->flag&f_extern)==0?setwordpost(cstok2):setwordext(&cstok2->number); |
1504 | else if((cstok2->flag&f_reloc)!=0)AddReloc(cstok2->segm); |
1507 | else if((cstok2->flag&f_reloc)!=0)AddReloc(cstok2->segm); |
1505 | if(ctok2==tk_undefofs)AddUndefOff(2,cstok2->name); |
1508 | if(ctok2==tk_undefofs)AddUndefOff(2,cstok2->name); |
1506 | } |
1509 | } |
1507 | outdword(cstok2->number); |
1510 | outdword(cstok2->number); |
1508 | } |
1511 | } |
1509 | if(i==1)break; |
1512 | if(i==1)break; |
1510 | outword(0x75); |
1513 | outword(0x75); |
1511 | ofs=outptr; |
1514 | ofs=outptr; |
1512 | reg=cstok->number&255; |
1515 | reg=cstok->number&255; |
1513 | } |
1516 | } |
1514 | output[ofs-1]=outptr-ofs; |
1517 | output[ofs-1]=outptr-ofs; |
1515 | break; |
1518 | break; |
1516 | default: |
1519 | default: |
1517 | if(swapped)err=1; |
1520 | if(swapped)err=1; |
1518 | else return(outcmp(1,ctok2,cstok2,cbuf2,cstr2,ctok,cstok,cbuf,cstr,typet)); |
1521 | else return(outcmp(1,ctok2,cstok2,cbuf2,cstr2,ctok,cstok,cbuf,cstr,typet)); |
1519 | break; |
1522 | break; |
1520 | } |
1523 | } |
1521 | break; |
1524 | break; |
1522 | case tk_reg32: |
1525 | case tk_reg32: |
1523 | case tk_reg: |
1526 | case tk_reg: |
1524 | switch(ctok2){ |
1527 | switch(ctok2){ |
1525 | case tk_reg: |
1528 | case tk_reg: |
1526 | case tk_reg32: |
1529 | case tk_reg32: |
1527 | if(ctok!=ctok2)err=1; |
1530 | if(ctok!=ctok2)err=1; |
1528 | else{ |
1531 | else{ |
1529 | op66(typet); |
1532 | op66(typet); |
1530 | op(0x39); //cmp reg,reg |
1533 | op(0x39); //cmp reg,reg |
1531 | op(0xC0+(unsigned int)cstok->number+(unsigned int)cstok2->number*8); |
1534 | op(0xC0+(unsigned int)cstok->number+(unsigned int)cstok2->number*8); |
1532 | } |
1535 | } |
1533 | break; |
1536 | break; |
1534 | case tk_number: |
1537 | case tk_number: |
1535 | if(cstok2->number==0&&(cstok2->flag&f_reloc)==0){ |
1538 | if(cstok2->number==0&&(cstok2->flag&f_reloc)==0){ |
1536 | op66(typet); |
1539 | op66(typet); |
1537 | op(0x85); //test reg,reg |
1540 | op(0x85); //test reg,reg |
1538 | op(0xc0+(unsigned int)cstok->number*9); |
1541 | op(0xc0+(unsigned int)cstok->number*9); |
1539 | break; |
1542 | break; |
1540 | } |
1543 | } |
1541 | case tk_postnumber: |
1544 | case tk_postnumber: |
1542 | case tk_undefofs: |
1545 | case tk_undefofs: |
1543 | op66(typet); |
1546 | op66(typet); |
1544 | //ïðîâåðêà íà âîçìîæíîñòü áîëåå êîðîòêîãî êîäà |
1547 | //ïðîâåðêà íà âîçìîæíîñòü áîëåå êîðîòêîãî êîäà |
1545 | if((cstok2->flag&f_reloc)==0&&ctok2!=tk_postnumber&&ctok2!=tk_undefofs&& |
1548 | if((cstok2->flag&f_reloc)==0&&ctok2!=tk_postnumber&&ctok2!=tk_undefofs&& |
1546 | short_ok(cstok2->number,ctok==tk_reg?FALSE:TRUE)){ |
1549 | short_ok(cstok2->number,ctok==tk_reg?FALSE:TRUE)){ |
1547 | op(0x83); //cmp reg, |
1550 | op(0x83); //cmp reg, |
1548 | op(0xF8+(unsigned int)cstok->number); |
1551 | op(0xF8+(unsigned int)cstok->number); |
1549 | op(cstok2->number); |
1552 | op(cstok2->number); |
1550 | break; |
1553 | break; |
1551 | } |
1554 | } |
1552 | if(cstok->number==AX)op(0x3D); |
1555 | if(cstok->number==AX)op(0x3D); |
1553 | else{ |
1556 | else{ |
1554 | op(0x81); |
1557 | op(0x81); |
1555 | op(0xF8+(unsigned int)cstok->number); |
1558 | op(0xF8+(unsigned int)cstok->number); |
1556 | } |
1559 | } |
1557 | if(ctok2==tk_postnumber)(cstok2->flag&f_extern)==0?setwordpost(cstok2):setwordext(&cstok2->number); |
1560 | if(ctok2==tk_postnumber)(cstok2->flag&f_extern)==0?setwordpost(cstok2):setwordext(&cstok2->number); |
1558 | else if((cstok2->flag&f_reloc)!=0)AddReloc(cstok2->segm); |
1561 | else if((cstok2->flag&f_reloc)!=0)AddReloc(cstok2->segm); |
1559 | if(ctok2==tk_undefofs)AddUndefOff(2,cstok2->name); |
1562 | if(ctok2==tk_undefofs)AddUndefOff(2,cstok2->name); |
1560 | if(ctok==tk_reg)outword((unsigned int)cstok2->number); |
1563 | if(ctok==tk_reg)outword((unsigned int)cstok2->number); |
1561 | else outdword(cstok2->number); |
1564 | else outdword(cstok2->number); |
1562 | break; |
1565 | break; |
1563 | default: |
1566 | default: |
1564 | if(swapped)err=1; |
1567 | if(swapped)err=1; |
1565 | else return(outcmp(1,ctok2,cstok2,cbuf2,cstr2,ctok,cstok,cbuf,cstr,typet)); |
1568 | else return(outcmp(1,ctok2,cstok2,cbuf2,cstr2,ctok,cstok,cbuf,cstr,typet)); |
1566 | break; |
1569 | break; |
1567 | } |
1570 | } |
1568 | break; |
1571 | break; |
1569 | case tk_qwordvar: |
1572 | case tk_qwordvar: |
1570 | cstok->number+=4; |
1573 | cstok->number+=4; |
1571 | compressoffset(cstok); |
1574 | compressoffset(cstok); |
1572 | switch(ctok2){ |
1575 | switch(ctok2){ |
1573 | case tk_postnumber: |
1576 | case tk_postnumber: |
1574 | case tk_number: |
1577 | case tk_number: |
1575 | case tk_undefofs: |
1578 | case tk_undefofs: |
1576 | lnumber=cstok2->lnumber>>32; |
1579 | lnumber=cstok2->lnumber>>32; |
1577 | CheckAllMassiv(cbuf,8,cstr,cstok); |
1580 | CheckAllMassiv(cbuf,8,cstr,cstok); |
1578 | for(i=0;i<2;i++){ |
1581 | for(i=0;i<2;i++){ |
1579 | op66(r32); |
1582 | op66(r32); |
1580 | outseg(cstok,2); |
1583 | outseg(cstok,2); |
1581 | //ïðîâåðêà íà âîçìîæíîñòü áîëåå êîðîòêîãî êîäà |
1584 | //ïðîâåðêà íà âîçìîæíîñòü áîëåå êîðîòêîãî êîäà |
1582 | if((cstok2->flag&f_reloc)==0&&ctok2!=tk_postnumber&&ctok2!=tk_undefofs&& |
1585 | if((cstok2->flag&f_reloc)==0&&ctok2!=tk_postnumber&&ctok2!=tk_undefofs&& |
1583 | short_ok(lnumber,1)){ |
1586 | short_ok(lnumber,1)){ |
1584 | op(0x83); |
1587 | op(0x83); |
1585 | op(0x38+cstok->rm); |
1588 | op(0x38+cstok->rm); |
1586 | outaddress(cstok); |
1589 | outaddress(cstok); |
1587 | op(lnumber); |
1590 | op(lnumber); |
1588 | } |
1591 | } |
1589 | else{ |
1592 | else{ |
1590 | op(0x81); |
1593 | op(0x81); |
1591 | op(0x38+cstok->rm); |
1594 | op(0x38+cstok->rm); |
1592 | outaddress(cstok); |
1595 | outaddress(cstok); |
1593 | if(i==1){ |
1596 | if(i==1){ |
1594 | if(ctok2==tk_postnumber)(cstok2->flag&f_extern)==0?setwordpost(cstok2):setwordext(&cstok2->number); |
1597 | if(ctok2==tk_postnumber)(cstok2->flag&f_extern)==0?setwordpost(cstok2):setwordext(&cstok2->number); |
1595 | else if((cstok2->flag&f_reloc)!=0)AddReloc(cstok2->segm); |
1598 | else if((cstok2->flag&f_reloc)!=0)AddReloc(cstok2->segm); |
1596 | if(ctok2==tk_undefofs)AddUndefOff(2,cstok2->name); |
1599 | if(ctok2==tk_undefofs)AddUndefOff(2,cstok2->name); |
1597 | } |
1600 | } |
1598 | outdword(lnumber); |
1601 | outdword(lnumber); |
1599 | } |
1602 | } |
1600 | if(i==1)break; |
1603 | if(i==1)break; |
1601 | outword(0x75); |
1604 | outword(0x75); |
1602 | ofs=outptr; |
1605 | ofs=outptr; |
1603 | cstok->number-=4; |
1606 | cstok->number-=4; |
1604 | compressoffset(cstok); |
1607 | compressoffset(cstok); |
1605 | lnumber=cstok2->lnumber; |
1608 | lnumber=cstok2->lnumber; |
1606 | } |
1609 | } |
1607 | output[ofs-1]=outptr-ofs; |
1610 | output[ofs-1]=outptr-ofs; |
1608 | break; |
1611 | break; |
1609 | case tk_reg64: |
1612 | case tk_reg64: |
1610 | CheckAllMassiv(cbuf,8,cstr,cstok); |
1613 | CheckAllMassiv(cbuf,8,cstr,cstok); |
1611 | reg=cstok2->number/256; |
1614 | reg=cstok2->number/256; |
1612 | for(i=0;i<2;i++){ |
1615 | for(i=0;i<2;i++){ |
1613 | op66(r32); |
1616 | op66(r32); |
1614 | outseg(cstok,2); |
1617 | outseg(cstok,2); |
1615 | op(0x39); /* CMP [word],AX */ |
1618 | op(0x39); /* CMP [word],AX */ |
1616 | op(cstok->rm+reg*8); |
1619 | op(cstok->rm+reg*8); |
1617 | outaddress(cstok); |
1620 | outaddress(cstok); |
1618 | if(i==1)break; |
1621 | if(i==1)break; |
1619 | reg=cstok2->number&255; |
1622 | reg=cstok2->number&255; |
1620 | outword(0x75); |
1623 | outword(0x75); |
1621 | ofs=outptr; |
1624 | ofs=outptr; |
1622 | cstok->number-=4; |
1625 | cstok->number-=4; |
1623 | compressoffset(cstok); |
1626 | compressoffset(cstok); |
1624 | } |
1627 | } |
1625 | output[ofs-1]=outptr-ofs; |
1628 | output[ofs-1]=outptr-ofs; |
1626 | break; |
1629 | break; |
1627 | default: |
1630 | default: |
1628 | i=EAX|(EDX*256); |
1631 | i=EAX|(EDX*256); |
1629 | getintoreg64(i); |
1632 | getintoreg64(i); |
1630 | doregmath64(i); |
1633 | doregmath64(i); |
1631 | CheckAllMassiv(cbuf,8,cstr,cstok); |
1634 | CheckAllMassiv(cbuf,8,cstr,cstok); |
1632 | reg=EDX; |
1635 | reg=EDX; |
1633 | for(i=0;i<2;i++){ |
1636 | for(i=0;i<2;i++){ |
1634 | op66(r32); |
1637 | op66(r32); |
1635 | outseg(cstok,2); |
1638 | outseg(cstok,2); |
1636 | op(0x39); /* CMP [word],AX */ |
1639 | op(0x39); /* CMP [word],AX */ |
1637 | op(cstok->rm+reg*8); |
1640 | op(cstok->rm+reg*8); |
1638 | outaddress(cstok); |
1641 | outaddress(cstok); |
1639 | if(i==1)break; |
1642 | if(i==1)break; |
1640 | reg=EAX; |
1643 | reg=EAX; |
1641 | outword(0x75); |
1644 | outword(0x75); |
1642 | ofs=outptr; |
1645 | ofs=outptr; |
1643 | cstok->number-=4; |
1646 | cstok->number-=4; |
1644 | compressoffset(cstok); |
1647 | compressoffset(cstok); |
1645 | } |
1648 | } |
1646 | output[ofs-1]=outptr-ofs; |
1649 | output[ofs-1]=outptr-ofs; |
1647 | break; |
1650 | break; |
1648 | } |
1651 | } |
1649 | break; |
1652 | break; |
1650 | case tk_intvar: |
1653 | case tk_intvar: |
1651 | case tk_wordvar: |
1654 | case tk_wordvar: |
1652 | if(swapped&&typet==r32)typet=r16; |
1655 | if(swapped&&typet==r32)typet=r16; |
1653 | case tk_longvar: |
1656 | case tk_longvar: |
1654 | case tk_dwordvar: |
1657 | case tk_dwordvar: |
1655 | switch(ctok2){ |
1658 | switch(ctok2){ |
1656 | case tk_reg32: |
1659 | case tk_reg32: |
1657 | case tk_reg: |
1660 | case tk_reg: |
1658 | CheckAllMassiv(cbuf,typet,cstr,cstok); |
1661 | CheckAllMassiv(cbuf,typet,cstr,cstok); |
1659 | op66(typet); |
1662 | op66(typet); |
1660 | outseg(cstok,2); |
1663 | outseg(cstok,2); |
1661 | op(0x39); |
1664 | op(0x39); |
1662 | op((unsigned int)cstok2->number*8+cstok->rm); |
1665 | op((unsigned int)cstok2->number*8+cstok->rm); |
1663 | outaddress(cstok); |
1666 | outaddress(cstok); |
1664 | break; |
1667 | break; |
1665 | case tk_postnumber: |
1668 | case tk_postnumber: |
1666 | case tk_number: |
1669 | case tk_number: |
1667 | case tk_undefofs: |
1670 | case tk_undefofs: |
1668 | CheckAllMassiv(cbuf,typet,cstr,cstok); |
1671 | CheckAllMassiv(cbuf,typet,cstr,cstok); |
1669 | op66(typet); |
1672 | op66(typet); |
1670 | outseg(cstok,2); |
1673 | outseg(cstok,2); |
1671 | //ïðîâåðêà íà âîçìîæíîñòü áîëåå êîðîòêîãî êîäà |
1674 | //ïðîâåðêà íà âîçìîæíîñòü áîëåå êîðîòêîãî êîäà |
1672 | if((cstok2->flag&f_reloc)==0&&ctok2!=tk_postnumber&&ctok2!=tk_undefofs&& |
1675 | if((cstok2->flag&f_reloc)==0&&ctok2!=tk_postnumber&&ctok2!=tk_undefofs&& |
1673 | short_ok(cstok2->number,typet/2-1)){ |
1676 | short_ok(cstok2->number,typet/2-1)){ |
1674 | op(0x83); |
1677 | op(0x83); |
1675 | op(0x38+cstok->rm); |
1678 | op(0x38+cstok->rm); |
1676 | outaddress(cstok); |
1679 | outaddress(cstok); |
1677 | op(cstok2->number); |
1680 | op(cstok2->number); |
1678 | break; |
1681 | break; |
1679 | } |
1682 | } |
1680 | op(0x81); |
1683 | op(0x81); |
1681 | op(0x38+cstok->rm); |
1684 | op(0x38+cstok->rm); |
1682 | outaddress(cstok); |
1685 | outaddress(cstok); |
1683 | if(ctok2==tk_postnumber)(cstok2->flag&f_extern)==0?setwordpost(cstok2):setwordext(&cstok2->number); |
1686 | if(ctok2==tk_postnumber)(cstok2->flag&f_extern)==0?setwordpost(cstok2):setwordext(&cstok2->number); |
1684 | else if((cstok2->flag&f_reloc)!=0)AddReloc(cstok2->segm); |
1687 | else if((cstok2->flag&f_reloc)!=0)AddReloc(cstok2->segm); |
1685 | if(ctok2==tk_undefofs)AddUndefOff(2,cstok2->name); |
1688 | if(ctok2==tk_undefofs)AddUndefOff(2,cstok2->name); |
1686 | if(typet==r16)outword((unsigned int)cstok2->number); |
1689 | if(typet==r16)outword((unsigned int)cstok2->number); |
1687 | else outdword(cstok2->number); |
1690 | else outdword(cstok2->number); |
1688 | break; |
1691 | break; |
1689 | case tk_charvar: |
1692 | case tk_charvar: |
1690 | case tk_intvar: |
1693 | case tk_intvar: |
1691 | getinto_e_ax(1,ctok2,cstok2,cbuf2,cstr2,typet); |
1694 | getinto_e_ax(1,ctok2,cstok2,cbuf2,cstr2,typet); |
1692 | CheckAllMassiv(cbuf,typet,cstr,cstok); |
1695 | CheckAllMassiv(cbuf,typet,cstr,cstok); |
1693 | op66(typet); |
1696 | op66(typet); |
1694 | outseg(cstok,2); |
1697 | outseg(cstok,2); |
1695 | op(0x39); /* CMP [word],AX */ |
1698 | op(0x39); /* CMP [word],AX */ |
1696 | op(cstok->rm); |
1699 | op(cstok->rm); |
1697 | outaddress(cstok); |
1700 | outaddress(cstok); |
1698 | break; |
1701 | break; |
1699 | default: |
1702 | default: |
1700 | getinto_e_ax(0,ctok2,cstok2,cbuf2,cstr2,typet); |
1703 | getinto_e_ax(0,ctok2,cstok2,cbuf2,cstr2,typet); |
1701 | // ClearReg(AX); |
1704 | // ClearReg(AX); |
1702 | CheckAllMassiv(cbuf,typet,cstr,cstok); |
1705 | CheckAllMassiv(cbuf,typet,cstr,cstok); |
1703 | op66(typet); |
1706 | op66(typet); |
1704 | outseg(cstok,2); |
1707 | outseg(cstok,2); |
1705 | op(0x39); /* CMP [word],AX */ |
1708 | op(0x39); /* CMP [word],AX */ |
1706 | op(cstok->rm); |
1709 | op(cstok->rm); |
1707 | outaddress(cstok); |
1710 | outaddress(cstok); |
1708 | break; |
1711 | break; |
1709 | } |
1712 | } |
1710 | break; |
1713 | break; |
1711 | case tk_number: |
1714 | case tk_number: |
1712 | if(ctok2==tk_postnumber){ |
1715 | if(ctok2==tk_postnumber){ |
1713 | op(0xB8); /* MOV AX,# */ |
1716 | op(0xB8); /* MOV AX,# */ |
1714 | if((cstok->flag&f_reloc)!=0)AddReloc(cstok->segm); |
1717 | if((cstok->flag&f_reloc)!=0)AddReloc(cstok->segm); |
1715 | if(am32==FALSE)outword((unsigned int)cstok->number); |
1718 | if(am32==FALSE)outword((unsigned int)cstok->number); |
1716 | else outdword(cstok->number); |
1719 | else outdword(cstok->number); |
1717 | op(0x3D); /* CMP AX,# */ |
1720 | op(0x3D); /* CMP AX,# */ |
1718 | (cstok2->flag&f_extern)==0?setwordpost(cstok2):setwordext(&cstok2->number); |
1721 | (cstok2->flag&f_extern)==0?setwordpost(cstok2):setwordext(&cstok2->number); |
1719 | if(am32==FALSE)outword((unsigned int)cstok2->number); |
1722 | if(am32==FALSE)outword((unsigned int)cstok2->number); |
1720 | else outdword(cstok2->number); |
1723 | else outdword(cstok2->number); |
1721 | } |
1724 | } |
1722 | if(ctok2==tk_number){ |
1725 | if(ctok2==tk_number){ |
1723 | if(cstok2->rm!=tk_float&&cstok->rm!=tk_float){ |
1726 | if(cstok2->rm!=tk_float&&cstok->rm!=tk_float){ |
1724 | if((unsigned long)cstok2->number<256&&(unsigned long)cstok->number<256){ |
1727 | if((unsigned long)cstok2->number<256&&(unsigned long)cstok->number<256){ |
1725 | op(0xB0); //mov al,number |
1728 | op(0xB0); //mov al,number |
1726 | op(cstok->number); |
1729 | op(cstok->number); |
1727 | op(0x3C); //cmp Al,number |
1730 | op(0x3C); //cmp Al,number |
1728 | op(cstok2->number); |
1731 | op(cstok2->number); |
1729 | } |
1732 | } |
1730 | else if((unsigned long)cstok2->number<65536&& cstok->number<65536){ |
1733 | else if((unsigned long)cstok2->number<65536&& cstok->number<65536){ |
1731 | op66(r16); |
1734 | op66(r16); |
1732 | op(0xB8); /* MOV AX,# */ |
1735 | op(0xB8); /* MOV AX,# */ |
1733 | if((cstok->flag&f_reloc)!=0)AddReloc(cstok->segm); |
1736 | if((cstok->flag&f_reloc)!=0)AddReloc(cstok->segm); |
1734 | outword((unsigned int)cstok->number); |
1737 | outword((unsigned int)cstok->number); |
1735 | op66(r16); |
1738 | op66(r16); |
1736 | op(0x3D); /* CMP AX,# */ |
1739 | op(0x3D); /* CMP AX,# */ |
1737 | if((cstok2->flag&f_reloc)!=0)AddReloc(cstok2->segm); |
1740 | if((cstok2->flag&f_reloc)!=0)AddReloc(cstok2->segm); |
1738 | outword((unsigned int)cstok2->number); |
1741 | outword((unsigned int)cstok2->number); |
1739 | } |
1742 | } |
1740 | else{ |
1743 | else{ |
1741 | op66(r32); |
1744 | op66(r32); |
1742 | op(0xB8); /* MOV AX,# */ |
1745 | op(0xB8); /* MOV AX,# */ |
1743 | if((cstok->flag&f_reloc)!=0)AddReloc(cstok->segm); |
1746 | if((cstok->flag&f_reloc)!=0)AddReloc(cstok->segm); |
1744 | outdword(cstok->number); |
1747 | outdword(cstok->number); |
1745 | op66(r32); |
1748 | op66(r32); |
1746 | op(0x3D); /* CMP AX,# */ |
1749 | op(0x3D); /* CMP AX,# */ |
1747 | if((cstok2->flag&f_reloc)!=0)AddReloc(cstok2->segm); |
1750 | if((cstok2->flag&f_reloc)!=0)AddReloc(cstok2->segm); |
1748 | outdword(cstok2->number); |
1751 | outdword(cstok2->number); |
1749 | } |
1752 | } |
1750 | } |
1753 | } |
1751 | else{ |
1754 | else{ |
1752 | op(0x55); //push bp |
1755 | op(0x55); //push bp |
1753 | outword(0xe589);//mov bp,sp |
1756 | outword(0xe589);//mov bp,sp |
1754 | op66(r32); |
1757 | op66(r32); |
1755 | if(short_ok(cstok->number,TRUE)){ //push num |
1758 | if(short_ok(cstok->number,TRUE)){ //push num |
1756 | op(0x6A); |
1759 | op(0x6A); |
1757 | op(cstok->number); |
1760 | op(cstok->number); |
1758 | } |
1761 | } |
1759 | else{ |
1762 | else{ |
1760 | op(0x68); |
1763 | op(0x68); |
1761 | outdword(cstok->number); |
1764 | outdword(cstok->number); |
1762 | } |
1765 | } |
1763 | op66(r32); |
1766 | op66(r32); |
1764 | if(short_ok(cstok2->number,TRUE)){ //push num |
1767 | if(short_ok(cstok2->number,TRUE)){ //push num |
1765 | op(0x6A); |
1768 | op(0x6A); |
1766 | op(cstok2->number); |
1769 | op(cstok2->number); |
1767 | } |
1770 | } |
1768 | else{ |
1771 | else{ |
1769 | op(0x68); |
1772 | op(0x68); |
1770 | outdword(cstok2->number); |
1773 | outdword(cstok2->number); |
1771 | } |
1774 | } |
1772 | outword(am32==FALSE?0x46d9:0x45d9); |
1775 | outword(am32==FALSE?0x46d9:0x45d9); |
1773 | op(0xfC);//fld ssdword[bp-4] |
1776 | op(0xfC);//fld ssdword[bp-4] |
1774 | op(0xD8); |
1777 | op(0xD8); |
1775 | outword(0xF85e - am32); //fcomp [bp-8] |
1778 | outword(0xF85e - am32); //fcomp [bp-8] |
1776 | endcmpfloat(); |
1779 | endcmpfloat(); |
1777 | } |
1780 | } |
1778 | } |
1781 | } |
1779 | else{ |
1782 | else{ |
1780 | if(swapped)err=1; |
1783 | if(swapped)err=1; |
1781 | else return(outcmp(1,ctok2,cstok2,cbuf2,cstr2,ctok,cstok,cbuf,cstr,typet)); |
1784 | else return(outcmp(1,ctok2,cstok2,cbuf2,cstr2,ctok,cstok,cbuf,cstr,typet)); |
1782 | } |
1785 | } |
1783 | break; |
1786 | break; |
1784 | case tk_postnumber: |
1787 | case tk_postnumber: |
1785 | if(ctok2==tk_number||ctok2==tk_postnumber){ |
1788 | if(ctok2==tk_number||ctok2==tk_postnumber){ |
1786 | op(0xB8); /* MOV AX,# */ |
1789 | op(0xB8); /* MOV AX,# */ |
1787 | (cstok->flag&f_extern)==0?setwordpost(cstok):setwordext(&cstok->number); |
1790 | (cstok->flag&f_extern)==0?setwordpost(cstok):setwordext(&cstok->number); |
1788 | if(am32==FALSE)outword((unsigned int)cstok->number); |
1791 | if(am32==FALSE)outword((unsigned int)cstok->number); |
1789 | else outdword(cstok->number); |
1792 | else outdword(cstok->number); |
1790 | op(0x3D); /* CMP AX,# */ |
1793 | op(0x3D); /* CMP AX,# */ |
1791 | if(ctok2==tk_postnumber)(cstok2->flag&f_extern)==0?setwordpost(cstok2):setwordext(&cstok2->number); |
1794 | if(ctok2==tk_postnumber)(cstok2->flag&f_extern)==0?setwordpost(cstok2):setwordext(&cstok2->number); |
1792 | else if((cstok2->flag&f_reloc)!=0)AddReloc(cstok2->segm); |
1795 | else if((cstok2->flag&f_reloc)!=0)AddReloc(cstok2->segm); |
1793 | if(am32==FALSE)outword((unsigned int)cstok2->number); |
1796 | if(am32==FALSE)outword((unsigned int)cstok2->number); |
1794 | else outdword(cstok2->number); |
1797 | else outdword(cstok2->number); |
1795 | } |
1798 | } |
1796 | else{ |
1799 | else{ |
1797 | if(swapped)err=1; |
1800 | if(swapped)err=1; |
1798 | else return(outcmp(1,ctok2,cstok2,cbuf2,cstr2,ctok,cstok,cbuf,cstr,typet)); |
1801 | else return(outcmp(1,ctok2,cstok2,cbuf2,cstr2,ctok,cstok,cbuf,cstr,typet)); |
1799 | } |
1802 | } |
1800 | break; |
1803 | break; |
1801 | case tk_charvar: |
1804 | case tk_charvar: |
1802 | case tk_bytevar: |
1805 | case tk_bytevar: |
1803 | switch(ctok2){ |
1806 | switch(ctok2){ |
1804 | case tk_number: |
1807 | case tk_number: |
1805 | CheckAllMassiv(cbuf,1,cstr,cstok); |
1808 | CheckAllMassiv(cbuf,1,cstr,cstok); |
1806 | outseg(cstok,2); |
1809 | outseg(cstok,2); |
1807 | op(0x80); /* CMP [byte],# */ |
1810 | op(0x80); /* CMP [byte],# */ |
1808 | op(0x38+cstok->rm); |
1811 | op(0x38+cstok->rm); |
1809 | outaddress(cstok); |
1812 | outaddress(cstok); |
1810 | op((unsigned int)cstok2->number); |
1813 | op((unsigned int)cstok2->number); |
1811 | break; |
1814 | break; |
1812 | case tk_reg: |
1815 | case tk_reg: |
1813 | case tk_reg32: |
1816 | case tk_reg32: |
1814 | if(cstok2->number>3)goto defchar; |
1817 | if(cstok2->number>3)goto defchar; |
1815 | case tk_beg: |
1818 | case tk_beg: |
1816 | CheckAllMassiv(cbuf,1,cstr,cstok); |
1819 | CheckAllMassiv(cbuf,1,cstr,cstok); |
1817 | outseg(cstok,2); |
1820 | outseg(cstok,2); |
1818 | op(0x38); /* CMP [byte],beg */ |
1821 | op(0x38); /* CMP [byte],beg */ |
1819 | op((unsigned int)cstok2->number*8+cstok->rm); |
1822 | op((unsigned int)cstok2->number*8+cstok->rm); |
1820 | outaddress(cstok); |
1823 | outaddress(cstok); |
1821 | break; |
1824 | break; |
1822 | default: |
1825 | default: |
1823 | defchar: |
1826 | defchar: |
1824 | getintoal(ctok2,cstok2,cbuf2,cstr2); |
1827 | getintoal(ctok2,cstok2,cbuf2,cstr2); |
1825 | CheckAllMassiv(cbuf,1,cstr,cstok); |
1828 | CheckAllMassiv(cbuf,1,cstr,cstok); |
1826 | outseg(cstok,2); |
1829 | outseg(cstok,2); |
1827 | op(0x38); /* CMP [byte],AL */ |
1830 | op(0x38); /* CMP [byte],AL */ |
1828 | op(cstok->rm); |
1831 | op(cstok->rm); |
1829 | outaddress(cstok); |
1832 | outaddress(cstok); |
1830 | break; |
1833 | break; |
1831 | } |
1834 | } |
1832 | break; |
1835 | break; |
1833 | case tk_beg: |
1836 | case tk_beg: |
1834 | switch(ctok2){ |
1837 | switch(ctok2){ |
1835 | case tk_number: |
1838 | case tk_number: |
1836 | if(cstok2->number==0){ |
1839 | if(cstok2->number==0){ |
1837 | op(0x84); //test beg,beg |
1840 | op(0x84); //test beg,beg |
1838 | op(0xc0+(unsigned int)cstok->number*9); |
1841 | op(0xc0+(unsigned int)cstok->number*9); |
1839 | break; |
1842 | break; |
1840 | } |
1843 | } |
1841 | if((unsigned int)cstok->number==AL)op(0x3C); |
1844 | if((unsigned int)cstok->number==AL)op(0x3C); |
1842 | else{ |
1845 | else{ |
1843 | op(0x80); |
1846 | op(0x80); |
1844 | op(0xF8+(unsigned int)cstok->number); |
1847 | op(0xF8+(unsigned int)cstok->number); |
1845 | } |
1848 | } |
1846 | op((unsigned int)cstok2->number); |
1849 | op((unsigned int)cstok2->number); |
1847 | break; |
1850 | break; |
1848 | case tk_beg: |
1851 | case tk_beg: |
1849 | op(0x38); |
1852 | op(0x38); |
1850 | op(0xC0+(unsigned int)cstok->number+(unsigned int)cstok2->number*8); |
1853 | op(0xC0+(unsigned int)cstok->number+(unsigned int)cstok2->number*8); |
1851 | break; |
1854 | break; |
1852 | case tk_reg: |
1855 | case tk_reg: |
1853 | if((unsigned int)cstok2->number<=BX){ /* CMP beg,beg */ |
1856 | if((unsigned int)cstok2->number<=BX){ /* CMP beg,beg */ |
1854 | op(0x38); |
1857 | op(0x38); |
1855 | op(0xC0+(unsigned int)cstok->number+(unsigned int)cstok2->number*8); |
1858 | op(0xC0+(unsigned int)cstok->number+(unsigned int)cstok2->number*8); |
1856 | } |
1859 | } |
1857 | else{ |
1860 | else{ |
1858 | op66(r16); |
1861 | op66(r16); |
1859 | op(0x89); /* MOV AX,reg */ |
1862 | op(0x89); /* MOV AX,reg */ |
1860 | op(0xC0+(unsigned int)cstok2->number*8); |
1863 | op(0xC0+(unsigned int)cstok2->number*8); |
1861 | op(0x38); /* CMP beg,AL */ |
1864 | op(0x38); /* CMP beg,AL */ |
1862 | op(0xC0+(unsigned int)cstok->number); |
1865 | op(0xC0+(unsigned int)cstok->number); |
1863 | } |
1866 | } |
1864 | break; |
1867 | break; |
1865 | default: |
1868 | default: |
1866 | if(swapped)err=1; |
1869 | if(swapped)err=1; |
1867 | else return(outcmp(1,ctok2,cstok2,cbuf2,cstr2,ctok,cstok,cbuf,cstr,typet)); |
1870 | else return(outcmp(1,ctok2,cstok2,cbuf2,cstr2,ctok,cstok,cbuf,cstr,typet)); |
1868 | break; |
1871 | break; |
1869 | } |
1872 | } |
1870 | break; |
1873 | break; |
1871 | case tk_doublevar: |
1874 | case tk_doublevar: |
1872 | vop=4; |
1875 | vop=4; |
1873 | goto cont_float; |
1876 | goto cont_float; |
1874 | case tk_fpust: |
1877 | case tk_fpust: |
1875 | typef++; |
1878 | typef++; |
1876 | if(cstok->type==tp_modif)typef++; |
1879 | if(cstok->type==tp_modif)typef++; |
1877 | else{ |
1880 | else{ |
1878 | if(cstok->number!=0){ |
1881 | if(cstok->number!=0){ |
1879 | op(0xd9); //fld st(x) |
1882 | op(0xd9); //fld st(x) |
1880 | op(0xC0+cstok->number); |
1883 | op(0xC0+cstok->number); |
1881 | typef++; |
1884 | typef++; |
1882 | } |
1885 | } |
1883 | } |
1886 | } |
1884 | case tk_floatvar: |
1887 | case tk_floatvar: |
1885 | cont_float: |
1888 | cont_float: |
1886 | switch(ctok2){ |
1889 | switch(ctok2){ |
1887 | case tk_beg: |
1890 | case tk_beg: |
1888 | CheckInitBP(); |
1891 | CheckInitBP(); |
1889 | switch(cstok2->rm){ |
1892 | switch(cstok2->rm){ |
1890 | case tk_char: |
1893 | case tk_char: |
1891 | case tk_int: |
1894 | case tk_int: |
1892 | case tk_long: |
1895 | case tk_long: |
1893 | outword(0xBE0F); /* MOVSX AX,beg */ |
1896 | outword(0xBE0F); /* MOVSX AX,beg */ |
1894 | op(0xC0+(unsigned int)cstok2->number); |
1897 | op(0xC0+(unsigned int)cstok2->number); |
1895 | break; |
1898 | break; |
1896 | default: |
1899 | default: |
1897 | if((optimizespeed&&chip>3&&chip<7)||cstok2->number==AL){ |
1900 | if((optimizespeed&&chip>3&&chip<7)||cstok2->number==AL){ |
1898 | xorAHAH(); |
1901 | xorAHAH(); |
1899 | if(cstok2->number!=AL){ |
1902 | if(cstok2->number!=AL){ |
1900 | op(0x88); |
1903 | op(0x88); |
1901 | op(0xC0+cstok2->number*8); //mov al,beg |
1904 | op(0xC0+cstok2->number*8); //mov al,beg |
1902 | } |
1905 | } |
1903 | } |
1906 | } |
1904 | else{ |
1907 | else{ |
1905 | outword(0xB60F); // MOVZX AX,beg |
1908 | outword(0xB60F); // MOVZX AX,beg |
1906 | op(0xC0+(unsigned int)cstok2->number); |
1909 | op(0xC0+(unsigned int)cstok2->number); |
1907 | } |
1910 | } |
1908 | break; |
1911 | break; |
1909 | } |
1912 | } |
1910 | outword(0xDF50); //push AX |
1913 | outword(0xDF50); //push AX |
1911 | fld_stack(2+localsize); |
1914 | fld_stack(2+localsize); |
1912 | if(typef==2)outword(0xD9DE); //FCOMPP |
1915 | if(typef==2)outword(0xD9DE); //FCOMPP |
1913 | else if(typef==1)outword(0xD9D8); //FCOMP |
1916 | else if(typef==1)outword(0xD9D8); //FCOMP |
1914 | else{ |
1917 | else{ |
1915 | if(ESPloc&&am32&&cstok->segm==SS)cstok->number+=4; |
1918 | if(ESPloc&&am32&&cstok->segm==SS)cstok->number+=4; |
1916 | CheckAllMassiv(cbuf,4+vop,cstr,cstok); |
1919 | CheckAllMassiv(cbuf,4+vop,cstr,cstok); |
1917 | outseg(cstok,2); //fcomp var |
1920 | outseg(cstok,2); //fcomp var |
1918 | op(0xd8+vop); |
1921 | op(0xd8+vop); |
1919 | op(cstok->rm+0x18); |
1922 | op(cstok->rm+0x18); |
1920 | outaddress(cstok); |
1923 | outaddress(cstok); |
1921 | } |
1924 | } |
1922 | op(0x58); // pop EAX |
1925 | op(0x58); // pop EAX |
1923 | endcmpfloat(); |
1926 | endcmpfloat(); |
1924 | swapped=1; |
1927 | swapped=1; |
1925 | break; |
1928 | break; |
1926 | case tk_reg: |
1929 | case tk_reg: |
1927 | CheckInitBP(); |
1930 | CheckInitBP(); |
1928 | op66(r32); |
1931 | op66(r32); |
1929 | switch(cstok2->rm){ |
1932 | switch(cstok2->rm){ |
1930 | case tk_char: |
1933 | case tk_char: |
1931 | case tk_int: |
1934 | case tk_int: |
1932 | case tk_long: |
1935 | case tk_long: |
1933 | outword(0xBF0F); /* MOVSX EAX,reg */ |
1936 | outword(0xBF0F); /* MOVSX EAX,reg */ |
1934 | break; |
1937 | break; |
1935 | default: |
1938 | default: |
1936 | if(optimizespeed&&chip>3&&chip<7&&cstok2->number!=AX){ |
1939 | if(optimizespeed&&chip>3&&chip<7&&cstok2->number!=AX){ |
1937 | outword(0xC031); // xor EAX,EAX |
1940 | outword(0xC031); // xor EAX,EAX |
1938 | op66(r16); |
1941 | op66(r16); |
1939 | op(0x8B); |
1942 | op(0x8B); |
1940 | } |
1943 | } |
1941 | else outword(0xB70F); // MOVZX EAX,reg |
1944 | else outword(0xB70F); // MOVZX EAX,reg |
1942 | break; |
1945 | break; |
1943 | } |
1946 | } |
1944 | op(0xC0+(unsigned int)cstok2->number); |
1947 | op(0xC0+(unsigned int)cstok2->number); |
1945 | op66(r32); |
1948 | op66(r32); |
1946 | outword(0xDB50); //push EAX |
1949 | outword(0xDB50); //push EAX |
1947 | fld_stack(4+localsize); |
1950 | fld_stack(4+localsize); |
1948 | if(typef==2)outword(0xD9DE); //FCOMPP |
1951 | if(typef==2)outword(0xD9DE); //FCOMPP |
1949 | else if(typef==1)outword(0xD9D8); //FCOMP |
1952 | else if(typef==1)outword(0xD9D8); //FCOMP |
1950 | else{ |
1953 | else{ |
1951 | if(ESPloc&&am32&&cstok->segm==SS)cstok->number+=4; |
1954 | if(ESPloc&&am32&&cstok->segm==SS)cstok->number+=4; |
1952 | CheckAllMassiv(cbuf,4+vop,cstr,cstok); |
1955 | CheckAllMassiv(cbuf,4+vop,cstr,cstok); |
1953 | outseg(cstok,2); //fcomp var |
1956 | outseg(cstok,2); //fcomp var |
1954 | op(0xd8+vop); |
1957 | op(0xd8+vop); |
1955 | op(cstok->rm+0x18); |
1958 | op(cstok->rm+0x18); |
1956 | outaddress(cstok); |
1959 | outaddress(cstok); |
1957 | } |
1960 | } |
1958 | op66(r32); |
1961 | op66(r32); |
1959 | op(0x58); // pop EAX |
1962 | op(0x58); // pop EAX |
1960 | endcmpfloat(); |
1963 | endcmpfloat(); |
1961 | swapped=1; |
1964 | swapped=1; |
1962 | break; |
1965 | break; |
1963 | case tk_reg32: |
1966 | case tk_reg32: |
1964 | CheckInitBP(); |
1967 | CheckInitBP(); |
1965 | if(cstok2->rm==tk_float){ |
1968 | if(cstok2->rm==tk_float){ |
1966 | op66(r32); |
1969 | op66(r32); |
1967 | op(0x50+(unsigned int)cstok2->number); //push reg32 |
1970 | op(0x50+(unsigned int)cstok2->number); //push reg32 |
1968 | op(0xd9); |
1971 | op(0xd9); |
1969 | fld_stack(4+localsize); |
1972 | fld_stack(4+localsize); |
1970 | if(typef==2)outword(0xD9DE); //FCOMPP |
1973 | if(typef==2)outword(0xD9DE); //FCOMPP |
1971 | else if(typef==1)outword(0xD9D8); //FCOMP |
1974 | else if(typef==1)outword(0xD9D8); //FCOMP |
1972 | else{ |
1975 | else{ |
1973 | if(ESPloc&&am32&&cstok->segm==SS)cstok->number+=4; |
1976 | if(ESPloc&&am32&&cstok->segm==SS)cstok->number+=4; |
1974 | CheckAllMassiv(cbuf,4+vop,cstr,cstok); |
1977 | CheckAllMassiv(cbuf,4+vop,cstr,cstok); |
1975 | outseg(cstok,2); //fcomp var |
1978 | outseg(cstok,2); //fcomp var |
1976 | op(0xd8+vop); |
1979 | op(0xd8+vop); |
1977 | op(cstok->rm+0x18); |
1980 | op(cstok->rm+0x18); |
1978 | outaddress(cstok); |
1981 | outaddress(cstok); |
1979 | } |
1982 | } |
1980 | op66(r32); |
1983 | op66(r32); |
1981 | op(0x58); // pop EAX |
1984 | op(0x58); // pop EAX |
1982 | } |
1985 | } |
1983 | else{ |
1986 | else{ |
1984 | if(cstok2->rm!=tk_char&&cstok2->rm!=tk_int&&cstok2->rm!=tk_long){ |
1987 | if(cstok2->rm!=tk_char&&cstok2->rm!=tk_int&&cstok2->rm!=tk_long){ |
1985 | typet=tk_word; |
1988 | typet=tk_word; |
1986 | op66(r32); |
1989 | op66(r32); |
1987 | outword(0x6a); //$push 0 |
1990 | outword(0x6a); //$push 0 |
1988 | if(ESPloc&&am32&&cstok->segm==SS)cstok->number+=4; |
1991 | if(ESPloc&&am32&&cstok->segm==SS)cstok->number+=4; |
1989 | } |
1992 | } |
1990 | op66(r32); |
1993 | op66(r32); |
1991 | op(0x50+cstok2->number); //push reg32 |
1994 | op(0x50+cstok2->number); //push reg32 |
1992 | if(typet!=r16)fildq_stack(); |
1995 | if(typet!=r16)fildq_stack(); |
1993 | else{ |
1996 | else{ |
1994 | op(0xdb); |
1997 | op(0xdb); |
1995 | fld_stack(4+localsize); |
1998 | fld_stack(4+localsize); |
1996 | } |
1999 | } |
1997 | if(typef==2)outword(0xD9DE); //FCOMPP |
2000 | if(typef==2)outword(0xD9DE); //FCOMPP |
1998 | else if(typef==1)outword(0xD9D8); //FCOMP |
2001 | else if(typef==1)outword(0xD9D8); //FCOMP |
1999 | else{ |
2002 | else{ |
2000 | if(ESPloc&&am32&&cstok->segm==SS)cstok->number+=4; |
2003 | if(ESPloc&&am32&&cstok->segm==SS)cstok->number+=4; |
2001 | CheckAllMassiv(cbuf,4+vop,cstr,cstok); |
2004 | CheckAllMassiv(cbuf,4+vop,cstr,cstok); |
2002 | outseg(cstok,2); //fcomp var |
2005 | outseg(cstok,2); //fcomp var |
2003 | op(0xd8+vop); |
2006 | op(0xd8+vop); |
2004 | op(cstok->rm+0x18); |
2007 | op(cstok->rm+0x18); |
2005 | outaddress(cstok); |
2008 | outaddress(cstok); |
2006 | } |
2009 | } |
2007 | if(typet!=r16){ |
2010 | if(typet!=r16){ |
2008 | if(optimizespeed||am32==FALSE){ |
2011 | if(optimizespeed||am32==FALSE){ |
2009 | outword(0xC483); |
2012 | outword(0xC483); |
2010 | op(8); |
2013 | op(8); |
2011 | } |
2014 | } |
2012 | else{ |
2015 | else{ |
2013 | op(0x58); // pop EAX |
2016 | op(0x58); // pop EAX |
2014 | op(0x58); // pop EAX |
2017 | op(0x58); // pop EAX |
2015 | } |
2018 | } |
2016 | } |
2019 | } |
2017 | else{ |
2020 | else{ |
2018 | op66(r32); |
2021 | op66(r32); |
2019 | op(0x58); // pop EAX |
2022 | op(0x58); // pop EAX |
2020 | } |
2023 | } |
2021 | } |
2024 | } |
2022 | endcmpfloat(); |
2025 | endcmpfloat(); |
2023 | swapped=1; |
2026 | swapped=1; |
2024 | break; |
2027 | break; |
2025 | case tk_charvar: |
2028 | case tk_charvar: |
2026 | CheckAllMassiv(cbuf2,1,cstr2,cstok2); |
2029 | CheckAllMassiv(cbuf2,1,cstr2,cstok2); |
2027 | outseg(cstok2,3); /* MOVSX AX,[charvar] */ |
2030 | outseg(cstok2,3); /* MOVSX AX,[charvar] */ |
2028 | outword(0xBE0F); op(cstok2->rm); |
2031 | outword(0xBE0F); op(cstok2->rm); |
2029 | outaddress(cstok2); |
2032 | outaddress(cstok2); |
2030 | CheckInitBP(); |
2033 | CheckInitBP(); |
2031 | outword(0xdf50); //push ax |
2034 | outword(0xdf50); //push ax |
2032 | fld_stack(2+localsize); |
2035 | fld_stack(2+localsize); |
2033 | if(typef==2)outword(0xD9DE); //FCOMPP |
2036 | if(typef==2)outword(0xD9DE); //FCOMPP |
2034 | else if(typef==1)outword(0xD9D8); //FCOMP |
2037 | else if(typef==1)outword(0xD9D8); //FCOMP |
2035 | else{ |
2038 | else{ |
2036 | if(ESPloc&&am32&&cstok->segm==SS)cstok->number+=4; |
2039 | if(ESPloc&&am32&&cstok->segm==SS)cstok->number+=4; |
2037 | CheckAllMassiv(cbuf,4+vop,cstr,cstok); |
2040 | CheckAllMassiv(cbuf,4+vop,cstr,cstok); |
2038 | outseg(cstok,2); //fcomp var |
2041 | outseg(cstok,2); //fcomp var |
2039 | op(0xd8+vop); |
2042 | op(0xd8+vop); |
2040 | op(cstok->rm+0x18); |
2043 | op(cstok->rm+0x18); |
2041 | outaddress(cstok); |
2044 | outaddress(cstok); |
2042 | } |
2045 | } |
2043 | op(0x58); // pop EAX |
2046 | op(0x58); // pop EAX |
2044 | endcmpfloat(); |
2047 | endcmpfloat(); |
2045 | swapped=1; |
2048 | swapped=1; |
2046 | break; |
2049 | break; |
2047 | case tk_intvar: |
2050 | case tk_intvar: |
2048 | CheckAllMassiv(cbuf2,2,cstr2,cstok2); |
2051 | CheckAllMassiv(cbuf2,2,cstr2,cstok2); |
2049 | outseg(cstok2,2); |
2052 | outseg(cstok2,2); |
2050 | if(typef){ |
2053 | if(typef){ |
2051 | op(0xDE); //ficomp var2 |
2054 | op(0xDE); //ficomp var2 |
2052 | op(cstok2->rm+0x08+typef*8); |
2055 | op(cstok2->rm+0x08+typef*8); |
2053 | outaddress(cstok2); |
2056 | outaddress(cstok2); |
2054 | } |
2057 | } |
2055 | else{ |
2058 | else{ |
2056 | op(0xdf); //fild var |
2059 | op(0xdf); //fild var |
2057 | op(cstok2->rm); |
2060 | op(cstok2->rm); |
2058 | outaddress(cstok2); |
2061 | outaddress(cstok2); |
2059 | CheckAllMassiv(cbuf,4+vop,cstr,cstok); |
2062 | CheckAllMassiv(cbuf,4+vop,cstr,cstok); |
2060 | outseg(cstok,2); //fcomp var |
2063 | outseg(cstok,2); //fcomp var |
2061 | op(0xd8+vop); |
2064 | op(0xd8+vop); |
2062 | op(cstok->rm+0x18); |
2065 | op(cstok->rm+0x18); |
2063 | outaddress(cstok); |
2066 | outaddress(cstok); |
2064 | swapped=1; |
2067 | swapped=1; |
2065 | } |
2068 | } |
2066 | fwait3_4(); |
2069 | fwait3_4(); |
2067 | outword(0xE0DF);//fstsw ax |
2070 | outword(0xE0DF);//fstsw ax |
2068 | op(0x9E); |
2071 | op(0x9E); |
2069 | break; |
2072 | break; |
2070 | case tk_bytevar: |
2073 | case tk_bytevar: |
2071 | CheckAllMassiv(cbuf2,1,cstr2,cstok2); |
2074 | CheckAllMassiv(cbuf2,1,cstr2,cstok2); |
2072 | if(optimizespeed&&chip>3&&chip<7){ |
2075 | if(optimizespeed&&chip>3&&chip<7){ |
2073 | outword(0xC031); |
2076 | outword(0xC031); |
2074 | outseg(cstok2,2); |
2077 | outseg(cstok2,2); |
2075 | op(0x8A); |
2078 | op(0x8A); |
2076 | } |
2079 | } |
2077 | else{ |
2080 | else{ |
2078 | outseg(cstok2,3); |
2081 | outseg(cstok2,3); |
2079 | outword(0xB60F); |
2082 | outword(0xB60F); |
2080 | } |
2083 | } |
2081 | op(cstok2->rm); // MOVZX regL,[byte] |
2084 | op(cstok2->rm); // MOVZX regL,[byte] |
2082 | outaddress(cstok2); |
2085 | outaddress(cstok2); |
2083 | CheckInitBP(); |
2086 | CheckInitBP(); |
2084 | outword(0xDF50); //push ax |
2087 | outword(0xDF50); //push ax |
2085 | fld_stack(2+localsize); |
2088 | fld_stack(2+localsize); |
2086 | if(typef==2)outword(0xD9DE); //FCOMPP |
2089 | if(typef==2)outword(0xD9DE); //FCOMPP |
2087 | else if(typef==1)outword(0xD9D8); //FCOMP |
2090 | else if(typef==1)outword(0xD9D8); //FCOMP |
2088 | else{ |
2091 | else{ |
2089 | if(ESPloc&&am32&&cstok->segm==SS)cstok->number+=4; |
2092 | if(ESPloc&&am32&&cstok->segm==SS)cstok->number+=4; |
2090 | CheckAllMassiv(cbuf,4+vop,cstr,cstok); |
2093 | CheckAllMassiv(cbuf,4+vop,cstr,cstok); |
2091 | outseg(cstok,2); //fcomp var |
2094 | outseg(cstok,2); //fcomp var |
2092 | op(0xd8+vop); |
2095 | op(0xd8+vop); |
2093 | op(cstok->rm+0x18); |
2096 | op(cstok->rm+0x18); |
2094 | outaddress(cstok); |
2097 | outaddress(cstok); |
2095 | } |
2098 | } |
2096 | op(0x58); // pop EAX |
2099 | op(0x58); // pop EAX |
2097 | endcmpfloat(); |
2100 | endcmpfloat(); |
2098 | swapped=1; |
2101 | swapped=1; |
2099 | break; |
2102 | break; |
2100 | case tk_wordvar: |
2103 | case tk_wordvar: |
2101 | CheckInitBP(); |
2104 | CheckInitBP(); |
2102 | op66(r16); |
2105 | op66(r16); |
2103 | outword(0x6a); //push 0 |
2106 | outword(0x6a); //push 0 |
2104 | CheckAllMassiv(cbuf2,2,cstr2,cstok2); |
2107 | CheckAllMassiv(cbuf2,2,cstr2,cstok2); |
2105 | op66(r16); |
2108 | op66(r16); |
2106 | outseg(cstok2,2); //push var |
2109 | outseg(cstok2,2); //push var |
2107 | op(0xFF); |
2110 | op(0xFF); |
2108 | op(cstok2->rm+0x30); |
2111 | op(cstok2->rm+0x30); |
2109 | outaddress(cstok2); |
2112 | outaddress(cstok2); |
2110 | op(0xDB); |
2113 | op(0xDB); |
2111 | fld_stack(4+localsize); |
2114 | fld_stack(4+localsize); |
2112 | if(typef==2)outword(0xD9DE); //FCOMPP |
2115 | if(typef==2)outword(0xD9DE); //FCOMPP |
2113 | else if(typef==1)outword(0xD9D8); //FCOMP |
2116 | else if(typef==1)outword(0xD9D8); //FCOMP |
2114 | else{ |
2117 | else{ |
2115 | if(ESPloc&&am32&&cstok->segm==SS)cstok->number+=4; |
2118 | if(ESPloc&&am32&&cstok->segm==SS)cstok->number+=4; |
2116 | CheckAllMassiv(cbuf,4+vop,cstr,cstok); |
2119 | CheckAllMassiv(cbuf,4+vop,cstr,cstok); |
2117 | outseg(cstok,2); //fcomp var |
2120 | outseg(cstok,2); //fcomp var |
2118 | op(0xd8+vop); |
2121 | op(0xd8+vop); |
2119 | op(cstok->rm+0x18); |
2122 | op(cstok->rm+0x18); |
2120 | outaddress(cstok); |
2123 | outaddress(cstok); |
2121 | } |
2124 | } |
2122 | op66(r32); |
2125 | op66(r32); |
2123 | op(0x58); // pop EAX |
2126 | op(0x58); // pop EAX |
2124 | endcmpfloat(); |
2127 | endcmpfloat(); |
2125 | swapped=1; |
2128 | swapped=1; |
2126 | break; |
2129 | break; |
2127 | case tk_dwordvar: |
2130 | case tk_dwordvar: |
2128 | CheckInitBP(); |
2131 | CheckInitBP(); |
2129 | op66(r32); //push 0L |
2132 | op66(r32); //push 0L |
2130 | outword(0x6a); |
2133 | outword(0x6a); |
2131 | CheckAllMassiv(cbuf2,4,cstr2,cstok2); |
2134 | CheckAllMassiv(cbuf2,4,cstr2,cstok2); |
2132 | op66(r32); //push var |
2135 | op66(r32); //push var |
2133 | outseg(cstok2,2); |
2136 | outseg(cstok2,2); |
2134 | op(0xFF); |
2137 | op(0xFF); |
2135 | op(cstok2->rm+0x30); |
2138 | op(cstok2->rm+0x30); |
2136 | outaddress(cstok2); |
2139 | outaddress(cstok2); |
2137 | fildq_stack(); |
2140 | fildq_stack(); |
2138 | if(typef==2)outword(0xD9DE); //FCOMPP |
2141 | if(typef==2)outword(0xD9DE); //FCOMPP |
2139 | else if(typef==1)outword(0xD9D8); //FCOMP |
2142 | else if(typef==1)outword(0xD9D8); //FCOMP |
2140 | else{ |
2143 | else{ |
2141 | if(ESPloc&&am32&&cstok->segm==SS)cstok->number+=8; |
2144 | if(ESPloc&&am32&&cstok->segm==SS)cstok->number+=8; |
2142 | CheckAllMassiv(cbuf,4+vop,cstr,cstok); |
2145 | CheckAllMassiv(cbuf,4+vop,cstr,cstok); |
2143 | outseg(cstok,2); //fcomp var |
2146 | outseg(cstok,2); //fcomp var |
2144 | op(0xd8+vop); |
2147 | op(0xd8+vop); |
2145 | op(cstok->rm+0x18); |
2148 | op(cstok->rm+0x18); |
2146 | outaddress(cstok); |
2149 | outaddress(cstok); |
2147 | } |
2150 | } |
2148 | if(optimizespeed||am32==FALSE){ |
2151 | if(optimizespeed||am32==FALSE){ |
2149 | outword(0xC483); |
2152 | outword(0xC483); |
2150 | op(8); |
2153 | op(8); |
2151 | } |
2154 | } |
2152 | else{ |
2155 | else{ |
2153 | op(0x58); // pop EAX |
2156 | op(0x58); // pop EAX |
2154 | op(0x58); // pop EAX |
2157 | op(0x58); // pop EAX |
2155 | } |
2158 | } |
2156 | endcmpfloat(); |
2159 | endcmpfloat(); |
2157 | swapped=1; |
2160 | swapped=1; |
2158 | break; |
2161 | break; |
2159 | case tk_longvar: |
2162 | case tk_longvar: |
2160 | CheckAllMassiv(cbuf2,4,cstr2,cstok2); |
2163 | CheckAllMassiv(cbuf2,4,cstr2,cstok2); |
2161 | outseg(cstok2,2); |
2164 | outseg(cstok2,2); |
2162 | if(typef){ |
2165 | if(typef){ |
2163 | op(0xDA); //ficomp var2 |
2166 | op(0xDA); //ficomp var2 |
2164 | op(cstok2->rm+0x08+typef*8); |
2167 | op(cstok2->rm+0x08+typef*8); |
2165 | outaddress(cstok2); |
2168 | outaddress(cstok2); |
2166 | } |
2169 | } |
2167 | else{ |
2170 | else{ |
2168 | op(0xdb); //fild var |
2171 | op(0xdb); //fild var |
2169 | op(cstok2->rm); |
2172 | op(cstok2->rm); |
2170 | outaddress(cstok2); |
2173 | outaddress(cstok2); |
2171 | CheckAllMassiv(cbuf,4+vop,cstr,cstok); |
2174 | CheckAllMassiv(cbuf,4+vop,cstr,cstok); |
2172 | outseg(cstok,2); //fcomp var |
2175 | outseg(cstok,2); //fcomp var |
2173 | op(0xd8+vop); |
2176 | op(0xd8+vop); |
2174 | op(cstok->rm+0x18); |
2177 | op(cstok->rm+0x18); |
2175 | outaddress(cstok); |
2178 | outaddress(cstok); |
2176 | swapped=1; |
2179 | swapped=1; |
2177 | } |
2180 | } |
2178 | endcmpfloat(); |
2181 | endcmpfloat(); |
2179 | break; |
2182 | break; |
2180 | case tk_number: |
2183 | case tk_number: |
2181 | if(!typef){ |
2184 | if(!typef){ |
2182 | CheckAllMassiv(cbuf,4,cstr,cstok); |
2185 | CheckAllMassiv(cbuf,4,cstr,cstok); |
2183 | outseg(cstok,2); //fld val |
2186 | outseg(cstok,2); //fld val |
2184 | op(0xd9); |
2187 | op(0xd9); |
2185 | op(cstok->rm); |
2188 | op(cstok->rm); |
2186 | outaddress(cstok); |
2189 | outaddress(cstok); |
2187 | } |
2190 | } |
2188 | if(cstok2->rm!=tk_double&&cstok2->rm!=tk_float){ |
2191 | if(cstok2->rm!=tk_double&&cstok2->rm!=tk_float){ |
2189 | cstok2->dnumber=cstok2->lnumber; |
2192 | cstok2->dnumber=cstok2->lnumber; |
2190 | cstok2->rm=tk_double; |
2193 | cstok2->rm=tk_double; |
2191 | } |
2194 | } |
2192 | else if(vop==4&&cstok2->rm==tk_float){ |
2195 | else if(vop==4&&cstok2->rm==tk_float){ |
2193 | cstok2->dnumber=cstok2->fnumber; |
2196 | cstok2->dnumber=cstok2->fnumber; |
2194 | cstok2->rm=tk_double; |
2197 | cstok2->rm=tk_double; |
2195 | } |
2198 | } |
2196 | if(am32&&(cstok2->rm==tk_float&&cstok2->fnumber==0.0)|| |
2199 | if(am32&&(cstok2->rm==tk_float&&cstok2->fnumber==0.0)|| |
2197 | (cstok2->rm==tk_double&&cstok2->dnumber==0.0)||cstok2->lnumber==0){ |
2200 | (cstok2->rm==tk_double&&cstok2->dnumber==0.0)||cstok2->lnumber==0){ |
2198 | outword(0xe4d9); //ftst |
2201 | outword(0xe4d9); //ftst |
2199 | if(typef!=1)outword(0xC0DD); //ffree |
2202 | if(typef!=1)outword(0xC0DD); //ffree |
2200 | } |
2203 | } |
2201 | else{ |
2204 | else{ |
2202 | op66(r32); |
2205 | op66(r32); |
2203 | int rm; |
2206 | int rm; |
2204 | rm=(am32==FALSE?0x1eD8:0x1DD8); |
2207 | rm=(am32==FALSE?0x1eD8:0x1DD8); |
2205 | if(typef==1)rm-=0x800; |
2208 | if(typef==1)rm-=0x800; |
2206 | if(cstok2->rm==tk_double||vop==4)rm+=4; |
2209 | if(cstok2->rm==tk_double||vop==4)rm+=4; |
2207 | outword(rm); //fcom(p) |
2210 | outword(rm); //fcom(p) |
2208 | AddFloatConst(cstok2->lnumber,cstok2->rm); |
2211 | AddFloatConst(cstok2->lnumber,cstok2->rm); |
2209 | outword(0); |
2212 | outword(0); |
2210 | if(am32)outword(0); |
2213 | if(am32)outword(0); |
2211 | } |
2214 | } |
2212 | endcmpfloat(); |
2215 | endcmpfloat(); |
2213 | break; |
2216 | break; |
2214 | case tk_floatvar: |
2217 | case tk_floatvar: |
2215 | if(!typef){ |
2218 | if(!typef){ |
2216 | CheckAllMassiv(cbuf,4+vop,cstr,cstok); |
2219 | CheckAllMassiv(cbuf,4+vop,cstr,cstok); |
2217 | outseg(cstok,2); //fld val |
2220 | outseg(cstok,2); //fld val |
2218 | op(0xd9+vop); |
2221 | op(0xd9+vop); |
2219 | op(cstok->rm); |
2222 | op(cstok->rm); |
2220 | outaddress(cstok); |
2223 | outaddress(cstok); |
2221 | } |
2224 | } |
2222 | CheckAllMassiv(cbuf2,4,cstr2,cstok2); |
2225 | CheckAllMassiv(cbuf2,4,cstr2,cstok2); |
2223 | outseg(cstok2,2); //fcomp var |
2226 | outseg(cstok2,2); //fcomp var |
2224 | op(0xd8); |
2227 | op(0xd8); |
2225 | op(cstok2->rm+(typef==1?0x10:0x18)); |
2228 | op(cstok2->rm+(typef==1?0x10:0x18)); |
2226 | outaddress(cstok2); |
2229 | outaddress(cstok2); |
2227 | endcmpfloat(); |
2230 | endcmpfloat(); |
2228 | break; |
2231 | break; |
2229 | case tk_doublevar: |
2232 | case tk_doublevar: |
2230 | if(!typef){ |
2233 | if(!typef){ |
2231 | CheckAllMassiv(cbuf,4+vop,cstr,cstok); |
2234 | CheckAllMassiv(cbuf,4+vop,cstr,cstok); |
2232 | outseg(cstok,2); //fld val |
2235 | outseg(cstok,2); //fld val |
2233 | op(0xd9+vop); |
2236 | op(0xd9+vop); |
2234 | op(cstok->rm); |
2237 | op(cstok->rm); |
2235 | outaddress(cstok); |
2238 | outaddress(cstok); |
2236 | } |
2239 | } |
2237 | CheckAllMassiv(cbuf2,8,cstr2,cstok2); |
2240 | CheckAllMassiv(cbuf2,8,cstr2,cstok2); |
2238 | outseg(cstok2,2); //fcomp var |
2241 | outseg(cstok2,2); //fcomp var |
2239 | op(0xd8+4); |
2242 | op(0xd8+4); |
2240 | op(cstok2->rm+(typef==1?0x10:0x18)); |
2243 | op(cstok2->rm+(typef==1?0x10:0x18)); |
2241 | outaddress(cstok2); |
2244 | outaddress(cstok2); |
2242 | endcmpfloat(); |
2245 | endcmpfloat(); |
2243 | break; |
2246 | break; |
2244 | case tk_fpust: |
2247 | case tk_fpust: |
2245 | if(typef==2){ //fcomp |
2248 | if(typef==2){ //fcomp |
2246 | if(chip>=7){ //fcomip |
2249 | if(chip>=7){ //fcomip |
2247 | op(0xDF); |
2250 | op(0xDF); |
2248 | op(0xF0+cstok2->number+1); |
2251 | op(0xF0+cstok2->number+1); |
2249 | swapped=1; |
2252 | swapped=1; |
2250 | break; |
2253 | break; |
2251 | } |
2254 | } |
2252 | op(0xD8); |
2255 | op(0xD8); |
2253 | op(0xD8+cstok2->number+1); |
2256 | op(0xD8+cstok2->number+1); |
2254 | } |
2257 | } |
2255 | else if(typef==1){ //fcom |
2258 | else if(typef==1){ //fcom |
2256 | if(chip>=7){ //fcomi |
2259 | if(chip>=7){ //fcomi |
2257 | op(0xDB); |
2260 | op(0xDB); |
2258 | op(0xF0+cstok2->number); |
2261 | op(0xF0+cstok2->number); |
2259 | swapped=1; |
2262 | swapped=1; |
2260 | break; |
2263 | break; |
2261 | } |
2264 | } |
2262 | op(0xD8); |
2265 | op(0xD8); |
2263 | op(0xD0+cstok2->number); |
2266 | op(0xD0+cstok2->number); |
2264 | } |
2267 | } |
2265 | else{ |
2268 | else{ |
2266 | if(cstok2->type!=tp_modif){ |
2269 | if(cstok2->type!=tp_modif){ |
2267 | op(0xd9); //fld st(x) |
2270 | op(0xd9); //fld st(x) |
2268 | op(0xC0+cstok2->number); |
2271 | op(0xC0+cstok2->number); |
2269 | } |
2272 | } |
2270 | CheckAllMassiv(cbuf,4+vop,cstr,cstok); |
2273 | CheckAllMassiv(cbuf,4+vop,cstr,cstok); |
2271 | outseg(cstok,2); //fcomp var |
2274 | outseg(cstok,2); //fcomp var |
2272 | op(0xd8+vop); |
2275 | op(0xd8+vop); |
2273 | op(cstok->rm+0x18); |
2276 | op(cstok->rm+0x18); |
2274 | outaddress(cstok); |
2277 | outaddress(cstok); |
2275 | } |
2278 | } |
2276 | endcmpfloat(); |
2279 | endcmpfloat(); |
2277 | swapped=1; |
2280 | swapped=1; |
2278 | break; |
2281 | break; |
2279 | default: |
2282 | default: |
2280 | err=1; |
2283 | err=1; |
2281 | break; |
2284 | break; |
2282 | } |
2285 | } |
2283 | break; |
2286 | break; |
2284 | default: err=1; break; |
2287 | default: err=1; break; |
2285 | } |
2288 | } |
2286 | if(err)preerror("unable to create comparison, check restrictions"); |
2289 | if(err)preerror("unable to create comparison, check restrictions"); |
2287 | return(swapped); |
2290 | return(swapped); |
2288 | } |
2291 | } |
2289 | 2292 | ||
2290 | int CheckCompareTok(int reg) |
2293 | int CheckCompareTok(int reg) |
2291 | { |
2294 | { |
2292 | int comparetok=tk_equalto; |
2295 | int comparetok=tk_equalto; |
2293 | if(itok.type==tp_compare)comparetok=tok; |
2296 | if(itok.type==tp_compare)comparetok=tok; |
2294 | else unknowncompop(); |
2297 | else unknowncompop(); |
2295 | getoperand(reg); |
2298 | getoperand(reg); |
2296 | return comparetok; |
2299 | return comparetok; |
2297 | } |
2300 | } |
2298 | 2301 | ||
2299 | int typenumber(int vtok) |
2302 | int typenumber(int vtok) |
2300 | { |
2303 | { |
2301 | switch(vtok){ |
2304 | switch(vtok){ |
2302 | case tk_char: |
2305 | case tk_char: |
2303 | case tk_beg: |
2306 | case tk_beg: |
2304 | case tk_byte: |
2307 | case tk_byte: |
2305 | return tk_byte; |
2308 | return tk_byte; |
2306 | case tk_int: |
2309 | case tk_int: |
2307 | case tk_reg: |
2310 | case tk_reg: |
2308 | case tk_word: |
2311 | case tk_word: |
2309 | return tk_word; |
2312 | return tk_word; |
2310 | case tk_reg64: |
2313 | case tk_reg64: |
2311 | case tk_qword: |
2314 | case tk_qword: |
2312 | return tk_qword; |
2315 | return tk_qword; |
2313 | case tk_floatvar: |
2316 | case tk_floatvar: |
2314 | case tk_float: |
2317 | case tk_float: |
2315 | return tk_float; |
2318 | return tk_float; |
2316 | case tk_doublevar: |
2319 | case tk_doublevar: |
2317 | case tk_double: |
2320 | case tk_double: |
2318 | return tk_double; |
2321 | return tk_double; |
2319 | } |
2322 | } |
2320 | return tk_dword; |
2323 | return tk_dword; |
2321 | } |
2324 | } |
2322 | 2325 | ||
2323 | #ifdef OPTVARCONST |
2326 | #ifdef OPTVARCONST |
2324 | int constructcompare(int invertflag,unsigned int startloc,LVIC *comconst) |
2327 | int constructcompare(int invertflag,unsigned int startloc,LVIC *comconst) |
2325 | #else |
2328 | #else |
2326 | int constructcompare(int invertflag,unsigned int startloc) |
2329 | int constructcompare(int invertflag,unsigned int startloc) |
2327 | #endif |
2330 | #endif |
2328 | /* build cmp for IF, if and do {} while */ |
2331 | /* build cmp for IF, if and do {} while */ |
2329 | { |
2332 | { |
2330 | int comparetok=0,jumptype,vartype=tokens,notflag=FALSE; |
2333 | int comparetok=0,jumptype,vartype=tokens,notflag=FALSE; |
2331 | int ittok,ittok2=tokens,type2=tokens;//,retcompare=tokens; |
2334 | int ittok,ittok2=tokens,type2=tokens;//,retcompare=tokens; |
2332 | int razr=r_undef; |
2335 | int razr=r_undef; |
2333 | char *ibuf,*ibuf2; |
2336 | char *ibuf,*ibuf2; |
2334 | ITOK htok,htok2; |
2337 | ITOK htok,htok2; |
2335 | SINFO hstr,hstr2; |
2338 | SINFO hstr,hstr2; |
2336 | int preg=(am32==TRUE?EAX:SI); |
2339 | int preg=(am32==TRUE?EAX:SI); |
2337 | int use_cxz=0; |
2340 | int use_cxz=0; |
2338 | char *ofsstr=NULL,*ofsstr2=NULL; |
2341 | char *ofsstr=NULL,*ofsstr2=NULL; |
2339 | int usereg=-1; |
2342 | int usereg=-1; |
2340 | int usereg2=-1; |
2343 | int usereg2=-1; |
2341 | 2344 | ||
2342 | //////04.10.04 13:45 |
2345 | //////04.10.04 13:45 |
2343 | int bracket=0; |
2346 | int bracket=0; |
2344 | unsigned char oinline=useinline; |
2347 | unsigned char oinline=useinline; |
2345 | useinline=0; |
2348 | useinline=0; |
2346 | do{ |
2349 | do{ |
2347 | nexttok(); |
2350 | nexttok(); |
2348 | // printf("tok=%d tok2=%d\n",tok,tok2); |
2351 | // printf("tok=%d tok2=%d\n",tok,tok2); |
2349 | if(tok==tk_openbracket)bracket++; |
2352 | if(tok==tk_openbracket)bracket++; |
2350 | if(tok==tk_not)notflag=(notflag+1)%2; |
2353 | if(tok==tk_not)notflag=(notflag+1)%2; |
2351 | }while(tok2==tk_openbracket||tok2==tk_not); |
2354 | }while(tok2==tk_openbracket||tok2==tk_not); |
2352 | if(bracket==0)expected('('); |
2355 | if(bracket==0)expected('('); |
2353 | ///////////////// |
2356 | ///////////////// |
2354 | 2357 | ||
2355 | setzeroflag=FALSE; |
2358 | setzeroflag=FALSE; |
2356 | ofsstr=GetLecsem(tk_closebracket,tk_eof,tp_compare); |
2359 | ofsstr=GetLecsem(tk_closebracket,tk_eof,tp_compare); |
2357 | getoperand(); //NEW 04.10.04 13:45 |
2360 | getoperand(); //NEW 04.10.04 13:45 |
2358 | if(tok==tk_openbracket){ |
2361 | if(tok==tk_openbracket){ |
2359 | bracket++; |
2362 | bracket++; |
2360 | getoperand(); |
2363 | getoperand(); |
2361 | } |
2364 | } |
2362 | if(tok==tk_not){ |
2365 | if(tok==tk_not){ |
2363 | notflag=(notflag+1)%2; |
2366 | notflag=(notflag+1)%2; |
2364 | getoperand(); |
2367 | getoperand(); |
2365 | } |
2368 | } |
2366 | switch(tok){ |
2369 | switch(tok){ |
2367 | case tk_closebracket: |
2370 | case tk_closebracket: |
2368 | useinline=oinline; |
2371 | useinline=oinline; |
2369 | getoperand(); |
2372 | getoperand(); |
2370 | return voidcompr; |
2373 | return voidcompr; |
2371 | case tk_asm: |
2374 | case tk_asm: |
2372 | if(tok2==tk_openbrace){ |
2375 | if(tok2==tk_openbrace){ |
2373 | nexttok(); |
2376 | nexttok(); |
2374 | type2=tok; |
2377 | type2=tok; |
2375 | } |
2378 | } |
2376 | case tk_dollar: |
2379 | case tk_dollar: |
2377 | nexttok(); |
2380 | nexttok(); |
2378 | case tk_idasm: |
2381 | case tk_idasm: |
2379 | if(stricmp(itok.name,"test")==0){ |
2382 | if(stricmp(itok.name,"test")==0){ |
2380 | if(iTest(1)==FALSE)InvOperComp(); |
2383 | if(iTest(1)==FALSE)InvOperComp(); |
2381 | ittok=0x75; |
2384 | ittok=0x75; |
2382 | if(type2==tk_openbrace)expecting(tk_closebrace); |
2385 | if(type2==tk_openbrace)expecting(tk_closebrace); |
2383 | goto endcomp; |
2386 | goto endcomp; |
2384 | } |
2387 | } |
2385 | else preerror("Only 'TEST' possible use in compare"); |
2388 | else preerror("Only 'TEST' possible use in compare"); |
2386 | break; |
2389 | break; |
2387 | case tk_qword: |
2390 | case tk_qword: |
2388 | case tk_double: |
2391 | case tk_double: |
2389 | razr+=4; |
2392 | razr+=4; |
2390 | case tk_beg: |
2393 | case tk_beg: |
2391 | case tk_reg32: |
2394 | case tk_reg32: |
2392 | case tk_reg: vartype=tok; break; |
2395 | case tk_reg: vartype=tok; break; |
2393 | case tk_float: |
2396 | case tk_float: |
2394 | case tk_long: |
2397 | case tk_long: |
2395 | case tk_dword: |
2398 | case tk_dword: |
2396 | razr+=2; |
2399 | razr+=2; |
2397 | case tk_int: |
2400 | case tk_int: |
2398 | case tk_word: |
2401 | case tk_word: |
2399 | razr++; |
2402 | razr++; |
2400 | case tk_char: |
2403 | case tk_char: |
2401 | case tk_byte: |
2404 | case tk_byte: |
2402 | razr++; |
2405 | razr++; |
2403 | vartype=tok; |
2406 | vartype=tok; |
2404 | getoperand(); |
2407 | getoperand(); |
2405 | if(tok==tk_closebracket&&bracket>1){ |
2408 | if(tok==tk_closebracket&&bracket>1){ |
2406 | bracket--; |
2409 | bracket--; |
2407 | getoperand(); |
2410 | getoperand(); |
2408 | } |
2411 | } |
2409 | break; |
2412 | break; |
2410 | case tk_undefproc: |
2413 | case tk_undefproc: |
2411 | case tk_declare: |
2414 | case tk_declare: |
2412 | // if(itok.rm==tk_void)itok.rm=(am32==FALSE?tk_word:tk_dword); |
2415 | // if(itok.rm==tk_void)itok.rm=(am32==FALSE?tk_word:tk_dword); |
2413 | case tk_proc: |
2416 | case tk_proc: |
2414 | case tk_apiproc: |
2417 | case tk_apiproc: |
2415 | vartype=itok.rm; |
2418 | vartype=itok.rm; |
2416 | if(vartype==tokens)vartype=(am32==FALSE?tk_word:tk_dword); |
2419 | if(vartype==tokens)vartype=(am32==FALSE?tk_word:tk_dword); |
2417 | else if(vartype==tk_void&&(itok.flag&f_retproc)==0){ |
2420 | else if(vartype==tk_void&&(itok.flag&f_retproc)==0){ |
2418 | retvoid(); |
2421 | retvoid(); |
2419 | vartype=itok.rm=(am32==FALSE?tk_word:tk_dword); |
2422 | vartype=itok.rm=(am32==FALSE?tk_word:tk_dword); |
2420 | } |
2423 | } |
2421 | if(ofsstr){ |
2424 | if(ofsstr){ |
2422 | free(ofsstr); |
2425 | free(ofsstr); |
2423 | ofsstr=NULL; |
2426 | ofsstr=NULL; |
2424 | } |
2427 | } |
2425 | break; |
2428 | break; |
2426 | case tk_bytevar: vartype=tk_byte; break; |
2429 | case tk_bytevar: vartype=tk_byte; break; |
2427 | case tk_charvar: vartype=tk_char; break; |
2430 | case tk_charvar: vartype=tk_char; break; |
2428 | case tk_intvar: vartype=tk_int; break; |
2431 | case tk_intvar: vartype=tk_int; break; |
2429 | case tk_wordvar: vartype=tk_word; break; |
2432 | case tk_wordvar: vartype=tk_word; break; |
2430 | case tk_dwordvar: vartype=tk_dword; break; |
2433 | case tk_dwordvar: vartype=tk_dword; break; |
2431 | case tk_longvar: vartype=tk_long; break; |
2434 | case tk_longvar: vartype=tk_long; break; |
2432 | case tk_floatvar: vartype=tk_float; break; |
2435 | case tk_floatvar: vartype=tk_float; break; |
2433 | case tk_qwordvar: vartype=tk_qword; break; |
2436 | case tk_qwordvar: vartype=tk_qword; break; |
2434 | case tk_fpust: |
2437 | case tk_fpust: |
2435 | case tk_doublevar: vartype=tk_double; break; |
2438 | case tk_doublevar: vartype=tk_double; break; |
2436 | case tk_bits: |
2439 | case tk_bits: |
2437 | int i; |
2440 | int i; |
2438 | i=itok.bit.ofs+itok.bit.siz; |
2441 | i=itok.bit.ofs+itok.bit.siz; |
2439 | if(i<=64){ |
2442 | if(i<=64){ |
2440 | vartype=tk_dword; |
2443 | vartype=tk_dword; |
2441 | razr=r64; |
2444 | razr=r64; |
2442 | } |
2445 | } |
2443 | if(i<=32){ |
2446 | if(i<=32){ |
2444 | vartype=tk_dword; |
2447 | vartype=tk_dword; |
2445 | razr=r32; |
2448 | razr=r32; |
2446 | } |
2449 | } |
2447 | if(i<=16){ |
2450 | if(i<=16){ |
2448 | vartype=tk_word; |
2451 | vartype=tk_word; |
2449 | razr=r16; |
2452 | razr=r16; |
2450 | } |
2453 | } |
2451 | if(i<=8){ |
2454 | if(i<=8){ |
2452 | vartype=tk_byte; |
2455 | vartype=tk_byte; |
2453 | razr=r8; |
2456 | razr=r8; |
2454 | } |
2457 | } |
2455 | break; |
2458 | break; |
2456 | case tk_at: |
2459 | case tk_at: |
2457 | if(ofsstr){ |
2460 | if(ofsstr){ |
2458 | free(ofsstr); |
2461 | free(ofsstr); |
2459 | ofsstr=NULL; |
2462 | ofsstr=NULL; |
2460 | } |
2463 | } |
2461 | nexttok(); |
2464 | nexttok(); |
2462 | if(itok.flag&f_retproc){ |
2465 | if(itok.flag&f_retproc){ |
2463 | comparetok=(itok.flag&f_retproc)/256+tk_overflowflag-1; |
2466 | comparetok=(itok.flag&f_retproc)/256+tk_overflowflag-1; |
2464 | // notflag=(notflag==FALSE?TRUE:FALSE); |
2467 | // notflag=(notflag==FALSE?TRUE:FALSE); |
2465 | vartype=tk_ID; |
2468 | vartype=tk_ID; |
2466 | ittok2=macros(vartype); |
2469 | ittok2=macros(vartype); |
2467 | if(tok2==tk_closebracket){ |
2470 | if(tok2==tk_closebracket){ |
2468 | nexttok(); |
2471 | nexttok(); |
2469 | ittok=0x70+comparetok-tk_overflowflag; |
2472 | ittok=0x70+comparetok-tk_overflowflag; |
2470 | goto endcomp; |
2473 | goto endcomp; |
2471 | } |
2474 | } |
2472 | if(ittok2==0){ |
2475 | if(ittok2==0){ |
2473 | vartype=itok.rm; |
2476 | vartype=itok.rm; |
2474 | break; |
2477 | break; |
2475 | } |
2478 | } |
2476 | goto mac1; |
2479 | goto mac1; |
2477 | } |
2480 | } |
2478 | if((itok.flag&f_typeproc)==tp_fastcall&&itok.segm!=NOT_DYNAMIC)vartype=itok.rm; |
2481 | if((itok.flag&f_typeproc)==tp_fastcall&&itok.segm!=NOT_DYNAMIC)vartype=itok.rm; |
2479 | else vartype=tk_ID; |
2482 | else vartype=tk_ID; |
2480 | if((ittok2=macros(vartype))==0){ |
2483 | if((ittok2=macros(vartype))==0){ |
2481 | vartype=itok.rm; |
2484 | vartype=itok.rm; |
2482 | break; |
2485 | break; |
2483 | } |
2486 | } |
2484 | mac1: |
2487 | mac1: |
2485 | vartype=ittok2; |
2488 | vartype=ittok2; |
2486 | switch(vartype){ |
2489 | switch(vartype){ |
2487 | case tk_byte: |
2490 | case tk_byte: |
2488 | case tk_char: tok=tk_beg; break; |
2491 | case tk_char: tok=tk_beg; break; |
2489 | case tk_int: |
2492 | case tk_int: |
2490 | case tk_word: tok=tk_reg; break; |
2493 | case tk_word: tok=tk_reg; break; |
2491 | case tk_float: |
2494 | case tk_float: |
2492 | case tk_dword: |
2495 | case tk_dword: |
2493 | case tk_long: tok=tk_reg32; break; |
2496 | case tk_long: tok=tk_reg32; break; |
2494 | case tk_double: |
2497 | case tk_double: |
2495 | case tk_qword: tok=tk_reg64; break; |
2498 | case tk_qword: tok=tk_reg64; break; |
2496 | default: |
2499 | default: |
2497 | preerror("Macro has a return type of void"); |
2500 | preerror("Macro has a return type of void"); |
2498 | tok=tk_reg; |
2501 | tok=tk_reg; |
2499 | vartype=tk_word; |
2502 | vartype=tk_word; |
2500 | break; |
2503 | break; |
2501 | } |
2504 | } |
2502 | itok.number=AX; // or AL or EAX |
2505 | itok.number=AX; // or AL or EAX |
2503 | break; |
2506 | break; |
2504 | default: |
2507 | default: |
2505 | if((tok>=tk_overflowflag)&&(tok<=tk_plusflag)){ |
2508 | if((tok>=tk_overflowflag)&&(tok<=tk_plusflag)){ |
2506 | ittok=0x70+tok-tk_overflowflag; |
2509 | ittok=0x70+tok-tk_overflowflag; |
2507 | nexttok(); |
2510 | nexttok(); |
2508 | if(tok!=tk_closebracket&&(tok==tk_oror||tok==tk_andand||tok==tk_notequal||tok==tk_equalto)){ |
2511 | if(tok!=tk_closebracket&&(tok==tk_oror||tok==tk_andand||tok==tk_notequal||tok==tk_equalto)){ |
2509 | int oper; |
2512 | int oper; |
2510 | int oper2; |
2513 | int oper2; |
2511 | oper=tok; |
2514 | oper=tok; |
2512 | nexttok(); |
2515 | nexttok(); |
2513 | ittok^=notflag; |
2516 | ittok^=notflag; |
2514 | notflag=0; |
2517 | notflag=0; |
2515 | if(tok==tk_not){ |
2518 | if(tok==tk_not){ |
2516 | notflag=TRUE; |
2519 | notflag=TRUE; |
2517 | nexttok(); |
2520 | nexttok(); |
2518 | } |
2521 | } |
2519 | if((tok>=tk_overflowflag)&&(tok<=tk_plusflag)){ |
2522 | if((tok>=tk_overflowflag)&&(tok<=tk_plusflag)){ |
2520 | ittok-=0x70; |
2523 | ittok-=0x70; |
2521 | ittok2=tok-tk_overflowflag; |
2524 | ittok2=tok-tk_overflowflag; |
2522 | ittok2^=notflag; |
2525 | ittok2^=notflag; |
2523 | notflag=0; |
2526 | notflag=0; |
2524 | nexttok(); |
2527 | nexttok(); |
2525 | switch(oper){ |
2528 | switch(oper){ |
2526 | case tk_oror: |
2529 | case tk_oror: |
2527 | if((ittok==2&&ittok2==4)||(ittok==4&&ittok2==2))ittok=6; |
2530 | if((ittok==2&&ittok2==4)||(ittok==4&&ittok2==2))ittok=6; |
2528 | else if(ittok==4&&(ittok2==8||ittok2==0))ittok=(ittok|ittok2)+1; |
2531 | else if(ittok==4&&(ittok2==8||ittok2==0))ittok=(ittok|ittok2)+1; |
2529 | else unknowncompop(); |
2532 | else unknowncompop(); |
2530 | break; |
2533 | break; |
2531 | case tk_andand: |
2534 | case tk_andand: |
2532 | if((ittok==3&&ittok2==5)||(ittok==5&&ittok2==3))ittok=7; |
2535 | if((ittok==3&&ittok2==5)||(ittok==5&&ittok2==3))ittok=7; |
2533 | else if(ittok==5&&(ittok2==8||ittok2==0))ittok=(ittok|ittok2)+1; |
2536 | else if(ittok==5&&(ittok2==8||ittok2==0))ittok=(ittok|ittok2)+1; |
2534 | else unknowncompop(); |
2537 | else unknowncompop(); |
2535 | break; |
2538 | break; |
2536 | case tk_notequal: |
2539 | case tk_notequal: |
2537 | if((ittok==8&&ittok2==0)||(ittok==0&&ittok2==8))ittok=12; |
2540 | if((ittok==8&&ittok2==0)||(ittok==0&&ittok2==8))ittok=12; |
2538 | else unknowncompop(); |
2541 | else unknowncompop(); |
2539 | break; |
2542 | break; |
2540 | case tk_equalto: |
2543 | case tk_equalto: |
2541 | if((ittok==8&&ittok2==0)||(ittok==0&&ittok2==8))ittok=13; |
2544 | if((ittok==8&&ittok2==0)||(ittok==0&&ittok2==8))ittok=13; |
2542 | else unknowncompop(); |
2545 | else unknowncompop(); |
2543 | break; |
2546 | break; |
2544 | } |
2547 | } |
2545 | if(tok!=tk_closebracket&&(tok==tk_notequal||tok==tk_equalto)){ |
2548 | if(tok!=tk_closebracket&&(tok==tk_notequal||tok==tk_equalto)){ |
2546 | oper2=tok; |
2549 | oper2=tok; |
2547 | nexttok(); |
2550 | nexttok(); |
2548 | if(tok==tk_not){ |
2551 | if(tok==tk_not){ |
2549 | notflag=TRUE; |
2552 | notflag=TRUE; |
2550 | nexttok(); |
2553 | nexttok(); |
2551 | } |
2554 | } |
2552 | if((tok>=tk_overflowflag)&&(tok<=tk_plusflag)){ |
2555 | if((tok>=tk_overflowflag)&&(tok<=tk_plusflag)){ |
2553 | ittok2=tok-tk_overflowflag; |
2556 | ittok2=tok-tk_overflowflag; |
2554 | ittok2^=notflag; |
2557 | ittok2^=notflag; |
2555 | notflag=0; |
2558 | notflag=0; |
2556 | nexttok(); |
2559 | nexttok(); |
2557 | if(oper2==tk_notequal){ |
2560 | if(oper2==tk_notequal){ |
2558 | if(oper==tk_oror&&((ittok==5&&ittok2==8)||(ittok==13&&ittok2==0)))ittok=14; |
2561 | if(oper==tk_oror&&((ittok==5&&ittok2==8)||(ittok==13&&ittok2==0)))ittok=14; |
2559 | else unknowncompop(); |
2562 | else unknowncompop(); |
2560 | } |
2563 | } |
2561 | else{ |
2564 | else{ |
2562 | if(oper==tk_andand&&((ittok==6&&ittok2==8)||(ittok==14&&ittok2==0)))ittok=15; |
2565 | if(oper==tk_andand&&((ittok==6&&ittok2==8)||(ittok==14&&ittok2==0)))ittok=15; |
2563 | else unknowncompop(); |
2566 | else unknowncompop(); |
2564 | } |
2567 | } |
2565 | } |
2568 | } |
2566 | else unknowncompop(); |
2569 | else unknowncompop(); |
2567 | } |
2570 | } |
2568 | } |
2571 | } |
2569 | else unknowncompop(); |
2572 | else unknowncompop(); |
2570 | ittok+=0x70; |
2573 | ittok+=0x70; |
2571 | } |
2574 | } |
2572 | goto endcomp; |
2575 | goto endcomp; |
2573 | } |
2576 | } |
2574 | vartype=(am32==FALSE?tk_word:tk_dword); |
2577 | vartype=(am32==FALSE?tk_word:tk_dword); |
2575 | break; |
2578 | break; |
2576 | } |
2579 | } |
2577 | CheckMinusNum(); |
2580 | CheckMinusNum(); |
2578 | if(itok2.type!=tp_compare&&tok2!=tk_closebracket){ //ñëîæíûé îïåðàíä |
2581 | if(itok2.type!=tp_compare&&tok2!=tk_closebracket){ //ñëîæíûé îïåðàíä |
2579 | if(ofsstr){ |
2582 | if(ofsstr){ |
2580 | int retreg; |
2583 | int retreg; |
2581 | razr=getrazr(vartype); |
2584 | razr=getrazr(vartype); |
2582 | if((retreg=CheckIDZReg(ofsstr,AX,razr))!=NOINREG){ |
2585 | if((retreg=CheckIDZReg(ofsstr,AX,razr))!=NOINREG){ |
2583 | GetEndLex(tk_closebracket,tk_semicolon,tp_compare); |
2586 | GetEndLex(tk_closebracket,tk_semicolon,tp_compare); |
2584 | nexttok(); |
2587 | nexttok(); |
2585 | if(razr==r16)ittok=tk_reg; |
2588 | if(razr==r16)ittok=tk_reg; |
2586 | else if(razr==r32)ittok=tk_reg32; |
2589 | else if(razr==r32)ittok=tk_reg32; |
2587 | else ittok=tk_beg; |
2590 | else ittok=tk_beg; |
2588 | usereg=htok.number=retreg==SKIPREG?AX:retreg; |
2591 | usereg=htok.number=retreg==SKIPREG?AX:retreg; |
2589 | goto nn1; |
2592 | goto nn1; |
2590 | } |
2593 | } |
2591 | } |
2594 | } |
2592 | comparetok=0;//èñïîëüçóåòñÿ âðåìåííî íå ïîñìûñëó |
2595 | comparetok=0;//èñïîëüçóåòñÿ âðåìåííî íå ïîñìûñëó |
2593 | ittok=tok; |
2596 | ittok=tok; |
2594 | htok=itok; |
2597 | htok=itok; |
2595 | ibuf=NULL; |
2598 | ibuf=NULL; |
2596 | hstr.bufstr=NULL; |
2599 | hstr.bufstr=NULL; |
2597 | ittok2=tok2; |
2600 | ittok2=tok2; |
2598 | preg=BX; |
2601 | preg=BX; |
2599 | switch(tok2){ |
2602 | switch(tok2){ |
2600 | case tk_assign: |
2603 | case tk_assign: |
2601 | case tk_plusplus: |
2604 | case tk_plusplus: |
2602 | case tk_minusminus: |
2605 | case tk_minusminus: |
2603 | case tk_divequals: |
2606 | case tk_divequals: |
2604 | case tk_minusequals: |
2607 | case tk_minusequals: |
2605 | case tk_multequals: |
2608 | case tk_multequals: |
2606 | case tk_plusequals: |
2609 | case tk_plusequals: |
2607 | switch(tok){ |
2610 | switch(tok){ |
2608 | case tk_charvar: comparetok=1; |
2611 | case tk_charvar: comparetok=1; |
2609 | case tk_bytevar: |
2612 | case tk_bytevar: |
2610 | if((comparetok=dobytevar(comparetok,0))==tk_reg||comparetok==tk_beg){ |
2613 | if((comparetok=dobytevar(comparetok,0))==tk_reg||comparetok==tk_beg){ |
2611 | usereg=htok.number=AX; |
2614 | usereg=htok.number=AX; |
2612 | ittok=tk_beg; |
2615 | ittok=tk_beg; |
2613 | } |
2616 | } |
2614 | break; |
2617 | break; |
2615 | case tk_intvar: comparetok=1; |
2618 | case tk_intvar: comparetok=1; |
2616 | case tk_wordvar: |
2619 | case tk_wordvar: |
2617 | if((comparetok=do_d_wordvar(comparetok,r16,0))==tk_reg){ |
2620 | if((comparetok=do_d_wordvar(comparetok,r16,0))==tk_reg){ |
2618 | usereg=htok.number=AX; |
2621 | usereg=htok.number=AX; |
2619 | ittok=tk_reg; |
2622 | ittok=tk_reg; |
2620 | } |
2623 | } |
2621 | break; |
2624 | break; |
2622 | case tk_longvar: comparetok=1; |
2625 | case tk_longvar: comparetok=1; |
2623 | case tk_dwordvar: |
2626 | case tk_dwordvar: |
2624 | if((comparetok=do_d_wordvar(comparetok,r32,0))==tk_reg32){ |
2627 | if((comparetok=do_d_wordvar(comparetok,r32,0))==tk_reg32){ |
2625 | usereg=htok.number=AX; |
2628 | usereg=htok.number=AX; |
2626 | ittok=tk_reg32; |
2629 | ittok=tk_reg32; |
2627 | } |
2630 | } |
2628 | break; |
2631 | break; |
2629 | case tk_floatvar: |
2632 | case tk_floatvar: |
2630 | if(dofloatvar(0,tk_fpust,0)==tk_fpust){ |
2633 | if(dofloatvar(0,tk_fpust,0)==tk_fpust){ |
2631 | ittok=tk_fpust; |
2634 | ittok=tk_fpust; |
2632 | htok.type=tp_modif; |
2635 | htok.type=tp_modif; |
2633 | } |
2636 | } |
2634 | break; |
2637 | break; |
2635 | case tk_qwordvar: |
2638 | case tk_qwordvar: |
2636 | if((comparetok=doqwordvar(0))==tk_reg64){ |
2639 | if((comparetok=doqwordvar(0))==tk_reg64){ |
2637 | ittok=tk_reg64; |
2640 | ittok=tk_reg64; |
2638 | usereg=htok.number=EAX|(EDX*256); |
2641 | usereg=htok.number=EAX|(EDX*256); |
2639 | } |
2642 | } |
2640 | break; |
2643 | break; |
2641 | case tk_reg64: |
2644 | case tk_reg64: |
2642 | usereg=itok.number; |
2645 | usereg=itok.number; |
2643 | getintoreg64(itok.number); |
2646 | getintoreg64(itok.number); |
2644 | doregmath64(itok.number); |
2647 | doregmath64(itok.number); |
2645 | comparetok=tk_reg64; |
2648 | comparetok=tk_reg64; |
2646 | break; |
2649 | break; |
2647 | case tk_reg32: |
2650 | case tk_reg32: |
2648 | usereg=itok.number; |
2651 | usereg=itok.number; |
2649 | comparetok=doreg_32((unsigned int)itok.number,r32,0); |
2652 | comparetok=doreg_32((unsigned int)itok.number,r32,0); |
2650 | // printf("comparetok=%d\n",comparetok); |
2653 | // printf("comparetok=%d\n",comparetok); |
2651 | break; |
2654 | break; |
2652 | case tk_reg: |
2655 | case tk_reg: |
2653 | usereg=itok.number; |
2656 | usereg=itok.number; |
2654 | comparetok=doreg_32((unsigned int)itok.number,r16,0); |
2657 | comparetok=doreg_32((unsigned int)itok.number,r16,0); |
2655 | break; |
2658 | break; |
2656 | case tk_beg: |
2659 | case tk_beg: |
2657 | usereg=itok.number; |
2660 | usereg=itok.number; |
2658 | comparetok=dobeg((unsigned int)itok.number,0); |
2661 | comparetok=dobeg((unsigned int)itok.number,0); |
2659 | break; |
2662 | break; |
2660 | default: InvOperComp(); break; |
2663 | default: InvOperComp(); break; |
2661 | } |
2664 | } |
2662 | if(ittok |
2665 | if(ittok |
2663 | if(ittok2!=tk_assign&&ittok2!=tk_divequals&&ittok2!=tk_multequals){ |
2666 | if(ittok2!=tk_assign&&ittok2!=tk_divequals&&ittok2!=tk_multequals){ |
2664 | if(tok==tk_closebracket){ |
2667 | if(tok==tk_closebracket){ |
2665 | ittok=0x75; |
2668 | ittok=0x75; |
2666 | goto endcomp; |
2669 | goto endcomp; |
2667 | } |
2670 | } |
2668 | if(tok2==tk_number&&itok2.number==0){ |
2671 | if(tok2==tk_number&&itok2.number==0){ |
2669 | if((ittok2==tk_plusplus||ittok2==tk_minusminus)&& |
2672 | if((ittok2==tk_plusplus||ittok2==tk_minusminus)&& |
2670 | tok!=tk_notequal&&tok!=tk_equalto)break; |
2673 | tok!=tk_notequal&&tok!=tk_equalto)break; |
2671 | comparetok=CheckCompareTok(BX); |
2674 | comparetok=CheckCompareTok(BX); |
2672 | nexttok(); |
2675 | nexttok(); |
2673 | goto createopcode; |
2676 | goto createopcode; |
2674 | } |
2677 | } |
2675 | } |
2678 | } |
2676 | } |
2679 | } |
2677 | break; |
2680 | break; |
2678 | default: |
2681 | default: |
2679 | switch(vartype){ |
2682 | switch(vartype){ |
2680 | case tk_int: comparetok=do_e_axmath(1,r16,&ofsstr); ittok=tk_reg; break; |
2683 | case tk_int: comparetok=do_e_axmath(1,r16,&ofsstr); ittok=tk_reg; break; |
2681 | case tk_reg: |
2684 | case tk_reg: |
2682 | case tk_word: comparetok=do_e_axmath(0,r16,&ofsstr); ittok=tk_reg; break; |
2685 | case tk_word: comparetok=do_e_axmath(0,r16,&ofsstr); ittok=tk_reg; break; |
2683 | case tk_char: comparetok=doalmath(1,&ofsstr); ittok=tk_beg; break; |
2686 | case tk_char: comparetok=doalmath(1,&ofsstr); ittok=tk_beg; break; |
2684 | case tk_beg: |
2687 | case tk_beg: |
2685 | case tk_byte: comparetok=doalmath(0,&ofsstr); ittok=tk_beg; break; |
2688 | case tk_byte: comparetok=doalmath(0,&ofsstr); ittok=tk_beg; break; |
2686 | case tk_long: comparetok=do_e_axmath(1,r32,&ofsstr); ittok=tk_reg32; break; |
2689 | case tk_long: comparetok=do_e_axmath(1,r32,&ofsstr); ittok=tk_reg32; break; |
2687 | case tk_reg32: |
2690 | case tk_reg32: |
2688 | case tk_dword: |
2691 | case tk_dword: |
2689 | comparetok=do_e_axmath(0,r32,&ofsstr); |
2692 | comparetok=do_e_axmath(0,r32,&ofsstr); |
2690 | ittok=tk_reg32; |
2693 | ittok=tk_reg32; |
2691 | break; |
2694 | break; |
2692 | case tk_qword: |
2695 | case tk_qword: |
2693 | usereg=htok.number=EAX|(EDX*256); |
2696 | usereg=htok.number=EAX|(EDX*256); |
2694 | getintoreg64(usereg); |
2697 | getintoreg64(usereg); |
2695 | doregmath64(usereg); |
2698 | doregmath64(usereg); |
2696 | comparetok=ittok=tk_reg64; |
2699 | comparetok=ittok=tk_reg64; |
2697 | break; |
2700 | break; |
2698 | case tk_float: |
2701 | case tk_float: |
2699 | doeaxfloatmath(tk_fpust); |
2702 | doeaxfloatmath(tk_fpust); |
2700 | ittok=tk_fpust; |
2703 | ittok=tk_fpust; |
2701 | htok.type=tp_modif; |
2704 | htok.type=tp_modif; |
2702 | break; |
2705 | break; |
2703 | default: |
2706 | default: |
2704 | if(itok.flag&f_retproc){ |
2707 | if(itok.flag&f_retproc){ |
2705 | comparetok=(itok.flag&f_retproc)/256+tk_overflowflag-1; |
2708 | comparetok=(itok.flag&f_retproc)/256+tk_overflowflag-1; |
2706 | // printf("tok=%d flag=%08X comparetok=%u %s\n",tok,itok.flag,comparetok,itok.name); |
2709 | // printf("tok=%d flag=%08X comparetok=%u %s\n",tok,itok.flag,comparetok,itok.name); |
2707 | // notflag=(notflag==FALSE?TRUE:FALSE); |
2710 | // notflag=(notflag==FALSE?TRUE:FALSE); |
2708 | switch(tok){ |
2711 | switch(tok){ |
2709 | case tk_undefproc: |
2712 | case tk_undefproc: |
2710 | case tk_declare: |
2713 | case tk_declare: |
2711 | case tk_apiproc: |
2714 | case tk_apiproc: |
2712 | doanyundefproc(); |
2715 | doanyundefproc(); |
2713 | break; |
2716 | break; |
2714 | case tk_proc: |
2717 | case tk_proc: |
2715 | doanyproc(); |
2718 | doanyproc(); |
2716 | break; |
2719 | break; |
2717 | } |
2720 | } |
2718 | nexttok(); |
2721 | nexttok(); |
2719 | if(tok!=tk_closebracket){ |
2722 | if(tok!=tk_closebracket){ |
2720 | retvoid(); |
2723 | retvoid(); |
2721 | do{ |
2724 | do{ |
2722 | nexttok(); |
2725 | nexttok(); |
2723 | }while(tok!=tk_closebracket); |
2726 | }while(tok!=tk_closebracket); |
2724 | } |
2727 | } |
2725 | } |
2728 | } |
2726 | else{ |
2729 | else{ |
2727 | internalerror("Bad vartype value in constructcompare();"); |
2730 | internalerror("Bad vartype value in constructcompare();"); |
2728 | tok=tk_reg; break; |
2731 | tok=tk_reg; break; |
2729 | } |
2732 | } |
2730 | } |
2733 | } |
2731 | if(ittok!=tk_reg64)usereg=htok.number=AX; // same value as AL and EAX |
2734 | if(ittok!=tk_reg64)usereg=htok.number=AX; // same value as AL and EAX |
2732 | } |
2735 | } |
2733 | RestoreStack(); |
2736 | RestoreStack(); |
2734 | } |
2737 | } |
2735 | else{ |
2738 | else{ |
2736 | #ifdef OPTVARCONST |
2739 | #ifdef OPTVARCONST |
2737 | CheckConstVar3(&tok,&itok,razr); |
2740 | CheckConstVar3(&tok,&itok,razr); |
2738 | #endif |
2741 | #endif |
2739 | if(tok>=tk_charvar&&tok<=tk_doublevar){ |
2742 | if(tok>=tk_charvar&&tok<=tk_doublevar){ |
2740 | switch(vartype){ |
2743 | switch(vartype){ |
2741 | case tk_int: tok=tk_intvar; break; |
2744 | case tk_int: tok=tk_intvar; break; |
2742 | case tk_word: tok=tk_wordvar; break; |
2745 | case tk_word: tok=tk_wordvar; break; |
2743 | case tk_char: tok=tk_charvar; break; |
2746 | case tk_char: tok=tk_charvar; break; |
2744 | case tk_byte: tok=tk_bytevar; break; |
2747 | case tk_byte: tok=tk_bytevar; break; |
2745 | case tk_long: tok=tk_longvar; break; |
2748 | case tk_long: tok=tk_longvar; break; |
2746 | case tk_dword: tok=tk_dwordvar; break; |
2749 | case tk_dword: tok=tk_dwordvar; break; |
2747 | case tk_float: tok=tk_floatvar; break; |
2750 | case tk_float: tok=tk_floatvar; break; |
2748 | case tk_qword: tok=tk_qwordvar; break; |
2751 | case tk_qword: tok=tk_qwordvar; break; |
2749 | case tk_double: tok=tk_doublevar; break; |
2752 | case tk_double: tok=tk_doublevar; break; |
2750 | } |
2753 | } |
2751 | } |
2754 | } |
2752 | else if(tok==tk_number){ |
2755 | else if(tok==tk_number){ |
2753 | if(tok2==tk_closebracket){ |
2756 | if(tok2==tk_closebracket){ |
2754 | invertflag=(itok.number==0?zerocompr:voidcompr); |
2757 | invertflag=(itok.number==0?zerocompr:voidcompr); |
2755 | nexttok(); |
2758 | nexttok(); |
2756 | getoperand(); |
2759 | getoperand(); |
2757 | useinline=oinline; |
2760 | useinline=oinline; |
2758 | return invertflag; |
2761 | return invertflag; |
2759 | } |
2762 | } |
2760 | if(itok.rm==tk_float)vartype=tk_float; |
2763 | if(itok.rm==tk_float)vartype=tk_float; |
2761 | } |
2764 | } |
2762 | else if(tok==tk_bits){ |
2765 | else if(tok==tk_bits){ |
2763 | bits2reg(AX,razr); |
2766 | bits2reg(AX,razr); |
2764 | switch(razr){ |
2767 | switch(razr){ |
2765 | case r64: |
2768 | case r64: |
2766 | case r32: |
2769 | case r32: |
2767 | tok=tk_reg32; |
2770 | tok=tk_reg32; |
2768 | break; |
2771 | break; |
2769 | case r16: |
2772 | case r16: |
2770 | tok=tk_reg; |
2773 | tok=tk_reg; |
2771 | break; |
2774 | break; |
2772 | case r8: |
2775 | case r8: |
2773 | tok=tk_beg; |
2776 | tok=tk_beg; |
2774 | break; |
2777 | break; |
2775 | } |
2778 | } |
2776 | itok.number=0; |
2779 | itok.number=0; |
2777 | } |
2780 | } |
2778 | if(tok==tk_beg||tok==tk_reg||tok==tk_reg32)itok.rm=vartype; //òèï ñîäåðæèìîãî â reg32 |
2781 | if(tok==tk_beg||tok==tk_reg||tok==tk_reg32)itok.rm=vartype; //òèï ñîäåðæèìîãî â reg32 |
2779 | ittok=tok; |
2782 | ittok=tok; |
2780 | htok=itok; |
2783 | htok=itok; |
2781 | ibuf=bufrm; |
2784 | ibuf=bufrm; |
2782 | bufrm=NULL; |
2785 | bufrm=NULL; |
2783 | hstr=strinf; |
2786 | hstr=strinf; |
2784 | strinf.bufstr=NULL; |
2787 | strinf.bufstr=NULL; |
2785 | nexttok(); |
2788 | nexttok(); |
2786 | } |
2789 | } |
2787 | nn1: |
2790 | nn1: |
2788 | if(razr==r_undef){ |
2791 | if(razr==r_undef){ |
2789 | switch(vartype){ |
2792 | switch(vartype){ |
2790 | case tk_qword: |
2793 | case tk_qword: |
2791 | case tk_double: |
2794 | case tk_double: |
2792 | razr+=4; |
2795 | razr+=4; |
2793 | case tk_long: |
2796 | case tk_long: |
2794 | case tk_dword: |
2797 | case tk_dword: |
2795 | case tk_float: |
2798 | case tk_float: |
2796 | case tk_reg32: |
2799 | case tk_reg32: |
2797 | razr+=2; |
2800 | razr+=2; |
2798 | case tk_int: |
2801 | case tk_int: |
2799 | case tk_word: |
2802 | case tk_word: |
2800 | case tk_reg: |
2803 | case tk_reg: |
2801 | razr++; |
2804 | razr++; |
2802 | case tk_char: |
2805 | case tk_char: |
2803 | case tk_byte: |
2806 | case tk_byte: |
2804 | case tk_beg: |
2807 | case tk_beg: |
2805 | razr++; |
2808 | razr++; |
2806 | } |
2809 | } |
2807 | } |
2810 | } |
2808 | if(tok!=tk_closebracket){ //ñðàâíåíèå |
2811 | if(tok!=tk_closebracket){ //ñðàâíåíèå |
2809 | ofsstr2=GetLecsem(tk_closebracket); |
2812 | ofsstr2=GetLecsem(tk_closebracket); |
2810 | comparetok=CheckCompareTok(preg); |
2813 | comparetok=CheckCompareTok(preg); |
2811 | if(tok>=tk_char&&tok<=tk_double){ |
2814 | if(tok>=tk_char&&tok<=tk_double){ |
2812 | type2=tok; |
2815 | type2=tok; |
2813 | if(ofsstr2)free(ofsstr2); |
2816 | if(ofsstr2)free(ofsstr2); |
2814 | ofsstr2=GetLecsem(tk_closebracket); |
2817 | ofsstr2=GetLecsem(tk_closebracket); |
2815 | getoperand(preg); |
2818 | getoperand(preg); |
2816 | } |
2819 | } |
2817 | if(tok==tk_minus){ |
2820 | if(tok==tk_minus){ |
2818 | if(CheckMinusNum()==FALSE){ |
2821 | if(CheckMinusNum()==FALSE){ |
2819 | preerror("only negative of constants valid within compairsons"); |
2822 | preerror("only negative of constants valid within compairsons"); |
2820 | nexttok(); |
2823 | nexttok(); |
2821 | } |
2824 | } |
2822 | } |
2825 | } |
2823 | #ifdef OPTVARCONST |
2826 | #ifdef OPTVARCONST |
2824 | CheckConstVar3(&tok,&itok,razr); |
2827 | CheckConstVar3(&tok,&itok,razr); |
2825 | #endif |
2828 | #endif |
2826 | if(tok==tk_number){ |
2829 | if(tok==tk_number){ |
2827 | switch(vartype){ |
2830 | switch(vartype){ |
2828 | case tk_long: |
2831 | case tk_long: |
2829 | case tk_int: |
2832 | case tk_int: |
2830 | case tk_char: |
2833 | case tk_char: |
2831 | htok2.number=doconstlongmath(); |
2834 | htok2.number=doconstlongmath(); |
2832 | itok.flag=(unsigned char)postnumflag; |
2835 | itok.flag=(unsigned char)postnumflag; |
2833 | break; |
2836 | break; |
2834 | case tk_dword: |
2837 | case tk_dword: |
2835 | case tk_reg32: |
2838 | case tk_reg32: |
2836 | case tk_beg: |
2839 | case tk_beg: |
2837 | case tk_reg: |
2840 | case tk_reg: |
2838 | case tk_word: |
2841 | case tk_word: |
2839 | case tk_byte: |
2842 | case tk_byte: |
2840 | htok2.number=doconstdwordmath(); |
2843 | htok2.number=doconstdwordmath(); |
2841 | itok.flag=(unsigned char)postnumflag; |
2844 | itok.flag=(unsigned char)postnumflag; |
2842 | break; |
2845 | break; |
2843 | case tk_float: |
2846 | case tk_float: |
2844 | htok2.number=doconstfloatmath(); |
2847 | htok2.number=doconstfloatmath(); |
2845 | break; |
2848 | break; |
2846 | case tk_reg64: |
2849 | case tk_reg64: |
2847 | case tk_qword: |
2850 | case tk_qword: |
2848 | htok2.lnumber=doconstqwordmath(); |
2851 | htok2.lnumber=doconstqwordmath(); |
2849 | itok.flag=(unsigned char)postnumflag; |
2852 | itok.flag=(unsigned char)postnumflag; |
2850 | break; |
2853 | break; |
2851 | case tk_double: |
2854 | case tk_double: |
2852 | htok2.lnumber=doconstdoublemath(); |
2855 | htok2.lnumber=doconstdoublemath(); |
2853 | break; |
2856 | break; |
2854 | } |
2857 | } |
2855 | htok2.rm=typenumber(vartype); |
2858 | htok2.rm=typenumber(vartype); |
2856 | ittok2=tk_number; |
2859 | ittok2=tk_number; |
2857 | htok2.flag=itok.flag; |
2860 | htok2.flag=itok.flag; |
2858 | } |
2861 | } |
2859 | else{ |
2862 | else{ |
2860 | if(ittok>=tk_charvar&&ittok<=tk_doublevar&&(tok==tk_proc||tok==tk_id|| |
2863 | if(ittok>=tk_charvar&&ittok<=tk_doublevar&&(tok==tk_proc||tok==tk_id|| |
2861 | tok==tk_undefproc||tok==tk_declare||tok==tk_apiproc||tok==tk_ID|| |
2864 | tok==tk_undefproc||tok==tk_declare||tok==tk_apiproc||tok==tk_ID|| |
2862 | itok2.type==tp_opperand||(tok>=tk_charvar&&tok<=tk_doublevar))){ |
2865 | itok2.type==tp_opperand||(tok>=tk_charvar&&tok<=tk_doublevar))){ |
2863 | if(ofsstr2){ |
2866 | if(ofsstr2){ |
2864 | int retreg; |
2867 | int retreg; |
2865 | razr=getrazr(vartype); |
2868 | razr=getrazr(vartype); |
2866 | if((retreg=CheckIDZReg(ofsstr2,AX,razr))!=NOINREG){ |
2869 | if((retreg=CheckIDZReg(ofsstr2,AX,razr))!=NOINREG){ |
2867 | GetEndLex(tk_closebracket); |
2870 | GetEndLex(tk_closebracket); |
2868 | usereg2=retreg==SKIPREG?AX:retreg; |
2871 | usereg2=retreg==SKIPREG?AX:retreg; |
2869 | if(razr==r16)ittok2=tk_reg; |
2872 | if(razr==r16)ittok2=tk_reg; |
2870 | else if(razr==r32)ittok2=tk_reg32; |
2873 | else if(razr==r32)ittok2=tk_reg32; |
2871 | else ittok2=tk_beg; |
2874 | else ittok2=tk_beg; |
2872 | htok2.number=usereg2; |
2875 | htok2.number=usereg2; |
2873 | nexttok(); |
2876 | nexttok(); |
2874 | goto en2; |
2877 | goto en2; |
2875 | } |
2878 | } |
2876 | } |
2879 | } |
2877 | int sign=0; |
2880 | int sign=0; |
2878 | switch(ittok){ |
2881 | switch(ittok){ |
2879 | case tk_charvar: sign=1; |
2882 | case tk_charvar: sign=1; |
2880 | case tk_bytevar: |
2883 | case tk_bytevar: |
2881 | doalmath(sign,&ofsstr2); |
2884 | doalmath(sign,&ofsstr2); |
2882 | usereg2=htok2.number=AX; |
2885 | usereg2=htok2.number=AX; |
2883 | ittok2=tk_beg; |
2886 | ittok2=tk_beg; |
2884 | break; |
2887 | break; |
2885 | case tk_intvar: sign=1; |
2888 | case tk_intvar: sign=1; |
2886 | case tk_wordvar: |
2889 | case tk_wordvar: |
2887 | do_e_axmath(sign,r16,&ofsstr2); |
2890 | do_e_axmath(sign,r16,&ofsstr2); |
2888 | usereg2=htok2.number=AX; |
2891 | usereg2=htok2.number=AX; |
2889 | ittok2=tk_reg; |
2892 | ittok2=tk_reg; |
2890 | break; |
2893 | break; |
2891 | case tk_longvar: sign=1; |
2894 | case tk_longvar: sign=1; |
2892 | case tk_dwordvar: |
2895 | case tk_dwordvar: |
2893 | do_e_axmath(sign,r32,&ofsstr2); |
2896 | do_e_axmath(sign,r32,&ofsstr2); |
2894 | usereg2=htok2.number=AX; |
2897 | usereg2=htok2.number=AX; |
2895 | ittok2=tk_reg32; |
2898 | ittok2=tk_reg32; |
2896 | break; |
2899 | break; |
2897 | case tk_floatvar: |
2900 | case tk_floatvar: |
2898 | doeaxfloatmath(tk_fpust); |
2901 | doeaxfloatmath(tk_fpust); |
2899 | ittok2=tk_fpust; |
2902 | ittok2=tk_fpust; |
2900 | htok2.type=tp_modif; |
2903 | htok2.type=tp_modif; |
2901 | htok2.number=0; |
2904 | htok2.number=0; |
2902 | ClearReg(AX); |
2905 | ClearReg(AX); |
2903 | break; |
2906 | break; |
2904 | case tk_doublevar: |
2907 | case tk_doublevar: |
2905 | doeaxfloatmath(tk_fpust,0,4); |
2908 | doeaxfloatmath(tk_fpust,0,4); |
2906 | ittok2=tk_fpust; |
2909 | ittok2=tk_fpust; |
2907 | htok2.type=tp_modif; |
2910 | htok2.type=tp_modif; |
2908 | htok2.number=0; |
2911 | htok2.number=0; |
2909 | ClearReg(AX); |
2912 | ClearReg(AX); |
2910 | break; |
2913 | break; |
2911 | case tk_qwordvar: |
2914 | case tk_qwordvar: |
2912 | usereg2=htok2.number=EAX|(EDX*256); |
2915 | usereg2=htok2.number=EAX|(EDX*256); |
2913 | getintoreg64(usereg2); |
2916 | getintoreg64(usereg2); |
2914 | doregmath64(usereg2); |
2917 | doregmath64(usereg2); |
2915 | ittok2=tk_reg64; |
2918 | ittok2=tk_reg64; |
2916 | ClearReg(AX); |
2919 | ClearReg(AX); |
2917 | ClearReg(DX); |
2920 | ClearReg(DX); |
2918 | break; |
2921 | break; |
2919 | } |
2922 | } |
2920 | } |
2923 | } |
2921 | else{ |
2924 | else{ |
2922 | if(tok==tk_bits){ |
2925 | if(tok==tk_bits){ |
2923 | int i=itok.bit.ofs+itok.bit.siz; |
2926 | int i=itok.bit.ofs+itok.bit.siz; |
2924 | int vops; |
2927 | int vops; |
2925 | if(i<=64)vops=r64; |
2928 | if(i<=64)vops=r64; |
2926 | if(i<=32)vops=r32; |
2929 | if(i<=32)vops=r32; |
2927 | if(i<=16)vops=r16; |
2930 | if(i<=16)vops=r16; |
2928 | if(i<=8)vops=r8; |
2931 | if(i<=8)vops=r8; |
2929 | if(vops |
2932 | if(vops |
2930 | i=AX; |
2933 | i=AX; |
2931 | if((ittok==tk_reg32||ittok==tk_reg||ittok==tk_beg)&&htok.number==0)i=CX; |
2934 | if((ittok==tk_reg32||ittok==tk_reg||ittok==tk_beg)&&htok.number==0)i=CX; |
2932 | bits2reg(i,vops); |
2935 | bits2reg(i,vops); |
2933 | switch(razr){ |
2936 | switch(razr){ |
2934 | case r64: |
2937 | case r64: |
2935 | case r32: |
2938 | case r32: |
2936 | tok=tk_reg32; |
2939 | tok=tk_reg32; |
2937 | break; |
2940 | break; |
2938 | case r16: |
2941 | case r16: |
2939 | tok=tk_reg; |
2942 | tok=tk_reg; |
2940 | break; |
2943 | break; |
2941 | case r8: |
2944 | case r8: |
2942 | tok=tk_beg; |
2945 | tok=tk_beg; |
2943 | break; |
2946 | break; |
2944 | } |
2947 | } |
2945 | itok.number=i; |
2948 | itok.number=i; |
2946 | ClearReg(i); |
2949 | ClearReg(i); |
2947 | } |
2950 | } |
2948 | switch(tok){ |
2951 | switch(tok){ |
2949 | case tk_beg: |
2952 | case tk_beg: |
2950 | case tk_reg: |
2953 | case tk_reg: |
2951 | case tk_reg32: |
2954 | case tk_reg32: |
2952 | itok.rm=type2; //òèï ñîäåðæèìîãî â reg32 |
2955 | itok.rm=type2; //òèï ñîäåðæèìîãî â reg32 |
2953 | if((ittok==tk_reg32||ittok==tk_reg||ittok==tk_beg)&& |
2956 | if((ittok==tk_reg32||ittok==tk_reg||ittok==tk_beg)&& |
2954 | htok.number==itok.number)preerror("Comparison two identical registers"); |
2957 | htok.number==itok.number)preerror("Comparison two identical registers"); |
2955 | break; |
2958 | break; |
2956 | } |
2959 | } |
2957 | int next=TRUE; |
2960 | int next=TRUE; |
2958 | int sign=0; |
2961 | int sign=0; |
2959 | if(ittok==tk_reg32){ |
2962 | if(ittok==tk_reg32){ |
2960 | if(ofsstr2){ |
2963 | if(ofsstr2){ |
2961 | int retreg; |
2964 | int retreg; |
2962 | int treg; |
2965 | int treg; |
2963 | treg=(htok.number==0?DX:AX); |
2966 | treg=(htok.number==0?DX:AX); |
2964 | razr=r32; |
2967 | razr=r32; |
2965 | if((retreg=CheckIDZReg(ofsstr2,treg,r32))!=NOINREG){ |
2968 | if((retreg=CheckIDZReg(ofsstr2,treg,r32))!=NOINREG){ |
2966 | if(retreg==SKIPREG)retreg=treg; |
2969 | if(retreg==SKIPREG)retreg=treg; |
2967 | if(retreg!=htok.number){ |
2970 | if(retreg!=htok.number){ |
2968 | GetEndLex(tk_closebracket); |
2971 | GetEndLex(tk_closebracket); |
2969 | ittok2=tk_reg32; |
2972 | ittok2=tk_reg32; |
2970 | htok2.number=usereg2=retreg; |
2973 | htok2.number=usereg2=retreg; |
2971 | nexttok(); |
2974 | nexttok(); |
2972 | goto en2; |
2975 | goto en2; |
2973 | } |
2976 | } |
2974 | } |
2977 | } |
2975 | } |
2978 | } |
2976 | switch(tok){ |
2979 | switch(tok){ |
2977 | case tk_intvar: |
2980 | case tk_intvar: |
2978 | sign=1; |
2981 | sign=1; |
2979 | case tk_wordvar: |
2982 | case tk_wordvar: |
2980 | if(htok.number!=0){ |
2983 | if(htok.number!=0){ |
2981 | do_e_axmath(sign,r32,&ofsstr2); |
2984 | do_e_axmath(sign,r32,&ofsstr2); |
2982 | usereg2=itok.number=0; |
2985 | usereg2=itok.number=0; |
2983 | } |
2986 | } |
2984 | else{ |
2987 | else{ |
2985 | getintoreg_32(DX,r32,sign,&ofsstr2); |
2988 | getintoreg_32(DX,r32,sign,&ofsstr2); |
2986 | usereg2=itok.number=DX; |
2989 | usereg2=itok.number=DX; |
2987 | } |
2990 | } |
2988 | warningreg(regs[1][itok.number]); |
2991 | warningreg(regs[1][itok.number]); |
2989 | next=FALSE; |
2992 | next=FALSE; |
2990 | ittok2=tk_reg32; |
2993 | ittok2=tk_reg32; |
2991 | htok2=itok; |
2994 | htok2=itok; |
2992 | } |
2995 | } |
2993 | } |
2996 | } |
2994 | if(next){ |
2997 | if(next){ |
2995 | ittok2=tok; |
2998 | ittok2=tok; |
2996 | htok2=itok; |
2999 | htok2=itok; |
2997 | ibuf2=bufrm; |
3000 | ibuf2=bufrm; |
2998 | bufrm=NULL; |
3001 | bufrm=NULL; |
2999 | hstr2=strinf; |
3002 | hstr2=strinf; |
3000 | strinf.bufstr=NULL; |
3003 | strinf.bufstr=NULL; |
3001 | nexttok(); |
3004 | nexttok(); |
3002 | } |
3005 | } |
3003 | } |
3006 | } |
3004 | RestoreStack(); |
3007 | RestoreStack(); |
3005 | } |
3008 | } |
3006 | } |
3009 | } |
3007 | else{ // !=0 |
3010 | else{ // !=0 |
3008 | if((comparetok>=tk_overflowflag)&&(comparetok<=tk_plusflag)){ |
3011 | if((comparetok>=tk_overflowflag)&&(comparetok<=tk_plusflag)){ |
3009 | ittok=0x70+comparetok-tk_overflowflag; |
3012 | ittok=0x70+comparetok-tk_overflowflag; |
3010 | goto endcomp; |
3013 | goto endcomp; |
3011 | } |
3014 | } |
3012 | htok2.rm=typenumber(vartype); |
3015 | htok2.rm=typenumber(vartype); |
3013 | comparetok=tk_notequal; |
3016 | comparetok=tk_notequal; |
3014 | ittok2=tk_number; |
3017 | ittok2=tk_number; |
3015 | htok2.number=0; |
3018 | htok2.number=0; |
3016 | htok2.flag=0; |
3019 | htok2.flag=0; |
3017 | } |
3020 | } |
3018 | if(ittok2==tk_number&&htok2.number==0&&(htok2.flag&f_reloc)==0){ |
3021 | if(ittok2==tk_number&&htok2.number==0&&(htok2.flag&f_reloc)==0){ |
3019 | if(setzeroflag){ |
3022 | if(setzeroflag){ |
3020 | if(comparetok==tk_notequal){ |
3023 | if(comparetok==tk_notequal){ |
3021 | ittok=0x75; |
3024 | ittok=0x75; |
3022 | goto endcomp; |
3025 | goto endcomp; |
3023 | } |
3026 | } |
3024 | if(comparetok==tk_equalto){ |
3027 | if(comparetok==tk_equalto){ |
3025 | ittok=0x74; |
3028 | ittok=0x74; |
3026 | goto endcomp; |
3029 | goto endcomp; |
3027 | } |
3030 | } |
3028 | } |
3031 | } |
3029 | if(htok.number==CX&&optimizespeed==0){ |
3032 | if(htok.number==CX&&optimizespeed==0){ |
3030 | if(ittok==tk_reg||ittok==tk_reg32){ |
3033 | if(ittok==tk_reg||ittok==tk_reg32){ |
3031 | if(comparetok==tk_notequal)use_cxz=notflag==0?cxnzcompr:cxzcompr; |
3034 | if(comparetok==tk_notequal)use_cxz=notflag==0?cxnzcompr:cxzcompr; |
3032 | else if(comparetok==tk_equalto)use_cxz=notflag==TRUE?cxnzcompr:cxzcompr; |
3035 | else if(comparetok==tk_equalto)use_cxz=notflag==TRUE?cxnzcompr:cxzcompr; |
3033 | } |
3036 | } |
3034 | } |
3037 | } |
3035 | } |
3038 | } |
3036 | en2: |
3039 | en2: |
3037 | if(ittok>=tk_charvar&&ittok<=tk_floatvar){ |
3040 | if(ittok>=tk_charvar&&ittok<=tk_floatvar){ |
3038 | if(ofsstr){ |
3041 | if(ofsstr){ |
3039 | int retreg; |
3042 | int retreg; |
3040 | razr=getrazr(vartype); |
3043 | razr=getrazr(vartype); |
3041 | if((retreg=CheckIDZReg(ofsstr,AX,razr))!=NOINREG){ |
3044 | if((retreg=CheckIDZReg(ofsstr,AX,razr))!=NOINREG){ |
3042 | usereg=retreg==SKIPREG?AX:retreg; |
3045 | usereg=retreg==SKIPREG?AX:retreg; |
3043 | if(!((ittok2==tk_reg||ittok2==tk_reg32||ittok2==tk_beg)&&usereg==htok2.number)){ |
3046 | if(!((ittok2==tk_reg||ittok2==tk_reg32||ittok2==tk_beg)&&usereg==htok2.number)){ |
3044 | if(razr==r16)ittok=tk_reg; |
3047 | if(razr==r16)ittok=tk_reg; |
3045 | else if(razr==r32)ittok=tk_reg32; |
3048 | else if(razr==r32)ittok=tk_reg32; |
3046 | else ittok=tk_beg; |
3049 | else ittok=tk_beg; |
3047 | htok.number=usereg; |
3050 | htok.number=usereg; |
3048 | if(ibuf){ |
3051 | if(ibuf){ |
3049 | free(ibuf); |
3052 | free(ibuf); |
3050 | ibuf=NULL; |
3053 | ibuf=NULL; |
3051 | } |
3054 | } |
3052 | if(hstr.bufstr){ |
3055 | if(hstr.bufstr){ |
3053 | free(hstr.bufstr); |
3056 | free(hstr.bufstr); |
3054 | hstr.bufstr=NULL; |
3057 | hstr.bufstr=NULL; |
3055 | } |
3058 | } |
3056 | } |
3059 | } |
3057 | else{ |
3060 | else{ |
3058 | usereg=-1; |
3061 | usereg=-1; |
3059 | } |
3062 | } |
3060 | } |
3063 | } |
3061 | else{ |
3064 | else{ |
3062 | if(ittok==tk_floatvar)ClearReg(AX); |
3065 | if(ittok==tk_floatvar)ClearReg(AX); |
3063 | else if(ittok>=tk_intvar&&ittok |
3066 | else if(ittok>=tk_intvar&&ittok |
3064 | switch(ittok2){ |
3067 | switch(ittok2){ |
3065 | case tk_reg: |
3068 | case tk_reg: |
3066 | case tk_reg32: |
3069 | case tk_reg32: |
3067 | case tk_number: |
3070 | case tk_number: |
3068 | case tk_postnumber: |
3071 | case tk_postnumber: |
3069 | case tk_undefofs: |
3072 | case tk_undefofs: |
3070 | break; |
3073 | break; |
3071 | default: |
3074 | default: |
3072 | usereg2=0; |
3075 | usereg2=0; |
3073 | break; |
3076 | break; |
3074 | } |
3077 | } |
3075 | } |
3078 | } |
3076 | else{ |
3079 | else{ |
3077 | switch(ittok2){ |
3080 | switch(ittok2){ |
3078 | case tk_reg: |
3081 | case tk_reg: |
3079 | case tk_reg32: |
3082 | case tk_reg32: |
3080 | ClearReg(AX); |
3083 | ClearReg(AX); |
3081 | case tk_number: |
3084 | case tk_number: |
3082 | case tk_beg: |
3085 | case tk_beg: |
3083 | break; |
3086 | break; |
3084 | default: |
3087 | default: |
3085 | usereg2=0; |
3088 | usereg2=0; |
3086 | break; |
3089 | break; |
3087 | } |
3090 | } |
3088 | } |
3091 | } |
3089 | } |
3092 | } |
3090 | } |
3093 | } |
3091 | } |
3094 | } |
3092 | if(ittok==tk_number&&htok.flag==0&&ittok2==tk_number&&htok2.flag==0){ |
3095 | if(ittok==tk_number&&htok.flag==0&&ittok2==tk_number&&htok2.flag==0){ |
3093 | invertflag=(htok.number!=htok2.number?zerocompr:voidcompr); |
3096 | invertflag=(htok.number!=htok2.number?zerocompr:voidcompr); |
3094 | useinline=oinline; |
3097 | useinline=oinline; |
3095 | return invertflag; |
3098 | return invertflag; |
3096 | } |
3099 | } |
3097 | if((ittok==tk_number||ittok==tk_postnumber)&&(ittok2==tk_number||ittok2==tk_postnumber))usereg=0; |
3100 | if((ittok==tk_number||ittok==tk_postnumber)&&(ittok2==tk_number||ittok2==tk_postnumber))usereg=0; |
3098 | #ifdef OPTVARCONST |
3101 | #ifdef OPTVARCONST |
3099 | if(comconst){ |
3102 | if(comconst){ |
3100 | if(comparetok==tk_equalto||comparetok==tk_notequal){ |
3103 | if(comparetok==tk_equalto||comparetok==tk_notequal){ |
3101 | if(ittok>=tk_charvar&&ittok<=tk_doublevar&&ittok2==tk_number&& |
3104 | if(ittok>=tk_charvar&&ittok<=tk_doublevar&&ittok2==tk_number&& |
3102 | (htok2.flag&f_reloc)==0&&htok.rec&&(htok.flag&f_useidx)==0){ |
3105 | (htok2.flag&f_reloc)==0&&htok.rec&&(htok.flag&f_useidx)==0){ |
3103 | comconst->rec=htok.rec; |
3106 | comconst->rec=htok.rec; |
3104 | comconst->lnumber=htok2.lnumber; |
3107 | comconst->lnumber=htok2.lnumber; |
3105 | comconst->contype=htok2.rm; |
3108 | comconst->contype=htok2.rm; |
3106 | } |
3109 | } |
3107 | else if(ittok2>=tk_charvar&&ittok2<=tk_doublevar&&ittok==tk_number&& |
3110 | else if(ittok2>=tk_charvar&&ittok2<=tk_doublevar&&ittok==tk_number&& |
3108 | (htok.flag&f_reloc)==0&&htok2.rec&&(htok2.flag&f_useidx)==0){ |
3111 | (htok.flag&f_reloc)==0&&htok2.rec&&(htok2.flag&f_useidx)==0){ |
3109 | comconst->rec=htok2.rec; |
3112 | comconst->rec=htok2.rec; |
3110 | comconst->lnumber=htok.lnumber; |
3113 | comconst->lnumber=htok.lnumber; |
3111 | comconst->contype=htok.rm; |
3114 | comconst->contype=htok.rm; |
3112 | } |
3115 | } |
3113 | comconst->typevar=comparetok; |
3116 | comconst->typevar=comparetok; |
3114 | if(notflag)comconst->typevar=(comparetok==tk_equalto?tk_notequal:tk_equalto); |
3117 | if(notflag)comconst->typevar=(comparetok==tk_equalto?tk_notequal:tk_equalto); |
3115 | } |
3118 | } |
3116 | } |
3119 | } |
3117 | #endif |
3120 | #endif |
3118 | if(outcmp(0,ittok,&htok,ibuf,&hstr,ittok2,&htok2,ibuf2,&hstr2,razr)){ |
3121 | if(outcmp(0,ittok,&htok,ibuf,&hstr,ittok2,&htok2,ibuf2,&hstr2,razr)){ |
3119 | switch(comparetok){ |
3122 | switch(comparetok){ |
3120 | case tk_less: comparetok=tk_greater; break; |
3123 | case tk_less: comparetok=tk_greater; break; |
3121 | case tk_lessequal: comparetok=tk_greaterequal; break; |
3124 | case tk_lessequal: comparetok=tk_greaterequal; break; |
3122 | case tk_greater: comparetok=tk_less; break; |
3125 | case tk_greater: comparetok=tk_less; break; |
3123 | case tk_greaterequal: comparetok=tk_lessequal; break; |
3126 | case tk_greaterequal: comparetok=tk_lessequal; break; |
3124 | } |
3127 | } |
3125 | } |
3128 | } |
3126 | createopcode: |
3129 | createopcode: |
3127 | jumptype=0; |
3130 | jumptype=0; |
3128 | if(vartype==tk_char||vartype==tk_int||vartype==tk_long)jumptype=1; |
3131 | if(vartype==tk_char||vartype==tk_int||vartype==tk_long)jumptype=1; |
3129 | switch(comparetok){ |
3132 | switch(comparetok){ |
3130 | case tk_equalto: ittok=0x74; break; |
3133 | case tk_equalto: ittok=0x74; break; |
3131 | case tk_notequal: ittok=0x75; break; |
3134 | case tk_notequal: ittok=0x75; break; |
3132 | case tk_greater: |
3135 | case tk_greater: |
3133 | ittok=(jumptype==0?0x77:0x7F); |
3136 | ittok=(jumptype==0?0x77:0x7F); |
3134 | break; |
3137 | break; |
3135 | case tk_less: |
3138 | case tk_less: |
3136 | ittok=(jumptype==0?0x72:0x7C); |
3139 | ittok=(jumptype==0?0x72:0x7C); |
3137 | break; |
3140 | break; |
3138 | case tk_greaterequal: |
3141 | case tk_greaterequal: |
3139 | ittok=(jumptype==0?0x73:0x7D); |
3142 | ittok=(jumptype==0?0x73:0x7D); |
3140 | break; |
3143 | break; |
3141 | case tk_lessequal: |
3144 | case tk_lessequal: |
3142 | ittok=(jumptype==0?0x76:0x7E); |
3145 | ittok=(jumptype==0?0x76:0x7E); |
3143 | break; |
3146 | break; |
3144 | default: unknowncompop(); break; |
3147 | default: unknowncompop(); break; |
3145 | } |
3148 | } |
3146 | endcomp: |
3149 | endcomp: |
3147 | if(ofsstr){ |
3150 | if(ofsstr){ |
3148 | if(usereg!=-1)IDZToReg(ofsstr,usereg,razr); |
3151 | if(usereg!=-1)IDZToReg(ofsstr,usereg,razr); |
3149 | free(ofsstr); |
3152 | free(ofsstr); |
3150 | } |
3153 | } |
3151 | if(ofsstr2){ |
3154 | if(ofsstr2){ |
3152 | // printf("usereg2=%08X %s\n",usereg2,ofsstr2); |
3155 | // printf("usereg2=%08X %s\n",usereg2,ofsstr2); |
3153 | if(usereg2!=-1)IDZToReg(ofsstr2,usereg2,razr); |
3156 | if(usereg2!=-1)IDZToReg(ofsstr2,usereg2,razr); |
3154 | free(ofsstr2); |
3157 | free(ofsstr2); |
3155 | } |
3158 | } |
3156 | if(invertflag==2)invertflag=((outptr+2-startloc)>128?1:0); |
3159 | if(invertflag==2)invertflag=((outptr+2-startloc)>128?1:0); |
3157 | ittok^=invertflag; |
3160 | ittok^=invertflag; |
3158 | ittok^=notflag; |
3161 | ittok^=notflag; |
3159 | op(ittok); /* output instruction code */ |
3162 | op(ittok); /* output instruction code */ |
3160 | expecting(tk_closebracket); |
3163 | expecting(tk_closebracket); |
3161 | useinline=oinline; |
3164 | useinline=oinline; |
3162 | return invertflag|use_cxz; |
3165 | return invertflag|use_cxz; |
3163 | } |
3166 | } |
3164 | 3167 | ||
3165 | #ifdef OPTVARCONST |
3168 | #ifdef OPTVARCONST |
3166 | ICOMP *compare(int type,unsigned int *numcomp,REGISTERSTAT **bakreg,REGISTERSTAT **changereg,LVIC *comconst) |
3169 | ICOMP *compare(int type,unsigned int *numcomp,REGISTERSTAT **bakreg,REGISTERSTAT **changereg,LVIC *comconst) |
3167 | #else |
3170 | #else |
3168 | ICOMP *compare(int type,unsigned int *numcomp,REGISTERSTAT **bakreg,REGISTERSTAT **changereg) |
3171 | ICOMP *compare(int type,unsigned int *numcomp,REGISTERSTAT **bakreg,REGISTERSTAT **changereg) |
3169 | #endif |
3172 | #endif |
3170 | { |
3173 | { |
3171 | unsigned int i; |
3174 | unsigned int i; |
3172 | ICOMP *icomp; |
3175 | ICOMP *icomp; |
3173 | int j=0; |
3176 | int j=0; |
3174 | int ifline=linenumber; |
3177 | int ifline=linenumber; |
3175 | int ptok=tk_oror; |
3178 | int ptok=tk_oror; |
3176 | int rcompr; |
3179 | int rcompr; |
3177 | int useor=FALSE; |
3180 | int useor=FALSE; |
3178 | REGISTERSTAT *bakregstat=NULL,*changeregstat=NULL; |
3181 | REGISTERSTAT *bakregstat=NULL,*changeregstat=NULL; |
3179 | if(am32)j=2; |
3182 | if(am32)j=2; |
3180 | icomp=(ICOMP *)MALLOC(sizeof(ICOMP)*MAXIF); //áëîê äëÿ èíôî î ñðàâíåíèÿõ |
3183 | icomp=(ICOMP *)MALLOC(sizeof(ICOMP)*MAXIF); //áëîê äëÿ èíôî î ñðàâíåíèÿõ |
3181 | i=0; |
3184 | i=0; |
3182 | 3185 | ||
3183 | do{ |
3186 | do{ |
3184 | #ifdef OPTVARCONST |
3187 | #ifdef OPTVARCONST |
3185 | if((rcompr=constructcompare(0,outptr,comconst))==voidcompr||rcompr==zerocompr)i=1; |
3188 | if((rcompr=constructcompare(0,outptr,comconst))==voidcompr||rcompr==zerocompr)i=1; |
3186 | #else |
3189 | #else |
3187 | if((rcompr=constructcompare(0,outptr))==voidcompr||rcompr==zerocompr)i=1; |
3190 | if((rcompr=constructcompare(0,outptr))==voidcompr||rcompr==zerocompr)i=1; |
3188 | #endif |
3191 | #endif |
3189 | if(i){ |
3192 | if(i){ |
3190 | if(rcompr==voidcompr&&ptok==tk_andand){ |
3193 | if(rcompr==voidcompr&&ptok==tk_andand){ |
3191 | i=0; |
3194 | i=0; |
3192 | ptok=tok; |
3195 | ptok=tok; |
3193 | } |
3196 | } |
3194 | continue; |
3197 | continue; |
3195 | } |
3198 | } |
3196 | op(0x03+j); |
3199 | op(0x03+j); |
3197 | if(tok!=tk_oror){ |
3200 | if(tok!=tk_oror){ |
3198 | JXorJMP(); |
3201 | JXorJMP(); |
3199 | if(am32!=FALSE)outword(0); |
3202 | if(am32!=FALSE)outword(0); |
3200 | outword(0); |
3203 | outword(0); |
3201 | } |
3204 | } |
3202 | (icomp+*numcomp)->loc=outptr; |
3205 | (icomp+*numcomp)->loc=outptr; |
3203 | (icomp+*numcomp)->type=tok; |
3206 | (icomp+*numcomp)->type=tok; |
3204 | // (icomp+*numcomp)->use_cxz=rcompr&0xFC; |
3207 | // (icomp+*numcomp)->use_cxz=rcompr&0xFC; |
3205 | (*numcomp)++ ; |
3208 | (*numcomp)++ ; |
3206 | if(*numcomp==MAXIF){ |
3209 | if(*numcomp==MAXIF){ |
3207 | ManyLogicCompare(); |
3210 | ManyLogicCompare(); |
3208 | free(icomp); |
3211 | free(icomp); |
3209 | return NULL; |
3212 | return NULL; |
3210 | } |
3213 | } |
3211 | ptok=tok; |
3214 | ptok=tok; |
3212 | /* if(tok!=tk_andand&&tok!=tk_oror&&bakregstat==NULL){ |
3215 | /* if(tok!=tk_andand&&tok!=tk_oror&&bakregstat==NULL){ |
3213 | bakregstat=BakRegStat(); |
3216 | bakregstat=BakRegStat(); |
3214 | changeregstat=BakRegStat(); |
3217 | changeregstat=BakRegStat(); |
3215 | }*/ |
3218 | }*/ |
3216 | }while(tok==tk_oror||tok==tk_andand); |
3219 | }while(tok==tk_oror||tok==tk_andand); |
3217 | if(tok==tk_closebracket)nexttok(); |
3220 | if(tok==tk_closebracket)nexttok(); |
3218 | for(i=0;i<*numcomp;i++){ |
3221 | for(i=0;i<*numcomp;i++){ |
3219 | unsigned long temp=outptr-(icomp+i)->loc; |
3222 | unsigned long temp=outptr-(icomp+i)->loc; |
3220 | if((icomp+i)->type==tk_oror){ |
3223 | if((icomp+i)->type==tk_oror){ |
3221 | #ifdef OPTVARCONST |
3224 | #ifdef OPTVARCONST |
3222 | if(comconst)comconst->rec=NULL; |
3225 | if(comconst)comconst->rec=NULL; |
3223 | #endif |
3226 | #endif |
3224 | if(temp>127)CompareOr(); |
3227 | if(temp>127)CompareOr(); |
3225 | output[(icomp+i)->loc-1]=(unsigned char)temp; |
3228 | output[(icomp+i)->loc-1]=(unsigned char)temp; |
3226 | clearregstat(); |
3229 | clearregstat(); |
3227 | useor=TRUE; |
3230 | useor=TRUE; |
3228 | } |
3231 | } |
3229 | else if(chip>2){ |
3232 | else if(chip>2){ |
3230 | if(am32==FALSE)*(unsigned short *)&output[(icomp+i)->loc-2]=(unsigned short)temp; |
3233 | if(am32==FALSE)*(unsigned short *)&output[(icomp+i)->loc-2]=(unsigned short)temp; |
3231 | else *(unsigned long *)&output[(icomp+i)->loc-4]=(unsigned long)temp; |
3234 | else *(unsigned long *)&output[(icomp+i)->loc-4]=(unsigned long)temp; |
3232 | } |
3235 | } |
3233 | } |
3236 | } |
3234 | 3237 | ||
3235 | if(bakregstat==NULL){ |
3238 | if(bakregstat==NULL){ |
3236 | bakregstat=BakRegStat(); |
3239 | bakregstat=BakRegStat(); |
3237 | changeregstat=BakRegStat(); |
3240 | changeregstat=BakRegStat(); |
3238 | } |
3241 | } |
3239 | if(type==tk_if&&rcompr!=zerocompr){ |
3242 | if(type==tk_if&&rcompr!=zerocompr){ |
3240 | if(rcompr==voidcompr)warcompeqconst(); |
3243 | if(rcompr==voidcompr)warcompeqconst(); |
3241 | if(tok==tk_return||tok==tk_RETURN){ |
3244 | if(tok==tk_return||tok==tk_RETURN){ |
3242 | if(tok2==tk_semicolon||(tok2==tk_openbracket&&ScanTok3()==tk_closebracket)){ |
3245 | if(tok2==tk_semicolon||(tok2==tk_openbracket&&ScanTok3()==tk_closebracket)){ |
3243 | if(insertmode||(!optimizespeed)){ |
3246 | if(insertmode||(!optimizespeed)){ |
3244 | if(tok==tk_return||tok==tk_RETURN)goto merge_if; |
3247 | if(tok==tk_return||tok==tk_RETURN)goto merge_if; |
3245 | } |
3248 | } |
3246 | } |
3249 | } |
3247 | startblock(); |
3250 | startblock(); |
3248 | doreturn(tok); |
3251 | doreturn(tok); |
3249 | endblock(); |
3252 | endblock(); |
3250 | int di; |
3253 | int di; |
3251 | if(rcompr==voidcompr)di=0; |
3254 | if(rcompr==voidcompr)di=0; |
3252 | else di=am32==FALSE?2:4; |
3255 | else di=am32==FALSE?2:4; |
3253 | for(unsigned int i=0;i<*numcomp;i++){ |
3256 | for(unsigned int i=0;i<*numcomp;i++){ |
3254 | if((icomp+i)->type!=tk_oror){ |
3257 | if((icomp+i)->type!=tk_oror){ |
3255 | if(am32==FALSE)*(unsigned short *)&output[(icomp+i)->loc-di]=(unsigned short)(outptr-(icomp+i)->loc); |
3258 | if(am32==FALSE)*(unsigned short *)&output[(icomp+i)->loc-di]=(unsigned short)(outptr-(icomp+i)->loc); |
3256 | else *(unsigned long *)&output[(icomp+i)->loc-di]=(unsigned long)(outptr-(icomp+i)->loc); |
3259 | else *(unsigned long *)&output[(icomp+i)->loc-di]=(unsigned long)(outptr-(icomp+i)->loc); |
3257 | } |
3260 | } |
3258 | } |
3261 | } |
3259 | if((outptr-icomp->loc)<=127)warningjmp(mesIF,ifline); |
3262 | if((outptr-icomp->loc)<=127)warningjmp(mesIF,ifline); |
3260 | if(tok==tk_else||tok==tk_ELSE){ |
3263 | if(tok==tk_else||tok==tk_ELSE){ |
3261 | notunreach=TRUE; |
3264 | notunreach=TRUE; |
3262 | nexttok(); |
3265 | nexttok(); |
3263 | docommand(); |
3266 | docommand(); |
3264 | } |
3267 | } |
3265 | free(icomp); |
3268 | free(icomp); |
3266 | return NULL; |
3269 | return NULL; |
3267 | } |
3270 | } |
3268 | if(tok==tk_break||tok==tk_BREAK||tok==tk_continue||tok==tk_CONTINUE||tok==tk_goto||tok==tk_GOTO){ |
3271 | if(tok==tk_break||tok==tk_BREAK||tok==tk_continue||tok==tk_CONTINUE||tok==tk_goto||tok==tk_GOTO){ |
3269 | merge_if: |
3272 | merge_if: |
3270 | if(rcompr==voidcompr)goto endp; |
3273 | if(rcompr==voidcompr)goto endp; |
3271 | if(chip<3){ |
3274 | if(chip<3){ |
3272 | for(i=0;i<*numcomp;i++){ |
3275 | for(i=0;i<*numcomp;i++){ |
3273 | if((icomp+i)->type==tk_oror)output[(icomp+i)->loc-1]=(unsigned char)(output[(icomp+i)->loc-1]-3-j); |
3276 | if((icomp+i)->type==tk_oror)output[(icomp+i)->loc-1]=(unsigned char)(output[(icomp+i)->loc-1]-3-j); |
3274 | else{ |
3277 | else{ |
3275 | if((icomp+i)->type!=tk_andand)output[(icomp+i)->loc-5-j]=(unsigned char)(output[(icomp+i)->loc-5-j]^1); |
3278 | if((icomp+i)->type!=tk_andand)output[(icomp+i)->loc-5-j]=(unsigned char)(output[(icomp+i)->loc-5-j]^1); |
3276 | else{ |
3279 | else{ |
3277 | if(am32==FALSE)*(unsigned short *)&output[(icomp+i)->loc-2]=(unsigned short)(outptr-(icomp+i)->loc); |
3280 | if(am32==FALSE)*(unsigned short *)&output[(icomp+i)->loc-2]=(unsigned short)(outptr-(icomp+i)->loc); |
3278 | else *(unsigned long *)&output[(icomp+i)->loc-4]=(unsigned long)(outptr-(icomp+i)->loc); |
3281 | else *(unsigned long *)&output[(icomp+i)->loc-4]=(unsigned long)(outptr-(icomp+i)->loc); |
3279 | } |
3282 | } |
3280 | } |
3283 | } |
3281 | } |
3284 | } |
3282 | outptr-=3+j; |
3285 | outptr-=3+j; |
3283 | } |
3286 | } |
3284 | else{ |
3287 | else{ |
3285 | for(i=0;i<*numcomp;i++){ |
3288 | for(i=0;i<*numcomp;i++){ |
3286 | if((icomp+i)->type==tk_oror)output[(icomp+i)->loc-1]=(unsigned char)(output[(icomp+i)->loc-1]-2-j); |
3289 | if((icomp+i)->type==tk_oror)output[(icomp+i)->loc-1]=(unsigned char)(output[(icomp+i)->loc-1]-2-j); |
3287 | else{ |
3290 | else{ |
3288 | if((icomp+i)->type!=tk_andand){ |
3291 | if((icomp+i)->type!=tk_andand){ |
3289 | output[(icomp+i)->loc-4-j]=(unsigned char)(output[(icomp+i)->loc-3-j]-0x10); |
3292 | output[(icomp+i)->loc-4-j]=(unsigned char)(output[(icomp+i)->loc-3-j]-0x10); |
3290 | output[(icomp+i)->loc-3-j]=(unsigned char)(3+j); |
3293 | output[(icomp+i)->loc-3-j]=(unsigned char)(3+j); |
3291 | } |
3294 | } |
3292 | else{ |
3295 | else{ |
3293 | if(am32==FALSE)*(unsigned short *)&output[(icomp+i)->loc-2]=(unsigned short)(outptr-(icomp+i)->loc+1); |
3296 | if(am32==FALSE)*(unsigned short *)&output[(icomp+i)->loc-2]=(unsigned short)(outptr-(icomp+i)->loc+1); |
3294 | else *(unsigned long *)&output[(icomp+i)->loc-4]=(unsigned long)(outptr-(icomp+i)->loc+1); |
3297 | else *(unsigned long *)&output[(icomp+i)->loc-4]=(unsigned long)(outptr-(icomp+i)->loc+1); |
3295 | } |
3298 | } |
3296 | } |
3299 | } |
3297 | } |
3300 | } |
3298 | outptr-=2+j; |
3301 | outptr-=2+j; |
3299 | if(cpu<3)cpu=3; |
3302 | if(cpu<3)cpu=3; |
3300 | } |
3303 | } |
3301 | int delta=0; //new 07.06.06 20:27 |
3304 | int delta=0; //new 07.06.06 20:27 |
3302 | 3305 | ||
3303 | if(tok==tk_break||tok==tk_BREAK){ |
3306 | if(tok==tk_break||tok==tk_BREAK){ |
3304 | if(useor==FALSE){ |
3307 | if(useor==FALSE){ |
3305 | int ooutptr=outptr-2; |
3308 | int ooutptr=outptr-2; |
3306 | int otok=tok; |
3309 | int otok=tok; |
3307 | i=(unsigned char)(output[ooutptr]^1); |
3310 | i=(unsigned char)(output[ooutptr]^1); |
3308 | outptr--; |
3311 | outptr--; |
3309 | if(tok==tk_break)i+=0x10; |
3312 | if(tok==tk_break)i+=0x10; |
3310 | else outptr--; |
3313 | else outptr--; |
3311 | doBREAK((unsigned char)(tok==tk_BREAK?BREAK_SHORT:(am32==FALSE?BREAK_NEAR:BREAK_32))); |
3314 | doBREAK((unsigned char)(tok==tk_BREAK?BREAK_SHORT:(am32==FALSE?BREAK_NEAR:BREAK_32))); |
3312 | if(otok==tk_break){ |
3315 | if(otok==tk_break){ |
3313 | output[ooutptr]=0x0f; |
3316 | output[ooutptr]=0x0f; |
3314 | output[ooutptr+1]=i; |
3317 | output[ooutptr+1]=i; |
3315 | delta=-1; |
3318 | delta=-1; |
3316 | } |
3319 | } |
3317 | else{ |
3320 | else{ |
3318 | output[ooutptr]=i; |
3321 | output[ooutptr]=i; |
3319 | delta=(am32==TRUE?-5:-3); |
3322 | delta=(am32==TRUE?-5:-3); |
3320 | } |
3323 | } |
3321 | } |
3324 | } |
3322 | else{ |
3325 | else{ |
3323 | if(tok==tk_BREAK){ |
3326 | if(tok==tk_BREAK){ |
3324 | output[outptr-1]-=(am32==TRUE?3:1); |
3327 | output[outptr-1]-=(am32==TRUE?3:1); |
3325 | } |
3328 | } |
3326 | doBREAK((unsigned char)(tok==tk_BREAK?BREAK_SHORT:(am32==FALSE?BREAK_NEAR:BREAK_32))); |
3329 | doBREAK((unsigned char)(tok==tk_BREAK?BREAK_SHORT:(am32==FALSE?BREAK_NEAR:BREAK_32))); |
3327 | } |
3330 | } |
3328 | } |
3331 | } |
3329 | else if(tok==tk_return||tok==tk_RETURN){ |
3332 | else if(tok==tk_return||tok==tk_RETURN){ |
3330 | //new 07.06.06 21:12 |
3333 | //new 07.06.06 21:12 |
3331 | if(useor==FALSE){ |
3334 | if(useor==FALSE){ |
3332 | int ooutptr=outptr-2; |
3335 | int ooutptr=outptr-2; |
3333 | int otok=tok; |
3336 | int otok=tok; |
3334 | i=(unsigned char)(output[ooutptr]^1); |
3337 | i=(unsigned char)(output[ooutptr]^1); |
3335 | outptr--; |
3338 | outptr--; |
3336 | if(tok==tk_return){ |
3339 | if(tok==tk_return){ |
3337 | i+=0x10; |
3340 | i+=0x10; |
3338 | } |
3341 | } |
3339 | else outptr--; |
3342 | else outptr--; |
3340 | AddRetList(outptr+1,linenumber,tok); |
3343 | AddRetList(outptr+1,linenumber,tok); |
3341 | if(tok2==tk_openbracket){ |
3344 | if(tok2==tk_openbracket){ |
3342 | nexttok(); |
3345 | nexttok(); |
3343 | nexttok(); |
3346 | nexttok(); |
3344 | } |
3347 | } |
3345 | if(otok==tk_return){ |
3348 | if(otok==tk_return){ |
3346 | output[ooutptr]=0x0f; |
3349 | output[ooutptr]=0x0f; |
3347 | output[ooutptr+1]=i; |
3350 | output[ooutptr+1]=i; |
3348 | delta=-1; |
3351 | delta=-1; |
3349 | } |
3352 | } |
3350 | else{ |
3353 | else{ |
3351 | output[ooutptr]=i; |
3354 | output[ooutptr]=i; |
3352 | delta=(am32==TRUE?-5:-3); |
3355 | delta=(am32==TRUE?-5:-3); |
3353 | } |
3356 | } |
3354 | } |
3357 | } |
3355 | else{ |
3358 | else{ |
3356 | if(tok==tk_RETURN)output[outptr-1]-=(am32==TRUE?3:1); |
3359 | if(tok==tk_RETURN)output[outptr-1]-=(am32==TRUE?3:1); |
3357 | AddRetList(outptr+1,linenumber,tok); |
3360 | AddRetList(outptr+1,linenumber,tok); |
3358 | if(tok==tk_return&&tok2==tk_openbracket){ |
3361 | if(tok==tk_return&&tok2==tk_openbracket){ |
3359 | nexttok(); |
3362 | nexttok(); |
3360 | nexttok(); |
3363 | nexttok(); |
3361 | } |
3364 | } |
3362 | } |
3365 | } |
3363 | nextseminext(); |
3366 | nextseminext(); |
3364 | clearregstat(); |
3367 | clearregstat(); |
3365 | #ifdef OPTVARCONST |
3368 | #ifdef OPTVARCONST |
3366 | ClearLVIC(); |
3369 | ClearLVIC(); |
3367 | #endif |
3370 | #endif |
3368 | } |
3371 | } |
3369 | else if(tok==tk_goto||tok==tk_GOTO){ |
3372 | else if(tok==tk_goto||tok==tk_GOTO){ |
3370 | int ooutptr=outptr; |
3373 | int ooutptr=outptr; |
3371 | if(useor==FALSE){ |
3374 | if(useor==FALSE){ |
3372 | if(tok==tk_GOTO){ |
3375 | if(tok==tk_GOTO){ |
3373 | outptr-=2; |
3376 | outptr-=2; |
3374 | i=(unsigned char)(output[outptr]^1); |
3377 | i=(unsigned char)(output[outptr]^1); |
3375 | GOTOdo(); |
3378 | GOTOdo(); |
3376 | output[outptr-2]=i; |
3379 | output[outptr-2]=i; |
3377 | delta=(am32==0?-3:-5); |
3380 | delta=(am32==0?-3:-5); |
3378 | } |
3381 | } |
3379 | else{ |
3382 | else{ |
3380 | int otok2=tok2; |
3383 | int otok2=tok2; |
3381 | gotodo(); |
3384 | gotodo(); |
3382 | if(output[ooutptr]==0xEB){ //áûë êîðîòêèé ïåðåõîä |
3385 | if(output[ooutptr]==0xEB){ //áûë êîðîòêèé ïåðåõîä |
3383 | outptr=ooutptr-2; |
3386 | outptr=ooutptr-2; |
3384 | op(output[outptr]^1); |
3387 | op(output[outptr]^1); |
3385 | op(output[ooutptr+1]+2); |
3388 | op(output[ooutptr+1]+2); |
3386 | delta=(am32==0?-3:-5); |
3389 | delta=(am32==0?-3:-5); |
3387 | } |
3390 | } |
3388 | else if(am32&&otok2==tk_number){ |
3391 | else if(am32&&otok2==tk_number){ |
3389 | outptr=ooutptr-2; |
3392 | outptr=ooutptr-2; |
3390 | i=(unsigned char)((output[outptr]^1)+0x10); |
3393 | i=(unsigned char)((output[outptr]^1)+0x10); |
3391 | op(0x0f); |
3394 | op(0x0f); |
3392 | op(i); |
3395 | op(i); |
3393 | if(output[outptr]==0xE9)outdword(*(unsigned long *)&output[ooutptr+1]+1); |
3396 | if(output[outptr]==0xE9)outdword(*(unsigned long *)&output[ooutptr+1]+1); |
3394 | else outdword(*(unsigned short *)&output[ooutptr+2]); |
3397 | else outdword(*(unsigned short *)&output[ooutptr+2]); |
3395 | delta=-1; |
3398 | delta=-1; |
3396 | } |
3399 | } |
3397 | } |
3400 | } |
3398 | } |
3401 | } |
3399 | else{ // useor |
3402 | else{ // useor |
3400 | if(tok==tk_goto)gotodo(); |
3403 | if(tok==tk_goto)gotodo(); |
3401 | else GOTOdo(); |
3404 | else GOTOdo(); |
3402 | if(output[ooutptr]==0xEB){ //áûë êîðîòêèé ïåðåõîä |
3405 | if(output[ooutptr]==0xEB){ //áûë êîðîòêèé ïåðåõîä |
3403 | output[ooutptr-1]-=(am32==TRUE?3:1); |
3406 | output[ooutptr-1]-=(am32==TRUE?3:1); |
3404 | } |
3407 | } |
3405 | } |
3408 | } |
3406 | } |
3409 | } |
3407 | else{ |
3410 | else{ |
3408 | if(useor==FALSE){ |
3411 | if(useor==FALSE){ |
3409 | int ooutptr=outptr-2; |
3412 | int ooutptr=outptr-2; |
3410 | int otok=tok; |
3413 | int otok=tok; |
3411 | i=(unsigned char)(output[ooutptr]^1); |
3414 | i=(unsigned char)(output[ooutptr]^1); |
3412 | outptr--; |
3415 | outptr--; |
3413 | if(tok==tk_continue)i+=0x10; |
3416 | if(tok==tk_continue)i+=0x10; |
3414 | else outptr--; |
3417 | else outptr--; |
3415 | doCONTINUE((unsigned char)(tok==tk_CONTINUE?CONTINUE_SHORT:(am32==FALSE?CONTINUE_NEAR:CONTINUE_32))); |
3418 | doCONTINUE((unsigned char)(tok==tk_CONTINUE?CONTINUE_SHORT:(am32==FALSE?CONTINUE_NEAR:CONTINUE_32))); |
3416 | if(otok==tk_continue){ |
3419 | if(otok==tk_continue){ |
3417 | output[ooutptr]=0x0f; |
3420 | output[ooutptr]=0x0f; |
3418 | output[ooutptr+1]=i; |
3421 | output[ooutptr+1]=i; |
3419 | delta=-1; |
3422 | delta=-1; |
3420 | } |
3423 | } |
3421 | else{ |
3424 | else{ |
3422 | output[ooutptr]=i; |
3425 | output[ooutptr]=i; |
3423 | delta=(am32==TRUE?-5:-3); |
3426 | delta=(am32==TRUE?-5:-3); |
3424 | } |
3427 | } |
3425 | } |
3428 | } |
3426 | else{ |
3429 | else{ |
3427 | if(tok==tk_CONTINUE){ |
3430 | if(tok==tk_CONTINUE){ |
3428 | output[outptr-1]-=(am32==TRUE?3:1); |
3431 | output[outptr-1]-=(am32==TRUE?3:1); |
3429 | } |
3432 | } |
3430 | doCONTINUE((unsigned char)(tok==tk_CONTINUE?CONTINUE_SHORT:(am32==FALSE?CONTINUE_NEAR:CONTINUE_32))); |
3433 | doCONTINUE((unsigned char)(tok==tk_CONTINUE?CONTINUE_SHORT:(am32==FALSE?CONTINUE_NEAR:CONTINUE_32))); |
3431 | } |
3434 | } |
3432 | } |
3435 | } |
3433 | for(i=0;i<*numcomp;i++){ |
3436 | for(i=0;i<*numcomp;i++){ |
3434 | // if((icomp+i)->type==tk_oror)output[(icomp+i)->loc-1]+=delta; |
3437 | // if((icomp+i)->type==tk_oror)output[(icomp+i)->loc-1]+=delta; |
3435 | // else |
3438 | // else |
3436 | if((icomp+i)->type==tk_andand){ |
3439 | if((icomp+i)->type==tk_andand){ |
3437 | if(am32==FALSE)*(signed short *)&output[(icomp+i)->loc-2]+=delta; |
3440 | if(am32==FALSE)*(signed short *)&output[(icomp+i)->loc-2]+=delta; |
3438 | else *(signed long *)&output[(icomp+i)->loc-4]+=delta; |
3441 | else *(signed long *)&output[(icomp+i)->loc-4]+=delta; |
3439 | } |
3442 | } |
3440 | } |
3443 | } |
3441 | if(tok==tk_else||tok==tk_ELSE){ |
3444 | if(tok==tk_else||tok==tk_ELSE){ |
3442 | notunreach=TRUE; |
3445 | notunreach=TRUE; |
3443 | nexttok(); |
3446 | nexttok(); |
3444 | docommand(); |
3447 | docommand(); |
3445 | } |
3448 | } |
3446 | free(icomp); |
3449 | free(icomp); |
3447 | return NULL; |
3450 | return NULL; |
3448 | } |
3451 | } |
3449 | } |
3452 | } |
3450 | endp: |
3453 | endp: |
3451 | if(type!=tk_for){ |
3454 | if(type!=tk_for){ |
3452 | startblock(); |
3455 | startblock(); |
3453 | if(rcompr==zerocompr)warcompneqconst(); |
3456 | if(rcompr==zerocompr)warcompneqconst(); |
3454 | if(tok==tk_openbrace){ |
3457 | if(tok==tk_openbrace){ |
3455 | if(rcompr==zerocompr){ |
3458 | if(rcompr==zerocompr){ |
3456 | cha=cha2; |
3459 | cha=cha2; |
3457 | inptr=inptr2; |
3460 | inptr=inptr2; |
3458 | SkipBlock(); |
3461 | SkipBlock(); |
3459 | inptr2=inptr; |
3462 | inptr2=inptr; |
3460 | cha2=cha; |
3463 | cha2=cha; |
3461 | linenum2=linenumber; |
3464 | linenum2=linenumber; |
3462 | nexttok(); |
3465 | nexttok(); |
3463 | } |
3466 | } |
3464 | else{ |
3467 | else{ |
3465 | #ifdef OPTVARCONST |
3468 | #ifdef OPTVARCONST |
3466 | if(comconst&&comconst->rec&&comconst->typevar==tk_equalto){ |
3469 | if(comconst&&comconst->rec&&comconst->typevar==tk_equalto){ |
3467 | Const2VarRec(comconst); |
3470 | Const2VarRec(comconst); |
3468 | } |
3471 | } |
3469 | #endif |
3472 | #endif |
3470 | doblock(); |
3473 | doblock(); |
3471 | nexttok(); |
3474 | nexttok(); |
3472 | } |
3475 | } |
3473 | } |
3476 | } |
3474 | else{ |
3477 | else{ |
3475 | if(rcompr==zerocompr){ |
3478 | if(rcompr==zerocompr){ |
3476 | do{ |
3479 | do{ |
3477 | nexttok(); |
3480 | nexttok(); |
3478 | }while(tok!=tk_semicolon&&tok!=tk_eof); |
3481 | }while(tok!=tk_semicolon&&tok!=tk_eof); |
3479 | } |
3482 | } |
3480 | else{ |
3483 | else{ |
3481 | #ifdef OPTVARCONST |
3484 | #ifdef OPTVARCONST |
3482 | if(comconst&&comconst->rec&&comconst->typevar==tk_equalto){ |
3485 | if(comconst&&comconst->rec&&comconst->typevar==tk_equalto){ |
3483 | Const2VarRec(comconst); |
3486 | Const2VarRec(comconst); |
3484 | } |
3487 | } |
3485 | #endif |
3488 | #endif |
3486 | docommand(); |
3489 | docommand(); |
3487 | } |
3490 | } |
3488 | } |
3491 | } |
3489 | endblock(); |
3492 | endblock(); |
3490 | RestoreStack(); |
3493 | RestoreStack(); |
3491 | } |
3494 | } |
3492 | if(bakreg)*bakreg=bakregstat; |
3495 | if(bakreg)*bakreg=bakregstat; |
3493 | if(changereg)*changereg=changeregstat; |
3496 | if(changereg)*changereg=changeregstat; |
3494 | return icomp; |
3497 | return icomp; |
3495 | } |
3498 | } |
3496 | 3499 | ||
3497 | void opt_if_else_stop(unsigned int newptr) |
3500 | void opt_if_else_stop(unsigned int newptr) |
3498 | { |
3501 | { |
3499 | unsigned int ooutptr,ooutptrdata; |
3502 | unsigned int ooutptr,ooutptrdata; |
3500 | unsigned char instr; |
3503 | unsigned char instr; |
3501 | dbgact++; |
3504 | dbgact++; |
3502 | ooutptr=outptr; |
3505 | ooutptr=outptr; |
3503 | ooutptrdata=outptrdata; |
3506 | ooutptrdata=outptrdata; |
3504 | outptr=newptr; |
3507 | outptr=newptr; |
3505 | instr=output[outptr]; |
3508 | instr=output[outptr]; |
3506 | docommand(); |
3509 | docommand(); |
3507 | if(output[newptr]==0xEB){ |
3510 | if(output[newptr]==0xEB){ |
3508 | signed char ofs=output[newptr+1]; |
3511 | signed char ofs=output[newptr+1]; |
3509 | if(output[newptr-1]==0x0F&&instr>=0x80&&instr<0x90){ |
3512 | if(output[newptr-1]==0x0F&&instr>=0x80&&instr<0x90){ |
3510 | ofs--; |
3513 | ofs--; |
3511 | if(am32)ofs-=(signed char)2; |
3514 | if(am32)ofs-=(signed char)2; |
3512 | } |
3515 | } |
3513 | if(am32)*(long *)&output[newptr+1]=ofs; |
3516 | if(am32)*(long *)&output[newptr+1]=ofs; |
3514 | else*(short *)&output[newptr+1]=ofs; |
3517 | else*(short *)&output[newptr+1]=ofs; |
3515 | } |
3518 | } |
3516 | if(am32&&output[newptr]==0x66&&output[newptr+1]==0xE9){ |
3519 | if(am32&&output[newptr]==0x66&&output[newptr+1]==0xE9){ |
3517 | signed short ofs=(signed short)(*(short *)&output[newptr+2]-1); |
3520 | signed short ofs=(signed short)(*(short *)&output[newptr+2]-1); |
3518 | *(long *)&output[newptr+1]=ofs; |
3521 | *(long *)&output[newptr+1]=ofs; |
3519 | } |
3522 | } |
3520 | output[newptr]=instr; |
3523 | output[newptr]=instr; |
3521 | outptr=ooutptr; |
3524 | outptr=ooutptr; |
3522 | outptrdata=ooutptrdata; |
3525 | outptrdata=ooutptrdata; |
3523 | dbgact--; |
3526 | dbgact--; |
3524 | } |
3527 | } |
3525 | 3528 | ||
3526 | void doif() |
3529 | void doif() |
3527 | { |
3530 | { |
3528 | unsigned int startloc,elseline,numcomp=0,ifline; |
3531 | unsigned int startloc,elseline,numcomp=0,ifline; |
3529 | ICOMP *icomp; |
3532 | ICOMP *icomp; |
3530 | REGISTERSTAT *bakregstat=NULL,*changeregstat=NULL; |
3533 | REGISTERSTAT *bakregstat=NULL,*changeregstat=NULL; |
3531 | unsigned int oaddESP=addESP; |
3534 | unsigned int oaddESP=addESP; |
3532 | ifline=linenumber; |
3535 | ifline=linenumber; |
3533 | #ifdef OPTVARCONST |
3536 | #ifdef OPTVARCONST |
3534 | LVIC comconst; |
3537 | LVIC comconst; |
3535 | comconst.rec=NULL; |
3538 | comconst.rec=NULL; |
3536 | icomp=compare(tk_if,&numcomp,&bakregstat,&changeregstat,&comconst); |
3539 | icomp=compare(tk_if,&numcomp,&bakregstat,&changeregstat,&comconst); |
3537 | #else |
3540 | #else |
3538 | icomp=compare(tk_if,&numcomp,&bakregstat,&changeregstat); |
3541 | icomp=compare(tk_if,&numcomp,&bakregstat,&changeregstat); |
3539 | #endif |
3542 | #endif |
3540 | // i=CheckStopBlock(); |
3543 | // i=CheckStopBlock(); |
3541 | /*-----------------19.08.99 22:35------------------- |
3544 | /*-----------------19.08.99 22:35------------------- |
3542 | Óáèðàòü else ìîæíî òîëüêî ïîñëå ïåðâîãî if |
3545 | Óáèðàòü else ìîæíî òîëüêî ïîñëå ïåðâîãî if |
3543 | Ïîñëå else if â ñëåäóþùèé else óáèðàòü íåëüçÿ |
3546 | Ïîñëå else if â ñëåäóþùèé else óáèðàòü íåëüçÿ |
3544 | --------------------------------------------------*/ |
3547 | --------------------------------------------------*/ |
3545 | if(icomp!=NULL){ |
3548 | if(icomp!=NULL){ |
3546 | elseline=linenumber; |
3549 | elseline=linenumber; |
3547 | unsigned long temp; |
3550 | unsigned long temp; |
3548 | unsigned int j=0; |
3551 | unsigned int j=0; |
3549 | unsigned int otok=tok; |
3552 | unsigned int otok=tok; |
3550 | unsigned int oinptr=inptr2; |
3553 | unsigned int oinptr=inptr2; |
3551 | unsigned char ocha=cha2; |
3554 | unsigned char ocha=cha2; |
3552 | unsigned int oline=linenumber; |
3555 | unsigned int oline=linenumber; |
3553 | if(tok==tk_else||tok==tk_ELSE){ |
3556 | if(tok==tk_else||tok==tk_ELSE){ |
3554 | if(dbg)AddLine(); |
3557 | if(dbg)AddLine(); |
3555 | j=(am32==FALSE?3:5); |
3558 | j=(am32==FALSE?3:5); |
3556 | if(tok2==tk_goto||tok2==tk_break||tok2==tk_continue||//ïîãëîòèòü èõ |
3559 | if(tok2==tk_goto||tok2==tk_break||tok2==tk_continue||//ïîãëîòèòü èõ |
3557 | tok2==tk_RETURN||tok2==tk_return||tok2==tk_GOTO||tok2==tk_BREAK||tok2==tk_CONTINUE){ |
3560 | tok2==tk_RETURN||tok2==tk_return||tok2==tk_GOTO||tok2==tk_BREAK||tok2==tk_CONTINUE){ |
3558 | nexttok(); |
3561 | nexttok(); |
3559 | switch(tok){ |
3562 | switch(tok){ |
3560 | case tk_GOTO: otok=tk_goto; break; |
3563 | case tk_GOTO: otok=tk_goto; break; |
3561 | case tk_BREAK: otok=tk_break; break; |
3564 | case tk_BREAK: otok=tk_break; break; |
3562 | case tk_CONTINUE: otok=tk_continue; break; |
3565 | case tk_CONTINUE: otok=tk_continue; break; |
3563 | case tk_return: |
3566 | case tk_return: |
3564 | case tk_RETURN: |
3567 | case tk_RETURN: |
3565 | if(tok2==tk_semicolon||(tok2==tk_openbracket&& |
3568 | if(tok2==tk_semicolon||(tok2==tk_openbracket&& |
3566 | ScanTok3()==tk_closebracket)){ |
3569 | ScanTok3()==tk_closebracket)){ |
3567 | startblock(); |
3570 | startblock(); |
3568 | otok=tk_return; |
3571 | otok=tk_return; |
3569 | break; |
3572 | break; |
3570 | } |
3573 | } |
3571 | tok=otok; //íåâîçìîæíî îïòèìèçèðîâàòü |
3574 | tok=otok; //íåâîçìîæíî îïòèìèçèðîâàòü |
3572 | inptr2=oinptr; |
3575 | inptr2=oinptr; |
3573 | cha2=ocha; |
3576 | cha2=ocha; |
3574 | linenumber=oline; |
3577 | linenumber=oline; |
3575 | goto nooptim; |
3578 | goto nooptim; |
3576 | default:otok=tok; break; |
3579 | default:otok=tok; break; |
3577 | } |
3580 | } |
3578 | oinptr=inptr2; |
3581 | oinptr=inptr2; |
3579 | ocha=cha2; |
3582 | ocha=cha2; |
3580 | oline=linenumber; |
3583 | oline=linenumber; |
3581 | for(unsigned int i=0;i |
3584 | for(unsigned int i=0;i |
3582 | if((icomp+i)->type!=tk_oror){ |
3585 | if((icomp+i)->type!=tk_oror){ |
3583 | notunreach=TRUE; |
3586 | notunreach=TRUE; |
3584 | tok=otok; |
3587 | tok=otok; |
3585 | inptr2=oinptr; |
3588 | inptr2=oinptr; |
3586 | cha2=ocha; |
3589 | cha2=ocha; |
3587 | linenumber=oline; |
3590 | linenumber=oline; |
3588 | opt_if_else_stop((icomp+i)->loc-j); |
3591 | opt_if_else_stop((icomp+i)->loc-j); |
3589 | } |
3592 | } |
3590 | } |
3593 | } |
3591 | if(otok==tk_return)endblock(); |
3594 | if(otok==tk_return)endblock(); |
3592 | if((outptr+j-icomp->loc)<=127)warningjmp(mesIF,ifline); |
3595 | if((outptr+j-icomp->loc)<=127)warningjmp(mesIF,ifline); |
3593 | free(icomp); |
3596 | free(icomp); |
3594 | retproc=FALSE; |
3597 | retproc=FALSE; |
3595 | lastcommand=tk_if; |
3598 | lastcommand=tk_if; |
3596 | return; |
3599 | return; |
3597 | } |
3600 | } |
3598 | nooptim: |
3601 | nooptim: |
3599 | if(tok==tk_ELSE)j=2; |
3602 | if(tok==tk_ELSE)j=2; |
3600 | } |
3603 | } |
3601 | notunreach=TRUE; |
3604 | notunreach=TRUE; |
3602 | for(unsigned int i=0;i |
3605 | for(unsigned int i=0;i |
3603 | if((icomp+i)->type!=tk_oror){ |
3606 | if((icomp+i)->type!=tk_oror){ |
3604 | if(am32==FALSE)*(unsigned short *)&output[(icomp+i)->loc-2]=(unsigned short)(outptr+j-(icomp+i)->loc); |
3607 | if(am32==FALSE)*(unsigned short *)&output[(icomp+i)->loc-2]=(unsigned short)(outptr+j-(icomp+i)->loc); |
3605 | else *(unsigned long *)&output[(icomp+i)->loc-4]=(unsigned long)(outptr+j-(icomp+i)->loc); |
3608 | else *(unsigned long *)&output[(icomp+i)->loc-4]=(unsigned long)(outptr+j-(icomp+i)->loc); |
3606 | } |
3609 | } |
3607 | } |
3610 | } |
3608 | if((outptr+j-icomp->loc)<=127)warningjmp(mesIF,ifline); |
3611 | if((outptr+j-icomp->loc)<=127)warningjmp(mesIF,ifline); |
3609 | switch(lastcommand){ |
3612 | switch(lastcommand){ |
3610 | case tk_return: |
3613 | case tk_return: |
3611 | case tk_RETURN: |
3614 | case tk_RETURN: |
3612 | case tk_goto: |
3615 | case tk_goto: |
3613 | case tk_GOTO: |
3616 | case tk_GOTO: |
3614 | case tk_break: |
3617 | case tk_break: |
3615 | case tk_BREAK: |
3618 | case tk_BREAK: |
3616 | case tk_continue: |
3619 | case tk_continue: |
3617 | case tk_CONTINUE: |
3620 | case tk_CONTINUE: |
3618 | addESP=oaddESP; |
3621 | addESP=oaddESP; |
3619 | break; |
3622 | break; |
3620 | } |
3623 | } |
3621 | if(retproc)CopyRegStat(bakregstat); |
3624 | if(retproc)CopyRegStat(bakregstat); |
3622 | else{ |
3625 | else{ |
3623 | switch(lastcommand){ |
3626 | switch(lastcommand){ |
3624 | case tk_return: |
3627 | case tk_return: |
3625 | case tk_RETURN: |
3628 | case tk_RETURN: |
3626 | case tk_goto: |
3629 | case tk_goto: |
3627 | case tk_GOTO: |
3630 | case tk_GOTO: |
3628 | case tk_break: |
3631 | case tk_break: |
3629 | case tk_BREAK: |
3632 | case tk_BREAK: |
3630 | case tk_continue: |
3633 | case tk_continue: |
3631 | case tk_CONTINUE: |
3634 | case tk_CONTINUE: |
3632 | CopyRegStat(bakregstat); |
3635 | CopyRegStat(bakregstat); |
3633 | break; |
3636 | break; |
3634 | default: |
3637 | default: |
3635 | CompareRegStat(changeregstat); |
3638 | CompareRegStat(changeregstat); |
3636 | break; |
3639 | break; |
3637 | } |
3640 | } |
3638 | } |
3641 | } |
3639 | // printf("lastcommand=%d\n",lastcommand); |
3642 | // printf("lastcommand=%d\n",lastcommand); |
3640 | // CompareRegStat(changeregstat); |
3643 | // CompareRegStat(changeregstat); |
3641 | if(tok==tk_else/*&&i==FALSE*/){ |
3644 | if(tok==tk_else/*&&i==FALSE*/){ |
3642 | addESP=oaddESP; |
3645 | addESP=oaddESP; |
3643 | RestoreStack(); |
3646 | RestoreStack(); |
3644 | CopyRegStat(bakregstat); |
3647 | CopyRegStat(bakregstat); |
3645 | jumploc0(); |
3648 | jumploc0(); |
3646 | startloc=outptr; |
3649 | startloc=outptr; |
3647 | getoperand(); |
3650 | getoperand(); |
3648 | #ifdef OPTVARCONST |
3651 | #ifdef OPTVARCONST |
3649 | if(tok!=tk_if&&tok!=tk_IF&&comconst.rec&&comconst.typevar==tk_notequal){ |
3652 | if(tok!=tk_if&&tok!=tk_IF&&comconst.rec&&comconst.typevar==tk_notequal){ |
3650 | Const2VarRec(&comconst); |
3653 | Const2VarRec(&comconst); |
3651 | } |
3654 | } |
3652 | #endif |
3655 | #endif |
3653 | startblock(); |
3656 | startblock(); |
3654 | if(tok==tk_return||tok==tk_RETURN){ |
3657 | if(tok==tk_return||tok==tk_RETURN){ |
3655 | if(dbg)AddLine(); |
3658 | if(dbg)AddLine(); |
3656 | doreturn(tok); |
3659 | doreturn(tok); |
3657 | } |
3660 | } |
3658 | else docommand(); |
3661 | else docommand(); |
3659 | endblock(); |
3662 | endblock(); |
3660 | RestoreStack(); |
3663 | RestoreStack(); |
3661 | temp=outptr-startloc; |
3664 | temp=outptr-startloc; |
3662 | if(temp<=127)warningjmp(mesELSE,elseline); |
3665 | if(temp<=127)warningjmp(mesELSE,elseline); |
3663 | if(am32==FALSE)*(unsigned short *)&output[startloc-2]=(unsigned short)temp; |
3666 | if(am32==FALSE)*(unsigned short *)&output[startloc-2]=(unsigned short)temp; |
3664 | else *(unsigned long *)&output[startloc-4]=temp; |
3667 | else *(unsigned long *)&output[startloc-4]=temp; |
3665 | CompareRegStat(changeregstat); |
3668 | CompareRegStat(changeregstat); |
3666 | } |
3669 | } |
3667 | else if(tok==tk_ELSE/*&&i==FALSE*/){ |
3670 | else if(tok==tk_ELSE/*&&i==FALSE*/){ |
3668 | addESP=oaddESP; |
3671 | addESP=oaddESP; |
3669 | RestoreStack(); |
3672 | RestoreStack(); |
3670 | CopyRegStat(bakregstat); |
3673 | CopyRegStat(bakregstat); |
3671 | outword(0x00EB); |
3674 | outword(0x00EB); |
3672 | startloc=outptr; |
3675 | startloc=outptr; |
3673 | getoperand(); |
3676 | getoperand(); |
3674 | #ifdef OPTVARCONST |
3677 | #ifdef OPTVARCONST |
3675 | if(tok!=tk_if&&tok!=tk_IF&&comconst.rec&&comconst.typevar==tk_notequal){ |
3678 | if(tok!=tk_if&&tok!=tk_IF&&comconst.rec&&comconst.typevar==tk_notequal){ |
3676 | Const2VarRec(&comconst); |
3679 | Const2VarRec(&comconst); |
3677 | } |
3680 | } |
3678 | #endif |
3681 | #endif |
3679 | startblock(); |
3682 | startblock(); |
3680 | if(tok==tk_return||tok==tk_RETURN){ |
3683 | if(tok==tk_return||tok==tk_RETURN){ |
3681 | if(dbg)AddLine(); |
3684 | if(dbg)AddLine(); |
3682 | doreturn(tok); |
3685 | doreturn(tok); |
3683 | } |
3686 | } |
3684 | else docommand(); |
3687 | else docommand(); |
3685 | endblock(); |
3688 | endblock(); |
3686 | RestoreStack(); |
3689 | RestoreStack(); |
3687 | temp=outptr-startloc; |
3690 | temp=outptr-startloc; |
3688 | if(temp>127)jumperror(elseline,mesELSE); |
3691 | if(temp>127)jumperror(elseline,mesELSE); |
3689 | output[startloc-1]=(unsigned char)temp; |
3692 | output[startloc-1]=(unsigned char)temp; |
3690 | CompareRegStat(changeregstat); |
3693 | CompareRegStat(changeregstat); |
3691 | } |
3694 | } |
3692 | /* else{ |
3695 | /* else{ |
3693 | if(i!=FALSE&&(tok==tk_else||tok==tk_ELSE))nexttok(); |
3696 | if(i!=FALSE&&(tok==tk_else||tok==tk_ELSE))nexttok(); |
3694 | }*/ |
3697 | }*/ |
3695 | free(icomp); |
3698 | free(icomp); |
3696 | CopyRegStat(changeregstat); |
3699 | CopyRegStat(changeregstat); |
3697 | } |
3700 | } |
3698 | FreeStat(bakregstat); |
3701 | FreeStat(bakregstat); |
3699 | FreeStat(changeregstat); |
3702 | FreeStat(changeregstat); |
3700 | retproc=FALSE; |
3703 | retproc=FALSE; |
3701 | lastcommand=tk_if; |
3704 | lastcommand=tk_if; |
3702 | } |
3705 | } |
3703 | 3706 | ||
3704 | #ifdef OPTVARCONST |
3707 | #ifdef OPTVARCONST |
3705 | ICOMP *bigcompare(int type,unsigned int *numcomp,REGISTERSTAT **bakreg,REGISTERSTAT **changereg,LVIC *comconst) |
3708 | ICOMP *bigcompare(int type,unsigned int *numcomp,REGISTERSTAT **bakreg,REGISTERSTAT **changereg,LVIC *comconst) |
3706 | #else |
3709 | #else |
3707 | ICOMP *bigcompare(int type,unsigned int *numcomp,REGISTERSTAT **bakreg,REGISTERSTAT **changereg) |
3710 | ICOMP *bigcompare(int type,unsigned int *numcomp,REGISTERSTAT **bakreg,REGISTERSTAT **changereg) |
3708 | #endif |
3711 | #endif |
3709 | { |
3712 | { |
3710 | unsigned int ifline; |
3713 | unsigned int ifline; |
3711 | ICOMP *icomp; |
3714 | ICOMP *icomp; |
3712 | unsigned int i=0; |
3715 | unsigned int i=0; |
3713 | int j=0; |
3716 | int j=0; |
3714 | int ptok=tk_oror; |
3717 | int ptok=tk_oror; |
3715 | int rcompr; |
3718 | int rcompr; |
3716 | int useor=FALSE; |
3719 | int useor=FALSE; |
3717 | REGISTERSTAT *bakregstat=NULL,*changeregstat=NULL; |
3720 | REGISTERSTAT *bakregstat=NULL,*changeregstat=NULL; |
3718 | if(am32!=FALSE)j=2; |
3721 | if(am32!=FALSE)j=2; |
3719 | icomp=(ICOMP *)MALLOC(sizeof(ICOMP)*MAXIF); //áëîê äëÿ èíôî î ñðàâíåíèÿõ |
3722 | icomp=(ICOMP *)MALLOC(sizeof(ICOMP)*MAXIF); //áëîê äëÿ èíôî î ñðàâíåíèÿõ |
3720 | ifline=linenumber; |
3723 | ifline=linenumber; |
3721 | do{ |
3724 | do{ |
3722 | #ifdef OPTVARCONST |
3725 | #ifdef OPTVARCONST |
3723 | if((rcompr=constructcompare(1,outptr,comconst))==voidcompr||rcompr==zerocompr)i=1; |
3726 | if((rcompr=constructcompare(1,outptr,comconst))==voidcompr||rcompr==zerocompr)i=1; |
3724 | #else |
3727 | #else |
3725 | if((rcompr=constructcompare(1,outptr))==voidcompr||rcompr==zerocompr)i=1; |
3728 | if((rcompr=constructcompare(1,outptr))==voidcompr||rcompr==zerocompr)i=1; |
3726 | #endif |
3729 | #endif |
3727 | (icomp+*numcomp)->use_cxz=rcompr&0xFC; |
3730 | (icomp+*numcomp)->use_cxz=rcompr&0xFC; |
3728 | if(i){ |
3731 | if(i){ |
3729 | if(rcompr==voidcompr&&ptok==tk_andand){ |
3732 | if(rcompr==voidcompr&&ptok==tk_andand){ |
3730 | i=0; |
3733 | i=0; |
3731 | ptok=tok; |
3734 | ptok=tok; |
3732 | } |
3735 | } |
3733 | continue; |
3736 | continue; |
3734 | } |
3737 | } |
3735 | op(0x00); |
3738 | op(0x00); |
3736 | (icomp+*numcomp)->loc=outptr; |
3739 | (icomp+*numcomp)->loc=outptr; |
3737 | (icomp+*numcomp)->type=tok; |
3740 | (icomp+*numcomp)->type=tok; |
3738 | (*numcomp)++; |
3741 | (*numcomp)++; |
3739 | if(*numcomp==MAXIF){ |
3742 | if(*numcomp==MAXIF){ |
3740 | ManyLogicCompare(); |
3743 | ManyLogicCompare(); |
3741 | free(icomp); |
3744 | free(icomp); |
3742 | return NULL; |
3745 | return NULL; |
3743 | } |
3746 | } |
3744 | ptok=tok; |
3747 | ptok=tok; |
3745 | /* if(tok==tk_andand&&bakregstat==NULL){ |
3748 | /* if(tok==tk_andand&&bakregstat==NULL){ |
3746 | bakregstat=BakRegStat(); |
3749 | bakregstat=BakRegStat(); |
3747 | changeregstat=BakRegStat(); |
3750 | changeregstat=BakRegStat(); |
3748 | }*/ |
3751 | }*/ |
3749 | }while(tok==tk_oror||tok==tk_andand); |
3752 | }while(tok==tk_oror||tok==tk_andand); |
3750 | if(tok==tk_closebracket)nexttok(); |
3753 | if(tok==tk_closebracket)nexttok(); |
3751 | for(i=0;i<*numcomp;i++){ |
3754 | for(i=0;i<*numcomp;i++){ |
3752 | if(outptr-(icomp+i)->loc>127)CompareOr(); |
3755 | if(outptr-(icomp+i)->loc>127)CompareOr(); |
3753 | output[(icomp+i)->loc-1]=(unsigned char)(outptr-(icomp+i)->loc); |
3756 | output[(icomp+i)->loc-1]=(unsigned char)(outptr-(icomp+i)->loc); |
3754 | if((icomp+i)->type==tk_oror){ |
3757 | if((icomp+i)->type==tk_oror){ |
3755 | #ifdef OPTVARCONST |
3758 | #ifdef OPTVARCONST |
3756 | if(comconst)comconst->rec=NULL; |
3759 | if(comconst)comconst->rec=NULL; |
3757 | #endif |
3760 | #endif |
3758 | output[(icomp+i)->loc-2]=(unsigned char)(output[(icomp+i)->loc-2]^1); |
3761 | output[(icomp+i)->loc-2]=(unsigned char)(output[(icomp+i)->loc-2]^1); |
3759 | clearregstat(); |
3762 | clearregstat(); |
3760 | useor=TRUE; |
3763 | useor=TRUE; |
3761 | } |
3764 | } |
3762 | } |
3765 | } |
3763 | if(bakregstat==NULL){ |
3766 | if(bakregstat==NULL){ |
3764 | bakregstat=BakRegStat(); |
3767 | bakregstat=BakRegStat(); |
3765 | changeregstat=BakRegStat(); |
3768 | changeregstat=BakRegStat(); |
3766 | } |
3769 | } |
3767 | if(type==tk_IF&&rcompr!=zerocompr){ |
3770 | if(type==tk_IF&&rcompr!=zerocompr){ |
3768 | if(rcompr==voidcompr)warcompeqconst(); |
3771 | if(rcompr==voidcompr)warcompeqconst(); |
3769 | if(tok==tk_return||tok==tk_RETURN){ |
3772 | if(tok==tk_return||tok==tk_RETURN){ |
3770 | if(tok2==tk_semicolon||(tok2==tk_openbracket&&ScanTok3()==tk_closebracket)){ |
3773 | if(tok2==tk_semicolon||(tok2==tk_openbracket&&ScanTok3()==tk_closebracket)){ |
3771 | if(insertmode||(!optimizespeed)){ |
3774 | if(insertmode||(!optimizespeed)){ |
3772 | if(tok==tk_RETURN)goto merge_if; |
3775 | if(tok==tk_RETURN)goto merge_if; |
3773 | else if(chip>2&&(insertmode||(paramsize&& |
3776 | else if(chip>2&&(insertmode||(paramsize&& |
3774 | (current_proc_type&f_typeproc)!=tp_cdecl)))goto merge_if2; |
3777 | (current_proc_type&f_typeproc)!=tp_cdecl)))goto merge_if2; |
3775 | } |
3778 | } |
3776 | } |
3779 | } |
3777 | startblock(); |
3780 | startblock(); |
3778 | doreturn(tok); |
3781 | doreturn(tok); |
3779 | endblock(); |
3782 | endblock(); |
3780 | for(unsigned int i=0;i<*numcomp;i++){ |
3783 | for(unsigned int i=0;i<*numcomp;i++){ |
3781 | if((icomp+i)->type!=tk_oror){ |
3784 | if((icomp+i)->type!=tk_oror){ |
3782 | if((outptr-(icomp+i)->loc)>127)jumperror(ifline,mesIF); |
3785 | if((outptr-(icomp+i)->loc)>127)jumperror(ifline,mesIF); |
3783 | output[(icomp+i)->loc-1]=(unsigned char)(outptr-(icomp+i)->loc); |
3786 | output[(icomp+i)->loc-1]=(unsigned char)(outptr-(icomp+i)->loc); |
3784 | } |
3787 | } |
3785 | } |
3788 | } |
3786 | if(tok==tk_else||tok==tk_ELSE){ |
3789 | if(tok==tk_else||tok==tk_ELSE){ |
3787 | notunreach=TRUE; |
3790 | notunreach=TRUE; |
3788 | getoperand(); |
3791 | getoperand(); |
3789 | docommand(); |
3792 | docommand(); |
3790 | } |
3793 | } |
3791 | free(icomp); |
3794 | free(icomp); |
3792 | return NULL; |
3795 | return NULL; |
3793 | } |
3796 | } |
3794 | if(tok==tk_BREAK||tok==tk_CONTINUE||tok==tk_GOTO){ |
3797 | if(tok==tk_BREAK||tok==tk_CONTINUE||tok==tk_GOTO){ |
3795 | merge_if: |
3798 | merge_if: |
3796 | int otok=tok; |
3799 | int otok=tok; |
3797 | for(i=0;i<*numcomp;i++){ |
3800 | for(i=0;i<*numcomp;i++){ |
3798 | unsigned char oldcode; |
3801 | unsigned char oldcode; |
3799 | if(((icomp+i)->type==tk_oror)||((i+1)==*numcomp)){ |
3802 | if(((icomp+i)->type==tk_oror)||((i+1)==*numcomp)){ |
3800 | outptr=(icomp+i)->loc-2; |
3803 | outptr=(icomp+i)->loc-2; |
3801 | oldcode=output[outptr]; |
3804 | oldcode=output[outptr]; |
3802 | if(tok==tk_BREAK)MakeBreak(BREAK_SHORT); |
3805 | if(tok==tk_BREAK)MakeBreak(BREAK_SHORT); |
3803 | else if(tok==tk_RETURN){ |
3806 | else if(tok==tk_RETURN){ |
3804 | AddRetList(outptr+1,ifline,tk_RETURN); |
3807 | AddRetList(outptr+1,ifline,tk_RETURN); |
3805 | clearregstat(); |
3808 | clearregstat(); |
3806 | #ifdef OPTVARCONST |
3809 | #ifdef OPTVARCONST |
3807 | ClearLVIC(); |
3810 | ClearLVIC(); |
3808 | #endif |
3811 | #endif |
3809 | } |
3812 | } |
3810 | else if(tok==tk_GOTO){ |
3813 | else if(tok==tk_GOTO){ |
3811 | if((i+1)!=*numcomp){ |
3814 | if((i+1)!=*numcomp){ |
3812 | int optr,ocha,oline; |
3815 | int optr,ocha,oline; |
3813 | optr=inptr2; |
3816 | optr=inptr2; |
3814 | ocha=cha2; |
3817 | ocha=cha2; |
3815 | oline=linenum2; |
3818 | oline=linenum2; |
3816 | GOTOdo(); |
3819 | GOTOdo(); |
3817 | if(outptr!=(icomp+i)->loc)jumperror(oline,"GOTO"); |
3820 | if(outptr!=(icomp+i)->loc)jumperror(oline,"GOTO"); |
3818 | inptr2=optr; |
3821 | inptr2=optr; |
3819 | cha2=(unsigned char)ocha; |
3822 | cha2=(unsigned char)ocha; |
3820 | linenum2=oline; |
3823 | linenum2=oline; |
3821 | tok=tk_GOTO; |
3824 | tok=tk_GOTO; |
3822 | } |
3825 | } |
3823 | else{ |
3826 | else{ |
3824 | getoperand(); |
3827 | getoperand(); |
3825 | CheckIP(); |
3828 | CheckIP(); |
3826 | if(tok==tk_number||tok==tk_interruptproc||tok==tk_proc){ |
3829 | if(tok==tk_number||tok==tk_interruptproc||tok==tk_proc){ |
3827 | long hnumber; |
3830 | long hnumber; |
3828 | if(tok==tk_number)hnumber=doconstdwordmath(); |
3831 | if(tok==tk_number)hnumber=doconstdwordmath(); |
3829 | else{ |
3832 | else{ |
3830 | hnumber=itok.number; |
3833 | hnumber=itok.number; |
3831 | nexttok(); |
3834 | nexttok(); |
3832 | } |
3835 | } |
3833 | long loc=hnumber-outptr-2; |
3836 | long loc=hnumber-outptr-2; |
3834 | if(loc>-129&&loc<128){ |
3837 | if(loc>-129&&loc<128){ |
3835 | op((unsigned char)(oldcode^1)); |
3838 | op((unsigned char)(oldcode^1)); |
3836 | op(loc); |
3839 | op(loc); |
3837 | } |
3840 | } |
3838 | else{ |
3841 | else{ |
3839 | loc-=3; |
3842 | loc-=3; |
3840 | outptr++; |
3843 | outptr++; |
3841 | op(am32==0?3:5); |
3844 | op(am32==0?3:5); |
3842 | op(0xE9); |
3845 | op(0xE9); |
3843 | if(am32==FALSE)outword(loc); |
3846 | if(am32==FALSE)outword(loc); |
3844 | else{ |
3847 | else{ |
3845 | loc-=2; |
3848 | loc-=2; |
3846 | outdword(loc); |
3849 | outdword(loc); |
3847 | } |
3850 | } |
3848 | } |
3851 | } |
3849 | seminext(); |
3852 | seminext(); |
3850 | break; |
3853 | break; |
3851 | } |
3854 | } |
3852 | else if(GOTO())nexttok(); |
3855 | else if(GOTO())nexttok(); |
3853 | seminext(); |
3856 | seminext(); |
3854 | } |
3857 | } |
3855 | } |
3858 | } |
3856 | else MakeContinue(CONTINUE_SHORT); |
3859 | else MakeContinue(CONTINUE_SHORT); |
3857 | if((i+1)==*numcomp)oldcode^=1; |
3860 | if((i+1)==*numcomp)oldcode^=1; |
3858 | output[outptr-2]=oldcode; |
3861 | output[outptr-2]=oldcode; |
3859 | } |
3862 | } |
3860 | } |
3863 | } |
3861 | if(tok==tk_RETURN&&tok2==tk_openbracket){ |
3864 | if(tok==tk_RETURN&&tok2==tk_openbracket){ |
3862 | nexttok(); |
3865 | nexttok(); |
3863 | nexttok(); |
3866 | nexttok(); |
3864 | } |
3867 | } |
3865 | if(otok!=tk_GOTO&&rcompr!=voidcompr)nextseminext(); |
3868 | if(otok!=tk_GOTO&&rcompr!=voidcompr)nextseminext(); |
3866 | 3869 | ||
3867 | if(tok==tk_else||tok==tk_ELSE){ |
3870 | if(tok==tk_else||tok==tk_ELSE){ |
3868 | notunreach=TRUE; |
3871 | notunreach=TRUE; |
3869 | getoperand(); |
3872 | getoperand(); |
3870 | docommand(); |
3873 | docommand(); |
3871 | } |
3874 | } |
3872 | free(icomp); |
3875 | free(icomp); |
3873 | return NULL; |
3876 | return NULL; |
3874 | } |
3877 | } |
3875 | if((tok==tk_break||tok==tk_continue||tok==tk_goto)&&chip>2){ |
3878 | if((tok==tk_break||tok==tk_continue||tok==tk_goto)&&chip>2){ |
3876 | merge_if2: |
3879 | merge_if2: |
3877 | 3880 | ||
3878 | // printf("%s (%u) %s %s tok=%d\n",(startfileinfo+currentfileinfo)->filename,linenumber,itok.name,string,tok); |
3881 | // printf("%s (%u) %s %s tok=%d\n",(startfileinfo+currentfileinfo)->filename,linenumber,itok.name,string,tok); |
3879 | 3882 | ||
3880 | if(*numcomp==1&&(!(tok==tk_goto&&(tok2==tk_reg||tok2==tk_reg32)))){ |
3883 | if(*numcomp==1&&(!(tok==tk_goto&&(tok2==tk_reg||tok2==tk_reg32)))){ |
3881 | outptr-=2; |
3884 | outptr-=2; |
3882 | i=(output[outptr]^1)+0x10; |
3885 | i=(output[outptr]^1)+0x10; |
3883 | op(0x0F); |
3886 | op(0x0F); |
3884 | } |
3887 | } |
3885 | if(tok==tk_break)doBREAK((unsigned char)(am32==FALSE?BREAK_NEAR:BREAK_32)); |
3888 | if(tok==tk_break)doBREAK((unsigned char)(am32==FALSE?BREAK_NEAR:BREAK_32)); |
3886 | else if(tok==tk_return){ |
3889 | else if(tok==tk_return){ |
3887 | AddRetList(outptr+1,ifline,tk_return); |
3890 | AddRetList(outptr+1,ifline,tk_return); |
3888 | if(tok2==tk_openbracket){ |
3891 | if(tok2==tk_openbracket){ |
3889 | nexttok(); |
3892 | nexttok(); |
3890 | nexttok(); |
3893 | nexttok(); |
3891 | } |
3894 | } |
3892 | nextseminext(); |
3895 | nextseminext(); |
3893 | clearregstat(); |
3896 | clearregstat(); |
3894 | #ifdef OPTVARCONST |
3897 | #ifdef OPTVARCONST |
3895 | ClearLVIC(); |
3898 | ClearLVIC(); |
3896 | #endif |
3899 | #endif |
3897 | } |
3900 | } |
3898 | else if(tok==tk_goto){ |
3901 | else if(tok==tk_goto){ |
3899 | nexttok(); |
3902 | nexttok(); |
3900 | CheckIP(); |
3903 | CheckIP(); |
3901 | if((tok==tk_number&&*numcomp==1)||tok==tk_interruptproc||tok==tk_proc){ |
3904 | if((tok==tk_number&&*numcomp==1)||tok==tk_interruptproc||tok==tk_proc){ |
3902 | if(tok==tk_proc&&tok2==tk_openbracket)doanyproc(TRUE); |
3905 | if(tok==tk_proc&&tok2==tk_openbracket)doanyproc(TRUE); |
3903 | else{ |
3906 | else{ |
3904 | long hnumber; |
3907 | long hnumber; |
3905 | if(tok==tk_number)hnumber=doconstdwordmath(); |
3908 | if(tok==tk_number)hnumber=doconstdwordmath(); |
3906 | else{ |
3909 | else{ |
3907 | hnumber=itok.number; |
3910 | hnumber=itok.number; |
3908 | nexttok(); |
3911 | nexttok(); |
3909 | } |
3912 | } |
3910 | long loc=hnumber-outptr-2; |
3913 | long loc=hnumber-outptr-2; |
3911 | if(loc>-130&&loc<127){ |
3914 | if(loc>-130&&loc<127){ |
3912 | outptr--; |
3915 | outptr--; |
3913 | op((unsigned char)(i-0x10)); |
3916 | op((unsigned char)(i-0x10)); |
3914 | op(loc+1); |
3917 | op(loc+1); |
3915 | seminext(); |
3918 | seminext(); |
3916 | goto c1; |
3919 | goto c1; |
3917 | } |
3920 | } |
3918 | else{ |
3921 | else{ |
3919 | loc--; |
3922 | loc--; |
3920 | op(0xE9); |
3923 | op(0xE9); |
3921 | if(am32==FALSE)outword(loc); |
3924 | if(am32==FALSE)outword(loc); |
3922 | else{ |
3925 | else{ |
3923 | loc-=2; |
3926 | loc-=2; |
3924 | outdword(loc); |
3927 | outdword(loc); |
3925 | } |
3928 | } |
3926 | } |
3929 | } |
3927 | } |
3930 | } |
3928 | } |
3931 | } |
3929 | else{ |
3932 | else{ |
3930 | if(tok==tk_reg||tok==tk_reg32){ |
3933 | if(tok==tk_reg||tok==tk_reg32){ |
3931 | i=outptr; |
3934 | i=outptr; |
3932 | if(gotol(0))nexttok(); |
3935 | if(gotol(0))nexttok(); |
3933 | i=outptr-i; |
3936 | i=outptr-i; |
3934 | output[outptr-i-1]=(unsigned char)i; |
3937 | output[outptr-i-1]=(unsigned char)i; |
3935 | goto c1; |
3938 | goto c1; |
3936 | } |
3939 | } |
3937 | if(gotol(0))nexttok(); |
3940 | if(gotol(0))nexttok(); |
3938 | } |
3941 | } |
3939 | seminext(); |
3942 | seminext(); |
3940 | } |
3943 | } |
3941 | else doCONTINUE((unsigned char)(am32==FALSE?CONTINUE_NEAR:CONTINUE_32)); |
3944 | else doCONTINUE((unsigned char)(am32==FALSE?CONTINUE_NEAR:CONTINUE_32)); |
3942 | if(*numcomp==1)output[outptr-3-j]=(unsigned char)i; |
3945 | if(*numcomp==1)output[outptr-3-j]=(unsigned char)i; |
3943 | c1: |
3946 | c1: |
3944 | if(cpu<3)cpu=3; |
3947 | if(cpu<3)cpu=3; |
3945 | if(tok==tk_else||tok==tk_ELSE){ |
3948 | if(tok==tk_else||tok==tk_ELSE){ |
3946 | notunreach=TRUE; |
3949 | notunreach=TRUE; |
3947 | getoperand(); |
3950 | getoperand(); |
3948 | docommand(); |
3951 | docommand(); |
3949 | } |
3952 | } |
3950 | if(*numcomp!=1){ |
3953 | if(*numcomp!=1){ |
3951 | for(unsigned int i=0;i<*numcomp;i++){ |
3954 | for(unsigned int i=0;i<*numcomp;i++){ |
3952 | if((icomp+i)->type!=tk_oror){ |
3955 | if((icomp+i)->type!=tk_oror){ |
3953 | if((outptr-(icomp+i)->loc)>127)jumperror(ifline,mesIF); |
3956 | if((outptr-(icomp+i)->loc)>127)jumperror(ifline,mesIF); |
3954 | output[(icomp+i)->loc-1]=(unsigned char)(outptr-(icomp+i)->loc); |
3957 | output[(icomp+i)->loc-1]=(unsigned char)(outptr-(icomp+i)->loc); |
3955 | } |
3958 | } |
3956 | } |
3959 | } |
3957 | } |
3960 | } |
3958 | free(icomp); |
3961 | free(icomp); |
3959 | return NULL; |
3962 | return NULL; |
3960 | } |
3963 | } |
3961 | } |
3964 | } |
3962 | if((icomp+(*numcomp-1))->use_cxz==cxnzcompr){ |
3965 | if((icomp+(*numcomp-1))->use_cxz==cxnzcompr){ |
3963 | outptr-=4; |
3966 | outptr-=4; |
3964 | outword(0xE3); |
3967 | outword(0xE3); |
3965 | (icomp+(*numcomp-1))->loc=outptr; |
3968 | (icomp+(*numcomp-1))->loc=outptr; |
3966 | for(i=(*numcomp-1);i!=0;i--){ |
3969 | for(i=(*numcomp-1);i!=0;i--){ |
3967 | if((icomp+i-1)->type==tk_oror)output[(icomp+i-1)->loc-1]-=(unsigned char)2; |
3970 | if((icomp+i-1)->type==tk_oror)output[(icomp+i-1)->loc-1]-=(unsigned char)2; |
3968 | } |
3971 | } |
3969 | } |
3972 | } |
3970 | if(type!=tk_FOR){ |
3973 | if(type!=tk_FOR){ |
3971 | startblock(); |
3974 | startblock(); |
3972 | if(rcompr==zerocompr)warcompneqconst(); |
3975 | if(rcompr==zerocompr)warcompneqconst(); |
3973 | if(tok==tk_openbrace){ |
3976 | if(tok==tk_openbrace){ |
3974 | if(rcompr==zerocompr){ |
3977 | if(rcompr==zerocompr){ |
3975 | cha=cha2; |
3978 | cha=cha2; |
3976 | inptr=inptr2; |
3979 | inptr=inptr2; |
3977 | SkipBlock(); |
3980 | SkipBlock(); |
3978 | inptr2=inptr; |
3981 | inptr2=inptr; |
3979 | cha2=cha; |
3982 | cha2=cha; |
3980 | linenum2=linenumber; |
3983 | linenum2=linenumber; |
3981 | nexttok(); |
3984 | nexttok(); |
3982 | } |
3985 | } |
3983 | else{ |
3986 | else{ |
3984 | #ifdef OPTVARCONST |
3987 | #ifdef OPTVARCONST |
3985 | if(comconst&&comconst->rec&&comconst->typevar==tk_equalto)Const2VarRec(comconst); |
3988 | if(comconst&&comconst->rec&&comconst->typevar==tk_equalto)Const2VarRec(comconst); |
3986 | #endif |
3989 | #endif |
3987 | doblock(); |
3990 | doblock(); |
3988 | nexttok(); |
3991 | nexttok(); |
3989 | } |
3992 | } |
3990 | } |
3993 | } |
3991 | else{ |
3994 | else{ |
3992 | if(rcompr==zerocompr){ |
3995 | if(rcompr==zerocompr){ |
3993 | do{ |
3996 | do{ |
3994 | nexttok(); |
3997 | nexttok(); |
3995 | }while(tok!=tk_semicolon&&tok!=tk_eof); |
3998 | }while(tok!=tk_semicolon&&tok!=tk_eof); |
3996 | } |
3999 | } |
3997 | else{ |
4000 | else{ |
3998 | #ifdef OPTVARCONST |
4001 | #ifdef OPTVARCONST |
3999 | if(comconst&&comconst->rec&&comconst->typevar==tk_equalto)Const2VarRec(comconst); |
4002 | if(comconst&&comconst->rec&&comconst->typevar==tk_equalto)Const2VarRec(comconst); |
4000 | #endif |
4003 | #endif |
4001 | docommand(); |
4004 | docommand(); |
4002 | } |
4005 | } |
4003 | } |
4006 | } |
4004 | endblock(); |
4007 | endblock(); |
4005 | RestoreStack(); |
4008 | RestoreStack(); |
4006 | } |
4009 | } |
4007 | if(bakreg)*bakreg=bakregstat; |
4010 | if(bakreg)*bakreg=bakregstat; |
4008 | if(changereg)*changereg=changeregstat; |
4011 | if(changereg)*changereg=changeregstat; |
4009 | return icomp; |
4012 | return icomp; |
4010 | } |
4013 | } |
4011 | 4014 | ||
4012 | void dobigif() |
4015 | void dobigif() |
4013 | { |
4016 | { |
4014 | unsigned int ifline,numcomp=0,j=0; |
4017 | unsigned int ifline,numcomp=0,j=0; |
4015 | ICOMP *icomp; |
4018 | ICOMP *icomp; |
4016 | int ic; |
4019 | int ic; |
4017 | unsigned int oaddESP=addESP; |
4020 | unsigned int oaddESP=addESP; |
4018 | REGISTERSTAT *bakregstat=NULL,*changeregstat=NULL; |
4021 | REGISTERSTAT *bakregstat=NULL,*changeregstat=NULL; |
4019 | ifline=linenumber; |
4022 | ifline=linenumber; |
4020 | #ifdef OPTVARCONST |
4023 | #ifdef OPTVARCONST |
4021 | LVIC comconst; |
4024 | LVIC comconst; |
4022 | comconst.rec=NULL; |
4025 | comconst.rec=NULL; |
4023 | icomp=bigcompare(tk_IF,&numcomp,&bakregstat,&changeregstat,&comconst); |
4026 | icomp=bigcompare(tk_IF,&numcomp,&bakregstat,&changeregstat,&comconst); |
4024 | #else |
4027 | #else |
4025 | icomp=bigcompare(tk_IF,&numcomp,&bakregstat,&changeregstat); |
4028 | icomp=bigcompare(tk_IF,&numcomp,&bakregstat,&changeregstat); |
4026 | #endif |
4029 | #endif |
4027 | if(icomp!=NULL){ |
4030 | if(icomp!=NULL){ |
4028 | unsigned int elseline; |
4031 | unsigned int elseline; |
4029 | elseline=linenumber; |
4032 | elseline=linenumber; |
4030 | if(tok==tk_else)j=(am32==FALSE?3:5); |
4033 | if(tok==tk_else)j=(am32==FALSE?3:5); |
4031 | else if(tok==tk_ELSE)j=2; |
4034 | else if(tok==tk_ELSE)j=2; |
4032 | notunreach=TRUE; |
4035 | notunreach=TRUE; |
4033 | if(dbg)AddLine(); |
4036 | if(dbg)AddLine(); |
4034 | for(unsigned int i=0;i |
4037 | for(unsigned int i=0;i |
4035 | if((icomp+i)->type!=tk_oror){ |
4038 | if((icomp+i)->type!=tk_oror){ |
4036 | if((outptr+j-(icomp+i)->loc)>127)jumperror(ifline,mesIF); |
4039 | if((outptr+j-(icomp+i)->loc)>127)jumperror(ifline,mesIF); |
4037 | output[(icomp+i)->loc-1]=(unsigned char)(outptr+j-(icomp+i)->loc); |
4040 | output[(icomp+i)->loc-1]=(unsigned char)(outptr+j-(icomp+i)->loc); |
4038 | } |
4041 | } |
4039 | } |
4042 | } |
4040 | switch(lastcommand){ |
4043 | switch(lastcommand){ |
4041 | case tk_return: |
4044 | case tk_return: |
4042 | case tk_RETURN: |
4045 | case tk_RETURN: |
4043 | case tk_goto: |
4046 | case tk_goto: |
4044 | case tk_GOTO: |
4047 | case tk_GOTO: |
4045 | case tk_break: |
4048 | case tk_break: |
4046 | case tk_BREAK: |
4049 | case tk_BREAK: |
4047 | case tk_continue: |
4050 | case tk_continue: |
4048 | case tk_CONTINUE: |
4051 | case tk_CONTINUE: |
4049 | addESP=oaddESP; |
4052 | addESP=oaddESP; |
4050 | break; |
4053 | break; |
4051 | } |
4054 | } |
4052 | if(retproc)CopyRegStat(bakregstat); |
4055 | if(retproc)CopyRegStat(bakregstat); |
4053 | else{ |
4056 | else{ |
4054 | switch(lastcommand){ |
4057 | switch(lastcommand){ |
4055 | case tk_return: |
4058 | case tk_return: |
4056 | case tk_RETURN: |
4059 | case tk_RETURN: |
4057 | case tk_goto: |
4060 | case tk_goto: |
4058 | case tk_GOTO: |
4061 | case tk_GOTO: |
4059 | case tk_break: |
4062 | case tk_break: |
4060 | case tk_BREAK: |
4063 | case tk_BREAK: |
4061 | case tk_continue: |
4064 | case tk_continue: |
4062 | case tk_CONTINUE: |
4065 | case tk_CONTINUE: |
4063 | CopyRegStat(bakregstat); |
4066 | CopyRegStat(bakregstat); |
4064 | break; |
4067 | break; |
4065 | default: |
4068 | default: |
4066 | CompareRegStat(changeregstat); |
4069 | CompareRegStat(changeregstat); |
4067 | break; |
4070 | break; |
4068 | } |
4071 | } |
4069 | // CompareRegStat(changeregstat); |
4072 | // CompareRegStat(changeregstat); |
4070 | } |
4073 | } |
4071 | if(tok==tk_else/*&&i==FALSE*/){ |
4074 | if(tok==tk_else/*&&i==FALSE*/){ |
4072 | addESP=oaddESP; |
4075 | addESP=oaddESP; |
4073 | RestoreStack(); |
4076 | RestoreStack(); |
4074 | CopyRegStat(bakregstat); |
4077 | CopyRegStat(bakregstat); |
4075 | jumploc0(); |
4078 | jumploc0(); |
4076 | ic = outptr; |
4079 | ic = outptr; |
4077 | getoperand(); |
4080 | getoperand(); |
4078 | #ifdef OPTVARCONST |
4081 | #ifdef OPTVARCONST |
4079 | if(tok!=tk_if&&tok!=tk_IF&&comconst.rec&&comconst.typevar==tk_notequal)Const2VarRec(&comconst); |
4082 | if(tok!=tk_if&&tok!=tk_IF&&comconst.rec&&comconst.typevar==tk_notequal)Const2VarRec(&comconst); |
4080 | #endif |
4083 | #endif |
4081 | startblock(); |
4084 | startblock(); |
4082 | if(tok==tk_return||tok==tk_RETURN){ |
4085 | if(tok==tk_return||tok==tk_RETURN){ |
4083 | if(dbg)AddLine(); |
4086 | if(dbg)AddLine(); |
4084 | doreturn(tok); |
4087 | doreturn(tok); |
4085 | } |
4088 | } |
4086 | else docommand(); |
4089 | else docommand(); |
4087 | endblock(); |
4090 | endblock(); |
4088 | RestoreStack(); |
4091 | RestoreStack(); |
4089 | if((outptr-ic)<=127)warningjmp(mesELSE,elseline); |
4092 | if((outptr-ic)<=127)warningjmp(mesELSE,elseline); |
4090 | if(am32==FALSE)*(unsigned short *)&output[ic-2]=(unsigned short)(outptr-ic); |
4093 | if(am32==FALSE)*(unsigned short *)&output[ic-2]=(unsigned short)(outptr-ic); |
4091 | else *(unsigned long *)&output[ic-4]=(unsigned long)(outptr-ic); |
4094 | else *(unsigned long *)&output[ic-4]=(unsigned long)(outptr-ic); |
4092 | CompareRegStat(changeregstat); |
4095 | CompareRegStat(changeregstat); |
4093 | } |
4096 | } |
4094 | else if(tok==tk_ELSE/*&&ic==FALSE*/){ |
4097 | else if(tok==tk_ELSE/*&&ic==FALSE*/){ |
4095 | addESP=oaddESP; |
4098 | addESP=oaddESP; |
4096 | RestoreStack(); |
4099 | RestoreStack(); |
4097 | CopyRegStat(bakregstat); |
4100 | CopyRegStat(bakregstat); |
4098 | outword(0x00EB); |
4101 | outword(0x00EB); |
4099 | ic=outptr; |
4102 | ic=outptr; |
4100 | getoperand(); |
4103 | getoperand(); |
4101 | #ifdef OPTVARCONST |
4104 | #ifdef OPTVARCONST |
4102 | if(tok!=tk_if&&tok!=tk_IF&&comconst.rec&&comconst.typevar==tk_notequal)Const2VarRec(&comconst); |
4105 | if(tok!=tk_if&&tok!=tk_IF&&comconst.rec&&comconst.typevar==tk_notequal)Const2VarRec(&comconst); |
4103 | #endif |
4106 | #endif |
4104 | startblock(); |
4107 | startblock(); |
4105 | if(tok==tk_return||tok==tk_RETURN){ |
4108 | if(tok==tk_return||tok==tk_RETURN){ |
4106 | if(dbg)AddLine(); |
4109 | if(dbg)AddLine(); |
4107 | doreturn(tok); |
4110 | doreturn(tok); |
4108 | } |
4111 | } |
4109 | else docommand(); |
4112 | else docommand(); |
4110 | endblock(); |
4113 | endblock(); |
4111 | RestoreStack(); |
4114 | RestoreStack(); |
4112 | if((outptr-ic)>127)jumperror(elseline,mesELSE); |
4115 | if((outptr-ic)>127)jumperror(elseline,mesELSE); |
4113 | output[ic-1]=(unsigned char)(outptr-ic); |
4116 | output[ic-1]=(unsigned char)(outptr-ic); |
4114 | CompareRegStat(changeregstat); |
4117 | CompareRegStat(changeregstat); |
4115 | } |
4118 | } |
4116 | free(icomp); |
4119 | free(icomp); |
4117 | CopyRegStat(changeregstat); |
4120 | CopyRegStat(changeregstat); |
4118 | } |
4121 | } |
4119 | FreeStat(bakregstat); |
4122 | FreeStat(bakregstat); |
4120 | FreeStat(changeregstat); |
4123 | FreeStat(changeregstat); |
4121 | retproc=FALSE; |
4124 | retproc=FALSE; |
4122 | lastcommand=tk_IF; |
4125 | lastcommand=tk_IF; |
4123 | } |
4126 | } |
4124 | 4127 | ||
4125 | void JXorJMP() |
4128 | void JXorJMP() |
4126 | { |
4129 | { |
4127 | if(chip<3){ |
4130 | if(chip<3){ |
4128 | op(0xE9); |
4131 | op(0xE9); |
4129 | } |
4132 | } |
4130 | else{ |
4133 | else{ |
4131 | unsigned char i; |
4134 | unsigned char i; |
4132 | outptr-=2; |
4135 | outptr-=2; |
4133 | i=(unsigned char)((output[outptr]^1)+0x10); |
4136 | i=(unsigned char)((output[outptr]^1)+0x10); |
4134 | op(0x0F); op(i); |
4137 | op(0x0F); op(i); |
4135 | if(cpu<3)cpu=3; |
4138 | if(cpu<3)cpu=3; |
4136 | } |
4139 | } |
4137 | } |
4140 | } |
4138 | 4141 | ||
4139 | void dowhile(unsigned int typeb) |
4142 | void dowhile(unsigned int typeb) |
4140 | { |
4143 | { |
4141 | unsigned int ifline,conloc,numcomp=0; |
4144 | unsigned int ifline,conloc,numcomp=0; |
4142 | ICOMP *icomp; |
4145 | ICOMP *icomp; |
4143 | REGISTERSTAT *bakregstat=NULL,*changeregstat=NULL; |
4146 | REGISTERSTAT *bakregstat=NULL,*changeregstat=NULL; |
4144 | uptdbr(); |
4147 | uptdbr(); |
4145 | if(AlignCycle)AlignCD(CS,aligncycle); |
4148 | if(AlignCycle)AlignCD(CS,aligncycle); |
4146 | conloc=outptr; |
4149 | conloc=outptr; |
4147 | ifline=linenumber; |
4150 | ifline=linenumber; |
4148 | if(typeb==tk_while) |
4151 | if(typeb==tk_while) |
4149 | #ifdef OPTVARCONST |
4152 | #ifdef OPTVARCONST |
4150 | icomp=compare(typeb,&numcomp,&bakregstat,&changeregstat,NULL); |
4153 | icomp=compare(typeb,&numcomp,&bakregstat,&changeregstat,NULL); |
4151 | #else |
4154 | #else |
4152 | icomp=compare(typeb,&numcomp,&bakregstat,&changeregstat); |
4155 | icomp=compare(typeb,&numcomp,&bakregstat,&changeregstat); |
4153 | #endif |
4156 | #endif |
4154 | else |
4157 | else |
4155 | #ifdef OPTVARCONST |
4158 | #ifdef OPTVARCONST |
4156 | icomp=bigcompare(typeb,&numcomp,&bakregstat,&changeregstat,NULL); |
4159 | icomp=bigcompare(typeb,&numcomp,&bakregstat,&changeregstat,NULL); |
4157 | #else |
4160 | #else |
4158 | icomp=bigcompare(typeb,&numcomp,&bakregstat,&changeregstat); |
4161 | icomp=bigcompare(typeb,&numcomp,&bakregstat,&changeregstat); |
4159 | #endif |
4162 | #endif |
4160 | SetContinueLabel(); |
4163 | SetContinueLabel(); |
4161 | jumploc(conloc); |
4164 | jumploc(conloc); |
4162 | if(icomp!=NULL){ |
4165 | if(icomp!=NULL){ |
4163 | if(typeb==tk_WHILE){ |
4166 | if(typeb==tk_WHILE){ |
4164 | for(unsigned int i=0;i |
4167 | for(unsigned int i=0;i |
4165 | if((icomp+i)->type!=tk_oror){ |
4168 | if((icomp+i)->type!=tk_oror){ |
4166 | if((outptr-(icomp+i)->loc)>127)jumperror(ifline,mesWHILE); |
4169 | if((outptr-(icomp+i)->loc)>127)jumperror(ifline,mesWHILE); |
4167 | output[(icomp+i)->loc-1]=(unsigned char)(outptr-(icomp+i)->loc); |
4170 | output[(icomp+i)->loc-1]=(unsigned char)(outptr-(icomp+i)->loc); |
4168 | } |
4171 | } |
4169 | } |
4172 | } |
4170 | } |
4173 | } |
4171 | else{ |
4174 | else{ |
4172 | for(unsigned int i=0;i |
4175 | for(unsigned int i=0;i |
4173 | if((icomp+i)->type!=tk_oror){ |
4176 | if((icomp+i)->type!=tk_oror){ |
4174 | if(am32==FALSE)*(unsigned short *)&output[(icomp+i)->loc-2]=(unsigned short)(outptr-(icomp+i)->loc); |
4177 | if(am32==FALSE)*(unsigned short *)&output[(icomp+i)->loc-2]=(unsigned short)(outptr-(icomp+i)->loc); |
4175 | else *(unsigned long *)&output[(icomp+i)->loc-4]=(unsigned long)(outptr-(icomp+i)->loc); |
4178 | else *(unsigned long *)&output[(icomp+i)->loc-4]=(unsigned long)(outptr-(icomp+i)->loc); |
4176 | } |
4179 | } |
4177 | } |
4180 | } |
4178 | if((outptr-icomp->loc)<=127)warningjmp(mesWHILE,ifline); |
4181 | if((outptr-icomp->loc)<=127)warningjmp(mesWHILE,ifline); |
4179 | } |
4182 | } |
4180 | free(icomp); |
4183 | free(icomp); |
4181 | } |
4184 | } |
4182 | if(retproc){ |
4185 | if(retproc){ |
4183 | if(bakregstat)CopyRegStat(bakregstat); |
4186 | if(bakregstat)CopyRegStat(bakregstat); |
4184 | } |
4187 | } |
4185 | else if(changeregstat)CompareRegStat(changeregstat); |
4188 | else if(changeregstat)CompareRegStat(changeregstat); |
4186 | if(changeregstat)CopyRegStat(changeregstat); |
4189 | if(changeregstat)CopyRegStat(changeregstat); |
4187 | SetBreakLabel(); |
4190 | SetBreakLabel(); |
4188 | if(usebr[curbr]!=0)clearregstat(); |
4191 | if(usebr[curbr]!=0)clearregstat(); |
4189 | FreeStat(bakregstat); |
4192 | FreeStat(bakregstat); |
4190 | FreeStat(changeregstat); |
4193 | FreeStat(changeregstat); |
4191 | #ifdef OPTVARCONST |
4194 | #ifdef OPTVARCONST |
4192 | ClearLVIC(); |
4195 | ClearLVIC(); |
4193 | #endif |
4196 | #endif |
4194 | lastcommand=tk_do; |
4197 | lastcommand=tk_do; |
4195 | } |
4198 | } |
4196 | 4199 | ||
4197 | void dowhilefast(unsigned int typeb) |
4200 | void dowhilefast(unsigned int typeb) |
4198 | { |
4201 | { |
4199 | unsigned int numcomp=0; |
4202 | unsigned int numcomp=0; |
4200 | unsigned int startloc,i; |
4203 | unsigned int startloc,i; |
4201 | ICOMP *icomp; |
4204 | ICOMP *icomp; |
4202 | ITOK oitok,ostructadr; |
4205 | ITOK oitok,ostructadr; |
4203 | SINFO ostr; |
4206 | SINFO ostr; |
4204 | unsigned int oldinptr; |
4207 | unsigned int oldinptr; |
4205 | int otok,otok2; |
4208 | int otok,otok2; |
4206 | char *ostring,*obufrm; |
4209 | char *ostring,*obufrm; |
4207 | int blinenum,olinenum,oinptr; |
4210 | int blinenum,olinenum,oinptr; |
4208 | char *ostartline,*bstartline; |
4211 | char *ostartline,*bstartline; |
4209 | char ocha,bcha; |
4212 | char ocha,bcha; |
4210 | int jmptocompr=0; |
4213 | int jmptocompr=0; |
4211 | int rcompr; |
4214 | int rcompr; |
4212 | unsigned char *oinput; |
4215 | unsigned char *oinput; |
4213 | unsigned int oaddESP=addESP; |
4216 | unsigned int oaddESP=addESP; |
4214 | ocha=cha2; |
4217 | ocha=cha2; |
4215 | oinptr=inptr2; |
4218 | oinptr=inptr2; |
4216 | olinenum=linenumber; |
4219 | olinenum=linenumber; |
4217 | ostartline=startline; |
4220 | ostartline=startline; |
4218 | clearregstat(); |
4221 | clearregstat(); |
4219 | #ifdef OPTVARCONST |
4222 | #ifdef OPTVARCONST |
4220 | ClearLVIC(); |
4223 | ClearLVIC(); |
4221 | #endif |
4224 | #endif |
4222 | do{ |
4225 | do{ |
4223 | nexttok(); |
4226 | nexttok(); |
4224 | if(tok2==tk_openbracket)nexttok(); |
4227 | if(tok2==tk_openbracket)nexttok(); |
4225 | if(tok2==tk_closebracket){ |
4228 | if(tok2==tk_closebracket){ |
4226 | nexttok(); |
4229 | nexttok(); |
4227 | jmptocompr=1; |
4230 | jmptocompr=1; |
4228 | break; |
4231 | break; |
4229 | } |
4232 | } |
4230 | if(tok2==tk_number){ |
4233 | if(tok2==tk_number){ |
4231 | nexttok(); |
4234 | nexttok(); |
4232 | if(tok2==tk_closebracket){ |
4235 | if(tok2==tk_closebracket){ |
4233 | if(itok.number!=0)jmptocompr=1; |
4236 | if(itok.number!=0)jmptocompr=1; |
4234 | else jmptocompr=2; |
4237 | else jmptocompr=2; |
4235 | nexttok(); |
4238 | nexttok(); |
4236 | break; |
4239 | break; |
4237 | } |
4240 | } |
4238 | } |
4241 | } |
4239 | nexttok(); //íåîáõîäèìî äëÿ èçáåæàíèÿ ïðåäóïðåæäåíèÿ î íåèíèöèàëèçèðîâàííîé ïåðåìåííîé |
4242 | nexttok(); //íåîáõîäèìî äëÿ èçáåæàíèÿ ïðåäóïðåæäåíèÿ î íåèíèöèàëèçèðîâàííîé ïåðåìåííîé |
4240 | cha=cha2; |
4243 | cha=cha2; |
4241 | inptr=inptr2; |
4244 | inptr=inptr2; |
4242 | SkipParam(); |
4245 | SkipParam(); |
4243 | inptr2=inptr; |
4246 | inptr2=inptr; |
4244 | cha2=cha; |
4247 | cha2=cha; |
4245 | linenum2=linenumber; |
4248 | linenum2=linenumber; |
4246 | nexttok(); |
4249 | nexttok(); |
4247 | if(typeb==tk_while&&tok==tk_oror&&optimizespeed==0){ |
4250 | if(typeb==tk_while&&tok==tk_oror&&optimizespeed==0){ |
4248 | cha2=ocha; |
4251 | cha2=ocha; |
4249 | inptr2=oinptr; |
4252 | inptr2=oinptr; |
4250 | linenumber=linenum2=olinenum; |
4253 | linenumber=linenum2=olinenum; |
4251 | startline=ostartline; |
4254 | startline=ostartline; |
4252 | dowhile(typeb); |
4255 | dowhile(typeb); |
4253 | if(ESPloc&&am32&&oaddESP!=addESP)warESP(); |
4256 | if(ESPloc&&am32&&oaddESP!=addESP)warESP(); |
4254 | return; |
4257 | return; |
4255 | } |
4258 | } |
4256 | if(bufrm){ |
4259 | if(bufrm){ |
4257 | free(bufrm); |
4260 | free(bufrm); |
4258 | bufrm=NULL; |
4261 | bufrm=NULL; |
4259 | } |
4262 | } |
4260 | if(strinf.bufstr){ |
4263 | if(strinf.bufstr){ |
4261 | free(strinf.bufstr); |
4264 | free(strinf.bufstr); |
4262 | strinf.bufstr=NULL; |
4265 | strinf.bufstr=NULL; |
4263 | } |
4266 | } |
4264 | }while(tok==tk_andand||tok==tk_oror); |
4267 | }while(tok==tk_andand||tok==tk_oror); |
4265 | while(tok==tk_closebracket)nexttok(); |
4268 | while(tok==tk_closebracket)nexttok(); |
4266 | if(!jmptocompr){ |
4269 | if(!jmptocompr){ |
4267 | if(typeb==tk_WHILE)outword(0x00EB); // JMP SHORT |
4270 | if(typeb==tk_WHILE)outword(0x00EB); // JMP SHORT |
4268 | else jumploc0(); |
4271 | else jumploc0(); |
4269 | } |
4272 | } |
4270 | i=outptr; |
4273 | i=outptr; |
4271 | if(AlignCycle)AlignCD(CS,aligncycle); |
4274 | if(AlignCycle)AlignCD(CS,aligncycle); |
4272 | startloc=outptr; |
4275 | startloc=outptr; |
4273 | uptdbr(); |
4276 | uptdbr(); |
4274 | if(tok!=tk_openbrace){ |
4277 | if(tok!=tk_openbrace){ |
4275 | if(jmptocompr==2){ |
4278 | if(jmptocompr==2){ |
4276 | do{ |
4279 | do{ |
4277 | nexttok(); |
4280 | nexttok(); |
4278 | }while(tok!=tk_semicolon&&tok!=tk_eof); |
4281 | }while(tok!=tk_semicolon&&tok!=tk_eof); |
4279 | } |
4282 | } |
4280 | else docommand(); |
4283 | else docommand(); |
4281 | } |
4284 | } |
4282 | else{ |
4285 | else{ |
4283 | if(jmptocompr==2){ |
4286 | if(jmptocompr==2){ |
4284 | cha=cha2; |
4287 | cha=cha2; |
4285 | inptr=inptr2; |
4288 | inptr=inptr2; |
4286 | SkipBlock(); |
4289 | SkipBlock(); |
4287 | inptr2=inptr; |
4290 | inptr2=inptr; |
4288 | cha2=cha; |
4291 | cha2=cha; |
4289 | linenum2=linenumber; |
4292 | linenum2=linenumber; |
4290 | nexttok(); |
4293 | nexttok(); |
4291 | } |
4294 | } |
4292 | else{ |
4295 | else{ |
4293 | startblock(); |
4296 | startblock(); |
4294 | doblock(); |
4297 | doblock(); |
4295 | nexttok(); |
4298 | nexttok(); |
4296 | endblock(); |
4299 | endblock(); |
4297 | } |
4300 | } |
4298 | } |
4301 | } |
4299 | RestoreStack(); |
4302 | RestoreStack(); |
4300 | if(!jmptocompr){ |
4303 | if(!jmptocompr){ |
4301 | if(typeb==tk_WHILE){ |
4304 | if(typeb==tk_WHILE){ |
4302 | if(i!=outptr){ |
4305 | if(i!=outptr){ |
4303 | if((outptr-i)>127)jumperror(olinenum,mesWHILE); |
4306 | if((outptr-i)>127)jumperror(olinenum,mesWHILE); |
4304 | output[i-1]=(unsigned char)(outptr-i); |
4307 | output[i-1]=(unsigned char)(outptr-i); |
4305 | } |
4308 | } |
4306 | else{ |
4309 | else{ |
4307 | if(dbg&1)KillLastLine(); |
4310 | if(dbg&1)KillLastLine(); |
4308 | outptr-=2; |
4311 | outptr-=2; |
4309 | startloc-=2; |
4312 | startloc-=2; |
4310 | } |
4313 | } |
4311 | } |
4314 | } |
4312 | else{ |
4315 | else{ |
4313 | if(i!=outptr){ |
4316 | if(i!=outptr){ |
4314 | if((outptr-i)<=127)warningjmp(mesWHILE,olinenum); |
4317 | if((outptr-i)<=127)warningjmp(mesWHILE,olinenum); |
4315 | if(am32) *(unsigned long *)&output[i-4]=(unsigned long)(outptr-i); |
4318 | if(am32) *(unsigned long *)&output[i-4]=(unsigned long)(outptr-i); |
4316 | else *(unsigned short *)&output[i-2]=(unsigned short)(outptr-i); |
4319 | else *(unsigned short *)&output[i-2]=(unsigned short)(outptr-i); |
4317 | } |
4320 | } |
4318 | else{ |
4321 | else{ |
4319 | i=3; |
4322 | i=3; |
4320 | if(am32)i+=2; |
4323 | if(am32)i+=2; |
4321 | if(dbg){ |
4324 | if(dbg){ |
4322 | KillLastLine(); |
4325 | KillLastLine(); |
4323 | KillLastLine(); |
4326 | KillLastLine(); |
4324 | } |
4327 | } |
4325 | outptr-=i; |
4328 | outptr-=i; |
4326 | startloc-=i; |
4329 | startloc-=i; |
4327 | } |
4330 | } |
4328 | } |
4331 | } |
4329 | } |
4332 | } |
4330 | SetContinueLabel(); |
4333 | SetContinueLabel(); |
4331 | clearregstat(); //06.09.04 21:56 |
4334 | clearregstat(); //06.09.04 21:56 |
4332 | #ifdef OPTVARCONST |
4335 | #ifdef OPTVARCONST |
4333 | ClearLVIC(); |
4336 | ClearLVIC(); |
4334 | #endif |
4337 | #endif |
4335 | icomp=(ICOMP *)MALLOC(sizeof(ICOMP)*MAXIF); //áëîê äëÿ èíôî î ñðàâíåíèÿõ |
4338 | icomp=(ICOMP *)MALLOC(sizeof(ICOMP)*MAXIF); //áëîê äëÿ èíôî î ñðàâíåíèÿõ |
4336 | // oitok2=itok2; |
4339 | // oitok2=itok2; |
4337 | 4340 | ||
4338 | ostring=BackString((char *)string); |
4341 | ostring=BackString((char *)string); |
4339 | oldinptr=inptr2; |
4342 | oldinptr=inptr2; |
4340 | oinput=input; |
4343 | oinput=input; |
4341 | bcha=cha2; |
4344 | bcha=cha2; |
4342 | otok=tok; |
4345 | otok=tok; |
4343 | otok2=tok2; |
4346 | otok2=tok2; |
4344 | oitok=itok; |
4347 | oitok=itok; |
4345 | ostructadr=structadr; |
4348 | ostructadr=structadr; |
4346 | ostr=strinf; |
4349 | ostr=strinf; |
4347 | strinf.bufstr=NULL; |
4350 | strinf.bufstr=NULL; |
4348 | obufrm=bufrm; |
4351 | obufrm=bufrm; |
4349 | int oldendinptr=endinptr; |
4352 | int oldendinptr=endinptr; |
4350 | COM_MOD *tempcurmod=cur_mod; |
4353 | COM_MOD *tempcurmod=cur_mod; |
4351 | if(cur_mod)BackMod(); |
4354 | if(cur_mod)BackMod(); |
4352 | 4355 | ||
4353 | bufrm=NULL; |
4356 | bufrm=NULL; |
4354 | blinenum=linenum2; |
4357 | blinenum=linenum2; |
4355 | inptr2=oinptr; |
4358 | inptr2=oinptr; |
4356 | cha2=ocha; |
4359 | cha2=ocha; |
4357 | linenumber=linenum2=olinenum; |
4360 | linenumber=linenum2=olinenum; |
4358 | bstartline=startline; |
4361 | bstartline=startline; |
4359 | startline=ostartline; |
4362 | startline=ostartline; |
4360 | 4363 | ||
4361 | if(dbg)AddLine(); |
4364 | if(dbg)AddLine(); |
4362 | int ptok=tk_oror; |
4365 | int ptok=tk_oror; |
4363 | do{ |
4366 | do{ |
4364 | i=0; |
4367 | i=0; |
4365 | #ifdef OPTVARCONST |
4368 | #ifdef OPTVARCONST |
4366 | if((rcompr=constructcompare(2,startloc,NULL))==voidcompr||rcompr==zerocompr)i=1; |
4369 | if((rcompr=constructcompare(2,startloc,NULL))==voidcompr||rcompr==zerocompr)i=1; |
4367 | #else |
4370 | #else |
4368 | if((rcompr=constructcompare(2,startloc))==voidcompr||rcompr==zerocompr)i=1; |
4371 | if((rcompr=constructcompare(2,startloc))==voidcompr||rcompr==zerocompr)i=1; |
4369 | #endif |
4372 | #endif |
4370 | if(i){ |
4373 | if(i){ |
4371 | if(ptok==tk_andand){ |
4374 | if(ptok==tk_andand){ |
4372 | // i=0; |
4375 | // i=0; |
4373 | ptok=tok; |
4376 | ptok=tok; |
4374 | } |
4377 | } |
4375 | continue; |
4378 | continue; |
4376 | } |
4379 | } |
4377 | if((rcompr&1)){; |
4380 | if((rcompr&1)){; |
4378 | op(0x03); |
4381 | op(0x03); |
4379 | if(tok!=tk_andand){ |
4382 | if(tok!=tk_andand){ |
4380 | JXorJMP(); |
4383 | JXorJMP(); |
4381 | if(am32==FALSE)outword(startloc-(outptr+2)); |
4384 | if(am32==FALSE)outword(startloc-(outptr+2)); |
4382 | else outdword(startloc-(outptr+4)); |
4385 | else outdword(startloc-(outptr+4)); |
4383 | } |
4386 | } |
4384 | } |
4387 | } |
4385 | else{ |
4388 | else{ |
4386 | op(startloc-(outptr+1)); /* the small jump */ |
4389 | op(startloc-(outptr+1)); /* the small jump */ |
4387 | if(tok==tk_andand)output[outptr-2]=(unsigned char)(output[outptr-2]^1); |
4390 | if(tok==tk_andand)output[outptr-2]=(unsigned char)(output[outptr-2]^1); |
4388 | } |
4391 | } |
4389 | (icomp+numcomp)->loc=outptr; |
4392 | (icomp+numcomp)->loc=outptr; |
4390 | (icomp+numcomp)->type=tok; |
4393 | (icomp+numcomp)->type=tok; |
4391 | numcomp++; |
4394 | numcomp++; |
4392 | if(numcomp==MAXIF){ |
4395 | if(numcomp==MAXIF){ |
4393 | ManyLogicCompare(); |
4396 | ManyLogicCompare(); |
4394 | break; |
4397 | break; |
4395 | } |
4398 | } |
4396 | ptok=tok; |
4399 | ptok=tok; |
4397 | }while(tok==tk_oror||tok==tk_andand); |
4400 | }while(tok==tk_oror||tok==tk_andand); |
4398 | if(jmptocompr==1)jumploc(startloc); |
4401 | if(jmptocompr==1)jumploc(startloc); |
4399 | 4402 | ||
4400 | startline=bstartline; |
4403 | startline=bstartline; |
4401 | strinf=ostr; |
4404 | strinf=ostr; |
4402 | inptr2=oldinptr; |
4405 | inptr2=oldinptr; |
4403 | input=oinput; |
4406 | input=oinput; |
4404 | endinptr=oldendinptr; |
4407 | endinptr=oldendinptr; |
4405 | cha2=bcha; |
4408 | cha2=bcha; |
4406 | tok=otok; |
4409 | tok=otok; |
4407 | itok=oitok; |
4410 | itok=oitok; |
4408 | structadr=ostructadr; |
4411 | structadr=ostructadr; |
4409 | bufrm=obufrm; |
4412 | bufrm=obufrm; |
4410 | tok2=otok2; |
4413 | tok2=otok2; |
4411 | cur_mod=tempcurmod; |
4414 | cur_mod=tempcurmod; |
4412 | strcpy((char *)string,ostring); |
4415 | strcpy((char *)string,ostring); |
4413 | free(ostring); |
4416 | free(ostring); |
4414 | linenumber=linenum2=blinenum; |
4417 | linenumber=linenum2=blinenum; |
4415 | itok2=oitok; |
4418 | itok2=oitok; |
4416 | 4419 | ||
4417 | for(i=0;i |
4420 | for(i=0;i |
4418 | if((icomp+i)->type==tk_andand){ |
4421 | if((icomp+i)->type==tk_andand){ |
4419 | if(outptr-(icomp+i)->loc>127)CompareOr(); |
4422 | if(outptr-(icomp+i)->loc>127)CompareOr(); |
4420 | output[(icomp+i)->loc-1]=(unsigned char)(outptr-(icomp+i)->loc); |
4423 | output[(icomp+i)->loc-1]=(unsigned char)(outptr-(icomp+i)->loc); |
4421 | } |
4424 | } |
4422 | } |
4425 | } |
4423 | if(rcompr==cxzcompr){ |
4426 | if(rcompr==cxzcompr){ |
4424 | outptr-=4; |
4427 | outptr-=4; |
4425 | op(0xE3); |
4428 | op(0xE3); |
4426 | op(startloc-outptr-1); |
4429 | op(startloc-outptr-1); |
4427 | for(i=(numcomp-1);i!=0;i--){ |
4430 | for(i=(numcomp-1);i!=0;i--){ |
4428 | if((icomp+i-1)->type==tk_andand)output[(icomp+i-1)->loc-1]-=(unsigned char)2; |
4431 | if((icomp+i-1)->type==tk_andand)output[(icomp+i-1)->loc-1]-=(unsigned char)2; |
4429 | } |
4432 | } |
4430 | } |
4433 | } |
4431 | SetBreakLabel(); |
4434 | SetBreakLabel(); |
4432 | clearregstat(); |
4435 | clearregstat(); |
4433 | #ifdef OPTVARCONST |
4436 | #ifdef OPTVARCONST |
4434 | ClearLVIC(); |
4437 | ClearLVIC(); |
4435 | #endif |
4438 | #endif |
4436 | free(icomp); |
4439 | free(icomp); |
4437 | if(ESPloc&&am32&&oaddESP!=addESP)warESP(); |
4440 | if(ESPloc&&am32&&oaddESP!=addESP)warESP(); |
4438 | lastcommand=tk_do; |
4441 | lastcommand=tk_do; |
4439 | } |
4442 | } |
4440 | 4443 | ||
4441 | void dodo() |
4444 | void dodo() |
4442 | { |
4445 | { |
4443 | unsigned int startloc,numcomp=0,i=0; |
4446 | unsigned int startloc,numcomp=0,i=0; |
4444 | ICOMP *icomp; |
4447 | ICOMP *icomp; |
4445 | int ptok=tk_oror; |
4448 | int ptok=tk_oror; |
4446 | int rcompr; |
4449 | int rcompr; |
4447 | unsigned int oaddESP=addESP; |
4450 | unsigned int oaddESP=addESP; |
4448 | nexttok(); |
4451 | nexttok(); |
4449 | if(AlignCycle)AlignCD(CS,aligncycle); |
4452 | if(AlignCycle)AlignCD(CS,aligncycle); |
4450 | startloc=outptr; |
4453 | startloc=outptr; |
4451 | uptdbr(); |
4454 | uptdbr(); |
4452 | if(dbg&1)KillLastLine(); |
4455 | if(dbg&1)KillLastLine(); |
4453 | clearregstat(); |
4456 | clearregstat(); |
4454 | #ifdef OPTVARCONST |
4457 | #ifdef OPTVARCONST |
4455 | ClearLVIC(); |
4458 | ClearLVIC(); |
4456 | #endif |
4459 | #endif |
4457 | docommand(); |
4460 | docommand(); |
4458 | SetContinueLabel(); |
4461 | SetContinueLabel(); |
4459 | if(dbg)AddLine(); |
4462 | if(dbg)AddLine(); |
4460 | if(tok!=tk_while)preerror("'while' expected following 'do'"); |
4463 | if(tok!=tk_while)preerror("'while' expected following 'do'"); |
4461 | icomp=(ICOMP *)MALLOC(sizeof(ICOMP)*MAXIF); //áëîê äëÿ èíôî î ñðàâíåíèÿõ |
4464 | icomp=(ICOMP *)MALLOC(sizeof(ICOMP)*MAXIF); //áëîê äëÿ èíôî î ñðàâíåíèÿõ |
4462 | do{ |
4465 | do{ |
4463 | #ifdef OPTVARCONST |
4466 | #ifdef OPTVARCONST |
4464 | if((rcompr=constructcompare(2,startloc,NULL))==voidcompr||rcompr==zerocompr)i=1; |
4467 | if((rcompr=constructcompare(2,startloc,NULL))==voidcompr||rcompr==zerocompr)i=1; |
4465 | #else |
4468 | #else |
4466 | if((rcompr=constructcompare(2,startloc))==voidcompr||rcompr==zerocompr)i=1; |
4469 | if((rcompr=constructcompare(2,startloc))==voidcompr||rcompr==zerocompr)i=1; |
4467 | #endif |
4470 | #endif |
4468 | if(i){ |
4471 | if(i){ |
4469 | if(ptok==tk_andand){ |
4472 | if(ptok==tk_andand){ |
4470 | i=0; |
4473 | i=0; |
4471 | ptok=tok; |
4474 | ptok=tok; |
4472 | } |
4475 | } |
4473 | continue; |
4476 | continue; |
4474 | } |
4477 | } |
4475 | if((rcompr&1)){; |
4478 | if((rcompr&1)){; |
4476 | op(0x03); |
4479 | op(0x03); |
4477 | if(tok!=tk_andand){ |
4480 | if(tok!=tk_andand){ |
4478 | JXorJMP(); |
4481 | JXorJMP(); |
4479 | if(am32==FALSE)outword(startloc-(outptr+2)); |
4482 | if(am32==FALSE)outword(startloc-(outptr+2)); |
4480 | else outdword(startloc-(outptr+4)); |
4483 | else outdword(startloc-(outptr+4)); |
4481 | } |
4484 | } |
4482 | } |
4485 | } |
4483 | else{ |
4486 | else{ |
4484 | op(startloc-(outptr+1)); /* the small jump */ |
4487 | op(startloc-(outptr+1)); /* the small jump */ |
4485 | if(tok==tk_andand)output[outptr-2]=(unsigned char)(output[outptr-2]^1); |
4488 | if(tok==tk_andand)output[outptr-2]=(unsigned char)(output[outptr-2]^1); |
4486 | } |
4489 | } |
4487 | (icomp+numcomp)->loc=outptr; |
4490 | (icomp+numcomp)->loc=outptr; |
4488 | (icomp+numcomp)->type=tok; |
4491 | (icomp+numcomp)->type=tok; |
4489 | numcomp++; |
4492 | numcomp++; |
4490 | if(numcomp==MAXIF){ |
4493 | if(numcomp==MAXIF){ |
4491 | ManyLogicCompare(); |
4494 | ManyLogicCompare(); |
4492 | goto end; |
4495 | goto end; |
4493 | } |
4496 | } |
4494 | ptok=tok; |
4497 | ptok=tok; |
4495 | }while(tok==tk_oror||tok==tk_andand); |
4498 | }while(tok==tk_oror||tok==tk_andand); |
4496 | if(i)jumploc(startloc); |
4499 | if(i)jumploc(startloc); |
4497 | if(tok==tk_closebracket)nexttok(); |
4500 | if(tok==tk_closebracket)nexttok(); |
4498 | for(i=0;i |
4501 | for(i=0;i |
4499 | if((icomp+i)->type==tk_andand){ |
4502 | if((icomp+i)->type==tk_andand){ |
4500 | if(outptr-(icomp+i)->loc>127)CompareOr(); |
4503 | if(outptr-(icomp+i)->loc>127)CompareOr(); |
4501 | output[(icomp+i)->loc-1]=(unsigned char)(outptr-(icomp+i)->loc); |
4504 | output[(icomp+i)->loc-1]=(unsigned char)(outptr-(icomp+i)->loc); |
4502 | } |
4505 | } |
4503 | } |
4506 | } |
4504 | if(rcompr==cxzcompr){ |
4507 | if(rcompr==cxzcompr){ |
4505 | outptr-=4; |
4508 | outptr-=4; |
4506 | op(0xE3); |
4509 | op(0xE3); |
4507 | op(startloc-outptr-1); |
4510 | op(startloc-outptr-1); |
4508 | for(i=(numcomp-1);i!=0;i--){ |
4511 | for(i=(numcomp-1);i!=0;i--){ |
4509 | if((icomp+i-1)->type==tk_andand)output[(icomp+i-1)->loc-1]-=(unsigned char)2; |
4512 | if((icomp+i-1)->type==tk_andand)output[(icomp+i-1)->loc-1]-=(unsigned char)2; |
4510 | } |
4513 | } |
4511 | } |
4514 | } |
4512 | seminext(); |
4515 | seminext(); |
4513 | SetBreakLabel(); |
4516 | SetBreakLabel(); |
4514 | if(usebr[curbr]!=0||useco[curco]!=0)clearregstat(); |
4517 | if(usebr[curbr]!=0||useco[curco]!=0)clearregstat(); |
4515 | end: |
4518 | end: |
4516 | #ifdef OPTVARCONST |
4519 | #ifdef OPTVARCONST |
4517 | ClearLVIC(); |
4520 | ClearLVIC(); |
4518 | #endif |
4521 | #endif |
4519 | free(icomp); |
4522 | free(icomp); |
4520 | if(ESPloc&&am32&&oaddESP!=addESP)warESP(); |
4523 | if(ESPloc&&am32&&oaddESP!=addESP)warESP(); |
4521 | lastcommand=tk_do; |
4524 | lastcommand=tk_do; |
4522 | } |
4525 | } |
4523 | 4526 | ||
4524 | void dofor(unsigned int typeb) |
4527 | void dofor(unsigned int typeb) |
4525 | { |
4528 | { |
4526 | unsigned int ifline,conloc,blinenum,numcomp=0; |
4529 | unsigned int ifline,conloc,blinenum,numcomp=0; |
4527 | unsigned char bcha; |
4530 | unsigned char bcha; |
4528 | unsigned char COMPARE=FALSE,modif=FALSE; |
4531 | unsigned char COMPARE=FALSE,modif=FALSE; |
4529 | int i; |
4532 | int i; |
4530 | unsigned char *buf; |
4533 | unsigned char *buf; |
4531 | unsigned int oaddESP=addESP; |
4534 | unsigned int oaddESP=addESP; |
4532 | ICOMP *icomp=NULL; |
4535 | ICOMP *icomp=NULL; |
4533 | REGISTERSTAT *bakregstat=NULL,*changeregstat=NULL; |
4536 | REGISTERSTAT *bakregstat=NULL,*changeregstat=NULL; |
4534 | ifline=linenumber; |
4537 | ifline=linenumber; |
4535 | // printf("start for, curco=%u curbr=%u\n",curco,curbr); |
4538 | // printf("start for, curco=%u curbr=%u\n",curco,curbr); |
4536 | uptdbr(); |
4539 | uptdbr(); |
4537 | nexttok(); |
4540 | nexttok(); |
4538 | i=inptr2; |
4541 | i=inptr2; |
4539 | bcha=cha2; |
4542 | bcha=cha2; |
4540 | expecting(tk_openbracket); //ïðîâ íà îòêð ñêîáêó |
4543 | expecting(tk_openbracket); //ïðîâ íà îòêð ñêîáêó |
4541 | if(tok!=tk_semicolon){ //ÅÑÒÜ ÏÐÅÄÂÀÐÈÒÅËÜÍÛÅ ÓÑÒÀÍÎÂÊÈ |
4544 | if(tok!=tk_semicolon){ //ÅÑÒÜ ÏÐÅÄÂÀÐÈÒÅËÜÍÛÅ ÓÑÒÀÍÎÂÊÈ |
4542 | for(;;){ //çàïèñàòü èõ â áóôåð |
4545 | for(;;){ //çàïèñàòü èõ â áóôåð |
4543 | AddBackBuf(i,bcha); |
4546 | AddBackBuf(i,bcha); |
4544 | if(tok==tk_semicolon)break; |
4547 | if(tok==tk_semicolon)break; |
4545 | if(tok!=tk_camma){ |
4548 | if(tok!=tk_camma){ |
4546 | expecting(tk_semicolon); |
4549 | expecting(tk_semicolon); |
4547 | break; |
4550 | break; |
4548 | } |
4551 | } |
4549 | i=inptr2; |
4552 | i=inptr2; |
4550 | bcha=cha2; |
4553 | bcha=cha2; |
4551 | nexttok(); |
4554 | nexttok(); |
4552 | } |
4555 | } |
4553 | if(bufrm){ |
4556 | if(bufrm){ |
4554 | free(bufrm); |
4557 | free(bufrm); |
4555 | bufrm=NULL; |
4558 | bufrm=NULL; |
4556 | } |
4559 | } |
4557 | if(strinf.bufstr){ |
4560 | if(strinf.bufstr){ |
4558 | free(strinf.bufstr); |
4561 | free(strinf.bufstr); |
4559 | strinf.bufstr=NULL; |
4562 | strinf.bufstr=NULL; |
4560 | } |
4563 | } |
4561 | CharToBackBuf('}'); |
4564 | CharToBackBuf('}'); |
4562 | CharToBackBuf(0); |
4565 | CharToBackBuf(0); |
4563 | RunBackText(); //âûïîëíèòü åãî |
4566 | RunBackText(); //âûïîëíèòü åãî |
4564 | } |
4567 | } |
4565 | clearregstat(); |
4568 | clearregstat(); |
4566 | #ifdef OPTVARCONST |
4569 | #ifdef OPTVARCONST |
4567 | ClearLVIC(); |
4570 | ClearLVIC(); |
4568 | #endif |
4571 | #endif |
4569 | bcha=cha2; |
4572 | bcha=cha2; |
4570 | i=inptr2; |
4573 | i=inptr2; |
4571 | nexttok(); |
4574 | nexttok(); |
4572 | if(AlignCycle)AlignCD(CS,aligncycle); |
4575 | if(AlignCycle)AlignCD(CS,aligncycle); |
4573 | conloc=outptr; //çàïîìíèòü òî÷êó íà÷àëà öèêëà |
4576 | conloc=outptr; //çàïîìíèòü òî÷êó íà÷àëà öèêëà |
4574 | 4577 | ||
4575 | if(tok!=tk_semicolon){ //åñëè åñòü óñëîâèå |
4578 | if(tok!=tk_semicolon){ //åñëè åñòü óñëîâèå |
4576 | if(tok!=tk_openbracket){ //åñëè óñëîâèå íà÷èíàåòñÿ íå ñ ( |
4579 | if(tok!=tk_openbracket){ //åñëè óñëîâèå íà÷èíàåòñÿ íå ñ ( |
4577 | CharToBackBuf('('); //äîáàâèòü åå |
4580 | CharToBackBuf('('); //äîáàâèòü åå |
4578 | COMPARE=TRUE; //è ôëàã óñòàíîâèòü |
4581 | COMPARE=TRUE; //è ôëàã óñòàíîâèòü |
4579 | } |
4582 | } |
4580 | AddBackBuf(i,bcha); //çàïîìíèòü óñëîâèå |
4583 | AddBackBuf(i,bcha); //çàïîìíèòü óñëîâèå |
4581 | if(tok!=tk_semicolon)expected(';'); |
4584 | if(tok!=tk_semicolon)expected(';'); |
4582 | SizeBackBuf--; |
4585 | SizeBackBuf--; |
4583 | if(COMPARE)CharToBackBuf(')'); //åñëè íàäî, çàêðûòü ñêîáêó |
4586 | if(COMPARE)CharToBackBuf(')'); //åñëè íàäî, çàêðûòü ñêîáêó |
4584 | CharToBackBuf(0); |
4587 | CharToBackBuf(0); |
4585 | int oendinptr=endinptr; |
4588 | int oendinptr=endinptr; |
4586 | endinptr=SizeBackBuf-1;//strlen(BackTextBlock); |
4589 | endinptr=SizeBackBuf-1;//strlen(BackTextBlock); |
4587 | i=inptr2; |
4590 | i=inptr2; |
4588 | buf=input; |
4591 | buf=input; |
4589 | bcha=cha2; |
4592 | bcha=cha2; |
4590 | input=(unsigned char *)BackTextBlock; |
4593 | input=(unsigned char *)BackTextBlock; |
4591 | SizeBackBuf=0; |
4594 | SizeBackBuf=0; |
4592 | inptr2=1; |
4595 | inptr2=1; |
4593 | cha2='('; |
4596 | cha2='('; |
4594 | if(typeb==tk_for) |
4597 | if(typeb==tk_for) |
4595 | #ifdef OPTVARCONST |
4598 | #ifdef OPTVARCONST |
4596 | icomp=compare(typeb,&numcomp,&bakregstat,&changeregstat,NULL); |
4599 | icomp=compare(typeb,&numcomp,&bakregstat,&changeregstat,NULL); |
4597 | #else |
4600 | #else |
4598 | icomp=compare(typeb,&numcomp,&bakregstat,&changeregstat); |
4601 | icomp=compare(typeb,&numcomp,&bakregstat,&changeregstat); |
4599 | #endif |
4602 | #endif |
4600 | else |
4603 | else |
4601 | #ifdef OPTVARCONST |
4604 | #ifdef OPTVARCONST |
4602 | icomp=bigcompare(typeb,&numcomp,&bakregstat,&changeregstat,NULL); |
4605 | icomp=bigcompare(typeb,&numcomp,&bakregstat,&changeregstat,NULL); |
4603 | #else |
4606 | #else |
4604 | icomp=bigcompare(typeb,&numcomp,&bakregstat,&changeregstat); |
4607 | icomp=bigcompare(typeb,&numcomp,&bakregstat,&changeregstat); |
4605 | #endif |
4608 | #endif |
4606 | free(input); |
4609 | free(input); |
4607 | input=buf; |
4610 | input=buf; |
4608 | inptr2=i; |
4611 | inptr2=i; |
4609 | cha2=bcha; |
4612 | cha2=bcha; |
4610 | endinptr=oendinptr; |
4613 | endinptr=oendinptr; |
4611 | COMPARE=TRUE; |
4614 | COMPARE=TRUE; |
4612 | nexttok(); |
4615 | nexttok(); |
4613 | } |
4616 | } |
4614 | else{ |
4617 | else{ |
4615 | i=inptr2; |
4618 | i=inptr2; |
4616 | bcha=cha2; |
4619 | bcha=cha2; |
4617 | nexttok(); |
4620 | nexttok(); |
4618 | } |
4621 | } |
4619 | 4622 | ||
4620 | if(tok!=tk_closebracket){ //åñòü ìîäèôèêàöèÿ |
4623 | if(tok!=tk_closebracket){ //åñòü ìîäèôèêàöèÿ |
4621 | modif=TRUE; |
4624 | modif=TRUE; |
4622 | while(tok!=tk_closebracket){ |
4625 | while(tok!=tk_closebracket){ |
4623 | AddBackBuf(i,bcha); |
4626 | AddBackBuf(i,bcha); |
4624 | if(cha==')'||cha==26){ |
4627 | if(cha==')'||cha==26){ |
4625 | CharToBackBuf(';'); |
4628 | CharToBackBuf(';'); |
4626 | nextchar(); |
4629 | nextchar(); |
4627 | cha2=cha; |
4630 | cha2=cha; |
4628 | inptr2=inptr; |
4631 | inptr2=inptr; |
4629 | break; |
4632 | break; |
4630 | } |
4633 | } |
4631 | if(bufrm){ |
4634 | if(bufrm){ |
4632 | free(bufrm); |
4635 | free(bufrm); |
4633 | bufrm=NULL; |
4636 | bufrm=NULL; |
4634 | } |
4637 | } |
4635 | if(strinf.bufstr){ |
4638 | if(strinf.bufstr){ |
4636 | free(strinf.bufstr); |
4639 | free(strinf.bufstr); |
4637 | strinf.bufstr=NULL; |
4640 | strinf.bufstr=NULL; |
4638 | } |
4641 | } |
4639 | i=inptr2; |
4642 | i=inptr2; |
4640 | bcha=cha2; |
4643 | bcha=cha2; |
4641 | nexttok(); |
4644 | nexttok(); |
4642 | } |
4645 | } |
4643 | CharToBackBuf('}'); |
4646 | CharToBackBuf('}'); |
4644 | CharToBackBuf(0); |
4647 | CharToBackBuf(0); |
4645 | buf=(unsigned char *)REALLOC(BackTextBlock,SizeBackBuf); |
4648 | buf=(unsigned char *)REALLOC(BackTextBlock,SizeBackBuf); |
4646 | SizeBackBuf=0; |
4649 | SizeBackBuf=0; |
4647 | } |
4650 | } |
4648 | 4651 | ||
4649 | blinenum=linenumber; |
4652 | blinenum=linenumber; |
4650 | nexttok(); |
4653 | nexttok(); |
4651 | /////////////////// |
4654 | /////////////////// |
4652 | if(tok==tk_openbrace){ |
4655 | if(tok==tk_openbrace){ |
4653 | if(COMPARE&&(icomp+numcomp)->use_cxz==zerocompr){ |
4656 | if(COMPARE&&(icomp+numcomp)->use_cxz==zerocompr){ |
4654 | warcompneqconst(); |
4657 | warcompneqconst(); |
4655 | cha=cha2; |
4658 | cha=cha2; |
4656 | inptr=inptr2; |
4659 | inptr=inptr2; |
4657 | SkipBlock(); |
4660 | SkipBlock(); |
4658 | inptr2=inptr; |
4661 | inptr2=inptr; |
4659 | cha2=cha; |
4662 | cha2=cha; |
4660 | linenum2=linenumber; |
4663 | linenum2=linenumber; |
4661 | nexttok(); |
4664 | nexttok(); |
4662 | } |
4665 | } |
4663 | else{ |
4666 | else{ |
4664 | startblock(); |
4667 | startblock(); |
4665 | doblock(); |
4668 | doblock(); |
4666 | nexttok(); |
4669 | nexttok(); |
4667 | endblock(); |
4670 | endblock(); |
4668 | } |
4671 | } |
4669 | } |
4672 | } |
4670 | else{ |
4673 | else{ |
4671 | if(COMPARE&&(icomp+numcomp)->use_cxz==zerocompr){ |
4674 | if(COMPARE&&(icomp+numcomp)->use_cxz==zerocompr){ |
4672 | warcompneqconst(); |
4675 | warcompneqconst(); |
4673 | do{ |
4676 | do{ |
4674 | nexttok(); |
4677 | nexttok(); |
4675 | }while(tok!=tk_semicolon&&tok!=tk_eof); |
4678 | }while(tok!=tk_semicolon&&tok!=tk_eof); |
4676 | } |
4679 | } |
4677 | else docommand(); |
4680 | else docommand(); |
4678 | } |
4681 | } |
4679 | 4682 | ||
4680 | RestoreStack(); |
4683 | RestoreStack(); |
4681 | SetContinueLabel(); |
4684 | SetContinueLabel(); |
4682 | // puts((char *)string2); |
4685 | // puts((char *)string2); |
4683 | // printf("end for, curco=%u curbr=%u\n",curco,curbr); |
4686 | // printf("end for, curco=%u curbr=%u\n",curco,curbr); |
4684 | if(modif){ |
4687 | if(modif){ |
4685 | unsigned int oldlinenum=linenum2; |
4688 | unsigned int oldlinenum=linenum2; |
4686 | ITOK oitok; |
4689 | ITOK oitok; |
4687 | oitok=itok2; |
4690 | oitok=itok2; |
4688 | BackTextBlock=(char *)buf; |
4691 | BackTextBlock=(char *)buf; |
4689 | linenum2=blinenum; |
4692 | linenum2=blinenum; |
4690 | RunBackText(); |
4693 | RunBackText(); |
4691 | linenumber=linenum2=oldlinenum; |
4694 | linenumber=linenum2=oldlinenum; |
4692 | itok2=oitok; |
4695 | itok2=oitok; |
4693 | } |
4696 | } |
4694 | 4697 | ||
4695 | if(COMPARE==FALSE||(COMPARE&&(icomp+numcomp)->use_cxz!=zerocompr)){ |
4698 | if(COMPARE==FALSE||(COMPARE&&(icomp+numcomp)->use_cxz!=zerocompr)){ |
4696 | if(COMPARE&&(icomp+numcomp)->use_cxz==voidcompr)warcompeqconst(); |
4699 | if(COMPARE&&(icomp+numcomp)->use_cxz==voidcompr)warcompeqconst(); |
4697 | jumploc(conloc);//JMP íà íà÷àëî öèêëà |
4700 | jumploc(conloc);//JMP íà íà÷àëî öèêëà |
4698 | } |
4701 | } |
4699 | 4702 | ||
4700 | if(COMPARE){ |
4703 | if(COMPARE){ |
4701 | for(unsigned int i=0;i |
4704 | for(unsigned int i=0;i |
4702 | if((icomp+i)->type!=tk_oror){ |
4705 | if((icomp+i)->type!=tk_oror){ |
4703 | if(typeb==tk_FOR){ |
4706 | if(typeb==tk_FOR){ |
4704 | if((outptr-(icomp+i)->loc)>127)jumperror(ifline,mesFOR); |
4707 | if((outptr-(icomp+i)->loc)>127)jumperror(ifline,mesFOR); |
4705 | output[(icomp+i)->loc-1]=(unsigned char)(outptr-(icomp+i)->loc); |
4708 | output[(icomp+i)->loc-1]=(unsigned char)(outptr-(icomp+i)->loc); |
4706 | } |
4709 | } |
4707 | else{ |
4710 | else{ |
4708 | if((outptr-(icomp+i)->loc)<=127)warningjmp(mesFOR,ifline); |
4711 | if((outptr-(icomp+i)->loc)<=127)warningjmp(mesFOR,ifline); |
4709 | if(am32==FALSE)*(unsigned short *)&output[(icomp+i)->loc-2]=(unsigned short)(outptr-(icomp+i)->loc); |
4712 | if(am32==FALSE)*(unsigned short *)&output[(icomp+i)->loc-2]=(unsigned short)(outptr-(icomp+i)->loc); |
4710 | else *(unsigned long *)&output[(icomp+i)->loc-4]=(unsigned long)(outptr-(icomp+i)->loc); |
4713 | else *(unsigned long *)&output[(icomp+i)->loc-4]=(unsigned long)(outptr-(icomp+i)->loc); |
4711 | } |
4714 | } |
4712 | } |
4715 | } |
4713 | } |
4716 | } |
4714 | free(icomp); |
4717 | free(icomp); |
4715 | } |
4718 | } |
4716 | if(retproc){ |
4719 | if(retproc){ |
4717 | if(bakregstat)CopyRegStat(bakregstat); |
4720 | if(bakregstat)CopyRegStat(bakregstat); |
4718 | } |
4721 | } |
4719 | else if(changeregstat)CompareRegStat(changeregstat); |
4722 | else if(changeregstat)CompareRegStat(changeregstat); |
4720 | if(changeregstat)CopyRegStat(changeregstat); |
4723 | if(changeregstat)CopyRegStat(changeregstat); |
4721 | SetBreakLabel(); |
4724 | SetBreakLabel(); |
4722 | if(usebr[curbr]!=0||useco[curco]!=0)clearregstat(); |
4725 | if(usebr[curbr]!=0||useco[curco]!=0)clearregstat(); |
4723 | FreeStat(bakregstat); |
4726 | FreeStat(bakregstat); |
4724 | FreeStat(changeregstat); |
4727 | FreeStat(changeregstat); |
4725 | #ifdef OPTVARCONST |
4728 | #ifdef OPTVARCONST |
4726 | ClearLVIC(); |
4729 | ClearLVIC(); |
4727 | #endif |
4730 | #endif |
4728 | if(ESPloc&&am32&&oaddESP!=addESP)warESP(); |
4731 | if(ESPloc&&am32&&oaddESP!=addESP)warESP(); |
4729 | lastcommand=tk_for; |
4732 | lastcommand=tk_for; |
4730 | } |
4733 | } |
4731 | 4734 | ||
4732 | void decit(int dectok,ITOK *detok,char *&decbuf,SINFO *dstr) |
4735 | void decit(int dectok,ITOK *detok,char *&decbuf,SINFO *dstr) |
4733 | // outputs code to decrement the given variable one. |
4736 | // outputs code to decrement the given variable one. |
4734 | { |
4737 | { |
4735 | int vop=0,i=0,razr=r16; |
4738 | int vop=0,i=0,razr=r16; |
4736 | switch(dectok){ |
4739 | switch(dectok){ |
4737 | case tk_dwordvar: |
4740 | case tk_dwordvar: |
4738 | case tk_longvar: |
4741 | case tk_longvar: |
4739 | CheckAllMassiv(decbuf,4,dstr,detok); |
4742 | CheckAllMassiv(decbuf,4,dstr,detok); |
4740 | op66(r32); |
4743 | op66(r32); |
4741 | if(cpu<3)cpu=3; |
4744 | if(cpu<3)cpu=3; |
4742 | vop=1; |
4745 | vop=1; |
4743 | goto l2; |
4746 | goto l2; |
4744 | case tk_wordvar: |
4747 | case tk_wordvar: |
4745 | case tk_intvar: vop=1; |
4748 | case tk_intvar: vop=1; |
4746 | op66(r16); |
4749 | op66(r16); |
4747 | i=1; |
4750 | i=1; |
4748 | case tk_bytevar: |
4751 | case tk_bytevar: |
4749 | case tk_charvar: |
4752 | case tk_charvar: |
4750 | i++; |
4753 | i++; |
4751 | CheckAllMassiv(decbuf,i,dstr,detok); |
4754 | CheckAllMassiv(decbuf,i,dstr,detok); |
4752 | if(vop!=0)op66(r16); |
4755 | if(vop!=0)op66(r16); |
4753 | l2: |
4756 | l2: |
4754 | outseg(detok,2); |
4757 | outseg(detok,2); |
4755 | op(0xFE + vop); |
4758 | op(0xFE + vop); |
4756 | op(0x08+detok->rm); |
4759 | op(0x08+detok->rm); |
4757 | outaddress(detok); |
4760 | outaddress(detok); |
4758 | break; |
4761 | break; |
4759 | case tk_reg32: |
4762 | case tk_reg32: |
4760 | if(cpu<3)cpu=3; |
4763 | if(cpu<3)cpu=3; |
4761 | razr=r32; |
4764 | razr=r32; |
4762 | case tk_reg: |
4765 | case tk_reg: |
4763 | op66(razr); |
4766 | op66(razr); |
4764 | op(0x48+detok->number); |
4767 | op(0x48+detok->number); |
4765 | break; |
4768 | break; |
4766 | case tk_beg: |
4769 | case tk_beg: |
4767 | op(0xFE); |
4770 | op(0xFE); |
4768 | op(0xC8+detok->number); |
4771 | op(0xC8+detok->number); |
4769 | break; |
4772 | break; |
4770 | default: |
4773 | default: |
4771 | preerror(invaliddecrem); |
4774 | preerror(invaliddecrem); |
4772 | break; |
4775 | break; |
4773 | } |
4776 | } |
4774 | } |
4777 | } |
4775 | 4778 | ||
4776 | void uptdbr(/*int usesw*/) |
4779 | void uptdbr(/*int usesw*/) |
4777 | { |
4780 | { |
4778 | listbr[curbr]=numbr; //íîìåð ýòîãî öèêëà |
4781 | listbr[curbr]=numbr; //íîìåð ýòîãî öèêëà |
4779 | usebr[curbr]=0; |
4782 | usebr[curbr]=0; |
4780 | curbr++; //÷èñëî âëîæåíèé |
4783 | curbr++; //÷èñëî âëîæåíèé |
4781 | numbr++; //âñåãî öèêëîâ |
4784 | numbr++; //âñåãî öèêëîâ |
4782 | // if(!usesw){ |
4785 | // if(!usesw){ |
4783 | useco[curco]=0; |
4786 | useco[curco]=0; |
4784 | curco++; |
4787 | curco++; |
4785 | // } |
4788 | // } |
4786 | if(curbr==MAXIN)preerror("to many inside bloks"); |
4789 | if(curbr==MAXIN)preerror("to many inside bloks"); |
4787 | } |
4790 | } |
4788 | 4791 | ||
4789 | void doloop(unsigned int typeb) // both short and long loops |
4792 | void doloop(unsigned int typeb) // both short and long loops |
4790 | { |
4793 | { |
4791 | unsigned int startloc,startloc2; |
4794 | unsigned int startloc,startloc2; |
4792 | int looptok; |
4795 | int looptok; |
4793 | ITOK lootok; |
4796 | ITOK lootok; |
4794 | char *loopbuf; |
4797 | char *loopbuf; |
4795 | signed char delta; |
4798 | signed char delta; |
4796 | SINFO lstr; |
4799 | SINFO lstr; |
4797 | int j=0,sline=linenumber; |
4800 | int j=0,sline=linenumber; |
4798 | unsigned int oaddESP=addESP; |
4801 | unsigned int oaddESP=addESP; |
4799 | nexttok(); |
4802 | nexttok(); |
4800 | // printf("tok=%u name=%s bufrm=%s\n",tok,itok.name,bufrm); |
4803 | // printf("tok=%u name=%s bufrm=%s\n",tok,itok.name,bufrm); |
4801 | expecting(tk_openbracket); |
4804 | expecting(tk_openbracket); |
4802 | looptok=tok; |
4805 | looptok=tok; |
4803 | lootok=itok; |
4806 | lootok=itok; |
4804 | loopbuf=bufrm; |
4807 | loopbuf=bufrm; |
4805 | bufrm=NULL; |
4808 | bufrm=NULL; |
4806 | lstr=strinf; |
4809 | lstr=strinf; |
4807 | strinf.bufstr=NULL; |
4810 | strinf.bufstr=NULL; |
4808 | // printf("bufrm=%s strinf=%s\n",loopbuf,lstr.bufstr); |
4811 | // printf("bufrm=%s strinf=%s\n",loopbuf,lstr.bufstr); |
4809 | clearregstat(); |
4812 | clearregstat(); |
4810 | #ifdef OPTVARCONST |
4813 | #ifdef OPTVARCONST |
4811 | ClearLVIC(); |
4814 | ClearLVIC(); |
4812 | #endif |
4815 | #endif |
4813 | uptdbr(); |
4816 | uptdbr(); |
4814 | if(dbg&1)KillLastLine(); |
4817 | if(dbg&1)KillLastLine(); |
4815 | if((tok |
4818 | if((tok |
4816 | &&tok!=tk_beg&&tok!=tk_closebracket) |
4819 | &&tok!=tk_beg&&tok!=tk_closebracket) |
4817 | preerror(invaliddecrem); |
4820 | preerror(invaliddecrem); |
4818 | if(tok!=tk_closebracket){ |
4821 | if(tok!=tk_closebracket){ |
4819 | if(typeb!=tk_loop){ |
4822 | if(typeb!=tk_loop){ |
4820 | if(dbg)AddLine(); |
4823 | if(dbg)AddLine(); |
4821 | int vop=tok==tk_reg?r16:r32; |
4824 | int vop=tok==tk_reg?r16:r32; |
4822 | if(typeb==tk_LOOPNZ&&((tok==tk_reg&&itok.number==CX)|| |
4825 | if(typeb==tk_LOOPNZ&&((tok==tk_reg&&itok.number==CX)|| |
4823 | (tok==tk_reg32&&itok.number==ECX))&&(!(optimizespeed&&chip>3&&chip<7))){ |
4826 | (tok==tk_reg32&&itok.number==ECX))&&(!(optimizespeed&&chip>3&&chip<7))){ |
4824 | op67(vop); |
4827 | op67(vop); |
4825 | outword(0xE3); |
4828 | outword(0xE3); |
4826 | } |
4829 | } |
4827 | else{ |
4830 | else{ |
4828 | if(tok==tk_reg||tok==tk_reg32||tok==tk_beg){ |
4831 | if(tok==tk_reg||tok==tk_reg32||tok==tk_beg){ |
4829 | if(tok==tk_beg)op(0x84); |
4832 | if(tok==tk_beg)op(0x84); |
4830 | else{ |
4833 | else{ |
4831 | op66(vop); |
4834 | op66(vop); |
4832 | op(0x85); |
4835 | op(0x85); |
4833 | } |
4836 | } |
4834 | op(0xc0+(unsigned int)itok.number*9); |
4837 | op(0xc0+(unsigned int)itok.number*9); |
4835 | } |
4838 | } |
4836 | else{ |
4839 | else{ |
4837 | ITOK htok2; |
4840 | ITOK htok2; |
4838 | htok2.number=0; |
4841 | htok2.number=0; |
4839 | htok2.rm=(am32==FALSE?rm_d16:rm_d32); |
4842 | htok2.rm=(am32==FALSE?rm_d16:rm_d32); |
4840 | htok2.segm=DS; |
4843 | htok2.segm=DS; |
4841 | htok2.post=0; |
4844 | htok2.post=0; |
4842 | htok2.sib=(am32==FALSE?CODE16:CODE32); |
4845 | htok2.sib=(am32==FALSE?CODE16:CODE32); |
4843 | htok2.flag=0; |
4846 | htok2.flag=0; |
4844 | int razr=r_undef; |
4847 | int razr=r_undef; |
4845 | switch(tok){ |
4848 | switch(tok){ |
4846 | case tk_longvar: |
4849 | case tk_longvar: |
4847 | case tk_dwordvar: |
4850 | case tk_dwordvar: |
4848 | razr=2; |
4851 | razr=2; |
4849 | case tk_intvar: |
4852 | case tk_intvar: |
4850 | case tk_wordvar: |
4853 | case tk_wordvar: |
4851 | razr++; |
4854 | razr++; |
4852 | case tk_charvar: |
4855 | case tk_charvar: |
4853 | case tk_bytevar: |
4856 | case tk_bytevar: |
4854 | razr++; |
4857 | razr++; |
4855 | } |
4858 | } |
4856 | outcmp(0,tok,&itok,bufrm,&strinf,tk_number,&htok2,loopbuf,&lstr,razr); |
4859 | outcmp(0,tok,&itok,bufrm,&strinf,tk_number,&htok2,loopbuf,&lstr,razr); |
4857 | } |
4860 | } |
4858 | if(typeb==tk_LOOPNZ)outword(0x74); |
4861 | if(typeb==tk_LOOPNZ)outword(0x74); |
4859 | else{ |
4862 | else{ |
4860 | if(chip<3){ |
4863 | if(chip<3){ |
4861 | outword(0x0375); // JNZ past jump up |
4864 | outword(0x0375); // JNZ past jump up |
4862 | op(0xE9); |
4865 | op(0xE9); |
4863 | } |
4866 | } |
4864 | else{ |
4867 | else{ |
4865 | outword(0x840F); |
4868 | outword(0x840F); |
4866 | } |
4869 | } |
4867 | outword(0); |
4870 | outword(0); |
4868 | if(am32!=FALSE)outword(0); |
4871 | if(am32!=FALSE)outword(0); |
4869 | } |
4872 | } |
4870 | } |
4873 | } |
4871 | } |
4874 | } |
4872 | nexttok(); //òî ÷òî óìåíüøàåòñÿ |
4875 | nexttok(); //òî ÷òî óìåíüøàåòñÿ |
4873 | } |
4876 | } |
4874 | expecting(tk_closebracket); |
4877 | expecting(tk_closebracket); |
4875 | startloc2=outptr; |
4878 | startloc2=outptr; |
4876 | if(AlignCycle)AlignCD(CS,aligncycle); |
4879 | if(AlignCycle)AlignCD(CS,aligncycle); |
4877 | startloc=outptr; |
4880 | startloc=outptr; |
4878 | docommand(); |
4881 | docommand(); |
4879 | RestoreStack(); |
4882 | RestoreStack(); |
4880 | SetContinueLabel(); |
4883 | SetContinueLabel(); |
4881 | if(looptok!=tk_closebracket){ |
4884 | if(looptok!=tk_closebracket){ |
4882 | if(((outptr-startloc)<=(127-3))&&(chip<3||optimizespeed==0)&& |
4885 | if(((outptr-startloc)<=(127-3))&&(chip<3||optimizespeed==0)&& |
4883 | ((looptok==tk_reg&&lootok.number==CX)||(looptok==tk_reg32&&lootok.number==ECX))){ |
4886 | ((looptok==tk_reg&&lootok.number==CX)||(looptok==tk_reg32&&lootok.number==ECX))){ |
4884 | delta=(char)(startloc-(outptr+2)); |
4887 | delta=(char)(startloc-(outptr+2)); |
4885 | if(op67(looptok==tk_reg?r16:r32)!=FALSE)delta--; |
4888 | if(op67(looptok==tk_reg?r16:r32)!=FALSE)delta--; |
4886 | op(0xE2); |
4889 | op(0xE2); |
4887 | op(delta); /* LOOP 'delta' */ |
4890 | op(delta); /* LOOP 'delta' */ |
4888 | } |
4891 | } |
4889 | else{ |
4892 | else{ |
4890 | decit(looptok,&lootok,loopbuf,&lstr); |
4893 | decit(looptok,&lootok,loopbuf,&lstr); |
4891 | if((outptr-startloc)>(unsigned int)(127-2-j)){ /* long jump */ |
4894 | if((outptr-startloc)>(unsigned int)(127-2-j)){ /* long jump */ |
4892 | if(chip<3){ |
4895 | if(chip<3){ |
4893 | outword(0x0374); // JZ past jump up |
4896 | outword(0x0374); // JZ past jump up |
4894 | op(0xE9); |
4897 | op(0xE9); |
4895 | } /* JMP top of loop */ |
4898 | } /* JMP top of loop */ |
4896 | else{ |
4899 | else{ |
4897 | outword(0x850F); |
4900 | outword(0x850F); |
4898 | if(cpu<3)cpu=3; |
4901 | if(cpu<3)cpu=3; |
4899 | } |
4902 | } |
4900 | if(am32==FALSE)outword(startloc-(outptr+2)); |
4903 | if(am32==FALSE)outword(startloc-(outptr+2)); |
4901 | else outdword(startloc-(outptr+4)); |
4904 | else outdword(startloc-(outptr+4)); |
4902 | } |
4905 | } |
4903 | else{ |
4906 | else{ |
4904 | op(0x75); // short jump |
4907 | op(0x75); // short jump |
4905 | op(startloc-(outptr+1)); |
4908 | op(startloc-(outptr+1)); |
4906 | } /* JNZ 'delta' */ |
4909 | } /* JNZ 'delta' */ |
4907 | } |
4910 | } |
4908 | } |
4911 | } |
4909 | else jumploc(startloc);//JMP íà íà÷àëî öèêëà |
4912 | else jumploc(startloc);//JMP íà íà÷àëî öèêëà |
4910 | if(typeb!=tk_loop){ |
4913 | if(typeb!=tk_loop){ |
4911 | looptok=outptr-startloc2; |
4914 | looptok=outptr-startloc2; |
4912 | if(typeb==tk_LOOPNZ){ |
4915 | if(typeb==tk_LOOPNZ){ |
4913 | if(looptok>127)jumperror(sline,mesLOOPNZ); |
4916 | if(looptok>127)jumperror(sline,mesLOOPNZ); |
4914 | output[startloc2-1]=(unsigned char)looptok; |
4917 | output[startloc2-1]=(unsigned char)looptok; |
4915 | } |
4918 | } |
4916 | else{ |
4919 | else{ |
4917 | if(looptok<=127)warningjmp(mesLOOPNZ,sline); |
4920 | if(looptok<=127)warningjmp(mesLOOPNZ,sline); |
4918 | if(am32==FALSE)*(unsigned short *)&output[startloc2-2]=(unsigned short)looptok; |
4921 | if(am32==FALSE)*(unsigned short *)&output[startloc2-2]=(unsigned short)looptok; |
4919 | else *(unsigned long *)&output[startloc2-4]=(unsigned long)looptok; |
4922 | else *(unsigned long *)&output[startloc2-4]=(unsigned long)looptok; |
4920 | } |
4923 | } |
4921 | } |
4924 | } |
4922 | SetBreakLabel(); |
4925 | SetBreakLabel(); |
4923 | if(usebr[curbr]!=0||useco[curco]!=0||typeb!=tk_loop)clearregstat(); |
4926 | if(usebr[curbr]!=0||useco[curco]!=0||typeb!=tk_loop)clearregstat(); |
4924 | #ifdef OPTVARCONST |
4927 | #ifdef OPTVARCONST |
4925 | ClearLVIC(); |
4928 | ClearLVIC(); |
4926 | #endif |
4929 | #endif |
4927 | if(ESPloc&&am32&&oaddESP!=addESP)warESP(); |
4930 | if(ESPloc&&am32&&oaddESP!=addESP)warESP(); |
4928 | lastcommand=tk_loop; |
4931 | lastcommand=tk_loop; |
4929 | } |
4932 | } |
4930 | 4933 | ||
4931 | void GetNameLabel(int type,int num) |
4934 | void GetNameLabel(int type,int num) |
4932 | { |
4935 | { |
4933 | sprintf((char *)string2,type==tk_break?"BREAK%04X":"CONTINUE%04X",listbr[num]); |
4936 | sprintf((char *)string2,type==tk_break?"BREAK%04X":"CONTINUE%04X",listbr[num]); |
4934 | } |
4937 | } |
4935 | 4938 | ||
4936 | void SetBreakLabel() |
4939 | void SetBreakLabel() |
4937 | { |
4940 | { |
4938 | curbr--; |
4941 | curbr--; |
4939 | if(usebr[curbr]!=0){ |
4942 | if(usebr[curbr]!=0){ |
4940 | GetNameLabel(tk_break,curbr); |
4943 | GetNameLabel(tk_break,curbr); |
4941 | updatecall((unsigned int)updatelocalvar((char *)string2,tk_number,outptr),outptr,procedure_start); |
4944 | updatecall((unsigned int)updatelocalvar((char *)string2,tk_number,outptr),outptr,procedure_start); |
4942 | // clearregstat(); |
4945 | // clearregstat(); |
4943 | } |
4946 | } |
4944 | } |
4947 | } |
4945 | 4948 | ||
4946 | void SetContinueLabel() |
4949 | void SetContinueLabel() |
4947 | { |
4950 | { |
4948 | curco--; |
4951 | curco--; |
4949 | if(useco[curco]!=0){ |
4952 | if(useco[curco]!=0){ |
4950 | GetNameLabel(tk_continue,curco); |
4953 | GetNameLabel(tk_continue,curco); |
4951 | updatecall((unsigned int)updatelocalvar((char *)string2,tk_number,outptr),outptr,procedure_start); |
4954 | updatecall((unsigned int)updatelocalvar((char *)string2,tk_number,outptr),outptr,procedure_start); |
4952 | } |
4955 | } |
4953 | } |
4956 | } |
4954 | 4957 | ||
4955 | /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ |
4958 | /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ |
4956 | 4959 | ||
4957 | void SaveDataVal(unsigned int ssize,unsigned long long val) |
4960 | void SaveDataVal(unsigned int ssize,unsigned long long val) |
4958 | { |
4961 | { |
4959 | switch(ssize){ |
4962 | switch(ssize){ |
4960 | case 1: opd(val); break; |
4963 | case 1: opd(val); break; |
4961 | case 2: outwordd(val); break; |
4964 | case 2: outwordd(val); break; |
4962 | case 4: outdwordd(val); break; |
4965 | case 4: outdwordd(val); break; |
4963 | case 8: outqwordd(val); break; |
4966 | case 8: outqwordd(val); break; |
4964 | } |
4967 | } |
4965 | } |
4968 | } |
4966 | 4969 | ||
4967 | long AddVarString() |
4970 | long AddVarString() |
4968 | { |
4971 | { |
4969 | long loop=0; |
4972 | long loop=0; |
4970 | int term; |
4973 | int term; |
4971 | do{ |
4974 | do{ |
4972 | term=itok.flag; |
4975 | term=itok.flag; |
4973 | for(int i=0;i |
4976 | for(int i=0;i |
4974 | opd(string[i]); |
4977 | opd(string[i]); |
4975 | loop++; |
4978 | loop++; |
4976 | } |
4979 | } |
4977 | nexttok(); |
4980 | nexttok(); |
4978 | }while(tok==tk_string); |
4981 | }while(tok==tk_string); |
4979 | switch(term&3){ |
4982 | switch(term&3){ |
4980 | case zero_term: |
4983 | case zero_term: |
4981 | if(term&s_unicod)opd(0); |
4984 | if(term&s_unicod)opd(0); |
4982 | opd(0); |
4985 | opd(0); |
4983 | loop++; |
4986 | loop++; |
4984 | break; |
4987 | break; |
4985 | case dos_term: |
4988 | case dos_term: |
4986 | if(term&s_unicod)opd(0); |
4989 | if(term&s_unicod)opd(0); |
4987 | opd('$'); |
4990 | opd('$'); |
4988 | loop++; |
4991 | loop++; |
4989 | break; |
4992 | break; |
4990 | } |
4993 | } |
4991 | return loop; |
4994 | return loop; |
4992 | } |
4995 | } |
4993 | 4996 | ||
4994 | long initglobalvar(int type,long elements,long ssize,char typev) |
4997 | long initglobalvar(int type,long elements,long ssize,char typev) |
4995 | { |
4998 | { |
4996 | long loop; |
4999 | long loop; |
4997 | long long i=0; |
5000 | long long i=0; |
4998 | int htok; |
5001 | int htok; |
4999 | char name[IDLENGTH]; |
5002 | char name[IDLENGTH]; |
5000 | nexttok(); |
5003 | nexttok(); |
5001 | loop=0; |
5004 | loop=0; |
5002 | if(dbg&2)AddDataLine((tok==tk_string&&typev!=pointer?(char)3:(char)ssize)); |
5005 | if(dbg&2)AddDataLine((tok==tk_string&&typev!=pointer?(char)3:(char)ssize)); |
5003 | loopsw: |
5006 | loopsw: |
5004 | htok=tok; |
5007 | htok=tok; |
5005 | switch(tok){ //çàïîëíèòü âåëè÷èíàìè |
5008 | switch(tok){ //çàïîëíèòü âåëè÷èíàìè |
5006 | case tk_apioffset: AddApiToPost(itok.number); nexttok(); break; |
5009 | case tk_apioffset: AddApiToPost(itok.number); nexttok(); break; |
5007 | case tk_postnumber: |
5010 | case tk_postnumber: |
5008 | (itok.flag&f_extern)==0?setwordpost(&itok):setwordext(&itok.number); |
5011 | (itok.flag&f_extern)==0?setwordpost(&itok):setwordext(&itok.number); |
5009 | itok.flag=0; |
5012 | itok.flag=0; |
5010 | goto cn1; |
5013 | goto cn1; |
5011 | case tk_undefofs: |
5014 | case tk_undefofs: |
5012 | strcpy(name,itok.name); |
5015 | strcpy(name,itok.name); |
5013 | // AddUndefOff(1,itok.name); |
5016 | // AddUndefOff(1,itok.name); |
5014 | cn1: |
5017 | cn1: |
5015 | tok=tk_number; |
5018 | tok=tk_number; |
5016 | case tk_minus: |
5019 | case tk_minus: |
5017 | case tk_number: |
5020 | case tk_number: |
5018 | if(type==tk_byte||type==tk_word||type==tk_dword)i+=doconstdwordmath(); |
5021 | if(type==tk_byte||type==tk_word||type==tk_dword)i+=doconstdwordmath(); |
5019 | else if(type==tk_float)i=doconstfloatmath(); |
5022 | else if(type==tk_float)i=doconstfloatmath(); |
5020 | else if(type==tk_double)i=doconstdoublemath(); |
5023 | else if(type==tk_double)i=doconstdoublemath(); |
5021 | else if(type==tk_qword)i+=doconstqwordmath(); |
5024 | else if(type==tk_qword)i+=doconstqwordmath(); |
5022 | else i+=doconstlongmath(); |
5025 | else i+=doconstlongmath(); |
5023 | if(tok==tk_plus&&tok2==tk_postnumber&&htok!=tk_undefofs){ |
5026 | if(tok==tk_plus&&tok2==tk_postnumber&&htok!=tk_undefofs){ |
5024 | nexttok(); |
5027 | nexttok(); |
5025 | goto loopsw; |
5028 | goto loopsw; |
5026 | } |
5029 | } |
5027 | if(elements!=0){ |
5030 | if(elements!=0){ |
5028 | for(;loop |
5031 | for(;loop |
5029 | if(postnumflag&f_reloc)AddReloc(); |
5032 | if(postnumflag&f_reloc)AddReloc(); |
5030 | if(htok==tk_undefofs)AddUndefOff(3,name); |
5033 | if(htok==tk_undefofs)AddUndefOff(3,name); |
5031 | SaveDataVal(ssize,i); |
5034 | SaveDataVal(ssize,i); |
5032 | } |
5035 | } |
5033 | } |
5036 | } |
5034 | loop=loop*ssize; |
5037 | loop=loop*ssize; |
5035 | break; |
5038 | break; |
5036 | case tk_string: |
5039 | case tk_string: |
5037 | if(typev==pointer){ |
5040 | if(typev==pointer){ |
5038 | loop=(am32==FALSE?2:4); |
5041 | loop=(am32==FALSE?2:4); |
5039 | i=addpoststring(DS); |
5042 | i=addpoststring(DS); |
5040 | if(am32==FALSE)outwordd(i); |
5043 | if(am32==FALSE)outwordd(i); |
5041 | else outdwordd(i); |
5044 | else outdwordd(i); |
5042 | nexttok(); |
5045 | nexttok(); |
5043 | } |
5046 | } |
5044 | else{ |
5047 | else{ |
5045 | loop=AddVarString(); |
5048 | loop=AddVarString(); |
5046 | if(elements!=0){ |
5049 | if(elements!=0){ |
5047 | for(;loop |
5050 | for(;loop |
5048 | opd(aligner); |
5051 | opd(aligner); |
5049 | } |
5052 | } |
5050 | } |
5053 | } |
5051 | } |
5054 | } |
5052 | break; |
5055 | break; |
5053 | case tk_from: //ñ÷èòàòü ôàéë ñ äàííûìè |
5056 | case tk_from: //ñ÷èòàòü ôàéë ñ äàííûìè |
5054 | nexttok(); |
5057 | nexttok(); |
5055 | loop=dofrom(); |
5058 | loop=dofrom(); |
5056 | if(elements!=0){ |
5059 | if(elements!=0){ |
5057 | for(;loop |
5060 | for(;loop |
5058 | } |
5061 | } |
5059 | nexttok(); |
5062 | nexttok(); |
5060 | break; |
5063 | break; |
5061 | case tk_extract: //ñ÷èòàòü ôðàãìåíò ôàéëà ñ äàííûìè |
5064 | case tk_extract: //ñ÷èòàòü ôðàãìåíò ôàéëà ñ äàííûìè |
5062 | nexttok(); |
5065 | nexttok(); |
5063 | loop=doextract(); |
5066 | loop=doextract(); |
5064 | if(elements!=0){ |
5067 | if(elements!=0){ |
5065 | for(;loop |
5068 | for(;loop |
5066 | } |
5069 | } |
5067 | break; |
5070 | break; |
5068 | case tk_openbrace: //ìàññèâ äàííûõ |
5071 | case tk_openbrace: //ìàññèâ äàííûõ |
5069 | nexttok(); |
5072 | nexttok(); |
5070 | while(tok!=tk_closebrace){ |
5073 | while(tok!=tk_closebrace){ |
5071 | htok=tok; |
5074 | htok=tok; |
5072 | if(typev==pointer){ |
5075 | if(typev==pointer){ |
5073 | if(tok==tk_string){ |
5076 | if(tok==tk_string){ |
5074 | i=addpoststring(DS); |
5077 | i=addpoststring(DS); |
5075 | nexttok(); |
5078 | nexttok(); |
5076 | } |
5079 | } |
5077 | else if(tok==tk_number||tok==tk_minus||tok==tk_undefofs){ |
5080 | else if(tok==tk_number||tok==tk_minus||tok==tk_undefofs){ |
5078 | if(tok==tk_undefofs){ |
5081 | if(tok==tk_undefofs){ |
5079 | tok=tk_number; |
5082 | tok=tk_number; |
5080 | strcpy(name,itok.name); |
5083 | strcpy(name,itok.name); |
5081 | // AddUndefOff(1,itok.name); |
5084 | // AddUndefOff(1,itok.name); |
5082 | } |
5085 | } |
5083 | // else if((itok.flag&f_reloc)!=0)AddReloc(); |
5086 | // else if((itok.flag&f_reloc)!=0)AddReloc(); |
5084 | i=doconstdwordmath(); |
5087 | i=doconstdwordmath(); |
5085 | } |
5088 | } |
5086 | else{ |
5089 | else{ |
5087 | numexpected(); |
5090 | numexpected(); |
5088 | nexttok(); |
5091 | nexttok(); |
5089 | } |
5092 | } |
5090 | if(postnumflag&f_reloc)AddReloc(); |
5093 | if(postnumflag&f_reloc)AddReloc(); |
5091 | if(htok==tk_undefofs)AddUndefOff(3,name); |
5094 | if(htok==tk_undefofs)AddUndefOff(3,name); |
5092 | if(am32==FALSE)outwordd(i); |
5095 | if(am32==FALSE)outwordd(i); |
5093 | else outdwordd(i); |
5096 | else outdwordd(i); |
5094 | } |
5097 | } |
5095 | else{ |
5098 | else{ |
5096 | switch(tok){ |
5099 | switch(tok){ |
5097 | case tk_apioffset: AddApiToPost(itok.number); nexttok(); break; |
5100 | case tk_apioffset: AddApiToPost(itok.number); nexttok(); break; |
5098 | case tk_string: |
5101 | case tk_string: |
5099 | loop+=AddVarString()/ssize-1; |
5102 | loop+=AddVarString()/ssize-1; |
5100 | break; |
5103 | break; |
5101 | case tk_postnumber: |
5104 | case tk_postnumber: |
5102 | (itok.flag&f_extern)==0?setwordpost(&itok):setwordext(&itok.number); |
5105 | (itok.flag&f_extern)==0?setwordpost(&itok):setwordext(&itok.number); |
5103 | itok.flag=0; |
5106 | itok.flag=0; |
5104 | goto cn2; |
5107 | goto cn2; |
5105 | case tk_undefofs: |
5108 | case tk_undefofs: |
5106 | strcpy(name,itok.name); |
5109 | strcpy(name,itok.name); |
5107 | // AddUndefOff(1,itok.name); |
5110 | // AddUndefOff(1,itok.name); |
5108 | cn2: |
5111 | cn2: |
5109 | tok=tk_number; |
5112 | tok=tk_number; |
5110 | case tk_number: |
5113 | case tk_number: |
5111 | case tk_minus: |
5114 | case tk_minus: |
5112 | if(type==tk_byte||type==tk_word||type==tk_dword)i=doconstdwordmath(); |
5115 | if(type==tk_byte||type==tk_word||type==tk_dword)i=doconstdwordmath(); |
5113 | else if(type==tk_float)i=doconstfloatmath(); |
5116 | else if(type==tk_float)i=doconstfloatmath(); |
5114 | else if(type==tk_double)i=doconstdoublemath(); |
5117 | else if(type==tk_double)i=doconstdoublemath(); |
5115 | else if(type==tk_qword)i=doconstqwordmath(); |
5118 | else if(type==tk_qword)i=doconstqwordmath(); |
5116 | else i=doconstlongmath(); |
5119 | else i=doconstlongmath(); |
5117 | // if((postnumflag&f_reloc)!=0)AddReloc(); |
5120 | // if((postnumflag&f_reloc)!=0)AddReloc(); |
5118 | if((postnumflag&f_reloc)!=0)AddReloc(); |
5121 | if((postnumflag&f_reloc)!=0)AddReloc(); |
5119 | if(htok==tk_undefofs)AddUndefOff(3,name); |
5122 | if(htok==tk_undefofs)AddUndefOff(3,name); |
5120 | SaveDataVal(ssize,i); |
5123 | SaveDataVal(ssize,i); |
5121 | break; |
5124 | break; |
5122 | default: |
5125 | default: |
5123 | numexpected(); |
5126 | numexpected(); |
5124 | nexttok(); |
5127 | nexttok(); |
5125 | break; |
5128 | break; |
5126 | } |
5129 | } |
5127 | } |
5130 | } |
5128 | loop++; |
5131 | loop++; |
5129 | if(tok==tk_closebrace)break; |
5132 | if(tok==tk_closebrace)break; |
5130 | expecting(tk_camma); |
5133 | expecting(tk_camma); |
5131 | } |
5134 | } |
5132 | if(elements!=0){ |
5135 | if(elements!=0){ |
5133 | for(;loop |
5136 | for(;loop |
5134 | } |
5137 | } |
5135 | loop=loop*ssize; |
5138 | loop=loop*ssize; |
5136 | nexttok(); |
5139 | nexttok(); |
5137 | break; |
5140 | break; |
5138 | default: |
5141 | default: |
5139 | // printf("tok=%d\n",tok); |
5142 | // printf("tok=%d\n",tok); |
5140 | numexpected(); nexttok(); break; |
5143 | numexpected(); nexttok(); break; |
5141 | } |
5144 | } |
5142 | return loop; |
5145 | return loop; |
5143 | } |
5146 | } |
5144 | 5147 | ||
5145 | void AddPostData(unsigned int loop) |
5148 | void AddPostData(unsigned int loop) |
5146 | { |
5149 | { |
5147 | if(dynamic_flag==0){ |
5150 | if(dynamic_flag==0){ |
5148 | unsigned int longpostsize=loop+postsize; |
5151 | unsigned int longpostsize=loop+postsize; |
5149 | if(am32==FALSE&&longpostsize>0xFFFFL)tobigpost(); |
5152 | if(am32==FALSE&&longpostsize>0xFFFFL)tobigpost(); |
5150 | else postsize=longpostsize; |
5153 | else postsize=longpostsize; |
5151 | } |
5154 | } |
5152 | } |
5155 | } |
5153 | 5156 | ||
5154 | void labelindata() |
5157 | void labelindata() |
5155 | { |
5158 | { |
5156 | //idrec *varrec; |
5159 | //idrec *varrec; |
5157 | FindOff((unsigned char *)itok.name,DS); |
5160 | FindOff((unsigned char *)itok.name,DS); |
5158 | tok=tk_number; |
5161 | tok=tk_number; |
5159 | itok.number=outptrdata; |
5162 | itok.number=outptrdata; |
5160 | itok.segm=DS; |
5163 | itok.segm=DS; |
5161 | string[0]=0; |
5164 | string[0]=0; |
5162 | if(FixUp)itok.flag=f_reloc; |
5165 | if(FixUp)itok.flag=f_reloc; |
5163 | /*varrec=*/addtotree(itok.name); |
5166 | /*varrec=*/addtotree(itok.name); |
5164 | /*varrec->count=*/FindOff((unsigned char *)itok.name,DS); |
5167 | /*varrec->count=*/FindOff((unsigned char *)itok.name,DS); |
5165 | nexttok(); |
5168 | nexttok(); |
5166 | nexttok(); |
5169 | nexttok(); |
5167 | } |
5170 | } |
5168 | 5171 | ||
5169 | void globalvar() /* both initialized and unitialized combined */ |
5172 | void globalvar() /* both initialized and unitialized combined */ |
5170 | { |
5173 | { |
5171 | long size,loop,i,elements,ssize; |
5174 | long size,loop,i,elements,ssize; |
5172 | char done=0,typev; |
5175 | char done=0,typev; |
5173 | char var_name[IDLENGTH]; |
5176 | char var_name[IDLENGTH]; |
5174 | int type=itok.rm,typebak; //òèï ïåðåìåííîé |
5177 | int type=itok.rm,typebak; //òèï ïåðåìåííîé |
5175 | unsigned int flag,fflag=itok.flag,dynamic; |
5178 | unsigned int flag,fflag=itok.flag,dynamic; |
5176 | unsigned int npointr=itok.npointr; |
5179 | unsigned int npointr=itok.npointr; |
5177 | int count; |
5180 | int count; |
5178 | idrec *varrec; |
5181 | idrec *varrec; |
5179 | size=typesize(type); //ðàçìåð ïåðåìåííîé |
5182 | size=typesize(type); //ðàçìåð ïåðåìåííîé |
5180 | if(FixUp)fflag|=f_reloc; |
5183 | if(FixUp)fflag|=f_reloc; |
5181 | typebak=type; |
5184 | typebak=type; |
5182 | while(tok!=tk_eof&&done==0){ |
5185 | while(tok!=tk_eof&&done==0){ |
5183 | int nnpointr=0; |
5186 | int nnpointr=0; |
5184 | typev=variable; |
5187 | typev=variable; |
5185 | ssize=size; |
5188 | ssize=size; |
5186 | flag=fflag; |
5189 | flag=fflag; |
5187 | type=typebak; |
5190 | type=typebak; |
5188 | // printf("type=%d\n",type); |
5191 | // printf("type=%d\n",type); |
5189 | if(tok==tk_far){ |
5192 | if(tok==tk_far){ |
5190 | flag|=f_far; |
5193 | flag|=f_far; |
5191 | nexttok(); |
5194 | nexttok(); |
5192 | } |
5195 | } |
5193 | while(tok==tk_mult){ //óêàçàòåëü |
5196 | while(tok==tk_mult){ //óêàçàòåëü |
5194 | npointr++; |
5197 | npointr++; |
5195 | nexttok(); |
5198 | nexttok(); |
5196 | } |
5199 | } |
5197 | if(tok==tk_openbracket){ |
5200 | if(tok==tk_openbracket){ |
5198 | nexttok(); |
5201 | nexttok(); |
5199 | while(tok==tk_mult){ //óêàçàòåëü íà ïðîöåäóðó |
5202 | while(tok==tk_mult){ //óêàçàòåëü íà ïðîöåäóðó |
5200 | nnpointr++; |
5203 | nnpointr++; |
5201 | nexttok(); |
5204 | nexttok(); |
5202 | } |
5205 | } |
5203 | } |
5206 | } |
5204 | if(npointr){ |
5207 | if(npointr){ |
5205 | if((flag&f_far)!=0||am32!=FALSE)ssize=4; |
5208 | if((flag&f_far)!=0||am32!=FALSE)ssize=4; |
5206 | else ssize=2; |
5209 | else ssize=2; |
5207 | typev=pointer; |
5210 | typev=pointer; |
5208 | type=am32==FALSE?tk_word:tk_dword; |
5211 | type=am32==FALSE?tk_word:tk_dword; |
5209 | } |
5212 | } |
5210 | // printf("tok=%d %s\n",tok,itok.name); |
5213 | // printf("tok=%d %s\n",tok,itok.name); |
5211 | switch(tok){ |
5214 | switch(tok){ |
5212 | case tk_id: |
5215 | case tk_id: |
5213 | case tk_ID: |
5216 | case tk_ID: |
5214 | if(tok2==tk_openbracket||nnpointr){ |
5217 | if(tok2==tk_openbracket||nnpointr){ |
5215 | if(npointr)type=am32==FALSE?tk_word:tk_dword; |
5218 | if(npointr)type=am32==FALSE?tk_word:tk_dword; |
5216 | declare_procedure(flag,type,nnpointr); |
5219 | declare_procedure(flag,type,nnpointr); |
5217 | break; |
5220 | break; |
5218 | } |
5221 | } |
5219 | strcpy(var_name,itok.name); //èìÿ ïåðåìåííîé |
5222 | strcpy(var_name,itok.name); //èìÿ ïåðåìåííîé |
5220 | elements=1; |
5223 | elements=1; |
5221 | nexttok(); |
5224 | nexttok(); |
5222 | if(tok==tk_openblock){ //[ |
5225 | if(tok==tk_openblock){ //[ |
5223 | nexttok(); |
5226 | nexttok(); |
5224 | if(tok==tk_closeblock){//íåèçâåñòíîå ÷èñëî ýëåìåíòîâ |
5227 | if(tok==tk_closeblock){//íåèçâåñòíîå ÷èñëî ýëåìåíòîâ |
5225 | elements=0; |
5228 | elements=0; |
5226 | nexttok(); |
5229 | nexttok(); |
5227 | } |
5230 | } |
5228 | else{ |
5231 | else{ |
5229 | CheckMinusNum(); |
5232 | CheckMinusNum(); |
5230 | if(tok!=tk_number){ |
5233 | if(tok!=tk_number){ |
5231 | numexpected(); |
5234 | numexpected(); |
5232 | nexttok(); |
5235 | nexttok(); |
5233 | } |
5236 | } |
5234 | else{ |
5237 | else{ |
5235 | elements=doconstlongmath(); //÷èñëî ýëåìåíòîâ |
5238 | elements=doconstlongmath(); //÷èñëî ýëåìåíòîâ |
5236 | expecting(tk_closeblock); |
5239 | expecting(tk_closeblock); |
5237 | } |
5240 | } |
5238 | } |
5241 | } |
5239 | } |
5242 | } |
5240 | if(type==tk_void){ |
5243 | if(type==tk_void){ |
5241 | preerror("type 'void' not use for declare variables"); |
5244 | preerror("type 'void' not use for declare variables"); |
5242 | break; |
5245 | break; |
5243 | } |
5246 | } |
5244 | dynamic=FALSE; |
5247 | dynamic=FALSE; |
5245 | if(tok==tk_assign||(notpost==TRUE&&dynamic_flag==0)){ //= èíèöèàëèçèðîâàíàÿ ïåðåìåííàÿ |
5248 | if(tok==tk_assign||(notpost==TRUE&&dynamic_flag==0)){ //= èíèöèàëèçèðîâàíàÿ ïåðåìåííàÿ |
5246 | if((flag&f_extern))preerror("extern variable do not initialize at declare"); |
5249 | if((flag&f_extern))preerror("extern variable do not initialize at declare"); |
5247 | i=tok; |
5250 | i=tok; |
5248 | itok.type=tp_gvar;// 11.07.05 21:56 tp_ucnovn; |
5251 | itok.type=tp_gvar;// 11.07.05 21:56 tp_ucnovn; |
5249 | SetNewTok(type,typev); |
5252 | SetNewTok(type,typev); |
5250 | if(useStartup==TRUE&&i!=tk_assign&&SaveStartUp(size*elements,var_name)!=FALSE){ |
5253 | if(useStartup==TRUE&&i!=tk_assign&&SaveStartUp(size*elements,var_name)!=FALSE){ |
5251 | if(elements==0)ZeroMassiv(); //îøèáêà |
5254 | if(elements==0)ZeroMassiv(); //îøèáêà |
5252 | tok=i; |
5255 | tok=i; |
5253 | break; |
5256 | break; |
5254 | } |
5257 | } |
5255 | if(alignword&&ssize&&(!dynamic_flag))alignersize+=AlignCD(DS,ssize); |
5258 | if(alignword&&ssize&&(!dynamic_flag))alignersize+=AlignCD(DS,ssize); |
5256 | itok.number=dynamic_flag==0?outptrdata:0; |
5259 | itok.number=dynamic_flag==0?outptrdata:0; |
5257 | itok.segm=(comfile==file_rom&&modelmem==TINY?CS:DS); |
5260 | itok.segm=(comfile==file_rom&&modelmem==TINY?CS:DS); |
5258 | itok.flag=flag; |
5261 | itok.flag=flag; |
5259 | // itok.post=dynamic; |
5262 | // itok.post=dynamic; |
5260 | itok.size=elements*ssize; |
5263 | itok.size=elements*ssize; |
5261 | itok.rm=(am32==FALSE?rm_d16:rm_d32); |
5264 | itok.rm=(am32==FALSE?rm_d16:rm_d32); |
5262 | itok.npointr=(unsigned short)npointr; |
5265 | itok.npointr=(unsigned short)npointr; |
5263 | 5266 | ||
5264 | varrec=addtotree(var_name); |
5267 | varrec=addtotree(var_name); |
5265 | if((count=FindOff((unsigned char *)var_name,DS))==0){ |
5268 | if((count=FindOff((unsigned char *)var_name,DS))==0){ |
5266 | if(dynamic_flag)dynamic=DYNAMIC_VAR; |
5269 | if(dynamic_flag)dynamic=DYNAMIC_VAR; |
5267 | } |
5270 | } |
5268 | else if(dynamic_flag)dynamic=USED_DIN_VAR; |
5271 | else if(dynamic_flag)dynamic=USED_DIN_VAR; |
5269 | if(i!=tk_assign){ |
5272 | if(i!=tk_assign){ |
5270 | if(elements==0)ZeroMassiv(); |
5273 | if(elements==0)ZeroMassiv(); |
5271 | else if(notpost==TRUE){ |
5274 | else if(notpost==TRUE){ |
5272 | for(loop=0;loop |
5275 | for(loop=0;loop |
5273 | loop=loop*ssize; |
5276 | loop=loop*ssize; |
5274 | varrec->recsize=loop; |
5277 | varrec->recsize=loop; |
5275 | datasize+=loop; |
5278 | datasize+=loop; |
5276 | } |
5279 | } |
5277 | tok=i; |
5280 | tok=i; |
5278 | break; |
5281 | break; |
5279 | } |
5282 | } |
5280 | if(dynamic){ |
5283 | if(dynamic){ |
5281 | varrec->sbuf=dynamic_var(); |
5284 | varrec->sbuf=dynamic_var(); |
5282 | varrec->recpost=dynamic; |
5285 | varrec->recpost=dynamic; |
5283 | } |
5286 | } |
5284 | else{ |
5287 | else{ |
5285 | loop=initglobalvar(type,elements,ssize,typev); |
5288 | loop=initglobalvar(type,elements,ssize,typev); |
5286 | varrec->recsize=loop; |
5289 | varrec->recsize=loop; |
5287 | datasize+=loop; |
5290 | datasize+=loop; |
5288 | } |
5291 | } |
5289 | varrec->count=count; |
5292 | varrec->count=count; |
5290 | } |
5293 | } |
5291 | else{ |
5294 | else{ |
5292 | if(elements==0){ |
5295 | if(elements==0){ |
5293 | ZeroMassiv(); |
5296 | ZeroMassiv(); |
5294 | break; |
5297 | break; |
5295 | } |
5298 | } |
5296 | if(CheckUseAsUndef((unsigned char *)var_name)==0&&dynamic_flag)dynamic=TRUE; |
5299 | if(CheckUseAsUndef((unsigned char *)var_name)==0&&dynamic_flag)dynamic=TRUE; |
5297 | switch(tok){ //íåèíèöèàëèçèðîâàííûå |
5300 | switch(tok){ //íåèíèöèàëèçèðîâàííûå |
5298 | default: expected(';'); |
5301 | default: expected(';'); |
5299 | case tk_semicolon: done=1;// ; |
5302 | case tk_semicolon: done=1;// ; |
5300 | case tk_camma: //, post global type |
5303 | case tk_camma: //, post global type |
5301 | itok.type=tp_postvar;//11.07.05 21:57 tp_ucnovn; |
5304 | itok.type=tp_postvar;//11.07.05 21:57 tp_ucnovn; |
5302 | SetNewTok(type,typev); |
5305 | SetNewTok(type,typev); |
5303 | if((flag&f_extern)==0&&useStartup==TRUE&&dynamic==0){ |
5306 | if((flag&f_extern)==0&&useStartup==TRUE&&dynamic==0){ |
5304 | if(SaveStartUp(ssize*elements,var_name)!=FALSE){ |
5307 | if(SaveStartUp(ssize*elements,var_name)!=FALSE){ |
5305 | nexttok(); |
5308 | nexttok(); |
5306 | break; |
5309 | break; |
5307 | } |
5310 | } |
5308 | } |
5311 | } |
5309 | if((flag&f_extern)==0&&alignword&&dynamic==0){ //âûðîâíÿòü íà ÷åòíûé àäðåñ |
5312 | if((flag&f_extern)==0&&alignword&&dynamic==0){ //âûðîâíÿòü íà ÷åòíûé àäðåñ |
5310 | if(ssize==2){ |
5313 | if(ssize==2){ |
5311 | if(postsize%2==1)postsize++; |
5314 | if(postsize%2==1)postsize++; |
5312 | } |
5315 | } |
5313 | else if(ssize==4&&postsize%4!=0)postsize+=4-(postsize%4); |
5316 | else if(ssize==4&&postsize%4!=0)postsize+=4-(postsize%4); |
5314 | } |
5317 | } |
5315 | count=FindOff((unsigned char *)var_name,VARPOST); |
5318 | count=FindOff((unsigned char *)var_name,VARPOST); |
5316 | itok.post=dynamic+1; |
5319 | itok.post=dynamic+1; |
5317 | itok.segm=DS; |
5320 | itok.segm=DS; |
5318 | loop=elements*ssize; |
5321 | loop=elements*ssize; |
5319 | itok.number=(flag&f_extern)==0?postsize:externnum++; |
5322 | itok.number=(flag&f_extern)==0?postsize:externnum++; |
5320 | itok.flag=flag; |
5323 | itok.flag=flag; |
5321 | itok.size=loop; |
5324 | itok.size=loop; |
5322 | itok.rm=(am32==FALSE?rm_d16:rm_d32); |
5325 | itok.rm=(am32==FALSE?rm_d16:rm_d32); |
5323 | itok.npointr=(unsigned short)npointr; |
5326 | itok.npointr=(unsigned short)npointr; |
5324 | varrec=addtotree(var_name); |
5327 | varrec=addtotree(var_name); |
5325 | varrec->count=count; |
5328 | varrec->count=count; |
5326 | if((flag&f_extern)==0)AddPostData(loop); |
5329 | if((flag&f_extern)==0)AddPostData(loop); |
5327 | nexttok(); |
5330 | nexttok(); |
5328 | break; |
5331 | break; |
5329 | } |
5332 | } |
5330 | } |
5333 | } |
5331 | break; |
5334 | break; |
5332 | case tk_undefproc: |
5335 | case tk_undefproc: |
5333 | if(tok2==tk_openbracket||nnpointr){ |
5336 | if(tok2==tk_openbracket||nnpointr){ |
5334 | if(npointr)type=am32==FALSE?tk_word:tk_dword; |
5337 | if(npointr)type=am32==FALSE?tk_word:tk_dword; |
5335 | declare_procedure(flag,type,nnpointr); |
5338 | declare_procedure(flag,type,nnpointr); |
5336 | break; |
5339 | break; |
5337 | } |
5340 | } |
5338 | case tk_proc: |
5341 | case tk_proc: |
5339 | case tk_floatvar: |
5342 | case tk_floatvar: |
5340 | case tk_dwordvar: |
5343 | case tk_dwordvar: |
5341 | case tk_longvar: |
5344 | case tk_longvar: |
5342 | case tk_charvar: |
5345 | case tk_charvar: |
5343 | case tk_intvar: |
5346 | case tk_intvar: |
5344 | case tk_bytevar: |
5347 | case tk_bytevar: |
5345 | case tk_pointer: |
5348 | case tk_pointer: |
5346 | case tk_wordvar: idalreadydefined(); nexttok(); break; |
5349 | case tk_wordvar: idalreadydefined(); nexttok(); break; |
5347 | default: expected(';'); |
5350 | default: expected(';'); |
5348 | case tk_semicolon: done=1; |
5351 | case tk_semicolon: done=1; |
5349 | case tk_camma: nexttok(); break; |
5352 | case tk_camma: nexttok(); break; |
5350 | } |
5353 | } |
5351 | npointr=0; |
5354 | npointr=0; |
5352 | } |
5355 | } |
5353 | dopoststrings(); |
5356 | dopoststrings(); |
5354 | } |
5357 | } |
5355 | 5358 | ||
5356 | void SetNewTok(int type,int typev) |
5359 | void SetNewTok(int type,int typev) |
5357 | { |
5360 | { |
5358 | switch(typev){ |
5361 | switch(typev){ |
5359 | case variable: |
5362 | case variable: |
5360 | if(type>=tk_char&&type<=tk_double)tok=type+(tk_charvar-tk_char); |
5363 | if(type>=tk_char&&type<=tk_double)tok=type+(tk_charvar-tk_char); |
5361 | break; |
5364 | break; |
5362 | case pointer: |
5365 | case pointer: |
5363 | // if(type>=tk_void&&type<=tk_float){ |
5366 | // if(type>=tk_void&&type<=tk_float){ |
5364 | tok=tk_pointer; |
5367 | tok=tk_pointer; |
5365 | itok.type=(unsigned short)type; |
5368 | itok.type=(unsigned short)type; |
5366 | // } |
5369 | // } |
5367 | break; |
5370 | break; |
5368 | } |
5371 | } |
5369 | } |
5372 | } |
5370 | 5373 | ||
5371 | int SaveStartUp(int size,char *var_name) |
5374 | int SaveStartUp(int size,char *var_name) |
5372 | { |
5375 | { |
5373 | int i=0; |
5376 | int i=0; |
5374 | if((startStartup+size)<=endStartup){ |
5377 | if((startStartup+size)<=endStartup){ |
5375 | if(alignword){ //âûðîâíÿòü íà ÷åòíûé àäðåñ |
5378 | if(alignword){ //âûðîâíÿòü íà ÷åòíûé àäðåñ |
5376 | if(size==2){ |
5379 | if(size==2){ |
5377 | if(startStartup%2==1)i=1; |
5380 | if(startStartup%2==1)i=1; |
5378 | } |
5381 | } |
5379 | else if(size==4&&startStartup%4!=0)i=4-(startStartup%4); |
5382 | else if(size==4&&startStartup%4!=0)i=4-(startStartup%4); |
5380 | } |
5383 | } |
5381 | if((startStartup+size+i)<=endStartup){ |
5384 | if((startStartup+size+i)<=endStartup){ |
5382 | startStartup+=i; |
5385 | startStartup+=i; |
5383 | itok.number=startStartup; |
5386 | itok.number=startStartup; |
5384 | itok.segm=DS; |
5387 | itok.segm=DS; |
5385 | itok.flag=0; |
5388 | itok.flag=0; |
5386 | itok.post=0; |
5389 | itok.post=0; |
5387 | itok.rm=(am32==FALSE?rm_d16:rm_d32); |
5390 | itok.rm=(am32==FALSE?rm_d16:rm_d32); |
5388 | itok.type=tp_ucnovn; |
5391 | itok.type=tp_ucnovn; |
5389 | addtotree(var_name); |
5392 | addtotree(var_name); |
5390 | startStartup+=size; |
5393 | startStartup+=size; |
5391 | return TRUE; |
5394 | return TRUE; |
5392 | } |
5395 | } |
5393 | } |
5396 | } |
5394 | return FALSE; |
5397 | return FALSE; |
5395 | } |
5398 | } |
5396 | 5399 | ||
5397 | /* ======= ñòàðò çàãîëîâêà ïðîöåäóðû ======== */ |
5400 | /* ======= ñòàðò çàãîëîâêà ïðîöåäóðû ======== */ |
5398 | 5401 | ||
5399 | void setuprm() |
5402 | void setuprm() |
5400 | { |
5403 | { |
5401 | itok.rm=returntype=(itok.rm==tokens?am32==FALSE?tk_word:tk_dword:itok.rm); |
5404 | itok.rm=returntype=(itok.rm==tokens?am32==FALSE?tk_word:tk_dword:itok.rm); |
5402 | if(itok.npointr)itok.rm=returntype=(am32==FALSE?tk_word:tk_dword); |
5405 | if(itok.npointr)itok.rm=returntype=(am32==FALSE?tk_word:tk_dword); |
5403 | } |
5406 | } |
5404 | 5407 | ||
5405 | void eaxToFloat(int reg=AX) |
5408 | void eaxToFloat(int reg=AX) |
5406 | { |
5409 | { |
5407 | int next=1; |
5410 | int next=1; |
5408 | CheckMinusNum(); |
5411 | CheckMinusNum(); |
5409 | if(itok2.type==tp_opperand){ //ñîñòàâíîå |
5412 | if(itok2.type==tp_opperand){ //ñîñòàâíîå |
5410 | doeaxfloatmath(tk_reg32,reg); |
5413 | doeaxfloatmath(tk_reg32,reg); |
5411 | next=0; |
5414 | next=0; |
5412 | } |
5415 | } |
5413 | else{ |
5416 | else{ |
5414 | switch(tok){ |
5417 | switch(tok){ |
5415 | case tk_number: |
5418 | case tk_number: |
5416 | if(itok.rm==tk_double)itok.fnumber=itok.dnumber; |
5419 | if(itok.rm==tk_double)itok.fnumber=itok.dnumber; |
5417 | else if(itok.rm!=tk_float){ |
5420 | else if(itok.rm!=tk_float){ |
5418 | float temp=itok.number; |
5421 | float temp=itok.number; |
5419 | *(float *)&itok.number=temp; |
5422 | *(float *)&itok.number=temp; |
5420 | } |
5423 | } |
5421 | op66(r32); |
5424 | op66(r32); |
5422 | op(0xb8+reg); // MOV EAX,# |
5425 | op(0xb8+reg); // MOV EAX,# |
5423 | outdword(itok.number); |
5426 | outdword(itok.number); |
5424 | break; |
5427 | break; |
5425 | case tk_floatvar: |
5428 | case tk_floatvar: |
5426 | if(reg==AX&&itok.rm==rm_d16&&itok.sib==CODE16){ |
5429 | if(reg==AX&&itok.rm==rm_d16&&itok.sib==CODE16){ |
5427 | op66(r32); |
5430 | op66(r32); |
5428 | outseg(&itok,1); |
5431 | outseg(&itok,1); |
5429 | op(0xA1); |
5432 | op(0xA1); |
5430 | outword((unsigned int)itok.number); |
5433 | outword((unsigned int)itok.number); |
5431 | } |
5434 | } |
5432 | else{ |
5435 | else{ |
5433 | CheckAllMassiv(bufrm,4,&strinf); |
5436 | CheckAllMassiv(bufrm,4,&strinf); |
5434 | op66(r32); |
5437 | op66(r32); |
5435 | outseg(&itok,2); |
5438 | outseg(&itok,2); |
5436 | op(0x8B); |
5439 | op(0x8B); |
5437 | op(itok.rm+reg*8); |
5440 | op(itok.rm+reg*8); |
5438 | outaddress(&itok); |
5441 | outaddress(&itok); |
5439 | } |
5442 | } |
5440 | break; |
5443 | break; |
5441 | default: |
5444 | default: |
5442 | if(doeaxfloatmath(tk_reg32,reg)!=tk_reg32&®!=AX){ |
5445 | if(doeaxfloatmath(tk_reg32,reg)!=tk_reg32&®!=AX){ |
5443 | if(!am32)Leave(); |
5446 | if(!am32)Leave(); |
5444 | op66(r32); |
5447 | op66(r32); |
5445 | op(0x89); |
5448 | op(0x89); |
5446 | op(0xc0+reg); |
5449 | op(0xc0+reg); |
5447 | } |
5450 | } |
5448 | next=0; |
5451 | next=0; |
5449 | } |
5452 | } |
5450 | } |
5453 | } |
5451 | if(next)nexttok(); |
5454 | if(next)nexttok(); |
5452 | } |
5455 | } |
5453 | 5456 | ||
5454 | void CalcRegPar(int reg,int def,char **ofsstr) |
5457 | void CalcRegPar(int reg,int def,char **ofsstr) |
5455 | { |
5458 | { |
5456 | char signflag=0; |
5459 | char signflag=0; |
5457 | int razr; |
5460 | int razr; |
5458 | unsigned char oinline=useinline; |
5461 | unsigned char oinline=useinline; |
5459 | useinline=0; |
5462 | useinline=0; |
5460 | // if(*ofsstr)puts(*ofsstr); |
5463 | // if(*ofsstr)puts(*ofsstr); |
5461 | if(tok!=tk_camma){ |
5464 | if(tok!=tk_camma){ |
5462 | if(tok==tk_openbracket){ |
5465 | if(tok==tk_openbracket){ |
5463 | nexttok(); |
5466 | nexttok(); |
5464 | if(tok>=tk_char&&tok<=tk_double)def=tok; |
5467 | if(tok>=tk_char&&tok<=tk_double)def=tok; |
5465 | nexttok(); |
5468 | nexttok(); |
5466 | expectingoperand(tk_closebracket); |
5469 | expectingoperand(tk_closebracket); |
5467 | } |
5470 | } |
5468 | if(tok>=tk_char&&tok<=tk_double){ |
5471 | if(tok>=tk_char&&tok<=tk_double){ |
5469 | def=tok; |
5472 | def=tok; |
5470 | getoperand(); |
5473 | getoperand(); |
5471 | } |
5474 | } |
5472 | if(tok==tk_string){ |
5475 | if(tok==tk_string){ |
5473 | op(0xB8+reg); |
5476 | op(0xB8+reg); |
5474 | if(am32==FALSE)outword(addpoststring()); |
5477 | if(am32==FALSE)outword(addpoststring()); |
5475 | else outdword(addpoststring()); |
5478 | else outdword(addpoststring()); |
5476 | nexttok(); |
5479 | nexttok(); |
5477 | razr=(am32==FALSE?r16:r32); |
5480 | razr=(am32==FALSE?r16:r32); |
5478 | } |
5481 | } |
5479 | else if(tok==tk_floatvar)eaxToFloat(reg); |
5482 | else if(tok==tk_floatvar)eaxToFloat(reg); |
5480 | else{ |
5483 | else{ |
5481 | switch(def){ |
5484 | switch(def){ |
5482 | case tk_int: signflag=1; |
5485 | case tk_int: signflag=1; |
5483 | case tk_word: |
5486 | case tk_word: |
5484 | if(reg==AX)do_e_axmath(signflag,r16,ofsstr); |
5487 | if(reg==AX)do_e_axmath(signflag,r16,ofsstr); |
5485 | else getintoreg(reg,r16,signflag,ofsstr); |
5488 | else getintoreg(reg,r16,signflag,ofsstr); |
5486 | razr=r16; |
5489 | razr=r16; |
5487 | break; |
5490 | break; |
5488 | case tk_char: signflag=1; |
5491 | case tk_char: signflag=1; |
5489 | case tk_byte: |
5492 | case tk_byte: |
5490 | if(reg==AX)doalmath(signflag,ofsstr); |
5493 | if(reg==AX)doalmath(signflag,ofsstr); |
5491 | else{ |
5494 | else{ |
5492 | getintobeg(reg,ofsstr); |
5495 | getintobeg(reg,ofsstr); |
5493 | dobegmath(reg); |
5496 | dobegmath(reg); |
5494 | } |
5497 | } |
5495 | razr=r8; |
5498 | razr=r8; |
5496 | break; |
5499 | break; |
5497 | case tk_long: signflag=1; |
5500 | case tk_long: signflag=1; |
5498 | case tk_dword: |
5501 | case tk_dword: |
5499 | if(reg==AX)do_e_axmath(signflag,r32,ofsstr); |
5502 | if(reg==AX)do_e_axmath(signflag,r32,ofsstr); |
5500 | else getintoreg(reg,r32,signflag,ofsstr); |
5503 | else getintoreg(reg,r32,signflag,ofsstr); |
5501 | razr=r32; |
5504 | razr=r32; |
5502 | break; |
5505 | break; |
5503 | case tk_float: |
5506 | case tk_float: |
5504 | eaxToFloat(reg); |
5507 | eaxToFloat(reg); |
5505 | razr=r32; |
5508 | razr=r32; |
5506 | break; |
5509 | break; |
5507 | case tk_qword: |
5510 | case tk_qword: |
5508 | getintoreg64(reg); |
5511 | getintoreg64(reg); |
5509 | doregmath64(reg); |
5512 | doregmath64(reg); |
5510 | razr=r64; |
5513 | razr=r64; |
5511 | break; |
5514 | break; |
5512 | case tokens: |
5515 | case tokens: |
5513 | razr=(am32==FALSE?r16:r32); |
5516 | razr=(am32==FALSE?r16:r32); |
5514 | if(reg==AX)do_e_axmath(0,razr,ofsstr); |
5517 | if(reg==AX)do_e_axmath(0,razr,ofsstr); |
5515 | else getintoreg(reg,razr,signflag,ofsstr); |
5518 | else getintoreg(reg,razr,signflag,ofsstr); |
5516 | break; |
5519 | break; |
5517 | } |
5520 | } |
5518 | } |
5521 | } |
5519 | AddRegistr(razr,reg); |
5522 | AddRegistr(razr,reg); |
5520 | // printf("%08X\n",reg); |
5523 | // printf("%08X\n",reg); |
5521 | } |
5524 | } |
5522 | useinline=oinline; |
5525 | useinline=oinline; |
5523 | } |
5526 | } |
5524 | 5527 | ||
5525 | int GetTypeParam(char c) |
5528 | int GetTypeParam(char c) |
5526 | { |
5529 | { |
5527 | switch(c){ |
5530 | switch(c){ |
5528 | case 'B': return tk_byte; |
5531 | case 'B': return tk_byte; |
5529 | case 'W': return tk_word; |
5532 | case 'W': return tk_word; |
5530 | case 'D': return tk_dword; |
5533 | case 'D': return tk_dword; |
5531 | case 'C': return tk_char; |
5534 | case 'C': return tk_char; |
5532 | case 'I': return tk_int; |
5535 | case 'I': return tk_int; |
5533 | case 'L': return tk_long; |
5536 | case 'L': return tk_long; |
5534 | case 'F': return tk_float; |
5537 | case 'F': return tk_float; |
5535 | case 'A': return tk_multipoint; |
5538 | case 'A': return tk_multipoint; |
5536 | case 'Q': return tk_qword; |
5539 | case 'Q': return tk_qword; |
5537 | case 'E': return tk_double; |
5540 | case 'E': return tk_double; |
5538 | case 'S': return tk_fpust; |
5541 | case 'S': return tk_fpust; |
5539 | case 'T': return tk_struct; |
5542 | case 'T': return tk_struct; |
5540 | case 'U': return tokens; |
5543 | case 'U': return tokens; |
5541 | default: |
5544 | default: |
5542 | extraparam(); |
5545 | extraparam(); |
5543 | // printf("%c\n",c); |
5546 | // printf("%c\n",c); |
5544 | return 0; |
5547 | return 0; |
5545 | } |
5548 | } |
5546 | } |
5549 | } |
5547 | 5550 | ||
5548 | void doregparams() |
5551 | void doregparams() |
5549 | { |
5552 | { |
5550 | int i=0; |
5553 | int i=0; |
5551 | char *ofsstr=NULL; |
5554 | char *ofsstr=NULL; |
5552 | int razr; |
5555 | int razr; |
5553 | int retreg; |
5556 | int retreg; |
5554 | ClearRegister(); |
5557 | ClearRegister(); |
5555 | if(tok!=tk_openbracket)expected('('); |
5558 | if(tok!=tk_openbracket)expected('('); |
5556 | while(tok2==tk_camma){ |
5559 | while(tok2==tk_camma){ |
5557 | nexttok(); |
5560 | nexttok(); |
5558 | i++; |
5561 | i++; |
5559 | } |
5562 | } |
5560 | ofsstr=GetLecsem(tk_camma,tk_closebracket); |
5563 | ofsstr=GetLecsem(tk_camma,tk_closebracket); |
5561 | getoperand(); |
5564 | getoperand(); |
5562 | if(tok!=tk_closebracket){ |
5565 | if(tok!=tk_closebracket){ |
5563 | if(strlen(param)!=0){ |
5566 | if(strlen(param)!=0){ |
5564 | int def; |
5567 | int def; |
5565 | char *oparam=BackString(param); |
5568 | char *oparam=BackString(param); |
5566 | for(;;){ |
5569 | for(;;){ |
5567 | while(tok==tk_camma){ |
5570 | while(tok==tk_camma){ |
5568 | if(ofsstr)free(ofsstr); |
5571 | if(ofsstr)free(ofsstr); |
5569 | ofsstr=GetLecsem(tk_camma,tk_closebracket); |
5572 | ofsstr=GetLecsem(tk_camma,tk_closebracket); |
5570 | getoperand(); |
5573 | getoperand(); |
5571 | } |
5574 | } |
5572 | if((def=GetTypeParam(oparam[i++]))==0){ |
5575 | if((def=GetTypeParam(oparam[i++]))==0){ |
5573 | nexttok(); |
5576 | nexttok(); |
5574 | break; |
5577 | break; |
5575 | } |
5578 | } |
5576 | if(def==tk_qword){ |
5579 | if(def==tk_qword){ |
5577 | int c1,c2; |
5580 | int c1,c2; |
5578 | c1=oparam[i++]-0x30; |
5581 | c1=oparam[i++]-0x30; |
5579 | c2=oparam[i++]-0x30; |
5582 | c2=oparam[i++]-0x30; |
5580 | retreg=c1|(c2*256); |
5583 | retreg=c1|(c2*256); |
5581 | // printf("%08X\n",retreg); |
5584 | // printf("%08X\n",retreg); |
5582 | } |
5585 | } |
5583 | else retreg=oparam[i++]-0x30; |
5586 | else retreg=oparam[i++]-0x30; |
5584 | if(ofsstr){ |
5587 | if(ofsstr){ |
5585 | if((razr=getrazr(def))!=r64){ |
5588 | if((razr=getrazr(def))!=r64){ |
5586 | int retr; |
5589 | int retr; |
5587 | if((retr=CheckIDZReg(ofsstr,retreg,razr))!=NOINREG){ |
5590 | if((retr=CheckIDZReg(ofsstr,retreg,razr))!=NOINREG){ |
5588 | GetEndLex(tk_camma,tk_closebracket); |
5591 | GetEndLex(tk_camma,tk_closebracket); |
5589 | if(retr!=SKIPREG)GenRegToReg(retreg,retr,razr); |
5592 | if(retr!=SKIPREG)GenRegToReg(retreg,retr,razr); |
5590 | nexttok(); |
5593 | nexttok(); |
5591 | goto endparam; |
5594 | goto endparam; |
5592 | } |
5595 | } |
5593 | } |
5596 | } |
5594 | } |
5597 | } |
5595 | if(def==tk_fpust)float2stack(retreg); |
5598 | if(def==tk_fpust)float2stack(retreg); |
5596 | else CalcRegPar(retreg,def,&ofsstr); |
5599 | else CalcRegPar(retreg,def,&ofsstr); |
5597 | endparam: |
5600 | endparam: |
5598 | if(ofsstr&&razr!=r64){ |
5601 | if(ofsstr&&razr!=r64){ |
5599 | IDZToReg(ofsstr,retreg,razr); |
5602 | IDZToReg(ofsstr,retreg,razr); |
5600 | free(ofsstr); |
5603 | free(ofsstr); |
5601 | ofsstr=NULL; |
5604 | ofsstr=NULL; |
5602 | } |
5605 | } |
5603 | if(tok!=tk_camma){ |
5606 | if(tok!=tk_camma){ |
5604 | if(tok!=tk_closebracket)expected(')'); |
5607 | if(tok!=tk_closebracket)expected(')'); |
5605 | if(oparam[i]!=0)missingpar(); |
5608 | if(oparam[i]!=0)missingpar(); |
5606 | break; |
5609 | break; |
5607 | } |
5610 | } |
5608 | } |
5611 | } |
5609 | free(oparam); |
5612 | free(oparam); |
5610 | } |
5613 | } |
5611 | else{ |
5614 | else{ |
5612 | char regpar[6]={AX,BX,CX,DX,DI,SI}; |
5615 | char regpar[6]={AX,BX,CX,DX,DI,SI}; |
5613 | for(;i<6;i++){ |
5616 | for(;i<6;i++){ |
5614 | if(tok==tk_camma){ |
5617 | if(tok==tk_camma){ |
5615 | if(ofsstr)free(ofsstr); |
5618 | if(ofsstr)free(ofsstr); |
5616 | ofsstr=GetLecsem(tk_camma,tk_closebracket); |
5619 | ofsstr=GetLecsem(tk_camma,tk_closebracket); |
5617 | getoperand(); |
5620 | getoperand(); |
5618 | if(tok==tk_camma)continue; |
5621 | if(tok==tk_camma)continue; |
5619 | } |
5622 | } |
5620 | retreg=regpar[i]; |
5623 | retreg=regpar[i]; |
5621 | if(ofsstr&&tok!=tk_camma){ |
5624 | if(ofsstr&&tok!=tk_camma){ |
5622 | razr=(am32==FALSE?r16:r32); |
5625 | razr=(am32==FALSE?r16:r32); |
5623 | int retr; |
5626 | int retr; |
5624 | if((retr=CheckIDZReg(ofsstr,retreg,razr))!=NOINREG){ |
5627 | if((retr=CheckIDZReg(ofsstr,retreg,razr))!=NOINREG){ |
5625 | GetEndLex(tk_camma,tk_closebracket); |
5628 | GetEndLex(tk_camma,tk_closebracket); |
5626 | if(retr!=SKIPREG)GenRegToReg(retreg,retr,razr); |
5629 | if(retr!=SKIPREG)GenRegToReg(retreg,retr,razr); |
5627 | nexttok(); |
5630 | nexttok(); |
5628 | goto endparam1; |
5631 | goto endparam1; |
5629 | } |
5632 | } |
5630 | } |
5633 | } |
5631 | CalcRegPar(retreg,tokens,&ofsstr); |
5634 | CalcRegPar(retreg,tokens,&ofsstr); |
5632 | endparam1: |
5635 | endparam1: |
5633 | if(ofsstr){ |
5636 | if(ofsstr){ |
5634 | IDZToReg(ofsstr,retreg,razr); |
5637 | IDZToReg(ofsstr,retreg,razr); |
5635 | free(ofsstr); |
5638 | free(ofsstr); |
5636 | ofsstr=NULL; |
5639 | ofsstr=NULL; |
5637 | } |
5640 | } |
5638 | if(tok!=tk_camma){ |
5641 | if(tok!=tk_camma){ |
5639 | if(tok!=tk_closebracket)expected(')'); |
5642 | if(tok!=tk_closebracket)expected(')'); |
5640 | break; |
5643 | break; |
5641 | } |
5644 | } |
5642 | } |
5645 | } |
5643 | } |
5646 | } |
5644 | setzeroflag=FALSE; |
5647 | setzeroflag=FALSE; |
5645 | } |
5648 | } |
5646 | if(ofsstr)free(ofsstr); |
5649 | if(ofsstr)free(ofsstr); |
5647 | } |
5650 | } |
5648 | 5651 | ||
5649 | int CheckUses() |
5652 | int CheckUses() |
5650 | { |
5653 | { |
5651 | int i; |
5654 | int i; |
5652 | int regs=0; |
5655 | int regs=0; |
5653 | int bracket=FALSE; |
5656 | int bracket=FALSE; |
5654 | memset((SAVEREG *)psavereg,0,sizeof(SAVEREG)); |
5657 | memset((SAVEREG *)psavereg,0,sizeof(SAVEREG)); |
5655 | if(tok==tk_openbracket){ |
5658 | if(tok==tk_openbracket){ |
5656 | if(stricmp(itok2.name,"uses")==0){ |
5659 | if(stricmp(itok2.name,"uses")==0){ |
5657 | bracket=TRUE; |
5660 | bracket=TRUE; |
5658 | nexttok(); |
5661 | nexttok(); |
5659 | } |
5662 | } |
5660 | else return 0; |
5663 | else return 0; |
5661 | } |
5664 | } |
5662 | if(stricmp(itok.name,"uses")==0){ |
5665 | if(stricmp(itok.name,"uses")==0){ |
5663 | nexttok(); |
5666 | nexttok(); |
5664 | while(tok==tk_reg32||tok==tk_reg||tok==tk_beg){ |
5667 | while(tok==tk_reg32||tok==tk_reg||tok==tk_beg){ |
5665 | i=r32; |
5668 | i=r32; |
5666 | switch(tok){ |
5669 | switch(tok){ |
5667 | case tk_beg: |
5670 | case tk_beg: |
5668 | if(itok.number>3)itok.number-=4; |
5671 | if(itok.number>3)itok.number-=4; |
5669 | i=(am32+1)*2; |
5672 | i=(am32+1)*2; |
5670 | break; |
5673 | break; |
5671 | case tk_reg: |
5674 | case tk_reg: |
5672 | if(!am32)i=r16; |
5675 | if(!am32)i=r16; |
5673 | break; |
5676 | break; |
5674 | } |
5677 | } |
5675 | regs=regs|(1< |
5678 | regs=regs|(1< |
5676 | psavereg->reg[itok.number]=i; |
5679 | psavereg->reg[itok.number]=i; |
5677 | i=1; |
5680 | i=1; |
5678 | if((am32&&i==r16)||(am32==0&&i==r32))i=2; |
5681 | if((am32&&i==r16)||(am32==0&&i==r32))i=2; |
5679 | psavereg->size+=i; |
5682 | psavereg->size+=i; |
5680 | nexttok(); |
5683 | nexttok(); |
5681 | if(tok==tk_camma)nexttok(); |
5684 | if(tok==tk_camma)nexttok(); |
5682 | } |
5685 | } |
5683 | if(strcmp(itok.name,"allregs")==0){ |
5686 | if(strcmp(itok.name,"allregs")==0){ |
5684 | psavereg->size=1; |
5687 | psavereg->size=1; |
5685 | psavereg->all=1; |
5688 | psavereg->all=1; |
5686 | regs=dEAX|dEBX|dECX|dEDX|dEBP|dEDI|dESI; |
5689 | regs=dEAX|dEBX|dECX|dEDX|dEBP|dEDI|dESI; |
5687 | nexttok(); |
5690 | nexttok(); |
5688 | } |
5691 | } |
5689 | } |
5692 | } |
5690 | if(bracket)expecting(tk_closebracket); |
5693 | if(bracket)expecting(tk_closebracket); |
5691 | return regs; |
5694 | return regs; |
5692 | } |
5695 | } |
5693 | 5696 | ||
5694 | void Enter() |
5697 | void Enter() |
5695 | { |
5698 | { |
5696 | if(ESPloc==FALSE||am32==FALSE){ |
5699 | if(ESPloc==FALSE||am32==FALSE){ |
5697 | op(0x55); //push bp |
5700 | op(0x55); //push bp |
5698 | outword(0xe589);//mov bp,sp |
5701 | outword(0xe589);//mov bp,sp |
5699 | } |
5702 | } |
5700 | } |
5703 | } |
5701 | 5704 | ||
5702 | void setproc(int defflag) |
5705 | void setproc(int defflag) |
5703 | { |
5706 | { |
5704 | char *bstring; |
5707 | char *bstring; |
5705 | unsigned char oinline,ooptimizespeed; |
5708 | unsigned char oinline,ooptimizespeed; |
5706 | ITOK otok; |
5709 | ITOK otok; |
5707 | unsigned int i; |
5710 | unsigned int i; |
5708 | int regs=0; |
5711 | int regs=0; |
5709 | unsigned char oESPloc=ESPloc; |
5712 | unsigned char oESPloc=ESPloc; |
5710 | int startline=linenumber; |
5713 | int startline=linenumber; |
5711 | unsigned int oregidx; |
5714 | unsigned int oregidx; |
5712 | 5715 | ||
5713 | clearregstat(); |
5716 | clearregstat(); |
5714 | addESP=inlineflag=0; |
5717 | addESP=inlineflag=0; |
5715 | oinline=useinline; |
5718 | oinline=useinline; |
5716 | ooptimizespeed=optimizespeed; |
5719 | ooptimizespeed=optimizespeed; |
5717 | oregidx=*(unsigned int *)&idxregs; |
5720 | oregidx=*(unsigned int *)&idxregs; |
5718 | current_proc_type=itok.flag; |
5721 | current_proc_type=itok.flag; |
5719 | 5722 | ||
5720 | if(itok.flag&f_extern)notexternfun(); //new 18.04.07 12:20 |
5723 | if(itok.flag&f_extern)notexternfun(); //new 18.04.07 12:20 |
5721 | // printf("%s tok=%d flag=%08X\n",itok.name,tok,itok.flag); |
5724 | // printf("%s tok=%d flag=%08X\n",itok.name,tok,itok.flag); |
5722 | 5725 | ||
5723 | tok=lastcommand=tk_proc; |
5726 | tok=lastcommand=tk_proc; |
5724 | itok.number=outptr; |
5727 | itok.number=outptr; |
5725 | if(itok.segm |
5728 | if(itok.segm |
5726 | setuprm(); |
5729 | setuprm(); |
5727 | // printf("rm=%d %s\n",itok.rm,itok.name); |
5730 | // printf("rm=%d %s\n",itok.rm,itok.name); |
5728 | if(defflag){ //ðàíåå óæå áûëè âûçîâû |
5731 | if(defflag){ //ðàíåå óæå áûëè âûçîâû |
5729 | // updatecall(updatetree(),(unsigned int)itok.number,0); |
5732 | // updatecall(updatetree(),(unsigned int)itok.number,0); |
5730 | regs=itok.post; |
5733 | regs=itok.post; |
5731 | if(updatecall(updatetree(),(unsigned int)itok.number,0)==-1&& |
5734 | if(updatecall(updatetree(),(unsigned int)itok.number,0)==-1&& |
5732 | strcmp(itok.name,mesmain)==0/*&&jumptomain!=CALL_NONE*/){ |
5735 | strcmp(itok.name,mesmain)==0/*&&jumptomain!=CALL_NONE*/){ |
5733 | itok.number=outptr=outptr-(jumptomain==CALL_SHORT?2:am32==FALSE?3:5); |
5736 | itok.number=outptr=outptr-(jumptomain==CALL_SHORT?2:am32==FALSE?3:5); |
5734 | if(dbg){ |
5737 | if(dbg){ |
5735 | KillLastLine(); |
5738 | KillLastLine(); |
5736 | KillLastLine(); |
5739 | KillLastLine(); |
5737 | AddLine(); |
5740 | AddLine(); |
5738 | } |
5741 | } |
5739 | updatetree(); |
5742 | updatetree(); |
5740 | } |
5743 | } |
5741 | } |
5744 | } |
5742 | else{ //èíà÷å äîáàâèòü â äåðåâî |
5745 | else{ //èíà÷å äîáàâèòü â äåðåâî |
5743 | string[0]=0; |
5746 | string[0]=0; |
5744 | itok.type=tp_ucnovn; |
5747 | itok.type=tp_ucnovn; |
5745 | addtotree(itok.name); |
5748 | addtotree(itok.name); |
5746 | } |
5749 | } |
5747 | // puts(itok.name); |
5750 | // puts(itok.name); |
5748 | if((i=FindOff((unsigned char *)itok.name,CS))!=0){ |
5751 | if((i=FindOff((unsigned char *)itok.name,CS))!=0){ |
5749 | itok.rec->count=i; |
5752 | itok.rec->count=i; |
5750 | } |
5753 | } |
5751 | bstring=BackString((char *)string); |
5754 | bstring=BackString((char *)string); |
5752 | otok=itok; |
5755 | otok=itok; |
5753 | if(strcmp(mesmain,otok.name)==0){ |
5756 | if(strcmp(mesmain,otok.name)==0){ |
5754 | if(startuptomain==TRUE&&comfile==file_com)doprestuff(); |
5757 | if(startuptomain==TRUE&&comfile==file_com)doprestuff(); |
5755 | if(numdomain!=0){ |
5758 | if(numdomain!=0){ |
5756 | for(i=0;i |
5759 | for(i=0;i |
5757 | strcpy(itok.name,domain+i*IDLENGTH); |
5760 | strcpy(itok.name,domain+i*IDLENGTH); |
5758 | tok=tk_ID; |
5761 | tok=tk_ID; |
5759 | searchvar(itok.name,0); |
5762 | searchvar(itok.name,0); |
5760 | switch(tok){ |
5763 | switch(tok){ |
5761 | case tk_ID: |
5764 | case tk_ID: |
5762 | case tk_id: |
5765 | case tk_id: |
5763 | tobedefined(am32==FALSE?CALL_NEAR:CALL_32,tk_void); |
5766 | tobedefined(am32==FALSE?CALL_NEAR:CALL_32,tk_void); |
5764 | (postbuf+posts-1)->loc=outptr+1; |
5767 | (postbuf+posts-1)->loc=outptr+1; |
5765 | callloc0(); /* produce CALL [#] */ |
5768 | callloc0(); /* produce CALL [#] */ |
5766 | break; |
5769 | break; |
5767 | case tk_declare: |
5770 | case tk_declare: |
5768 | tok=tk_undefproc; |
5771 | tok=tk_undefproc; |
5769 | updatetree(); |
5772 | updatetree(); |
5770 | case tk_undefproc: |
5773 | case tk_undefproc: |
5771 | addacall(itok.number,(unsigned char)((itok.flag&f_extern)!=0?CALL_EXT:(am32!=FALSE?CALL_32:CALL_NEAR))); |
5774 | addacall(itok.number,(unsigned char)((itok.flag&f_extern)!=0?CALL_EXT:(am32!=FALSE?CALL_32:CALL_NEAR))); |
5772 | callloc0(); /* produce CALL [#] */ |
5775 | callloc0(); /* produce CALL [#] */ |
5773 | break; |
5776 | break; |
5774 | case tk_proc: |
5777 | case tk_proc: |
5775 | if(itok.flag&f_far)op(0x0e); //push cs |
5778 | if(itok.flag&f_far)op(0x0e); //push cs |
5776 | if(itok.segm |
5779 | if(itok.segm |
5777 | addacall(itok.number,(unsigned char)(am32!=FALSE?CALL_32:CALL_NEAR)); |
5780 | addacall(itok.number,(unsigned char)(am32!=FALSE?CALL_32:CALL_NEAR)); |
5778 | itok.number=0; |
5781 | itok.number=0; |
5779 | } |
5782 | } |
5780 | callloc(itok.number); |
5783 | callloc(itok.number); |
5781 | break; |
5784 | break; |
5782 | default: |
5785 | default: |
5783 | preerror("impossible type for startup function"); |
5786 | preerror("impossible type for startup function"); |
5784 | break; |
5787 | break; |
5785 | } |
5788 | } |
5786 | } |
5789 | } |
5787 | numdomain=0; |
5790 | numdomain=0; |
5788 | free(domain); |
5791 | free(domain); |
5789 | } |
5792 | } |
5790 | } |
5793 | } |
5791 | nextexpecting2(tk_openbracket); |
5794 | nextexpecting2(tk_openbracket); |
5792 | startblock(); |
5795 | startblock(); |
5793 | if(searchteg&&(!(current_proc_type&f_static))&&(current_proc_type&f_typeproc)!=tp_pascal)AddThis(); |
5796 | if(searchteg&&(!(current_proc_type&f_static))&&(current_proc_type&f_typeproc)!=tp_pascal)AddThis(); |
5794 | if(tok!=tk_closebracket){ |
5797 | if(tok!=tk_closebracket){ |
5795 | if((current_proc_type&f_typeproc)!=tp_fastcall){ |
5798 | if((current_proc_type&f_typeproc)!=tp_fastcall){ |
5796 | declareparams(); |
5799 | declareparams(); |
5797 | if(otok.type==tp_declare&&defflag&&strcmp(bstring,param)!=0){ |
5800 | if(otok.type==tp_declare&&defflag&&strcmp(bstring,param)!=0){ |
5798 | // printf("old=%s new=%s\n",bstring,param); |
5801 | // printf("old=%s new=%s\n",bstring,param); |
5799 | redeclare(otok.name); |
5802 | redeclare(otok.name); |
5800 | } |
5803 | } |
5801 | // if(bstring[0]!=0&&bstring[0]!='A'&&strcmp(bstring,param)!=0)redeclare(); |
5804 | // if(bstring[0]!=0&&bstring[0]!='A'&&strcmp(bstring,param)!=0)redeclare(); |
5802 | } |
5805 | } |
5803 | else{ |
5806 | else{ |
5804 | declareparamreg(); |
5807 | declareparamreg(); |
5805 | } |
5808 | } |
5806 | if(bstring)free(bstring); |
5809 | if(bstring)free(bstring); |
5807 | bstring=BackString((char *)param); |
5810 | bstring=BackString((char *)param); |
5808 | } |
5811 | } |
5809 | else if((current_proc_type&f_typeproc)!=tp_fastcall&&bstring[0]!=0){ |
5812 | else if((current_proc_type&f_typeproc)!=tp_fastcall&&bstring[0]!=0){ |
5810 | if(bstring[0]!='V'&&bstring[0]!='A'){ |
5813 | if(bstring[0]!='V'&&bstring[0]!='A'){ |
5811 | redeclare(otok.name); |
5814 | redeclare(otok.name); |
5812 | // puts(bstring); |
5815 | // puts(bstring); |
5813 | } |
5816 | } |
5814 | } |
5817 | } |
5815 | 5818 | ||
5816 | strcpy((char *)string,bstring); |
5819 | strcpy((char *)string,bstring); |
5817 | itok=otok; |
5820 | itok=otok; |
5818 | tok=tk_proc; |
5821 | tok=tk_proc; |
5819 | updatetree(); |
5822 | updatetree(); |
5820 | 5823 | ||
5821 | if(searchteg&&(!(current_proc_type&f_static))&&(current_proc_type&f_typeproc)==tp_pascal)AddThis(); |
5824 | if(searchteg&&(!(current_proc_type&f_static))&&(current_proc_type&f_typeproc)==tp_pascal)AddThis(); |
5822 | nexttok(); |
5825 | nexttok(); |
5823 | blockproc=TRUE; |
5826 | blockproc=TRUE; |
5824 | // printf("tok=%d\n",tok); |
5827 | // printf("tok=%d\n",tok); |
5825 | if(tok==tk_inline){ |
5828 | if(tok==tk_inline){ |
5826 | inlineflag=1; |
5829 | inlineflag=1; |
5827 | nexttok(); |
5830 | nexttok(); |
5828 | } |
5831 | } |
5829 | else if(paramsize)Enter(); // PUSH BP MOV BP,SP |
5832 | else if(paramsize)Enter(); // PUSH BP MOV BP,SP |
5830 | if(tok==tk_colon&&(current_proc_type&fs_constructor)!=0){ |
5833 | if(tok==tk_colon&&(current_proc_type&fs_constructor)!=0){ |
5831 | do{ |
5834 | do{ |
5832 | AddBackBuf(inptr2,cha2); |
5835 | AddBackBuf(inptr2,cha2); |
5833 | }while(tok==tk_camma); |
5836 | }while(tok==tk_camma); |
5834 | nexttok(); |
5837 | nexttok(); |
5835 | } |
5838 | } |
5836 | regs|=CheckUses(); |
5839 | regs|=CheckUses(); |
5837 | CorrectParamVar(); |
5840 | CorrectParamVar(); |
5838 | if(tok!=tk_openbrace)declarelocals(0,inlineflag); |
5841 | if(tok!=tk_openbrace)declarelocals(0,inlineflag); |
5839 | #ifdef OPTVARCONST |
5842 | #ifdef OPTVARCONST |
5840 | ClearLVIC(); |
5843 | ClearLVIC(); |
5841 | #endif |
5844 | #endif |
5842 | // numblocks++; //íà ýòîì ìåñòå äëÿ ðàíåãî îïðåäåëåíèÿ ::var |
5845 | // numblocks++; //íà ýòîì ìåñòå äëÿ ðàíåãî îïðåäåëåíèÿ ::var |
5843 | expecting(tk_openbrace); |
5846 | expecting(tk_openbrace); |
5844 | declarelocals(1,inlineflag); |
5847 | declarelocals(1,inlineflag); |
5845 | retproc=FALSE; |
5848 | retproc=FALSE; |
5846 | if(paramsize||localsize/*||(lstructlist!=NULL)*/){ |
5849 | if(paramsize||localsize/*||(lstructlist!=NULL)*/){ |
5847 | initBP=1; |
5850 | initBP=1; |
5848 | if(inlineflag)warninline(); |
5851 | if(inlineflag)warninline(); |
5849 | } |
5852 | } |
5850 | 5853 | ||
5851 | #ifdef __NEWLEX__ |
5854 | #ifdef __NEWLEX__ |
5852 | doblockstart(otok.name); |
5855 | doblockstart(otok.name); |
5853 | #endif |
5856 | #endif |
5854 | doblock2(); // do proc |
5857 | doblock2(); // do proc |
5855 | if(current_proc_type&fs_destructor){ |
5858 | if(current_proc_type&fs_destructor){ |
5856 | elementteg *bazael=searchteg->baza; |
5859 | elementteg *bazael=searchteg->baza; |
5857 | for(i=0;i |
5860 | for(i=0;i |
5858 | if((bazael+i)->tok==tk_baseclass)CallDestructor((structteg *)(bazael+i)->rec); |
5861 | if((bazael+i)->tok==tk_baseclass)CallDestructor((structteg *)(bazael+i)->rec); |
5859 | } |
5862 | } |
5860 | } |
5863 | } |
5861 | i=numreturn; |
5864 | i=numreturn; |
5862 | setreturn(); |
5865 | setreturn(); |
5863 | if(inlineflag==0&&retproc==FALSE&&(i||(lastcommand!=tk_goto&&lastcommand!=tk_GOTO)))leaveproc(); |
5866 | if(inlineflag==0&&retproc==FALSE&&(i||(lastcommand!=tk_goto&&lastcommand!=tk_GOTO)))leaveproc(); |
5864 | endblock(); |
5867 | endblock(); |
5865 | initBP=0; |
5868 | initBP=0; |
5866 | strcpy((char *)string,bstring); |
5869 | strcpy((char *)string,bstring); |
5867 | itok=otok; |
5870 | itok=otok; |
5868 | tok=tk_proc; |
5871 | tok=tk_proc; |
5869 | itok.size=outptr-procedure_start; |
5872 | itok.size=outptr-procedure_start; |
5870 | itok.rec->recpost=regs; |
5873 | itok.rec->recpost=regs; |
5871 | // printf("reg=%08X set=%s\n",regs,itok.name); |
5874 | // printf("reg=%08X set=%s\n",regs,itok.name); |
5872 | #ifdef OPTVARCONST |
5875 | #ifdef OPTVARCONST |
5873 | if(inlineflag)itok.flag|=f_useidx; |
5876 | if(inlineflag)itok.flag|=f_useidx; |
5874 | #endif |
5877 | #endif |
5875 | updatetree(); |
5878 | updatetree(); |
5876 | if(mapfile)mapfun(startline); |
5879 | if(mapfile)mapfun(startline); |
5877 | i=linenumber; |
5880 | i=linenumber; |
5878 | linenumber=startline; |
5881 | linenumber=startline; |
5879 | killlocals(); |
5882 | killlocals(); |
5880 | linenumber=i; |
5883 | linenumber=i; |
5881 | free(bstring); |
5884 | free(bstring); |
5882 | optimizespeed=ooptimizespeed; |
5885 | optimizespeed=ooptimizespeed; |
5883 | useinline=oinline; |
5886 | useinline=oinline; |
5884 | *(unsigned int *)&idxregs=oregidx; |
5887 | *(unsigned int *)&idxregs=oregidx; |
5885 | if(searchteg)searchteg=NULL; |
5888 | if(searchteg)searchteg=NULL; |
5886 | blockproc=FALSE; |
5889 | blockproc=FALSE; |
5887 | ESPloc=oESPloc; |
5890 | ESPloc=oESPloc; |
5888 | nexttok(); |
5891 | nexttok(); |
5889 | } |
5892 | } |
5890 | 5893 | ||
5891 | void insertproc(/*int sizepar*/) |
5894 | void insertproc(/*int sizepar*/) |
5892 | { |
5895 | { |
5893 | unsigned char oinline,ooptimizespeed; |
5896 | unsigned char oinline,ooptimizespeed; |
5894 | struct treelocalrec *otlr; |
5897 | struct treelocalrec *otlr; |
5895 | struct structteg *olteglist; |
5898 | struct structteg *olteglist; |
5896 | //struct idrec *olstructlist; |
5899 | //struct idrec *olstructlist; |
5897 | struct idrec *rec; |
5900 | struct idrec *rec; |
5898 | unsigned int oparamsize; |
5901 | unsigned int oparamsize; |
5899 | unsigned int olocalsize; |
5902 | unsigned int olocalsize; |
5900 | unsigned char oinsertmode; |
5903 | unsigned char oinsertmode; |
5901 | unsigned int onumblocks; //íîìåð âëîæåííîãî áëîêà |
5904 | unsigned int onumblocks; //íîìåð âëîæåííîãî áëîêà |
5902 | unsigned int osizestack; |
5905 | unsigned int osizestack; |
5903 | RETLIST *olistreturn; |
5906 | RETLIST *olistreturn; |
5904 | unsigned int onumreturn; |
5907 | unsigned int onumreturn; |
5905 | int oinlineflag; |
5908 | int oinlineflag; |
5906 | SAVEREG *osavr; |
5909 | SAVEREG *osavr; |
5907 | unsigned int oaddESP=addESP; |
5910 | unsigned int oaddESP=addESP; |
5908 | addESP=0; |
5911 | addESP=0; |
5909 | clearregstat(); |
5912 | clearregstat(); |
5910 | osavr=psavereg; |
5913 | osavr=psavereg; |
5911 | psavereg=(SAVEREG*)MALLOC(sizeof(SAVEREG)); |
5914 | psavereg=(SAVEREG*)MALLOC(sizeof(SAVEREG)); |
5912 | oinsertmode=insertmode; |
5915 | oinsertmode=insertmode; |
5913 | insertmode=TRUE; //ôëàã ðåæèìà âñòàâêè |
5916 | insertmode=TRUE; //ôëàã ðåæèìà âñòàâêè |
5914 | oinline=useinline; |
5917 | oinline=useinline; |
5915 | ooptimizespeed=optimizespeed; |
5918 | ooptimizespeed=optimizespeed; |
5916 | current_proc_type=itok.flag; |
5919 | current_proc_type=itok.flag; |
5917 | rec=itok.rec; |
5920 | rec=itok.rec; |
5918 | otlr=tlr; |
5921 | otlr=tlr; |
5919 | olteglist=ltegtree; |
5922 | olteglist=ltegtree; |
5920 | // olstructlist=lstructlist; |
5923 | // olstructlist=lstructlist; |
5921 | oinlineflag=inlineflag; |
5924 | oinlineflag=inlineflag; |
5922 | osizestack=sizestack; |
5925 | osizestack=sizestack; |
5923 | sizestack=0; |
5926 | sizestack=0; |
5924 | tlr=NULL; |
5927 | tlr=NULL; |
5925 | ltegtree=NULL; |
5928 | ltegtree=NULL; |
5926 | // lstructlist=0; |
5929 | // lstructlist=0; |
5927 | oparamsize=paramsize; |
5930 | oparamsize=paramsize; |
5928 | olocalsize=localsize; |
5931 | olocalsize=localsize; |
5929 | onumblocks=numblocks; |
5932 | onumblocks=numblocks; |
5930 | olistreturn=listreturn; |
5933 | olistreturn=listreturn; |
5931 | onumreturn=numreturn; |
5934 | onumreturn=numreturn; |
5932 | paramsize=0; |
5935 | paramsize=0; |
5933 | localsize=0; |
5936 | localsize=0; |
5934 | numblocks=0; //íîìåð âëîæåííîãî áëîêà |
5937 | numblocks=0; //íîìåð âëîæåííîãî áëîêà |
5935 | listreturn=NULL; |
5938 | listreturn=NULL; |
5936 | numreturn=0; |
5939 | numreturn=0; |
5937 | inlineflag=0; |
5940 | inlineflag=0; |
5938 | nextexpecting2(tk_openbracket); |
5941 | nextexpecting2(tk_openbracket); |
5939 | if(tok!=tk_closebracket){ |
5942 | if(tok!=tk_closebracket){ |
5940 | if((current_proc_type&f_typeproc)!=tp_fastcall)declareparams(); |
5943 | if((current_proc_type&f_typeproc)!=tp_fastcall)declareparams(); |
5941 | else declareparamreg(); |
5944 | else declareparamreg(); |
5942 | } |
5945 | } |
5943 | CorrectParamVar(); |
5946 | CorrectParamVar(); |
5944 | nexttok(); |
5947 | nexttok(); |
5945 | if(tok==tk_inline){ |
5948 | if(tok==tk_inline){ |
5946 | nexttok(); |
5949 | nexttok(); |
5947 | inlineflag=1; |
5950 | inlineflag=1; |
5948 | expecting(tk_openbrace); |
5951 | expecting(tk_openbrace); |
5949 | } |
5952 | } |
5950 | else{ |
5953 | else{ |
5951 | if((current_proc_type&f_typeproc)!=tp_fastcall&¶msize>0)Enter(); // PUSH BP MOV BP,SP |
5954 | if((current_proc_type&f_typeproc)!=tp_fastcall&¶msize>0)Enter(); // PUSH BP MOV BP,SP |
5952 | rec->recpost|=CheckUses(); |
5955 | rec->recpost|=CheckUses(); |
5953 | if(tok!=tk_openbrace)declarelocals(0); |
5956 | if(tok!=tk_openbrace)declarelocals(0); |
5954 | expecting(tk_openbrace); |
5957 | expecting(tk_openbrace); |
5955 | declarelocals(1); |
5958 | declarelocals(1); |
5956 | } |
5959 | } |
5957 | retproc=FALSE; |
5960 | retproc=FALSE; |
5958 | #ifdef OPTVARCONST |
5961 | #ifdef OPTVARCONST |
5959 | ClearLVIC(); |
5962 | ClearLVIC(); |
5960 | #endif |
5963 | #endif |
5961 | startblock(); |
5964 | startblock(); |
5962 | doblock2(); |
5965 | doblock2(); |
5963 | sizestack=osizestack; // do proc |
5966 | sizestack=osizestack; // do proc |
5964 | setreturn(); |
5967 | setreturn(); |
5965 | endblock(); |
5968 | endblock(); |
5966 | RestoreSaveReg(); |
5969 | RestoreSaveReg(); |
5967 | if(inlineflag==0&&(localsize||paramsize)&&(ESPloc==FALSE||am32==FALSE))Leave(); |
5970 | if(inlineflag==0&&(localsize||paramsize)&&(ESPloc==FALSE||am32==FALSE))Leave(); |
5968 | killlocals(/*0*/); |
5971 | killlocals(/*0*/); |
5969 | optimizespeed=ooptimizespeed; |
5972 | optimizespeed=ooptimizespeed; |
5970 | useinline=oinline; |
5973 | useinline=oinline; |
5971 | paramsize=oparamsize; |
5974 | paramsize=oparamsize; |
5972 | localsize=olocalsize; |
5975 | localsize=olocalsize; |
5973 | tlr=otlr; |
5976 | tlr=otlr; |
5974 | ltegtree=olteglist; |
5977 | ltegtree=olteglist; |
5975 | // lstructlist=olstructlist; |
5978 | // lstructlist=olstructlist; |
5976 | insertmode=oinsertmode; |
5979 | insertmode=oinsertmode; |
5977 | numblocks=onumblocks; |
5980 | numblocks=onumblocks; |
5978 | listreturn=olistreturn; |
5981 | listreturn=olistreturn; |
5979 | numreturn=onumreturn; |
5982 | numreturn=onumreturn; |
5980 | inlineflag=oinlineflag; |
5983 | inlineflag=oinlineflag; |
5981 | free(psavereg); |
5984 | free(psavereg); |
5982 | psavereg=osavr; |
5985 | psavereg=osavr; |
5983 | addESP=oaddESP; |
5986 | addESP=oaddESP; |
5984 | // nexttok(); |
5987 | // nexttok(); |
5985 | // printf("tok=%d\n",tok); |
5988 | // printf("tok=%d\n",tok); |
5986 | } |
5989 | } |
5987 | 5990 | ||
5988 | void AddTypeVar(int type,int pos) |
5991 | void AddTypeVar(int type,int pos) |
5989 | { |
5992 | { |
5990 | switch(type){ |
5993 | switch(type){ |
5991 | case tk_char: |
5994 | case tk_char: |
5992 | param[pos]='C'; |
5995 | param[pos]='C'; |
5993 | break; |
5996 | break; |
5994 | case tk_byte: |
5997 | case tk_byte: |
5995 | param[pos]='B'; |
5998 | param[pos]='B'; |
5996 | break; |
5999 | break; |
5997 | case tk_int: |
6000 | case tk_int: |
5998 | param[pos]='I'; |
6001 | param[pos]='I'; |
5999 | break; |
6002 | break; |
6000 | case tk_word: |
6003 | case tk_word: |
6001 | param[pos]='W'; |
6004 | param[pos]='W'; |
6002 | break; |
6005 | break; |
6003 | case tk_long: |
6006 | case tk_long: |
6004 | param[pos]='L'; |
6007 | param[pos]='L'; |
6005 | break; |
6008 | break; |
6006 | case tk_dword: |
6009 | case tk_dword: |
6007 | param[pos]='D'; |
6010 | param[pos]='D'; |
6008 | break; |
6011 | break; |
6009 | case tk_float: |
6012 | case tk_float: |
6010 | param[pos]='F'; |
6013 | param[pos]='F'; |
6011 | break; |
6014 | break; |
6012 | case tk_qword: |
6015 | case tk_qword: |
6013 | param[pos]='Q'; |
6016 | param[pos]='Q'; |
6014 | break; |
6017 | break; |
6015 | case tk_double: |
6018 | case tk_double: |
6016 | param[pos]='E'; |
6019 | param[pos]='E'; |
6017 | break; |
6020 | break; |
6018 | 6021 | ||
6019 | } |
6022 | } |
6020 | } |
6023 | } |
6021 | 6024 | ||
6022 | void declareparamreg() /* declare procedure parameters */ |
6025 | void declareparamreg() /* declare procedure parameters */ |
6023 | { |
6026 | { |
6024 | int i=0,num=1; |
6027 | int i=0,num=1; |
6025 | unsigned char j=0; |
6028 | unsigned char j=0; |
6026 | do{ |
6029 | do{ |
6027 | if(tok>=tk_char&&tok<=tk_double){ |
6030 | if(tok>=tk_char&&tok<=tk_double){ |
6028 | AddTypeVar(tok,i++); |
6031 | AddTypeVar(tok,i++); |
6029 | nexttok(); |
6032 | nexttok(); |
6030 | j=1; |
6033 | j=1; |
6031 | } |
6034 | } |
6032 | else{ |
6035 | else{ |
6033 | switch(tok){ |
6036 | switch(tok){ |
6034 | case tk_beg: |
6037 | case tk_beg: |
6035 | if(j==0)param[i++]='B'; |
6038 | if(j==0)param[i++]='B'; |
6036 | param[i++]=(char)(itok.number+0x30); |
6039 | param[i++]=(char)(itok.number+0x30); |
6037 | j=0; |
6040 | j=0; |
6038 | break; |
6041 | break; |
6039 | case tk_reg: |
6042 | case tk_reg: |
6040 | if(j==0)param[i++]='W'; |
6043 | if(j==0)param[i++]='W'; |
6041 | param[i++]=(char)(itok.number+0x30); |
6044 | param[i++]=(char)(itok.number+0x30); |
6042 | j=0; |
6045 | j=0; |
6043 | break; |
6046 | break; |
6044 | case tk_reg32: |
6047 | case tk_reg32: |
6045 | if(j==0)param[i++]='D'; |
6048 | if(j==0)param[i++]='D'; |
6046 | param[i++]=(char)(itok.number+0x30); |
6049 | param[i++]=(char)(itok.number+0x30); |
6047 | j=0; |
6050 | j=0; |
6048 | break; |
6051 | break; |
6049 | case tk_reg64: |
6052 | case tk_reg64: |
6050 | param[i++]='Q'; |
6053 | param[i++]='Q'; |
6051 | param[i++]=(char)((itok.number&255)+0x30); |
6054 | param[i++]=(char)((itok.number&255)+0x30); |
6052 | param[i++]=(char)((itok.number/256)+0x30); |
6055 | param[i++]=(char)((itok.number/256)+0x30); |
6053 | j=0; |
6056 | j=0; |
6054 | break; |
6057 | break; |
6055 | case tk_fpust: |
6058 | case tk_fpust: |
6056 | param[i++]='S'; |
6059 | param[i++]='S'; |
6057 | param[i++]=(char)(itok.number+0x30); |
6060 | param[i++]=(char)(itok.number+0x30); |
6058 | j=0; |
6061 | j=0; |
6059 | break; |
6062 | break; |
6060 | case tk_closebracket: |
6063 | case tk_closebracket: |
6061 | if(j==0)goto endproc; |
6064 | if(j==0)goto endproc; |
6062 | default: edpip(num); |
6065 | default: edpip(num); |
6063 | } |
6066 | } |
6064 | nexttok(); |
6067 | nexttok(); |
6065 | if(tok==tk_camma){ |
6068 | if(tok==tk_camma){ |
6066 | if(j!=0){ |
6069 | if(j!=0){ |
6067 | edpip(num); |
6070 | edpip(num); |
6068 | param[i++]='0'; |
6071 | param[i++]='0'; |
6069 | j=0; |
6072 | j=0; |
6070 | } |
6073 | } |
6071 | nexttok(); |
6074 | nexttok(); |
6072 | } |
6075 | } |
6073 | } |
6076 | } |
6074 | num++; |
6077 | num++; |
6075 | }while(tok!=tk_closebracket); |
6078 | }while(tok!=tk_closebracket); |
6076 | endproc: |
6079 | endproc: |
6077 | if(j!=0){ |
6080 | if(j!=0){ |
6078 | edpip(num-1); |
6081 | edpip(num-1); |
6079 | param[i++]='0'; |
6082 | param[i++]='0'; |
6080 | } |
6083 | } |
6081 | param[i]=0; |
6084 | param[i]=0; |
6082 | } |
6085 | } |
6083 | 6086 | ||
6084 | void AddMultiPoint(int pos) |
6087 | void AddMultiPoint(int pos) |
6085 | { |
6088 | { |
6086 | param[pos]='A'; |
6089 | param[pos]='A'; |
6087 | nexttok(); |
6090 | nexttok(); |
6088 | if(tok!=tk_closebracket)SwTok(tk_closebracket); |
6091 | if(tok!=tk_closebracket)SwTok(tk_closebracket); |
6089 | } |
6092 | } |
6090 | 6093 | ||
6091 | void declareparamstack() /* declare procedure parameters */ |
6094 | void declareparamstack() /* declare procedure parameters */ |
6092 | { |
6095 | { |
6093 | int i=0,num=1; |
6096 | int i=0,num=1; |
6094 | unsigned char j=0; |
6097 | unsigned char j=0; |
6095 | /* |
6098 | /* |
6096 | 1 - îáúÿâëåí òèï |
6099 | 1 - îáúÿâëåí òèï |
6097 | 2 - áûëà çàïÿòàÿ |
6100 | 2 - áûëà çàïÿòàÿ |
6098 | 3 - áûëà òî÷êà ñ çàïÿòîé |
6101 | 3 - áûëà òî÷êà ñ çàïÿòîé |
6099 | 4 - |
6102 | 4 - |
6100 | 5 - áûë èäåíòèôèêàòîð |
6103 | 5 - áûë èäåíòèôèêàòîð |
6101 | 6 - òèï void |
6104 | 6 - òèï void |
6102 | */ |
6105 | */ |
6103 | int typevar=tk_multipoint; |
6106 | int typevar=tk_multipoint; |
6104 | structteg *tteg=NULL; |
6107 | structteg *tteg=NULL; |
6105 | int size; |
6108 | int size; |
6106 | do{ |
6109 | do{ |
6107 | if(tok==tk_struct)nexttok(); |
6110 | if(tok==tk_struct)nexttok(); |
6108 | if(tok>=tk_char&&tok<=tk_double){ |
6111 | if(tok>=tk_char&&tok<=tk_double){ |
6109 | if(j>3||j==1)edpip(num); |
6112 | if(j>3||j==1)edpip(num); |
6110 | j=1; |
6113 | j=1; |
6111 | typevar=tok; |
6114 | typevar=tok; |
6112 | nexttok(); |
6115 | nexttok(); |
6113 | } |
6116 | } |
6114 | else if((tteg=FindTeg(TRUE))!=NULL){ |
6117 | else if((tteg=FindTeg(TRUE))!=NULL){ |
6115 | size=Align(tteg->size,(am32+1)*2); |
6118 | size=Align(tteg->size,(am32+1)*2); |
6116 | // printf("%s size=%u\n",itok.name,size); |
6119 | // printf("%s size=%u\n",itok.name,size); |
6117 | j=1; |
6120 | j=1; |
6118 | typevar=tk_struct; |
6121 | typevar=tk_struct; |
6119 | nexttok(); |
6122 | nexttok(); |
6120 | } |
6123 | } |
6121 | while(tok==tk_mult){ |
6124 | while(tok==tk_mult){ |
6122 | param[i++]='*'; |
6125 | param[i++]='*'; |
6123 | nexttok(); |
6126 | nexttok(); |
6124 | } |
6127 | } |
6125 | if(tok==tk_camma){ |
6128 | if(tok==tk_camma){ |
6126 | if(j==1){ |
6129 | if(j==1){ |
6127 | if(typevar==tk_struct)i+=sprintf(¶m[i],"T%u",size); |
6130 | if(typevar==tk_struct)i+=sprintf(¶m[i],"T%u",size); |
6128 | else AddTypeVar(typevar,i++); |
6131 | else AddTypeVar(typevar,i++); |
6129 | } |
6132 | } |
6130 | else if(j!=5)edpip(num); |
6133 | else if(j!=5)edpip(num); |
6131 | j=2; |
6134 | j=2; |
6132 | num++; |
6135 | num++; |
6133 | } |
6136 | } |
6134 | else if(tok==tk_semicolon){ |
6137 | else if(tok==tk_semicolon){ |
6135 | if(j==1){ |
6138 | if(j==1){ |
6136 | if(typevar==tk_struct)i+=sprintf(¶m[i],"T%u",size); |
6139 | if(typevar==tk_struct)i+=sprintf(¶m[i],"T%u",size); |
6137 | else AddTypeVar(typevar,i++); |
6140 | else AddTypeVar(typevar,i++); |
6138 | } |
6141 | } |
6139 | else if(j!=5)edpip(num); |
6142 | else if(j!=5)edpip(num); |
6140 | j=3; |
6143 | j=3; |
6141 | num++; |
6144 | num++; |
6142 | } |
6145 | } |
6143 | else if(tok==tk_multipoint){ |
6146 | else if(tok==tk_multipoint){ |
6144 | AddMultiPoint(i++); |
6147 | AddMultiPoint(i++); |
6145 | break; |
6148 | break; |
6146 | } |
6149 | } |
6147 | else if(tok==tk_closebracket){ |
6150 | else if(tok==tk_closebracket){ |
6148 | if(j==0)param[i++]='A'; |
6151 | if(j==0)param[i++]='A'; |
6149 | else if(j==1){ |
6152 | else if(j==1){ |
6150 | if(typevar==tk_struct)i+=sprintf(¶m[i],"T%u",size); |
6153 | if(typevar==tk_struct)i+=sprintf(¶m[i],"T%u",size); |
6151 | else AddTypeVar(typevar,i++); |
6154 | else AddTypeVar(typevar,i++); |
6152 | } |
6155 | } |
6153 | else if(j<4)edpip(num); |
6156 | else if(j<4)edpip(num); |
6154 | break; |
6157 | break; |
6155 | } |
6158 | } |
6156 | else if(tok==tk_void){ |
6159 | else if(tok==tk_void){ |
6157 | if(j!=0)edpip(num); |
6160 | if(j!=0)edpip(num); |
6158 | param[i++]='V'; |
6161 | param[i++]='V'; |
6159 | j=6; |
6162 | j=6; |
6160 | } |
6163 | } |
6161 | else if(tok==tk_beg||tok==tk_reg||tok==tk_reg32||tok==tk_reg64||tok==tk_fpust){ |
6164 | else if(tok==tk_beg||tok==tk_reg||tok==tk_reg32||tok==tk_reg64||tok==tk_fpust){ |
6162 | if(j==1){ |
6165 | if(j==1){ |
6163 | if(typevar==tk_struct)i+=sprintf(¶m[i],"T%u",size); |
6166 | if(typevar==tk_struct)i+=sprintf(¶m[i],"T%u",size); |
6164 | else AddTypeVar(typevar,i++); |
6167 | else AddTypeVar(typevar,i++); |
6165 | } |
6168 | } |
6166 | else if(j<4){ |
6169 | else if(j<4){ |
6167 | switch(tok){ |
6170 | switch(tok){ |
6168 | case tk_beg: param[i++]='B'; break; |
6171 | case tk_beg: param[i++]='B'; break; |
6169 | case tk_reg: param[i++]='W'; break; |
6172 | case tk_reg: param[i++]='W'; break; |
6170 | case tk_reg32: param[i++]='D'; break; |
6173 | case tk_reg32: param[i++]='D'; break; |
6171 | case tk_fpust: param[i++]='S'; break; |
6174 | case tk_fpust: param[i++]='S'; break; |
6172 | case tk_reg64: |
6175 | case tk_reg64: |
6173 | param[i++]='Q'; |
6176 | param[i++]='Q'; |
6174 | param[i++]=(char)((itok.number&255)+0x30); |
6177 | param[i++]=(char)((itok.number&255)+0x30); |
6175 | itok.number/=256; |
6178 | itok.number/=256; |
6176 | break; |
6179 | break; |
6177 | } |
6180 | } |
6178 | } |
6181 | } |
6179 | else edpip(num); |
6182 | else edpip(num); |
6180 | param[i++]=(char)(itok.number+0x30); |
6183 | param[i++]=(char)(itok.number+0x30); |
6181 | j=5; |
6184 | j=5; |
6182 | } |
6185 | } |
6183 | else{ |
6186 | else{ |
6184 | if(j==1||j==2){ |
6187 | if(j==1||j==2){ |
6185 | if(typevar==tk_struct)i+=sprintf(¶m[i],"T%u",size); |
6188 | if(typevar==tk_struct)i+=sprintf(¶m[i],"T%u",size); |
6186 | else AddTypeVar(typevar,i++); |
6189 | else AddTypeVar(typevar,i++); |
6187 | } |
6190 | } |
6188 | else edpip(num); |
6191 | else edpip(num); |
6189 | j=5; |
6192 | j=5; |
6190 | } |
6193 | } |
6191 | nexttok(); |
6194 | nexttok(); |
6192 | }while(tok!=tk_eof); |
6195 | }while(tok!=tk_eof); |
6193 | param[i]=0; |
6196 | param[i]=0; |
6194 | // puts(param); |
6197 | // puts(param); |
6195 | } |
6198 | } |
6196 | 6199 | ||
6197 | void CorrectParamVar() |
6200 | void CorrectParamVar() |
6198 | { |
6201 | { |
6199 | unsigned int addnum; |
6202 | unsigned int addnum; |
6200 | int fspin; |
6203 | int fspin; |
6201 | struct localrec *ptr; |
6204 | struct localrec *ptr; |
6202 | if(paramsize==0)return; |
6205 | if(paramsize==0)return; |
6203 | if(insertmode)addnum=0; //ret-address |
6206 | if(insertmode)addnum=0; //ret-address |
6204 | else addnum=2; |
6207 | else addnum=2; |
6205 | if(ESPloc==FALSE||am32==FALSE)addnum+=2; //EBP |
6208 | if(ESPloc==FALSE||am32==FALSE)addnum+=2; //EBP |
6206 | if((current_proc_type&f_far))addnum+=2;// move over seg on stack |
6209 | if((current_proc_type&f_far))addnum+=2;// move over seg on stack |
6207 | if(am32)addnum*=2; |
6210 | if(am32)addnum*=2; |
6208 | if((current_proc_type&f_typeproc)==tp_cdecl||(current_proc_type&f_typeproc)==tp_stdcall)fspin=FALSE; |
6211 | if((current_proc_type&f_typeproc)==tp_cdecl||(current_proc_type&f_typeproc)==tp_stdcall)fspin=FALSE; |
6209 | else fspin=TRUE; |
6212 | else fspin=TRUE; |
6210 | treelocalrec *ntlr=tlr; |
6213 | treelocalrec *ntlr=tlr; |
6211 | while(ntlr&&ntlr->level>1)ntlr=ntlr->next; |
6214 | while(ntlr&&ntlr->level>1)ntlr=ntlr->next; |
6212 | for(ptr=ntlr->lrec;;ptr=ptr->rec.next){ |
6215 | for(ptr=ntlr->lrec;;ptr=ptr->rec.next){ |
6213 | if(ptr->rec.type==tp_paramvar){ |
6216 | if(ptr->rec.type==tp_paramvar){ |
6214 | if(fspin)ptr->rec.recnumber=paramsize-ptr->rec.recnumber-Align(ptr->rec.recsize,am32==FALSE?2:4); |
6217 | if(fspin)ptr->rec.recnumber=paramsize-ptr->rec.recnumber-Align(ptr->rec.recsize,am32==FALSE?2:4); |
6215 | ptr->rec.recnumber+=addnum; |
6218 | ptr->rec.recnumber+=addnum; |
6216 | } |
6219 | } |
6217 | if(ptr->rec.next==NULL)break; |
6220 | if(ptr->rec.next==NULL)break; |
6218 | } |
6221 | } |
6219 | } |
6222 | } |
6220 | 6223 | ||
6221 | void declareparams() /* declare procedure parameters */ |
6224 | void declareparams() /* declare procedure parameters */ |
6222 | { |
6225 | { |
6223 | int paramtok,sparamtok,i=0,type; |
6226 | int paramtok,sparamtok,i=0,type; |
6224 | char flag=33; |
6227 | char flag=33; |
6225 | int numpointr; |
6228 | int numpointr; |
6226 | localrec *lrec; |
6229 | localrec *lrec; |
6227 | structteg *tteg=NULL,*nteg; |
6230 | structteg *tteg=NULL,*nteg; |
6228 | do{ |
6231 | do{ |
6229 | if(flag!=33)nexttok(); |
6232 | if(flag!=33)nexttok(); |
6230 | flag=1; |
6233 | flag=1; |
6231 | if(tok==tk_multipoint){ |
6234 | if(tok==tk_multipoint){ |
6232 | AddMultiPoint(i++); |
6235 | AddMultiPoint(i++); |
6233 | break; |
6236 | break; |
6234 | } |
6237 | } |
6235 | if(tok==tk_void){ |
6238 | if(tok==tk_void){ |
6236 | param[i++]='V'; |
6239 | param[i++]='V'; |
6237 | nexttok(); |
6240 | nexttok(); |
6238 | if(tok!=tk_closebracket)SwTok(tk_closebracket); |
6241 | if(tok!=tk_closebracket)SwTok(tk_closebracket); |
6239 | break; |
6242 | break; |
6240 | } |
6243 | } |
6241 | if(tok>=tk_char&&tok<=tk_double){ |
6244 | if(tok>=tk_char&&tok<=tk_double){ |
6242 | type=tok; |
6245 | type=tok; |
6243 | SetNewTok(tok,variable); |
6246 | SetNewTok(tok,variable); |
6244 | paramtok=tok; |
6247 | paramtok=tok; |
6245 | } |
6248 | } |
6246 | else if(tok==tk_beg||tok==tk_reg||tok==tk_reg32||tok==tk_reg64||tok==tk_fpust)flag=3; |
6249 | else if(tok==tk_beg||tok==tk_reg||tok==tk_reg32||tok==tk_reg64||tok==tk_fpust)flag=3; |
6247 | else{ |
6250 | else{ |
6248 | if(tok==tk_struct)nexttok(); |
6251 | if(tok==tk_struct)nexttok(); |
6249 | if((tteg=FindTeg(TRUE))!=NULL)paramtok=tk_struct; |
6252 | if((tteg=FindTeg(TRUE))!=NULL)paramtok=tk_struct; |
6250 | else{ |
6253 | else{ |
6251 | datatype_expected(); |
6254 | datatype_expected(); |
6252 | flag=0; |
6255 | flag=0; |
6253 | nexttok(); |
6256 | nexttok(); |
6254 | } |
6257 | } |
6255 | } |
6258 | } |
6256 | if(flag){ |
6259 | if(flag){ |
6257 | do{ |
6260 | do{ |
6258 | numpointr=0; |
6261 | numpointr=0; |
6259 | skipfind=TRUE; |
6262 | skipfind=TRUE; |
6260 | if(flag!=3)nexttok(); |
6263 | if(flag!=3)nexttok(); |
6261 | while(tok==tk_mult){ |
6264 | while(tok==tk_mult){ |
6262 | nexttok(); |
6265 | nexttok(); |
6263 | numpointr++; |
6266 | numpointr++; |
6264 | param[i++]='*'; |
6267 | param[i++]='*'; |
6265 | } |
6268 | } |
6266 | if(tok==tk_id||tok==tk_ID){ //ïðîâåðèòü íà òèïû îïðåäåëåííûå ÷åðåç define |
6269 | if(tok==tk_id||tok==tk_ID){ //ïðîâåðèòü íà òèïû îïðåäåëåííûå ÷åðåç define |
6267 | skipfind=FALSE; |
6270 | skipfind=FALSE; |
6268 | int otok=tok; |
6271 | int otok=tok; |
6269 | searchtree(&ptok,&otok,string); |
6272 | searchtree(&ptok,&otok,string); |
6270 | if(otok>=tk_char&&otok<=tk_double){ |
6273 | if(otok>=tk_char&&otok<=tk_double){ |
6271 | tok=otok; |
6274 | tok=otok; |
6272 | itok=ptok; |
6275 | itok=ptok; |
6273 | } |
6276 | } |
6274 | skipfind=TRUE; |
6277 | skipfind=TRUE; |
6275 | } |
6278 | } |
6276 | if(tok==tk_struct){ |
6279 | if(tok==tk_struct){ |
6277 | nexttok(); |
6280 | nexttok(); |
6278 | if((tteg=FindTeg(TRUE))!=NULL){ |
6281 | if((tteg=FindTeg(TRUE))!=NULL){ |
6279 | paramtok=tk_struct; |
6282 | paramtok=tk_struct; |
6280 | nexttok(); |
6283 | nexttok(); |
6281 | } |
6284 | } |
6282 | else{ |
6285 | else{ |
6283 | edpip(); |
6286 | edpip(); |
6284 | nexttok(); |
6287 | nexttok(); |
6285 | goto endparam1; |
6288 | goto endparam1; |
6286 | } |
6289 | } |
6287 | } |
6290 | } |
6288 | else { |
6291 | else { |
6289 | if((nteg=FindTeg(TRUE))!=NULL){ |
6292 | if((nteg=FindTeg(TRUE))!=NULL){ |
6290 | tteg=nteg; |
6293 | tteg=nteg; |
6291 | paramtok=tk_struct; |
6294 | paramtok=tk_struct; |
6292 | nexttok(); |
6295 | nexttok(); |
6293 | } |
6296 | } |
6294 | else{ |
6297 | else{ |
6295 | if(tok>=tk_char&&tok<=tk_double){ |
6298 | if(tok>=tk_char&&tok<=tk_double){ |
6296 | type=tok; |
6299 | type=tok; |
6297 | SetNewTok(tok,variable); |
6300 | SetNewTok(tok,variable); |
6298 | paramtok=tok; |
6301 | paramtok=tok; |
6299 | nexttok(); |
6302 | nexttok(); |
6300 | while(tok==tk_mult){ |
6303 | while(tok==tk_mult){ |
6301 | nexttok(); |
6304 | nexttok(); |
6302 | numpointr++; |
6305 | numpointr++; |
6303 | param[i++]='*'; |
6306 | param[i++]='*'; |
6304 | } |
6307 | } |
6305 | flag=2; |
6308 | flag=2; |
6306 | } |
6309 | } |
6307 | skipfind=FALSE; |
6310 | skipfind=FALSE; |
6308 | if(tok==tk_beg||tok==tk_reg||tok==tk_reg32||tok==tk_reg64||tok==tk_fpust){ |
6311 | if(tok==tk_beg||tok==tk_reg||tok==tk_reg32||tok==tk_reg64||tok==tk_fpust){ |
6309 | if(flag==2)AddTypeVar(type,i++); |
6312 | if(flag==2)AddTypeVar(type,i++); |
6310 | else{ |
6313 | else{ |
6311 | switch(tok){ |
6314 | switch(tok){ |
6312 | case tk_beg: param[i++]='B'; break; |
6315 | case tk_beg: param[i++]='B'; break; |
6313 | case tk_reg: param[i++]='W'; break; |
6316 | case tk_reg: param[i++]='W'; break; |
6314 | case tk_reg32: param[i++]='D'; break; |
6317 | case tk_reg32: param[i++]='D'; break; |
6315 | case tk_fpust: param[i++]='S'; break; |
6318 | case tk_fpust: param[i++]='S'; break; |
6316 | case tk_reg64: |
6319 | case tk_reg64: |
6317 | param[i++]='Q'; |
6320 | param[i++]='Q'; |
6318 | param[i++]=(char)((itok.number&255)+0x30); |
6321 | param[i++]=(char)((itok.number&255)+0x30); |
6319 | itok.number/=256; |
6322 | itok.number/=256; |
6320 | break; |
6323 | break; |
6321 | } |
6324 | } |
6322 | } |
6325 | } |
6323 | param[i++]=(unsigned char)(itok.number+0x30); |
6326 | param[i++]=(unsigned char)(itok.number+0x30); |
6324 | flag=1; |
6327 | flag=1; |
6325 | goto endparam1; |
6328 | goto endparam1; |
6326 | } |
6329 | } |
6327 | } |
6330 | } |
6328 | } |
6331 | } |
6329 | sparamtok=paramtok; |
6332 | sparamtok=paramtok; |
6330 | if(tok==tk_multipoint){ |
6333 | if(tok==tk_multipoint){ |
6331 | AddMultiPoint(i++); |
6334 | AddMultiPoint(i++); |
6332 | break; |
6335 | break; |
6333 | } |
6336 | } |
6334 | if(tok!=tk_ID&&tok!=tk_id){ |
6337 | if(tok!=tk_ID&&tok!=tk_id){ |
6335 | idalreadydefined(); |
6338 | idalreadydefined(); |
6336 | break; |
6339 | break; |
6337 | } |
6340 | } |
6338 | int lsize; |
6341 | int lsize; |
6339 | if(am32)lsize=4; |
6342 | if(am32)lsize=4; |
6340 | else{ |
6343 | else{ |
6341 | lsize=2; |
6344 | lsize=2; |
6342 | if(sparamtok>=tk_longvar&&sparamtok<=tk_floatvar&&numpointr==0) |
6345 | if(sparamtok>=tk_longvar&&sparamtok<=tk_floatvar&&numpointr==0) |
6343 | lsize+=2;//add 2 more bytes |
6346 | lsize+=2;//add 2 more bytes |
6344 | } |
6347 | } |
6345 | if((sparamtok==tk_qwordvar||sparamtok==tk_doublevar)&&numpointr==0)lsize=8; |
6348 | if((sparamtok==tk_qwordvar||sparamtok==tk_doublevar)&&numpointr==0)lsize=8; |
6346 | AddTypeVar(type,i++); |
6349 | AddTypeVar(type,i++); |
6347 | if(sparamtok==tk_struct){ |
6350 | if(sparamtok==tk_struct){ |
6348 | //idrec *newrec,*trec; |
6351 | //idrec *newrec,*trec; |
6349 | lsize=Align(tteg->size,(am32+1)*2); |
6352 | lsize=Align(tteg->size,(am32+1)*2); |
6350 | i+=sprintf(¶m[i],"T%u",lsize); |
6353 | i+=sprintf(¶m[i],"T%u",lsize); |
6351 | // newrec=(struct idrec *)MALLOC(sizeof(struct idrec)); |
6354 | // newrec=(struct idrec *)MALLOC(sizeof(struct idrec)); |
6352 | // if(lstructlist==NULL)lstructlist=newrec; |
6355 | // if(lstructlist==NULL)lstructlist=newrec; |
6353 | // else{ |
6356 | // else{ |
6354 | // trec=lstructlist; |
6357 | // trec=lstructlist; |
6355 | // while(trec->left!=NULL)trec=trec->left; |
6358 | // while(trec->left!=NULL)trec=trec->left; |
6356 | // trec->left=newrec; |
6359 | // trec->left=newrec; |
6357 | // } |
6360 | // } |
6358 | // newrec->right=newrec->left=NULL; |
6361 | // newrec->right=newrec->left=NULL; |
6359 | lrec=addlocalvar(itok.name,tk_structvar,paramsize); |
6362 | lrec=addlocalvar(itok.name,tk_structvar,paramsize); |
6360 | lrec->rec.newid=(char *)tteg; |
6363 | lrec->rec.newid=(char *)tteg; |
6361 | lrec->rec.flag=tteg->flag; |
6364 | lrec->rec.flag=tteg->flag; |
6362 | lrec->rec.recrm=1; |
6365 | lrec->rec.recrm=1; |
6363 | lrec->rec.recpost=LOCAL; |
6366 | lrec->rec.recpost=LOCAL; |
6364 | goto endparam; |
6367 | goto endparam; |
6365 | } |
6368 | } |
6366 | lrec=addlocalvar(itok.name,sparamtok,paramsize); |
6369 | lrec=addlocalvar(itok.name,sparamtok,paramsize); |
6367 | lrec->rec.npointr=(unsigned short)numpointr; |
6370 | lrec->rec.npointr=(unsigned short)numpointr; |
6368 | endparam: |
6371 | endparam: |
6369 | lrec->rec.type=tp_paramvar; |
6372 | lrec->rec.type=tp_paramvar; |
6370 | lrec->rec.recsize=lsize; |
6373 | lrec->rec.recsize=lsize; |
6371 | paramsize+=lsize; |
6374 | paramsize+=lsize; |
6372 | endparam1: |
6375 | endparam1: |
6373 | nexttok(); |
6376 | nexttok(); |
6374 | }while(tok==tk_camma); |
6377 | }while(tok==tk_camma); |
6375 | } |
6378 | } |
6376 | }while(tok==tk_semicolon); |
6379 | }while(tok==tk_semicolon); |
6377 | param[i]=0; |
6380 | param[i]=0; |
6378 | // puts(param); |
6381 | // puts(param); |
6379 | } |
6382 | } |
6380 | 6383 | ||
6381 | void CharToBackBuf(char c) |
6384 | void CharToBackBuf(char c) |
6382 | { |
6385 | { |
6383 | if(SizeBackBuf==0){ |
6386 | if(SizeBackBuf==0){ |
6384 | MaxSizeBackBuf=STRLEN; |
6387 | MaxSizeBackBuf=STRLEN; |
6385 | BackTextBlock=(char *)MALLOC(STRLEN); |
6388 | BackTextBlock=(char *)MALLOC(STRLEN); |
6386 | } |
6389 | } |
6387 | else if(SizeBackBuf==MaxSizeBackBuf){ |
6390 | else if(SizeBackBuf==MaxSizeBackBuf){ |
6388 | MaxSizeBackBuf+=STRLEN; |
6391 | MaxSizeBackBuf+=STRLEN; |
6389 | BackTextBlock=(char *)REALLOC(BackTextBlock,MaxSizeBackBuf); |
6392 | BackTextBlock=(char *)REALLOC(BackTextBlock,MaxSizeBackBuf); |
6390 | } |
6393 | } |
6391 | BackTextBlock[SizeBackBuf++]=c; |
6394 | BackTextBlock[SizeBackBuf++]=c; |
6392 | } |
6395 | } |
6393 | 6396 | ||
6394 | void AddBackBuf(int oinptr,char ocha) |
6397 | void AddBackBuf(int oinptr,char ocha) |
6395 | //ñîçäàòü ëèñòèíã íà÷àëüíîé èíèöèàëèçàöèè ëîñàëüíûõ ïåðåìåííûõ |
6398 | //ñîçäàòü ëèñòèíã íà÷àëüíîé èíèöèàëèçàöèè ëîñàëüíûõ ïåðåìåííûõ |
6396 | { |
6399 | { |
6397 | int numblock=0; |
6400 | int numblock=0; |
6398 | unsigned char save; |
6401 | unsigned char save; |
6399 | char bcha; |
6402 | char bcha; |
6400 | inptr=oinptr; |
6403 | inptr=oinptr; |
6401 | cha=ocha; |
6404 | cha=ocha; |
6402 | for(;;){ |
6405 | for(;;){ |
6403 | save=TRUE; |
6406 | save=TRUE; |
6404 | switch(cha){ |
6407 | switch(cha){ |
6405 | case '(': |
6408 | case '(': |
6406 | case '{': |
6409 | case '{': |
6407 | case '[': |
6410 | case '[': |
6408 | numblock++; |
6411 | numblock++; |
6409 | break; |
6412 | break; |
6410 | case ')': |
6413 | case ')': |
6411 | case '}': |
6414 | case '}': |
6412 | case ']': |
6415 | case ']': |
6413 | numblock--; |
6416 | numblock--; |
6414 | if(numblock<0)return; |
6417 | if(numblock<0)return; |
6415 | break; |
6418 | break; |
6416 | case ',': |
6419 | case ',': |
6417 | if(numblock>0)break; |
6420 | if(numblock>0)break; |
6418 | tok=tk_camma; |
6421 | tok=tk_camma; |
6419 | goto endp; |
6422 | goto endp; |
6420 | case ';': |
6423 | case ';': |
6421 | case 26: |
6424 | case 26: |
6422 | tok=tk_semicolon; |
6425 | tok=tk_semicolon; |
6423 | endp: |
6426 | endp: |
6424 | CharToBackBuf(';'); |
6427 | CharToBackBuf(';'); |
6425 | nextchar(); |
6428 | nextchar(); |
6426 | inptr2=inptr; |
6429 | inptr2=inptr; |
6427 | cha2=cha; |
6430 | cha2=cha; |
6428 | return; |
6431 | return; |
6429 | case '/': //îòñëåäèòü êîììåíòàðèè |
6432 | case '/': //îòñëåäèòü êîììåíòàðèè |
6430 | nextchar(); |
6433 | nextchar(); |
6431 | if(cha=='*'){ |
6434 | if(cha=='*'){ |
6432 | do{ |
6435 | do{ |
6433 | nextchar(); |
6436 | nextchar(); |
6434 | if(cha=='*'){ |
6437 | if(cha=='*'){ |
6435 | nextchar(); |
6438 | nextchar(); |
6436 | if(cha=='/'){ |
6439 | if(cha=='/'){ |
6437 | save=FALSE; |
6440 | save=FALSE; |
6438 | break; |
6441 | break; |
6439 | } |
6442 | } |
6440 | } |
6443 | } |
6441 | }while(cha!=26); |
6444 | }while(cha!=26); |
6442 | } |
6445 | } |
6443 | else if(cha=='/'){ |
6446 | else if(cha=='/'){ |
6444 | do{ |
6447 | do{ |
6445 | nextchar(); |
6448 | nextchar(); |
6446 | }while(cha!=13&&cha!=26); |
6449 | }while(cha!=13&&cha!=26); |
6447 | } |
6450 | } |
6448 | else CharToBackBuf('/'); |
6451 | else CharToBackBuf('/'); |
6449 | break; |
6452 | break; |
6450 | case '"': |
6453 | case '"': |
6451 | case '\'': |
6454 | case '\'': |
6452 | bcha=cha; |
6455 | bcha=cha; |
6453 | do{ |
6456 | do{ |
6454 | CharToBackBuf(cha); |
6457 | CharToBackBuf(cha); |
6455 | nextchar(); |
6458 | nextchar(); |
6456 | if(cha=='\\'){ |
6459 | if(cha=='\\'){ |
6457 | CharToBackBuf(cha); |
6460 | CharToBackBuf(cha); |
6458 | nextchar(); |
6461 | nextchar(); |
6459 | CharToBackBuf(cha); |
6462 | CharToBackBuf(cha); |
6460 | nextchar(); |
6463 | nextchar(); |
6461 | } |
6464 | } |
6462 | }while(cha!=bcha); |
6465 | }while(cha!=bcha); |
6463 | break; |
6466 | break; |
6464 | } |
6467 | } |
6465 | if(save)CharToBackBuf(cha); |
6468 | if(save)CharToBackBuf(cha); |
6466 | nextchar(); |
6469 | nextchar(); |
6467 | } |
6470 | } |
6468 | } |
6471 | } |
6469 | 6472 | ||
6470 | void RunBackText() |
6473 | void RunBackText() |
6471 | { |
6474 | { |
6472 | ITOK oitok,ostructadr; |
6475 | ITOK oitok,ostructadr; |
6473 | SINFO ostr; |
6476 | SINFO ostr; |
6474 | unsigned char *oldinput; |
6477 | unsigned char *oldinput; |
6475 | unsigned int oldinptr,oldendinptr; |
6478 | unsigned int oldinptr,oldendinptr; |
6476 | unsigned char bcha; |
6479 | unsigned char bcha; |
6477 | int otok,otok2; |
6480 | int otok,otok2; |
6478 | char *ostartline; |
6481 | char *ostartline; |
6479 | char *ostring,*obufrm; |
6482 | char *ostring,*obufrm; |
6480 | COM_MOD *ocurmod; |
6483 | COM_MOD *ocurmod; |
6481 | ostring=BackString((char *)string); |
6484 | ostring=BackString((char *)string); |
6482 | oldinput=input; //ñîõð íåêîòîð ïåðåìåíûå |
6485 | oldinput=input; //ñîõð íåêîòîð ïåðåìåíûå |
6483 | oldinptr=inptr2; |
6486 | oldinptr=inptr2; |
6484 | ostructadr=structadr; |
6487 | ostructadr=structadr; |
6485 | bcha=cha2; |
6488 | bcha=cha2; |
6486 | oldendinptr=endinptr; |
6489 | oldendinptr=endinptr; |
6487 | otok=tok; |
6490 | otok=tok; |
6488 | otok2=tok2; |
6491 | otok2=tok2; |
6489 | oitok=itok; |
6492 | oitok=itok; |
6490 | ostr=strinf; |
6493 | ostr=strinf; |
6491 | strinf.bufstr=NULL; |
6494 | strinf.bufstr=NULL; |
6492 | obufrm=bufrm; |
6495 | obufrm=bufrm; |
6493 | bufrm=NULL; |
6496 | bufrm=NULL; |
6494 | 6497 | ||
6495 | ocurmod=cur_mod; |
6498 | ocurmod=cur_mod; |
6496 | cur_mod=NULL; |
6499 | cur_mod=NULL; |
6497 | 6500 | ||
6498 | input=(unsigned char *)BackTextBlock; |
6501 | input=(unsigned char *)BackTextBlock; |
6499 | inptr2=1; |
6502 | inptr2=1; |
6500 | cha2=input[0]; |
6503 | cha2=input[0]; |
6501 | tok=tk_openbrace; |
6504 | tok=tk_openbrace; |
6502 | SizeBackBuf=0; |
6505 | SizeBackBuf=0; |
6503 | ostartline=startline; |
6506 | ostartline=startline; |
6504 | startline=(char*)input; |
6507 | startline=(char*)input; |
6505 | endinptr=strlen((char *)input); |
6508 | endinptr=strlen((char *)input); |
6506 | endinput=startline+endinptr; |
6509 | endinput=startline+endinptr; |
6507 | 6510 | ||
6508 | doblock(); |
6511 | doblock(); |
6509 | 6512 | ||
6510 | endoffile=0; |
6513 | endoffile=0; |
6511 | startline=ostartline; |
6514 | startline=ostartline; |
6512 | strinf=ostr; |
6515 | strinf=ostr; |
6513 | free(input); |
6516 | free(input); |
6514 | input=oldinput; |
6517 | input=oldinput; |
6515 | inptr2=oldinptr; |
6518 | inptr2=oldinptr; |
6516 | cha2=bcha; |
6519 | cha2=bcha; |
6517 | endinptr=oldendinptr; |
6520 | endinptr=oldendinptr; |
6518 | tok=otok; |
6521 | tok=otok; |
6519 | itok=oitok; |
6522 | itok=oitok; |
6520 | if(bufrm)free(bufrm); |
6523 | if(bufrm)free(bufrm); |
6521 | bufrm=obufrm; |
6524 | bufrm=obufrm; |
6522 | tok2=otok2; |
6525 | tok2=otok2; |
6523 | strcpy((char *)string,ostring); |
6526 | strcpy((char *)string,ostring); |
6524 | if(strinf.bufstr)free(strinf.bufstr); |
6527 | if(strinf.bufstr)free(strinf.bufstr); |
6525 | structadr=ostructadr; |
6528 | structadr=ostructadr; |
6526 | free(ostring); |
6529 | free(ostring); |
6527 | 6530 | ||
6528 | cur_mod=ocurmod; |
6531 | cur_mod=ocurmod; |
6529 | } |
6532 | } |
6530 | 6533 | ||
6531 | int PushLocInit(int ofs) |
6534 | int PushLocInit(int ofs) |
6532 | { |
6535 | { |
6533 | ITOK oitok,ostructadr,wtok; |
6536 | ITOK oitok,ostructadr,wtok; |
6534 | SINFO ostr; |
6537 | SINFO ostr; |
6535 | unsigned char *oldinput; |
6538 | unsigned char *oldinput; |
6536 | unsigned int oldinptr,oldendinptr; |
6539 | unsigned int oldinptr,oldendinptr; |
6537 | unsigned char bcha; |
6540 | unsigned char bcha; |
6538 | int otok,otok2; |
6541 | int otok,otok2; |
6539 | char *ostartline; |
6542 | char *ostartline; |
6540 | char *ostring,*obufrm; |
6543 | char *ostring,*obufrm; |
6541 | int retcode=FALSE; |
6544 | int retcode=FALSE; |
6542 | // if(bufrm)puts(bufrm); |
6545 | // if(bufrm)puts(bufrm); |
6543 | ostring=BackString((char *)string); |
6546 | ostring=BackString((char *)string); |
6544 | oldinput=input; //ñîõð íåêîòîð ïåðåìåíûå |
6547 | oldinput=input; //ñîõð íåêîòîð ïåðåìåíûå |
6545 | oldinptr=inptr2; |
6548 | oldinptr=inptr2; |
6546 | ostructadr=structadr; |
6549 | ostructadr=structadr; |
6547 | bcha=cha2; |
6550 | bcha=cha2; |
6548 | oldendinptr=endinptr; |
6551 | oldendinptr=endinptr; |
6549 | otok=tok; |
6552 | otok=tok; |
6550 | otok2=tok2; |
6553 | otok2=tok2; |
6551 | oitok=itok; |
6554 | oitok=itok; |
6552 | ostr=strinf; |
6555 | ostr=strinf; |
6553 | strinf.bufstr=NULL; |
6556 | strinf.bufstr=NULL; |
6554 | obufrm=bufrm; |
6557 | obufrm=bufrm; |
6555 | bufrm=NULL; |
6558 | bufrm=NULL; |
6556 | input=(unsigned char *)BackTextBlock; |
6559 | input=(unsigned char *)BackTextBlock; |
6557 | inptr2=ofs; |
6560 | inptr2=ofs; |
6558 | ostartline=startline; |
6561 | ostartline=startline; |
6559 | cha2=input[inptr2++]; |
6562 | cha2=input[inptr2++]; |
6560 | endinptr=strlen((char *)input); |
6563 | endinptr=strlen((char *)input); |
6561 | startline=(char *)input+ofs; |
6564 | startline=(char *)input+ofs; |
6562 | endinput=startline+endinptr; |
6565 | endinput=startline+endinptr; |
6563 | nexttok(); |
6566 | nexttok(); |
6564 | wtok=itok; |
6567 | wtok=itok; |
6565 | nexttok(); |
6568 | nexttok(); |
6566 | nexttok(); |
6569 | nexttok(); |
6567 | if((retcode=Push(&wtok))!=FALSE){ |
6570 | if((retcode=Push(&wtok))!=FALSE){ |
6568 | retcode=TRUE; |
6571 | retcode=TRUE; |
6569 | for(inptr2=ofs;;inptr2++){ |
6572 | for(inptr2=ofs;;inptr2++){ |
6570 | cha2=input[inptr2]; |
6573 | cha2=input[inptr2]; |
6571 | input[inptr2]=' '; |
6574 | input[inptr2]=' '; |
6572 | if(cha2==';'||cha2==0)break; |
6575 | if(cha2==';'||cha2==0)break; |
6573 | } |
6576 | } |
6574 | } |
6577 | } |
6575 | endoffile=0; |
6578 | endoffile=0; |
6576 | startline=ostartline; |
6579 | startline=ostartline; |
6577 | strinf=ostr; |
6580 | strinf=ostr; |
6578 | input=oldinput; |
6581 | input=oldinput; |
6579 | inptr2=oldinptr; |
6582 | inptr2=oldinptr; |
6580 | cha2=bcha; |
6583 | cha2=bcha; |
6581 | endinptr=oldendinptr; |
6584 | endinptr=oldendinptr; |
6582 | tok=otok; |
6585 | tok=otok; |
6583 | itok=oitok; |
6586 | itok=oitok; |
6584 | if(bufrm)free(bufrm); |
6587 | if(bufrm)free(bufrm); |
6585 | bufrm=obufrm; |
6588 | bufrm=obufrm; |
6586 | tok2=otok2; |
6589 | tok2=otok2; |
6587 | strcpy((char *)string,ostring); |
6590 | strcpy((char *)string,ostring); |
6588 | if(strinf.bufstr)free(strinf.bufstr); |
6591 | if(strinf.bufstr)free(strinf.bufstr); |
6589 | structadr=ostructadr; |
6592 | structadr=ostructadr; |
6590 | free(ostring); |
6593 | free(ostring); |
6591 | return retcode; |
6594 | return retcode; |
6592 | } |
6595 | } |
6593 | 6596 | ||
6594 | int pushinit(int localline,unsigned int ofs) |
6597 | int pushinit(int localline,unsigned int ofs) |
6595 | { |
6598 | { |
6596 | int oline=linenumber; |
6599 | int oline=linenumber; |
6597 | COM_MOD *bcur_mod; |
6600 | COM_MOD *bcur_mod; |
6598 | int retcode; |
6601 | int retcode; |
6599 | linenum2=localline; |
6602 | linenum2=localline; |
6600 | bcur_mod=cur_mod; |
6603 | bcur_mod=cur_mod; |
6601 | cur_mod=NULL; |
6604 | cur_mod=NULL; |
6602 | retcode=PushLocInit(ofs); |
6605 | retcode=PushLocInit(ofs); |
6603 | cur_mod=bcur_mod; |
6606 | cur_mod=bcur_mod; |
6604 | linenumber=linenum2=oline; |
6607 | linenumber=linenum2=oline; |
6605 | return retcode; |
6608 | return retcode; |
6606 | } |
6609 | } |
6607 | 6610 | ||
6608 | int PossiblePush() |
6611 | int PossiblePush() |
6609 | { |
6612 | { |
6610 | int retcode=FALSE; |
6613 | int retcode=FALSE; |
6611 | nexttok(); |
6614 | nexttok(); |
6612 | switch(tok){ |
6615 | switch(tok){ |
6613 | case tk_dwordvar: |
6616 | case tk_dwordvar: |
6614 | case tk_longvar: |
6617 | case tk_longvar: |
6615 | case tk_reg32: |
6618 | case tk_reg32: |
6616 | if(am32==FALSE)break; |
6619 | if(am32==FALSE)break; |
6617 | case tk_postnumber: |
6620 | case tk_postnumber: |
6618 | case tk_string: |
6621 | case tk_string: |
6619 | case tk_intvar: |
6622 | case tk_intvar: |
6620 | case tk_wordvar: |
6623 | case tk_wordvar: |
6621 | case tk_reg: |
6624 | case tk_reg: |
6622 | if(tok2==tk_semicolon||tok2==tk_camma)retcode=TRUE; |
6625 | if(tok2==tk_semicolon||tok2==tk_camma)retcode=TRUE; |
6623 | break; |
6626 | break; |
6624 | case tk_undefofs: |
6627 | case tk_undefofs: |
6625 | tok=tk_number; |
6628 | tok=tk_number; |
6626 | goto chnum; |
6629 | goto chnum; |
6627 | case tk_minus: |
6630 | case tk_minus: |
6628 | if(tok2!=tk_number)break; |
6631 | if(tok2!=tk_number)break; |
6629 | nexttok(); |
6632 | nexttok(); |
6630 | case tk_number: |
6633 | case tk_number: |
6631 | chnum: |
6634 | chnum: |
6632 | doconstlongmath(); |
6635 | doconstlongmath(); |
6633 | if(tok==tk_semicolon||tok==tk_camma)retcode=TRUE; |
6636 | if(tok==tk_semicolon||tok==tk_camma)retcode=TRUE; |
6634 | break; |
6637 | break; |
6635 | } |
6638 | } |
6636 | 6639 | ||
6637 | //// New 20.07.07 22:01 |
6640 | //// New 20.07.07 22:01 |
6638 | if(bufrm){ |
6641 | if(bufrm){ |
6639 | free(bufrm); |
6642 | free(bufrm); |
6640 | bufrm=NULL; |
6643 | bufrm=NULL; |
6641 | } |
6644 | } |
6642 | if(strinf.bufstr){ |
6645 | if(strinf.bufstr){ |
6643 | free(strinf.bufstr); |
6646 | free(strinf.bufstr); |
6644 | strinf.bufstr=NULL; |
6647 | strinf.bufstr=NULL; |
6645 | } |
6648 | } |
6646 | //////////////////////////// |
6649 | //////////////////////////// |
6647 | 6650 | ||
6648 | return retcode; |
6651 | return retcode; |
6649 | } |
6652 | } |
6650 | 6653 | ||
6651 | #define MAXLOCVAR 128 |
6654 | #define MAXLOCVAR 128 |
6652 | 6655 | ||
6653 | void declarelocals(int mode,int finline) /* declare locals */ |
6656 | void declarelocals(int mode,int finline) /* declare locals */ |
6654 | /*-----------------01.06.02 15:12------------------- |
6657 | /*-----------------01.06.02 15:12------------------- |
6655 | mode = 0 if local vars prior { |
6658 | mode = 0 if local vars prior { |
6656 | mode = 1 if local vars after { |
6659 | mode = 1 if local vars after { |
6657 | --------------------------------------------------*/ |
6660 | --------------------------------------------------*/ |
6658 | { |
6661 | { |
6659 | unsigned int size,ssize,localtok; |
6662 | unsigned int size,ssize,localtok; |
6660 | int binptr; |
6663 | int binptr; |
6661 | int flag=0; |
6664 | int flag=0; |
6662 | char bcha; |
6665 | char bcha; |
6663 | int slocaltok; |
6666 | int slocaltok; |
6664 | int numpointr,type; |
6667 | int numpointr,type; |
6665 | unsigned int loop; |
6668 | unsigned int loop; |
6666 | static int localline; |
6669 | static int localline; |
6667 | static int numinit; |
6670 | static int numinit; |
6668 | static int maxlocvar; |
6671 | static int maxlocvar; |
6669 | static LILV *lilv=NULL; |
6672 | static LILV *lilv=NULL; |
6670 | static int headerinit; |
6673 | static int headerinit; |
6671 | if(localsize==0)localline=0; |
6674 | if(localsize==0)localline=0; |
6672 | if(lilv==NULL){ |
6675 | if(lilv==NULL){ |
6673 | numinit=0; |
6676 | numinit=0; |
6674 | lilv=(LILV *)MALLOC(sizeof(LILV)*MAXLOCVAR); |
6677 | lilv=(LILV *)MALLOC(sizeof(LILV)*MAXLOCVAR); |
6675 | maxlocvar=MAXLOCVAR; |
6678 | maxlocvar=MAXLOCVAR; |
6676 | if(paramsize&&(!finline))headerinit=TRUE; |
6679 | if(paramsize&&(!finline))headerinit=TRUE; |
6677 | else headerinit=FALSE; |
6680 | else headerinit=FALSE; |
6678 | } |
6681 | } |
6679 | dynamic_flag=0; |
6682 | dynamic_flag=0; |
6680 | do{ |
6683 | do{ |
6681 | while(tok==tk_semicolon)nexttok(); |
6684 | while(tok==tk_semicolon)nexttok(); |
6682 | if(tok==tk_static){ |
6685 | if(tok==tk_static){ |
6683 | flag|=f_static; |
6686 | flag|=f_static; |
6684 | nexttok(); |
6687 | nexttok(); |
6685 | } |
6688 | } |
6686 | size=0; |
6689 | size=0; |
6687 | switch(tok){ |
6690 | switch(tok){ |
6688 | case tk_union: |
6691 | case tk_union: |
6689 | loop=dounion(0,flag); |
6692 | loop=dounion(0,flag); |
6690 | goto locstruct; |
6693 | goto locstruct; |
6691 | case tk_struct: |
6694 | case tk_struct: |
6692 | loop=LocalStruct(flag,&localline); |
6695 | loop=LocalStruct(flag,&localline); |
6693 | locstruct: |
6696 | locstruct: |
6694 | (lilv+numinit)->size=-loop; |
6697 | (lilv+numinit)->size=-loop; |
6695 | break; |
6698 | break; |
6696 | case tk_int: localtok=tk_intvar; size=2; break; |
6699 | case tk_int: localtok=tk_intvar; size=2; break; |
6697 | case tk_word: localtok=tk_wordvar; size=2; break; |
6700 | case tk_word: localtok=tk_wordvar; size=2; break; |
6698 | case tk_char: localtok=tk_charvar; size=1; break; |
6701 | case tk_char: localtok=tk_charvar; size=1; break; |
6699 | case tk_byte: localtok=tk_bytevar; size=1; break; |
6702 | case tk_byte: localtok=tk_bytevar; size=1; break; |
6700 | case tk_long: localtok=tk_longvar; size=4; break; |
6703 | case tk_long: localtok=tk_longvar; size=4; break; |
6701 | case tk_dword: localtok=tk_dwordvar; size=4; break; |
6704 | case tk_dword: localtok=tk_dwordvar; size=4; break; |
6702 | case tk_float: localtok=tk_floatvar; size=4; break; |
6705 | case tk_float: localtok=tk_floatvar; size=4; break; |
6703 | case tk_qword: localtok=tk_qwordvar; size=8; break; |
6706 | case tk_qword: localtok=tk_qwordvar; size=8; break; |
6704 | case tk_double: localtok=tk_doublevar; size=8; break; |
6707 | case tk_double: localtok=tk_doublevar; size=8; break; |
6705 | default: |
6708 | default: |
6706 | if((tok>=tk_bits&&tok<=tk_doublevar)||tok==tk_pointer||tok==tk_proc |
6709 | if((tok>=tk_bits&&tok<=tk_doublevar)||tok==tk_pointer||tok==tk_proc |
6707 | ||tok==tk_declare||tok==tk_undefproc||tok==tk_structvar|| |
6710 | ||tok==tk_declare||tok==tk_undefproc||tok==tk_structvar|| |
6708 | (FindTeg(FALSE)==NULL&&FindTeg(TRUE)==NULL)){ |
6711 | (FindTeg(FALSE)==NULL&&FindTeg(TRUE)==NULL)){ |
6709 | if(mode==0){ |
6712 | if(mode==0){ |
6710 | (lilv+numinit)->size=0; |
6713 | (lilv+numinit)->size=0; |
6711 | datatype_expected(); |
6714 | datatype_expected(); |
6712 | nexttok(); |
6715 | nexttok(); |
6713 | } |
6716 | } |
6714 | else{ |
6717 | else{ |
6715 | if(localsize){ |
6718 | if(localsize){ |
6716 | if(!finline){ |
6719 | if(!finline){ |
6717 | numpointr=0; |
6720 | numpointr=0; |
6718 | if(SizeBackBuf){ |
6721 | if(SizeBackBuf){ |
6719 | BackTextBlock[SizeBackBuf]=0; |
6722 | BackTextBlock[SizeBackBuf]=0; |
6720 | for(type=numinit-1,numpointr=0;type>=0;type--){//îïð ÷èñëî èíèö. ïåðåìåííûõ â êîíöå |
6723 | for(type=numinit-1,numpointr=0;type>=0;type--){//îïð ÷èñëî èíèö. ïåðåìåííûõ â êîíöå |
6721 | if((lilv+type)->size<=0)break; |
6724 | if((lilv+type)->size<=0)break; |
6722 | numpointr+=(lilv+type)->size; |
6725 | numpointr+=(lilv+type)->size; |
6723 | } |
6726 | } |
6724 | type++; //÷èñëî îñòàâøèõñÿ ïåðåìåííûõ |
6727 | type++; //÷èñëî îñòàâøèõñÿ ïåðåìåííûõ |
6725 | ssize=type; |
6728 | ssize=type; |
6726 | } |
6729 | } |
6727 | size=localsize; |
6730 | size=localsize; |
6728 | if(lilv->size<=0&&optimizespeed==0&&chip>1){ |
6731 | if(lilv->size<=0&&optimizespeed==0&&chip>1){ |
6729 | size-=numpointr; |
6732 | size-=numpointr; |
6730 | if(headerinit)outptr-=3; /* remove PUSH BP and MOV BP,SP */ |
6733 | if(headerinit)outptr-=3; /* remove PUSH BP and MOV BP,SP */ |
6731 | op(0xC8); /* ENTER */ |
6734 | op(0xC8); /* ENTER */ |
6732 | outword(size); /* # of locals */ |
6735 | outword(size); /* # of locals */ |
6733 | op(0x00); /* level = 0 */ |
6736 | op(0x00); /* level = 0 */ |
6734 | flag=0; |
6737 | flag=0; |
6735 | type=0; |
6738 | type=0; |
6736 | headerinit=TRUE; |
6739 | headerinit=TRUE; |
6737 | size=numpointr; |
6740 | size=numpointr; |
6738 | } |
6741 | } |
6739 | else{ |
6742 | else{ |
6740 | if(headerinit==FALSE){ |
6743 | if(headerinit==FALSE){ |
6741 | Enter(); |
6744 | Enter(); |
6742 | headerinit=TRUE; |
6745 | headerinit=TRUE; |
6743 | } |
6746 | } |
6744 | flag=1; |
6747 | flag=1; |
6745 | } |
6748 | } |
6746 | if(SizeBackBuf){ |
6749 | if(SizeBackBuf){ |
6747 | if(lilv->size>0){ //åñòü èíèö ïåðåìåííûå â íà÷àëå |
6750 | if(lilv->size>0){ //åñòü èíèö ïåðåìåííûå â íà÷àëå |
6748 | for(loop=0;loop |
6751 | for(loop=0;loop |
6749 | // printf("size%d=%d %s\n",loop,(lilv+loop)->size,BackTextBlock); |
6752 | // printf("size%d=%d %s\n",loop,(lilv+loop)->size,BackTextBlock); |
6750 | if((lilv+loop)->size<=0)break; |
6753 | if((lilv+loop)->size<=0)break; |
6751 | if(pushinit(localline,(lilv+loop)->ofs)==FALSE)break; |
6754 | if(pushinit(localline,(lilv+loop)->ofs)==FALSE)break; |
6752 | (lilv+loop)->rec->fuse|=INITVAR; |
6755 | (lilv+loop)->rec->fuse|=INITVAR; |
6753 | size-=Align((lilv+loop)->size,(am32==FALSE?2:4)); |
6756 | size-=Align((lilv+loop)->size,(am32==FALSE?2:4)); |
6754 | type--; |
6757 | type--; |
6755 | } |
6758 | } |
6756 | } |
6759 | } |
6757 | if(size){ |
6760 | if(size){ |
6758 | binptr=size-numpointr; |
6761 | binptr=size-numpointr; |
6759 | if(binptr){ |
6762 | if(binptr){ |
6760 | if(!optimizespeed&&type<3&&(type*(am32+1)*2)>=binptr)for(;type!=0;type--)op(0x50+ECX); |
6763 | if(!optimizespeed&&type<3&&(type*(am32+1)*2)>=binptr)for(;type!=0;type--)op(0x50+ECX); |
6761 | else{ |
6764 | else{ |
6762 | if(binptr<128){ |
6765 | if(binptr<128){ |
6763 | outword(0xEC83); |
6766 | outword(0xEC83); |
6764 | op(binptr); |
6767 | op(binptr); |
6765 | } |
6768 | } |
6766 | else{ |
6769 | else{ |
6767 | outword(0xEC81); |
6770 | outword(0xEC81); |
6768 | if(am32==FALSE)outword(binptr); |
6771 | if(am32==FALSE)outword(binptr); |
6769 | else outdword((unsigned long)binptr); |
6772 | else outdword((unsigned long)binptr); |
6770 | } |
6773 | } |
6771 | } |
6774 | } |
6772 | } |
6775 | } |
6773 | if(numpointr){ |
6776 | if(numpointr){ |
6774 | for(;ssize |
6777 | for(;ssize |
6775 | // printf("size%d=%d %s\n",loop,(lilv+loop)->size,BackTextBlock); |
6778 | // printf("size%d=%d %s\n",loop,(lilv+loop)->size,BackTextBlock); |
6776 | if(pushinit(localline,(lilv+ssize)->ofs)==FALSE)break; |
6779 | if(pushinit(localline,(lilv+ssize)->ofs)==FALSE)break; |
6777 | (lilv+ssize)->rec->fuse|=INITVAR; |
6780 | (lilv+ssize)->rec->fuse|=INITVAR; |
6778 | } |
6781 | } |
6779 | } |
6782 | } |
6780 | } |
6783 | } |
6781 | } |
6784 | } |
6782 | else if(flag){ |
6785 | else if(flag){ |
6783 | if(localsize<128){ |
6786 | if(localsize<128){ |
6784 | outword(0xEC83); |
6787 | outword(0xEC83); |
6785 | op(localsize); |
6788 | op(localsize); |
6786 | } |
6789 | } |
6787 | else{ |
6790 | else{ |
6788 | outword(0xEC81); |
6791 | outword(0xEC81); |
6789 | if(am32==FALSE)outword(localsize); |
6792 | if(am32==FALSE)outword(localsize); |
6790 | else outdword((unsigned long)localsize); |
6793 | else outdword((unsigned long)localsize); |
6791 | } |
6794 | } |
6792 | } |
6795 | } |
6793 | } |
6796 | } |
6794 | else{ //finline |
6797 | else{ //finline |
6795 | if(SizeBackBuf!=0){ |
6798 | if(SizeBackBuf!=0){ |
6796 | free(BackTextBlock); |
6799 | free(BackTextBlock); |
6797 | SizeBackBuf=0; |
6800 | SizeBackBuf=0; |
6798 | } |
6801 | } |
6799 | } |
6802 | } |
6800 | } |
6803 | } |
6801 | if(psavereg->size){ |
6804 | if(psavereg->size){ |
6802 | if(psavereg->all){ |
6805 | if(psavereg->all){ |
6803 | op(0x60); |
6806 | op(0x60); |
6804 | addESP+=am32==FALSE?16:32; |
6807 | addESP+=am32==FALSE?16:32; |
6805 | } |
6808 | } |
6806 | else{ |
6809 | else{ |
6807 | for(int i=0;i<8;i++){ |
6810 | for(int i=0;i<8;i++){ |
6808 | if(psavereg->reg[i]){ |
6811 | if(psavereg->reg[i]){ |
6809 | op66(psavereg->reg[i]); |
6812 | op66(psavereg->reg[i]); |
6810 | op(0x50+i); |
6813 | op(0x50+i); |
6811 | addESP+=am32==FALSE?2:4; |
6814 | addESP+=am32==FALSE?2:4; |
6812 | 6815 | ||
6813 | } |
6816 | } |
6814 | } |
6817 | } |
6815 | } |
6818 | } |
6816 | if(ESPloc&&am32&&(itok.type==tp_localvar||itok.type==tp_paramvar))itok.number+=addESP; |
6819 | if(ESPloc&&am32&&(itok.type==tp_localvar||itok.type==tp_paramvar))itok.number+=addESP; |
6817 | } |
6820 | } |
6818 | // printf("numinit=%d firstinit=%d\n%s\n",numinit,firstinit,BackTextBlock); |
6821 | // printf("numinit=%d firstinit=%d\n%s\n",numinit,firstinit,BackTextBlock); |
6819 | if(SizeBackBuf!=0){ |
6822 | if(SizeBackBuf!=0){ |
6820 | CharToBackBuf('}'); |
6823 | CharToBackBuf('}'); |
6821 | CharToBackBuf(0); |
6824 | CharToBackBuf(0); |
6822 | int oline=linenumber; |
6825 | int oline=linenumber; |
6823 | linenum2=localline; |
6826 | linenum2=localline; |
6824 | COM_MOD *bcur_mod; |
6827 | COM_MOD *bcur_mod; |
6825 | bcur_mod=cur_mod; |
6828 | bcur_mod=cur_mod; |
6826 | cur_mod=NULL; |
6829 | cur_mod=NULL; |
6827 | RunBackText(); |
6830 | RunBackText(); |
6828 | cur_mod=bcur_mod; |
6831 | cur_mod=bcur_mod; |
6829 | linenumber=linenum2=oline; |
6832 | linenumber=linenum2=oline; |
6830 | } |
6833 | } |
6831 | if(lilv){ |
6834 | if(lilv){ |
6832 | free(lilv); |
6835 | free(lilv); |
6833 | lilv=NULL; |
6836 | lilv=NULL; |
6834 | } |
6837 | } |
6835 | return; |
6838 | return; |
6836 | } |
6839 | } |
6837 | } |
6840 | } |
6838 | else{ |
6841 | else{ |
6839 | loop=LocalStruct(flag,&localline); |
6842 | loop=LocalStruct(flag,&localline); |
6840 | (lilv+numinit)->size=-loop; |
6843 | (lilv+numinit)->size=-loop; |
6841 | } |
6844 | } |
6842 | break; |
6845 | break; |
6843 | } |
6846 | } |
6844 | if(size!=0){ |
6847 | if(size!=0){ |
6845 | do{ |
6848 | do{ |
6846 | binptr=inptr2; |
6849 | binptr=inptr2; |
6847 | bcha=cha2; |
6850 | bcha=cha2; |
6848 | skipfind=TRUE; //çàïðåòèòü èñêàòü â ãëîáàëüíîì äåðåâå |
6851 | skipfind=TRUE; //çàïðåòèòü èñêàòü â ãëîáàëüíîì äåðåâå |
6849 | nexttok(); |
6852 | nexttok(); |
6850 | if(tok==tk_static){ |
6853 | if(tok==tk_static){ |
6851 | flag|=f_static; |
6854 | flag|=f_static; |
6852 | binptr=inptr2; |
6855 | binptr=inptr2; |
6853 | bcha=cha2; |
6856 | bcha=cha2; |
6854 | nexttok(); |
6857 | nexttok(); |
6855 | } |
6858 | } |
6856 | slocaltok=localtok; |
6859 | slocaltok=localtok; |
6857 | ssize=size; |
6860 | ssize=size; |
6858 | numpointr=0; |
6861 | numpointr=0; |
6859 | type=tp_localvar; |
6862 | type=tp_localvar; |
6860 | while(tok==tk_mult){ |
6863 | while(tok==tk_mult){ |
6861 | binptr=inptr2; |
6864 | binptr=inptr2; |
6862 | bcha=cha2; |
6865 | bcha=cha2; |
6863 | nexttok(); |
6866 | nexttok(); |
6864 | numpointr++; |
6867 | numpointr++; |
6865 | } |
6868 | } |
6866 | if(tok!=tk_ID&&tok!=tk_id)idalreadydefined(); |
6869 | if(tok!=tk_ID&&tok!=tk_id)idalreadydefined(); |
6867 | else{ |
6870 | else{ |
6868 | long numcopyvar; |
6871 | long numcopyvar; |
6869 | numcopyvar=1; |
6872 | numcopyvar=1; |
6870 | localrec *lrec=addlocalvar(itok.name,slocaltok,(flag&f_static)==0?localsize:postsize); |
6873 | localrec *lrec=addlocalvar(itok.name,slocaltok,(flag&f_static)==0?localsize:postsize); |
6871 | loop=ssize; |
6874 | loop=ssize; |
6872 | if(numpointr)loop=am32==TRUE?4:2; |
6875 | if(numpointr)loop=am32==TRUE?4:2; |
6873 | skipfind=FALSE; //ðàçðåøèòü ïîèñê â ãëîáàëüíîì äåðåâå |
6876 | skipfind=FALSE; //ðàçðåøèòü ïîèñê â ãëîáàëüíîì äåðåâå |
6874 | if(tok2==tk_openblock){//[ |
6877 | if(tok2==tk_openblock){//[ |
6875 | nexttok(); |
6878 | nexttok(); |
6876 | nexttok(); |
6879 | nexttok(); |
6877 | CheckMinusNum(); |
6880 | CheckMinusNum(); |
6878 | if(tok!=tk_number){ |
6881 | if(tok!=tk_number){ |
6879 | numexpected(); |
6882 | numexpected(); |
6880 | nexttok(); |
6883 | nexttok(); |
6881 | } |
6884 | } |
6882 | else numcopyvar=doconstlongmath(); |
6885 | else numcopyvar=doconstlongmath(); |
6883 | loop=numcopyvar*ssize; |
6886 | loop=numcopyvar*ssize; |
6884 | if(tok!=tk_closeblock)expected(']'); |
6887 | if(tok!=tk_closeblock)expected(']'); |
6885 | } |
6888 | } |
6886 | lrec->rec.recsize=loop; |
6889 | lrec->rec.recsize=loop; |
6887 | if(!mode){ |
6890 | if(!mode){ |
6888 | nexttok(); |
6891 | nexttok(); |
6889 | } |
6892 | } |
6890 | if(flag&f_static){ |
6893 | if(flag&f_static){ |
6891 | if(tok==tk_assign||(mode&&tok2==tk_assign)){ |
6894 | if(tok==tk_assign||(mode&&tok2==tk_assign)){ |
6892 | if(mode)nexttok(); |
6895 | if(mode)nexttok(); |
6893 | if(numpointr){ |
6896 | if(numpointr){ |
6894 | type=tk_char+slocaltok-tk_charvar; |
6897 | type=tk_char+slocaltok-tk_charvar; |
6895 | slocaltok=tk_pointer; |
6898 | slocaltok=tk_pointer; |
6896 | } |
6899 | } |
6897 | lrec->rec.rectok=slocaltok; |
6900 | lrec->rec.rectok=slocaltok; |
6898 | lrec->rec.recnumber=0; |
6901 | lrec->rec.recnumber=0; |
6899 | lrec->rec.recpost=DYNAMIC_VAR; |
6902 | lrec->rec.recpost=DYNAMIC_VAR; |
6900 | lrec->rec.line=linenumber; |
6903 | lrec->rec.line=linenumber; |
6901 | lrec->rec.file=currentfileinfo; |
6904 | lrec->rec.file=currentfileinfo; |
6902 | lrec->rec.count=0; |
6905 | lrec->rec.count=0; |
6903 | // lptr->rec.type=(unsigned short)type; |
6906 | // lptr->rec.type=(unsigned short)type; |
6904 | lrec->rec.npointr=(unsigned short)numpointr; |
6907 | lrec->rec.npointr=(unsigned short)numpointr; |
6905 | lrec->rec.sbuf=dynamic_var(); |
6908 | lrec->rec.sbuf=dynamic_var(); |
6906 | lrec->rec.recsib=type; |
6909 | lrec->rec.recsib=type; |
6907 | lrec->rec.type=tp_gvar; |
6910 | lrec->rec.type=tp_gvar; |
6908 | 6911 | ||
6909 | // if(strcmp(lrec->rec.recid,"nnil")==0)crec=&lrec->rec; |
6912 | // if(strcmp(lrec->rec.recid,"nnil")==0)crec=&lrec->rec; |
6910 | 6913 | ||
6911 | } |
6914 | } |
6912 | else{ |
6915 | else{ |
6913 | lrec->rec.type=tp_postvar; |
6916 | lrec->rec.type=tp_postvar; |
6914 | AddPostData(loop); |
6917 | AddPostData(loop); |
6915 | if(mode)nexttok(); |
6918 | if(mode)nexttok(); |
6916 | } |
6919 | } |
6917 | } |
6920 | } |
6918 | else{ |
6921 | else{ |
6919 | lrec->rec.type=tp_localvar; |
6922 | lrec->rec.type=tp_localvar; |
6920 | lrec->rec.npointr=(unsigned short)numpointr; |
6923 | lrec->rec.npointr=(unsigned short)numpointr; |
6921 | localsize+=loop; |
6924 | localsize+=loop; |
6922 | if(mode)nexttok(); |
6925 | if(mode)nexttok(); |
6923 | (lilv+numinit)->size=-loop; |
6926 | (lilv+numinit)->size=-loop; |
6924 | if(tok==tk_assign){ |
6927 | if(tok==tk_assign){ |
6925 | if(localline==0)localline=linenumber; |
6928 | if(localline==0)localline=linenumber; |
6926 | if(numcopyvar!=1){ |
6929 | if(numcopyvar!=1){ |
6927 | int i=binptr; |
6930 | int i=binptr; |
6928 | while(input[i]!='[')i++; |
6931 | while(input[i]!='[')i++; |
6929 | i++; |
6932 | i++; |
6930 | input[i]='0'; |
6933 | input[i]='0'; |
6931 | i++; |
6934 | i++; |
6932 | for ( int j=1;j!=0;i++){ |
6935 | for ( int j=1;j!=0;i++){ |
6933 | switch(input[i]){ |
6936 | switch(input[i]){ |
6934 | case '[': |
6937 | case '[': |
6935 | j++; |
6938 | j++; |
6936 | break; |
6939 | break; |
6937 | case ']': |
6940 | case ']': |
6938 | j--; |
6941 | j--; |
6939 | break; |
6942 | break; |
6940 | } |
6943 | } |
6941 | if(j!=0)input[i]= ' '; |
6944 | if(j!=0)input[i]= ' '; |
6942 | } |
6945 | } |
6943 | } |
6946 | } |
6944 | else{ |
6947 | else{ |
6945 | switch(slocaltok){ |
6948 | switch(slocaltok){ |
6946 | case tk_floatvar: |
6949 | case tk_floatvar: |
6947 | case tk_doublevar: |
6950 | case tk_doublevar: |
6948 | case tk_qwordvar: |
6951 | case tk_qwordvar: |
6949 | // (lilv+numinit)->ofs=-1; |
6952 | // (lilv+numinit)->ofs=-1; |
6950 | break; |
6953 | break; |
6951 | default: |
6954 | default: |
6952 | if(PossiblePush()){ |
6955 | if(PossiblePush()){ |
6953 | (lilv+numinit)->size=loop; |
6956 | (lilv+numinit)->size=loop; |
6954 | (lilv+numinit)->rec=lrec; |
6957 | (lilv+numinit)->rec=lrec; |
6955 | } |
6958 | } |
6956 | break; |
6959 | break; |
6957 | } |
6960 | } |
6958 | } |
6961 | } |
6959 | (lilv+numinit)->ofs=SizeBackBuf; |
6962 | (lilv+numinit)->ofs=SizeBackBuf; |
6960 | AddBackBuf(binptr,bcha); |
6963 | AddBackBuf(binptr,bcha); |
6961 | // if(bufrm)puts(bufrm); |
6964 | // if(bufrm)puts(bufrm); |
6962 | } |
6965 | } |
6963 | numinit++; |
6966 | numinit++; |
6964 | if(numinit==maxlocvar){ |
6967 | if(numinit==maxlocvar){ |
6965 | maxlocvar+=MAXLOCVAR; |
6968 | maxlocvar+=MAXLOCVAR; |
6966 | lilv=(LILV *)REALLOC(lilv,maxlocvar*sizeof(LILV)); |
6969 | lilv=(LILV *)REALLOC(lilv,maxlocvar*sizeof(LILV)); |
6967 | } |
6970 | } |
6968 | lrec->rec.recnumber=-lrec->rec.recnumber-Align(loop,(am32==FALSE?2:4)); |
6971 | lrec->rec.recnumber=-lrec->rec.recnumber-Align(loop,(am32==FALSE?2:4)); |
6969 | } |
6972 | } |
6970 | } |
6973 | } |
6971 | if(localsize)localsize=Align(localsize,(am32==FALSE?2:4)); |
6974 | if(localsize)localsize=Align(localsize,(am32==FALSE?2:4)); |
6972 | }while(tok==tk_camma); |
6975 | }while(tok==tk_camma); |
6973 | seminext(); |
6976 | seminext(); |
6974 | } |
6977 | } |
6975 | else{ |
6978 | else{ |
6976 | numinit++; |
6979 | numinit++; |
6977 | if(numinit==maxlocvar){ |
6980 | if(numinit==maxlocvar){ |
6978 | maxlocvar+=MAXLOCVAR; |
6981 | maxlocvar+=MAXLOCVAR; |
6979 | lilv=(LILV *)REALLOC(lilv,maxlocvar*sizeof(LILV)); |
6982 | lilv=(LILV *)REALLOC(lilv,maxlocvar*sizeof(LILV)); |
6980 | } |
6983 | } |
6981 | } |
6984 | } |
6982 | flag=0; |
6985 | flag=0; |
6983 | // printf("tok=%d %s\n",tok,BackTextBlock); |
6986 | // printf("tok=%d %s\n",tok,BackTextBlock); |
6984 | }while(tok!=tk_openbrace&&tok!=tk_eof); |
6987 | }while(tok!=tk_openbrace&&tok!=tk_eof); |
6985 | } |
6988 | } |
6986 | 6989 | ||
6987 | int CheckDeclareProc() |
6990 | int CheckDeclareProc() |
6988 | { |
6991 | { |
6989 | unsigned int i=inptr2-1; |
6992 | unsigned int i=inptr2-1; |
6990 | while(input[i]!='('){ |
6993 | while(input[i]!='('){ |
6991 | i++; |
6994 | i++; |
6992 | if(i>=endinptr){ |
6995 | if(i>=endinptr){ |
6993 | unexpectedeof(); |
6996 | unexpectedeof(); |
6994 | break; |
6997 | break; |
6995 | } |
6998 | } |
6996 | } |
6999 | } |
6997 | lab1: |
7000 | lab1: |
6998 | i++; |
7001 | i++; |
6999 | for(int j=1;j!=0;i++){ |
7002 | for(int j=1;j!=0;i++){ |
7000 | char c=input[i]; |
7003 | char c=input[i]; |
7001 | if(c=='(')j++; |
7004 | if(c=='(')j++; |
7002 | else if(c==')')j--; |
7005 | else if(c==')')j--; |
7003 | if(i>=endinptr){ |
7006 | if(i>=endinptr){ |
7004 | unexpectedeof(); |
7007 | unexpectedeof(); |
7005 | break; |
7008 | break; |
7006 | } |
7009 | } |
7007 | } |
7010 | } |
7008 | for(;;i++){ |
7011 | for(;;i++){ |
7009 | if(input[i]=='(')goto lab1; |
7012 | if(input[i]=='(')goto lab1; |
7010 | if(input[i]>' ')break; |
7013 | if(input[i]>' ')break; |
7011 | if(i>=endinptr){ |
7014 | if(i>=endinptr){ |
7012 | unexpectedeof(); |
7015 | unexpectedeof(); |
7013 | break; |
7016 | break; |
7014 | } |
7017 | } |
7015 | } |
7018 | } |
7016 | 7019 | ||
7017 | for(;;i++){ |
7020 | for(;;i++){ |
7018 | if(input[i]==';'||input[i]==',')return TRUE; //îáúÿâëåíèå ïðîöåäóðû |
7021 | if(input[i]==';'||input[i]==',')return TRUE; //îáúÿâëåíèå ïðîöåäóðû |
7019 | if(input[i]>' ')break; |
7022 | if(input[i]>' ')break; |
7020 | if(i>=endinptr){ |
7023 | if(i>=endinptr){ |
7021 | unexpectedeof(); |
7024 | unexpectedeof(); |
7022 | break; |
7025 | break; |
7023 | } |
7026 | } |
7024 | } |
7027 | } |
7025 | return FALSE; |
7028 | return FALSE; |
7026 | } |
7029 | } |
7027 | 7030 | ||
7028 | void IsUses(idrec *rec) |
7031 | void IsUses(idrec *rec) |
7029 | { |
7032 | { |
7030 | int i; |
7033 | int i; |
7031 | if(tok==tk_openbracket&&stricmp(itok2.name,"uses")==0){ |
7034 | if(tok==tk_openbracket&&stricmp(itok2.name,"uses")==0){ |
7032 | nexttok(); |
7035 | nexttok(); |
7033 | i=0; |
7036 | i=0; |
7034 | nexttok(); |
7037 | nexttok(); |
7035 | while(tok==tk_reg32||tok==tk_reg||tok==tk_beg){ |
7038 | while(tok==tk_reg32||tok==tk_reg||tok==tk_beg){ |
7036 | if(tok==tk_beg&&itok.number>3)itok.number-=4; |
7039 | if(tok==tk_beg&&itok.number>3)itok.number-=4; |
7037 | i=i|(1< |
7040 | i=i|(1< |
7038 | nexttok(); |
7041 | nexttok(); |
7039 | if(tok==tk_camma)nexttok(); |
7042 | if(tok==tk_camma)nexttok(); |
7040 | } |
7043 | } |
7041 | if(strcmp(itok.name,"allregs")==0){ |
7044 | if(strcmp(itok.name,"allregs")==0){ |
7042 | i=256; |
7045 | i=256; |
7043 | nexttok(); |
7046 | nexttok(); |
7044 | } |
7047 | } |
7045 | rec->recpost=0xFF^i; |
7048 | rec->recpost=0xFF^i; |
7046 | expecting(tk_closebracket); |
7049 | expecting(tk_closebracket); |
7047 | } |
7050 | } |
7048 | } |
7051 | } |
7049 | 7052 | ||
7050 | void declare_procedure(int oflag,int orm,int npointr) |
7053 | void declare_procedure(int oflag,int orm,int npointr) |
7051 | { |
7054 | { |
7052 | int i,next=TRUE,j; |
7055 | int i,next=TRUE,j; |
7053 | char pname[IDLENGTH]; |
7056 | char pname[IDLENGTH]; |
7054 | idrec *rec; |
7057 | idrec *rec; |
7055 | strcpy(pname,itok.name); |
7058 | strcpy(pname,itok.name); |
7056 | param[0]=0; |
7059 | param[0]=0; |
7057 | nexttok(); |
7060 | nexttok(); |
7058 | if(npointr)expecting(tk_closebracket); |
7061 | if(npointr)expecting(tk_closebracket); |
7059 | expecting(tk_openbracket); |
7062 | expecting(tk_openbracket); |
7060 | if((oflag&f_typeproc)==tp_fastcall)declareparamreg(); |
7063 | if((oflag&f_typeproc)==tp_fastcall)declareparamreg(); |
7061 | else declareparamstack(); |
7064 | else declareparamstack(); |
7062 | if(tok2==tk_assign)nexttok(); |
7065 | if(tok2==tk_assign)nexttok(); |
7063 | itok.post=1; |
7066 | itok.post=1; |
7064 | if(npointr){ |
7067 | if(npointr){ |
7065 | itok.segm=DS; |
7068 | itok.segm=DS; |
7066 | itok.type=tk_proc; |
7069 | itok.type=tk_proc; |
7067 | itok.sib=am32==FALSE?rm_d16:rm_d32; |
7070 | itok.sib=am32==FALSE?rm_d16:rm_d32; |
7068 | i=2; |
7071 | i=2; |
7069 | if(am32||(oflag&f_far))i=4; |
7072 | if(am32||(oflag&f_far))i=4; |
7070 | if(tok==tk_assign||(notpost==TRUE&&dynamic_flag==0)){ //= èíèöèàëèçèðîâàíàÿ ïåðåìåííàÿ |
7073 | if(tok==tk_assign||(notpost==TRUE&&dynamic_flag==0)){ //= èíèöèàëèçèðîâàíàÿ ïåðåìåííàÿ |
7071 | if((oflag&f_extern))preerror("extern variable do not initialize at declare"); |
7074 | if((oflag&f_extern))preerror("extern variable do not initialize at declare"); |
7072 | if(alignword&&(!dynamic_flag))alignersize+=AlignCD(DS,i); |
7075 | if(alignword&&(!dynamic_flag))alignersize+=AlignCD(DS,i); |
7073 | FindOff((unsigned char *)pname,DS); |
7076 | FindOff((unsigned char *)pname,DS); |
7074 | itok.number=outptrdata; |
7077 | itok.number=outptrdata; |
7075 | if(tok!=tk_assign){ |
7078 | if(tok!=tk_assign){ |
7076 | if(dbg&2)AddDataLine(i); |
7079 | if(dbg&2)AddDataLine(i); |
7077 | outword(0); |
7080 | outword(0); |
7078 | if(i==4)outword(0); |
7081 | if(i==4)outword(0); |
7079 | } |
7082 | } |
7080 | else{ |
7083 | else{ |
7081 | ITOK oitok; |
7084 | ITOK oitok; |
7082 | oitok=itok; |
7085 | oitok=itok; |
7083 | initglobalvar(tk_word,1,i,variable); |
7086 | initglobalvar(tk_word,1,i,variable); |
7084 | itok=oitok; |
7087 | itok=oitok; |
7085 | next=FALSE; |
7088 | next=FALSE; |
7086 | } |
7089 | } |
7087 | itok.post=0; |
7090 | itok.post=0; |
7088 | datasize+=i; |
7091 | datasize+=i; |
7089 | } |
7092 | } |
7090 | else{ |
7093 | else{ |
7091 | if((oflag&f_extern)==0){ |
7094 | if((oflag&f_extern)==0){ |
7092 | itok.number=postsize; |
7095 | itok.number=postsize; |
7093 | AddPostData(i); |
7096 | AddPostData(i); |
7094 | } |
7097 | } |
7095 | else itok.number=externnum++; |
7098 | else itok.number=externnum++; |
7096 | } |
7099 | } |
7097 | j=tok; |
7100 | j=tok; |
7098 | tok=tk_pointer; |
7101 | tok=tk_pointer; |
7099 | } |
7102 | } |
7100 | else{ |
7103 | else{ |
7101 | tok=tk_declare; |
7104 | tok=tk_declare; |
7102 | itok.type=tp_declare; |
7105 | itok.type=tp_declare; |
7103 | itok.number=(oflag&f_extern)!=0?externnum++:secondcallnum++; |
7106 | itok.number=(oflag&f_extern)!=0?externnum++:secondcallnum++; |
7104 | itok.segm=NOT_DYNAMIC; |
7107 | itok.segm=NOT_DYNAMIC; |
7105 | itok.post=0; |
7108 | itok.post=0; |
7106 | } |
7109 | } |
7107 | itok.npointr=(unsigned short)npointr; |
7110 | itok.npointr=(unsigned short)npointr; |
7108 | itok.rm=orm; |
7111 | itok.rm=orm; |
7109 | itok.flag=oflag; |
7112 | itok.flag=oflag; |
7110 | if(itok.rm==tokens)itok.rm=(am32==0?tk_word:tk_dword); |
7113 | if(itok.rm==tokens)itok.rm=(am32==0?tk_word:tk_dword); |
7111 | // printf("rm=%d %s\n",itok.rm,itok.name); |
7114 | // printf("rm=%d %s\n",itok.rm,itok.name); |
7112 | strcpy((char *)string,param); |
7115 | strcpy((char *)string,param); |
7113 | rec=addtotree(pname); |
7116 | rec=addtotree(pname); |
7114 | if(next)nexttok(); |
7117 | if(next)nexttok(); |
7115 | else tok=j; |
7118 | else tok=j; |
7116 | IsUses(rec); |
7119 | IsUses(rec); |
7117 | } |
7120 | } |
7118 | 7121 | ||
7119 | void define_procedure() |
7122 | void define_procedure() |
7120 | { |
7123 | { |
7121 | if(dynamic_flag)dynamic_proc(); |
7124 | if(dynamic_flag)dynamic_proc(); |
7122 | else{ |
7125 | else{ |
7123 | itok.segm=NOT_DYNAMIC; |
7126 | itok.segm=NOT_DYNAMIC; |
7124 | if(AlignProc!=FALSE)AlignCD(CS,alignproc); |
7127 | if(AlignProc!=FALSE)AlignCD(CS,alignproc); |
7125 | procedure_start=outptr; |
7128 | procedure_start=outptr; |
7126 | if(dbg)AddLine(); |
7129 | if(dbg)AddLine(); |
7127 | // itok.flag&=~f_static; 26.08.05 00:09 |
7130 | // itok.flag&=~f_static; 26.08.05 00:09 |
7128 | setproc((tok==tk_id||tok==tk_ID)?0:1); |
7131 | setproc((tok==tk_id||tok==tk_ID)?0:1); |
7129 | dopoststrings(); |
7132 | dopoststrings(); |
7130 | } |
7133 | } |
7131 | } |
7134 | } |
7132 | 7135 | ||
7133 | void interruptproc() |
7136 | void interruptproc() |
7134 | { |
7137 | { |
7135 | char *bstring; |
7138 | char *bstring; |
7136 | ITOK otok; |
7139 | ITOK otok; |
7137 | inlineflag=0; |
7140 | inlineflag=0; |
7138 | procedure_start=outptr; |
7141 | procedure_start=outptr; |
7139 | returntype=tk_void; |
7142 | returntype=tk_void; |
7140 | current_proc_type=f_interrupt; |
7143 | current_proc_type=f_interrupt; |
7141 | localsize=paramsize=0; |
7144 | localsize=paramsize=0; |
7142 | nexttok(); |
7145 | nexttok(); |
7143 | // FindOff((unsigned char *)itok.name,CS); |
7146 | // FindOff((unsigned char *)itok.name,CS); |
7144 | itok.number=outptr; |
7147 | itok.number=outptr; |
7145 | itok.segm=NOT_DYNAMIC; |
7148 | itok.segm=NOT_DYNAMIC; |
7146 | itok.post=0; |
7149 | itok.post=0; |
7147 | itok.rm=tk_void; |
7150 | itok.rm=tk_void; |
7148 | itok.flag=0; |
7151 | itok.flag=0; |
7149 | if(tok==tk_ID||tok==tk_id){ |
7152 | if(tok==tk_ID||tok==tk_id){ |
7150 | tok=tk_interruptproc; |
7153 | tok=tk_interruptproc; |
7151 | itok.type=tp_ucnovn; |
7154 | itok.type=tp_ucnovn; |
7152 | addtotree((char *)string); |
7155 | addtotree((char *)string); |
7153 | } |
7156 | } |
7154 | else if(tok==tk_undefproc){ |
7157 | else if(tok==tk_undefproc){ |
7155 | tok=tk_interruptproc; |
7158 | tok=tk_interruptproc; |
7156 | long hold=updatetree(); |
7159 | long hold=updatetree(); |
7157 | updatecall((unsigned int)hold,(unsigned int)outptr,0); |
7160 | updatecall((unsigned int)hold,(unsigned int)outptr,0); |
7158 | } |
7161 | } |
7159 | else idalreadydefined(); |
7162 | else idalreadydefined(); |
7160 | itok.rec->count=FindOff((unsigned char *)itok.name,CS); |
7163 | itok.rec->count=FindOff((unsigned char *)itok.name,CS); |
7161 | bstring=BackString((char *)string); |
7164 | bstring=BackString((char *)string); |
7162 | otok=itok; |
7165 | otok=itok; |
7163 | nextexpecting2(tk_openbracket); |
7166 | nextexpecting2(tk_openbracket); |
7164 | expecting(tk_closebracket); |
7167 | expecting(tk_closebracket); |
7165 | if(tok==tk_inline){ |
7168 | if(tok==tk_inline){ |
7166 | inlineflag=1; |
7169 | inlineflag=1; |
7167 | nexttok(); |
7170 | nexttok(); |
7168 | } |
7171 | } |
7169 | else if(tok!=tk_openbrace)declarelocals(0); |
7172 | else if(tok!=tk_openbrace)declarelocals(0); |
7170 | expecting(tk_openbrace); |
7173 | expecting(tk_openbrace); |
7171 | declarelocals(1); |
7174 | declarelocals(1); |
7172 | startblock(); |
7175 | startblock(); |
7173 | doblock2(); /* do proc */ |
7176 | doblock2(); /* do proc */ |
7174 | endblock(); |
7177 | endblock(); |
7175 | if(retproc==FALSE){ |
7178 | if(retproc==FALSE){ |
7176 | if(inlineflag==0)leaveproc(); |
7179 | if(inlineflag==0)leaveproc(); |
7177 | else if(localsize>0)Leave(); |
7180 | else if(localsize>0)Leave(); |
7178 | } |
7181 | } |
7179 | initBP=0; |
7182 | initBP=0; |
7180 | strcpy((char *)string,bstring); |
7183 | strcpy((char *)string,bstring); |
7181 | itok=otok; |
7184 | itok=otok; |
7182 | tok=tk_interruptproc; |
7185 | tok=tk_interruptproc; |
7183 | itok.size=outptr-procedure_start; |
7186 | itok.size=outptr-procedure_start; |
7184 | updatetree(); |
7187 | updatetree(); |
7185 | free(bstring); |
7188 | free(bstring); |
7186 | killlocals(); |
7189 | killlocals(); |
7187 | nexttok(); |
7190 | nexttok(); |
7188 | dopoststrings(); |
7191 | dopoststrings(); |
7189 | } |
7192 | } |
7190 | 7193 | ||
7191 | int skipstring(int pos,unsigned char term) |
7194 | int skipstring(int pos,unsigned char term) |
7192 | { |
7195 | { |
7193 | unsigned char c; |
7196 | unsigned char c; |
7194 | do{ |
7197 | do{ |
7195 | pos++; |
7198 | pos++; |
7196 | c=input[pos]; |
7199 | c=input[pos]; |
7197 | if(c==0x5C){ |
7200 | if(c==0x5C){ |
7198 | pos++; |
7201 | pos++; |
7199 | continue; |
7202 | continue; |
7200 | // c=input[pos+1]; |
7203 | // c=input[pos+1]; |
7201 | } |
7204 | } |
7202 | }while(c!=term); |
7205 | }while(c!=term); |
7203 | return pos; |
7206 | return pos; |
7204 | } |
7207 | } |
7205 | 7208 | ||
7206 | int skipcomment(int pos) |
7209 | int skipcomment(int pos) |
7207 | { |
7210 | { |
7208 | if(input[pos+1]=='*'){ |
7211 | if(input[pos+1]=='*'){ |
7209 | pos+=2; |
7212 | pos+=2; |
7210 | for(;;pos++){ |
7213 | for(;;pos++){ |
7211 | if(input[pos]==13){ |
7214 | if(input[pos]==13){ |
7212 | linenumber++; |
7215 | linenumber++; |
7213 | } |
7216 | } |
7214 | else if(input[pos]=='*'){ |
7217 | else if(input[pos]=='*'){ |
7215 | pos++; |
7218 | pos++; |
7216 | if(input[pos]=='/')break; |
7219 | if(input[pos]=='/')break; |
7217 | } |
7220 | } |
7218 | if((unsigned int)pos>=endinptr){ |
7221 | if((unsigned int)pos>=endinptr){ |
7219 | unexpectedeof(); |
7222 | unexpectedeof(); |
7220 | break; |
7223 | break; |
7221 | } |
7224 | } |
7222 | } |
7225 | } |
7223 | } |
7226 | } |
7224 | else if(input[pos+1]=='/'){ |
7227 | else if(input[pos+1]=='/'){ |
7225 | pos+=2; |
7228 | pos+=2; |
7226 | for(;;pos++){ |
7229 | for(;;pos++){ |
7227 | if(input[pos]==13){ |
7230 | if(input[pos]==13){ |
7228 | linenumber++; |
7231 | linenumber++; |
7229 | break; |
7232 | break; |
7230 | } |
7233 | } |
7231 | if(input[pos]==10)break; |
7234 | if(input[pos]==10)break; |
7232 | } |
7235 | } |
7233 | } |
7236 | } |
7234 | return pos; |
7237 | return pos; |
7235 | } |
7238 | } |
7236 | 7239 | ||
7237 | int swapparam() |
7240 | int swapparam() |
7238 | { |
7241 | { |
7239 | int i,ns,j,lastofs; |
7242 | int i,ns,j,lastofs; |
7240 | int linep,linebak; |
7243 | int linep,linebak; |
7241 | char c,ochar; |
7244 | char c,ochar; |
7242 | unsigned char *bufpar; |
7245 | unsigned char *bufpar; |
7243 | int numpar=0; |
7246 | int numpar=0; |
7244 | unsigned char *oldinput; |
7247 | unsigned char *oldinput; |
7245 | paraminfo *pi; |
7248 | paraminfo *pi; |
7246 | if(tok!=tk_openbracket){ |
7249 | if(tok!=tk_openbracket){ |
7247 | expected('('); |
7250 | expected('('); |
7248 | do{ |
7251 | do{ |
7249 | nexttok(); |
7252 | nexttok(); |
7250 | }while(tok2!=tk_semicolon&&tok!=tk_eof); |
7253 | }while(tok2!=tk_semicolon&&tok!=tk_eof); |
7251 | return 0; |
7254 | return 0; |
7252 | } |
7255 | } |
7253 | pi=(paraminfo *)MALLOC(128*sizeof(paraminfo)); |
7256 | pi=(paraminfo *)MALLOC(128*sizeof(paraminfo)); |
7254 | do{ |
7257 | do{ |
7255 | inptr2--; |
7258 | inptr2--; |
7256 | }while(input[inptr2]!='('); |
7259 | }while(input[inptr2]!='('); |
7257 | inptr2++; |
7260 | inptr2++; |
7258 | pi->ofspar=inptr2; |
7261 | pi->ofspar=inptr2; |
7259 | pi->type[0]=0; |
7262 | pi->type[0]=0; |
7260 | linep=linenumber; |
7263 | linep=linenumber; |
7261 | for(i=inptr2,ns=1;ns>0;i++){ //ïîèñê êîíöà ïàðàìåòðîâ |
7264 | for(i=inptr2,ns=1;ns>0;i++){ //ïîèñê êîíöà ïàðàìåòðîâ |
7262 | switch(input[i]){ |
7265 | switch(input[i]){ |
7263 | case '(': ns++; break; |
7266 | case '(': ns++; break; |
7264 | case ')': ns--; break; |
7267 | case ')': ns--; break; |
7265 | case ',': |
7268 | case ',': |
7266 | if(ns==1){ |
7269 | if(ns==1){ |
7267 | if(numpar==127)preerror("To many parametrs in function"); |
7270 | if(numpar==127)preerror("To many parametrs in function"); |
7268 | numpar++; |
7271 | numpar++; |
7269 | (pi+numpar)->ofspar=i+1; |
7272 | (pi+numpar)->ofspar=i+1; |
7270 | (pi+numpar)->type[0]=0; |
7273 | (pi+numpar)->type[0]=0; |
7271 | } |
7274 | } |
7272 | break; |
7275 | break; |
7273 | case '/': |
7276 | case '/': |
7274 | i=skipcomment(i); |
7277 | i=skipcomment(i); |
7275 | break; |
7278 | break; |
7276 | case '"': |
7279 | case '"': |
7277 | case 0x27: |
7280 | case 0x27: |
7278 | i=skipstring(i,input[i]); |
7281 | i=skipstring(i,input[i]); |
7279 | break; |
7282 | break; |
7280 | case 13: |
7283 | case 13: |
7281 | linenumber++; |
7284 | linenumber++; |
7282 | break; |
7285 | break; |
7283 | } |
7286 | } |
7284 | if((unsigned int)i>=endinptr){ |
7287 | if((unsigned int)i>=endinptr){ |
7285 | unexpectedeof(); |
7288 | unexpectedeof(); |
7286 | break; |
7289 | break; |
7287 | } |
7290 | } |
7288 | } |
7291 | } |
7289 | for(j=0,ns=0;param[j]!=0;j++,ns++){//ïåðåâåðíóòü çàäåêëàðèðóåìûå ïàðàìåòðû |
7292 | for(j=0,ns=0;param[j]!=0;j++,ns++){//ïåðåâåðíóòü çàäåêëàðèðóåìûå ïàðàìåòðû |
7290 | lastofs=0; |
7293 | lastofs=0; |
7291 | ochar=c=param[j]; |
7294 | ochar=c=param[j]; |
7292 | (pi+ns)->type[0]=c; |
7295 | (pi+ns)->type[0]=c; |
7293 | while(c=='*'){ |
7296 | while(c=='*'){ |
7294 | j++; |
7297 | j++; |
7295 | ochar=c=param[j]; |
7298 | ochar=c=param[j]; |
7296 | (pi+ns)->type[++lastofs]=c; |
7299 | (pi+ns)->type[++lastofs]=c; |
7297 | } |
7300 | } |
7298 | if(c=='A'){ |
7301 | if(c=='A'){ |
7299 | if(ns){ |
7302 | if(ns){ |
7300 | while(ns<=numpar){ |
7303 | while(ns<=numpar){ |
7301 | (pi+ns)->type[0]='U'; |
7304 | (pi+ns)->type[0]='U'; |
7302 | (pi+ns)->type[1]=0; |
7305 | (pi+ns)->type[1]=0; |
7303 | ns++; |
7306 | ns++; |
7304 | } |
7307 | } |
7305 | break; |
7308 | break; |
7306 | } |
7309 | } |
7307 | } |
7310 | } |
7308 | if(ochar=='T'){ |
7311 | if(ochar=='T'){ |
7309 | do{ |
7312 | do{ |
7310 | j++; |
7313 | j++; |
7311 | lastofs++; |
7314 | lastofs++; |
7312 | c=param[j]; |
7315 | c=param[j]; |
7313 | (pi+ns)->type[lastofs]=c; |
7316 | (pi+ns)->type[lastofs]=c; |
7314 | }while(isdigit(c)); |
7317 | }while(isdigit(c)); |
7315 | (pi+ns)->type[lastofs]=0; |
7318 | (pi+ns)->type[lastofs]=0; |
7316 | j--; |
7319 | j--; |
7317 | continue; |
7320 | continue; |
7318 | } |
7321 | } |
7319 | c=param[j+1]; |
7322 | c=param[j+1]; |
7320 | if(c>='0'&&c<='7'){ |
7323 | if(c>='0'&&c<='7'){ |
7321 | (pi+ns)->type[1]=c; |
7324 | (pi+ns)->type[1]=c; |
7322 | j++; |
7325 | j++; |
7323 | lastofs++; |
7326 | lastofs++; |
7324 | if(ochar=='Q'){ |
7327 | if(ochar=='Q'){ |
7325 | (pi+ns)->type[2]=param[j+1]; |
7328 | (pi+ns)->type[2]=param[j+1]; |
7326 | j++; |
7329 | j++; |
7327 | lastofs++; |
7330 | lastofs++; |
7328 | } |
7331 | } |
7329 | } |
7332 | } |
7330 | (pi+ns)->type[++lastofs]=0; |
7333 | (pi+ns)->type[++lastofs]=0; |
7331 | } |
7334 | } |
7332 | ns--; |
7335 | ns--; |
7333 | for(j=0;ns>=0;ns--){ |
7336 | for(j=0;ns>=0;ns--){ |
7334 | lastofs=0; |
7337 | lastofs=0; |
7335 | c=(pi+ns)->type[lastofs++]; |
7338 | c=(pi+ns)->type[lastofs++]; |
7336 | while(c!=0){ |
7339 | while(c!=0){ |
7337 | param[j++]=c; |
7340 | param[j++]=c; |
7338 | c=(pi+ns)->type[lastofs++]; |
7341 | c=(pi+ns)->type[lastofs++]; |
7339 | } |
7342 | } |
7340 | } |
7343 | } |
7341 | param[j]=0; |
7344 | param[j]=0; |
7342 | // puts(param); |
7345 | // puts(param); |
7343 | // if(crec)printf("start0 swapparams num=%08X\n",crec->recnumber); |
7346 | // if(crec)printf("start0 swapparams num=%08X\n",crec->recnumber); |
7344 | bufpar=(unsigned char *)MALLOC(i-inptr2+2); |
7347 | bufpar=(unsigned char *)MALLOC(i-inptr2+2); |
7345 | // printf("crec=%08X size=%d bufpar=%08X size=%d\n",crec,sizeof(idrec),bufpar,i-inptr2+2); |
7348 | // printf("crec=%08X size=%d bufpar=%08X size=%d\n",crec,sizeof(idrec),bufpar,i-inptr2+2); |
7346 | inptr2=i; |
7349 | inptr2=i; |
7347 | ochar=input[inptr2]; |
7350 | ochar=input[inptr2]; |
7348 | inptr2++; |
7351 | inptr2++; |
7349 | i--; |
7352 | i--; |
7350 | lastofs=0; |
7353 | lastofs=0; |
7351 | for(;;){ |
7354 | for(;;){ |
7352 | j=(pi+numpar)->ofspar;//[numpar]; |
7355 | j=(pi+numpar)->ofspar;//[numpar]; |
7353 | for(ns=0;(j+ns)!=i;ns++){ |
7356 | for(ns=0;(j+ns)!=i;ns++){ |
7354 | bufpar[lastofs++]=input[j+ns]; |
7357 | bufpar[lastofs++]=input[j+ns]; |
7355 | } |
7358 | } |
7356 | i=j-1; |
7359 | i=j-1; |
7357 | numpar--; |
7360 | numpar--; |
7358 | if(numpar<0)break; |
7361 | if(numpar<0)break; |
7359 | bufpar[lastofs++]=','; |
7362 | bufpar[lastofs++]=','; |
7360 | } |
7363 | } |
7361 | bufpar[lastofs++]=')'; |
7364 | bufpar[lastofs++]=')'; |
7362 | *(short *)&bufpar[lastofs++]=';'; |
7365 | *(short *)&bufpar[lastofs++]=';'; |
7363 | free(pi); |
7366 | free(pi); |
7364 | oldinput=input; //ñîõð íåêîòîð ïåðåìåíûå |
7367 | oldinput=input; //ñîõð íåêîòîð ïåðåìåíûå |
7365 | // puts((char *)(input+inptr)); |
7368 | // puts((char *)(input+inptr)); |
7366 | // printf("cur_mod=%08X input=%08X\n",cur_mod,input); |
7369 | // printf("cur_mod=%08X input=%08X\n",cur_mod,input); |
7367 | ns=inptr2; |
7370 | ns=inptr2; |
7368 | j=endinptr; |
7371 | j=endinptr; |
7369 | input=bufpar; |
7372 | input=bufpar; |
7370 | // puts((char *)bufpar); |
7373 | // puts((char *)bufpar); |
7371 | inptr2=1; |
7374 | inptr2=1; |
7372 | cha2=input[0]; |
7375 | cha2=input[0]; |
7373 | endinptr=lastofs; |
7376 | endinptr=lastofs; |
7374 | tok=tk_openbracket; |
7377 | tok=tk_openbracket; |
7375 | if(bufrm!=NULL){ |
7378 | if(bufrm!=NULL){ |
7376 | free(bufrm); |
7379 | free(bufrm); |
7377 | bufrm=NULL; |
7380 | bufrm=NULL; |
7378 | } |
7381 | } |
7379 | if(strinf.bufstr!=NULL){ |
7382 | if(strinf.bufstr!=NULL){ |
7380 | free(strinf.bufstr); |
7383 | free(strinf.bufstr); |
7381 | strinf.bufstr=NULL; |
7384 | strinf.bufstr=NULL; |
7382 | } |
7385 | } |
7383 | linebak=linenumber; |
7386 | linebak=linenumber; |
7384 | linenumber=linep; |
7387 | linenumber=linep; |
7385 | i=doparams(); |
7388 | i=doparams(); |
7386 | endoffile=0; |
7389 | endoffile=0; |
7387 | input=oldinput; |
7390 | input=oldinput; |
7388 | inptr2=ns; |
7391 | inptr2=ns; |
7389 | cha2=ochar; |
7392 | cha2=ochar; |
7390 | endinptr=j; |
7393 | endinptr=j; |
7391 | linenumber=linebak; |
7394 | linenumber=linebak; |
7392 | // printf("cur_mod=%08X input=%08X\n",cur_mod,input); |
7395 | // printf("cur_mod=%08X input=%08X\n",cur_mod,input); |
7393 | free(bufpar); |
7396 | free(bufpar); |
7394 | // puts((char *)input); |
7397 | // puts((char *)input); |
7395 | return i; |
7398 | return i; |
7396 | } |
7399 | } |
7397 | 7400 | ||
7398 | int getrazr(int type) |
7401 | int getrazr(int type) |
7399 | { |
7402 | { |
7400 | switch(type){ |
7403 | switch(type){ |
7401 | case tk_char: |
7404 | case tk_char: |
7402 | case tk_byte: |
7405 | case tk_byte: |
7403 | return r8; |
7406 | return r8; |
7404 | case tk_word: |
7407 | case tk_word: |
7405 | case tk_int: |
7408 | case tk_int: |
7406 | return r16; |
7409 | return r16; |
7407 | case tk_long: |
7410 | case tk_long: |
7408 | case tk_dword: |
7411 | case tk_dword: |
7409 | case tk_float: |
7412 | case tk_float: |
7410 | return r32; |
7413 | return r32; |
7411 | case tk_qword: |
7414 | case tk_qword: |
7412 | case tk_double: |
7415 | case tk_double: |
7413 | return r64; |
7416 | return r64; |
7414 | } |
7417 | } |
7415 | if(am32)return r32; |
7418 | if(am32)return r32; |
7416 | return r16; |
7419 | return r16; |
7417 | } |
7420 | } |
7418 | 7421 | ||
7419 | int doparams() /* do stack procedure parameter pushing */ |
7422 | int doparams() /* do stack procedure parameter pushing */ |
7420 | { |
7423 | { |
7421 | char done=0,next; |
7424 | char done=0,next; |
7422 | int vartype; |
7425 | int vartype; |
7423 | int stackpar=0; |
7426 | int stackpar=0; |
7424 | int i; |
7427 | int i; |
7425 | int jj=0; |
7428 | int jj=0; |
7426 | char *bparam; //áóôåð äëÿ äåêëàðèðóåìûõ ïàðàìåòðîâ |
7429 | char *bparam; //áóôåð äëÿ äåêëàðèðóåìûõ ïàðàìåòðîâ |
7427 | int ip=-1; //íîìåð ïàðàìåòðà |
7430 | int ip=-1; //íîìåð ïàðàìåòðà |
7428 | char *ofsstr=NULL; |
7431 | char *ofsstr=NULL; |
7429 | int useAX=FALSE; |
7432 | int useAX=FALSE; |
7430 | int retreg=AX; |
7433 | int retreg=AX; |
7431 | unsigned char oaddstack=addstack; |
7434 | unsigned char oaddstack=addstack; |
7432 | unsigned char oinline=useinline; |
7435 | unsigned char oinline=useinline; |
7433 | useinline=0; |
7436 | useinline=0; |
7434 | int structsize; |
7437 | int structsize; |
7435 | struct idrec *ptrs; |
7438 | struct idrec *ptrs; |
7436 | addstack=FALSE; |
7439 | addstack=FALSE; |
7437 | if(am32!=FALSE)jj=2; |
7440 | if(am32!=FALSE)jj=2; |
7438 | bparam=BackString(param); |
7441 | bparam=BackString(param); |
7439 | if(param[0]!=0)ip=0; |
7442 | if(param[0]!=0)ip=0; |
7440 | ofsstr=GetLecsem(tk_camma,tk_closebracket); |
7443 | ofsstr=GetLecsem(tk_camma,tk_closebracket); |
7441 | expectingoperand(tk_openbracket); |
7444 | expectingoperand(tk_openbracket); |
7442 | ClearRegister(); |
7445 | ClearRegister(); |
7443 | if(tok!=tk_closebracket){ |
7446 | if(tok!=tk_closebracket){ |
7444 | while(tok!=tk_eof&&done==0){ |
7447 | while(tok!=tk_eof&&done==0){ |
7445 | useAX=FALSE; |
7448 | useAX=FALSE; |
7446 | retreg=AX; |
7449 | retreg=AX; |
7447 | i=0; |
7450 | i=0; |
7448 | next=1; |
7451 | next=1; |
7449 | if(ip!=-1){ |
7452 | if(ip!=-1){ |
7450 | if(bparam[ip]=='*'){ |
7453 | if(bparam[ip]=='*'){ |
7451 | while(bparam[ip]=='*')ip++; |
7454 | while(bparam[ip]=='*')ip++; |
7452 | ip++; |
7455 | ip++; |
7453 | vartype=(am32==FALSE?tk_word:tk_dword); |
7456 | vartype=(am32==FALSE?tk_word:tk_dword); |
7454 | } |
7457 | } |
7455 | else{ |
7458 | else{ |
7456 | if((vartype=GetTypeParam(bparam[ip++]))==0)ip=-1; |
7459 | if((vartype=GetTypeParam(bparam[ip++]))==0)ip=-1; |
7457 | else{ |
7460 | else{ |
7458 | int c=bparam[ip]; |
7461 | int c=bparam[ip]; |
7459 | if(vartype==tk_struct){ |
7462 | if(vartype==tk_struct){ |
7460 | structsize=0; |
7463 | structsize=0; |
7461 | while(isdigit(c)){ |
7464 | while(isdigit(c)){ |
7462 | c-='0'; |
7465 | c-='0'; |
7463 | structsize=structsize*10+c; |
7466 | structsize=structsize*10+c; |
7464 | ip++; |
7467 | ip++; |
7465 | c=param[ip]; |
7468 | c=param[ip]; |
7466 | } |
7469 | } |
7467 | } |
7470 | } |
7468 | else if(c>='0'&&c<='7'){ |
7471 | else if(c>='0'&&c<='7'){ |
7469 | ip++; |
7472 | ip++; |
7470 | c-=0x30; |
7473 | c-=0x30; |
7471 | if(vartype==tk_fpust)float2stack(c); |
7474 | if(vartype==tk_fpust)float2stack(c); |
7472 | else{ |
7475 | else{ |
7473 | if(vartype==tk_qword){ |
7476 | if(vartype==tk_qword){ |
7474 | c|=(bparam[ip]-0x30)*256; |
7477 | c|=(bparam[ip]-0x30)*256; |
7475 | ip++; |
7478 | ip++; |
7476 | } |
7479 | } |
7477 | CalcRegPar(c,vartype,&ofsstr); |
7480 | CalcRegPar(c,vartype,&ofsstr); |
7478 | } |
7481 | } |
7479 | goto endparam; |
7482 | goto endparam; |
7480 | } |
7483 | } |
7481 | } |
7484 | } |
7482 | } |
7485 | } |
7483 | if(vartype==tk_multipoint){ |
7486 | if(vartype==tk_multipoint){ |
7484 | vartype=tokens; |
7487 | vartype=tokens; |
7485 | ip--; |
7488 | ip--; |
7486 | } |
7489 | } |
7487 | } |
7490 | } |
7488 | if(tok==tk_string){ |
7491 | if(tok==tk_string){ |
7489 | if(chip<2||(optimizespeed&&(chip==5||chip==6))){ |
7492 | if(chip<2||(optimizespeed&&(chip==5||chip==6))){ |
7490 | op(0xB8); |
7493 | op(0xB8); |
7491 | if(am32!=FALSE)outdword(addpoststring()); |
7494 | if(am32!=FALSE)outdword(addpoststring()); |
7492 | else outword(addpoststring()); // MOV AX,imm16 |
7495 | else outword(addpoststring()); // MOV AX,imm16 |
7493 | op(0x50); |
7496 | op(0x50); |
7494 | useAX=TRUE; |
7497 | useAX=TRUE; |
7495 | ClearReg(EAX); //íàäî äîáàâèòü îïòèìèçàöèþ ðåãèñòðîâ à ïîêà òàê |
7498 | ClearReg(EAX); //íàäî äîáàâèòü îïòèìèçàöèþ ðåãèñòðîâ à ïîêà òàê |
7496 | } /* PUSH AX */ |
7499 | } /* PUSH AX */ |
7497 | else{ |
7500 | else{ |
7498 | op(0x68); /* PUSH imm16 */ |
7501 | op(0x68); /* PUSH imm16 */ |
7499 | if(am32!=FALSE)outdword(addpoststring()); |
7502 | if(am32!=FALSE)outdword(addpoststring()); |
7500 | else outword(addpoststring()); |
7503 | else outword(addpoststring()); |
7501 | if(cpu<2)cpu=2; |
7504 | if(cpu<2)cpu=2; |
7502 | } |
7505 | } |
7503 | stackpar+=2+jj; |
7506 | stackpar+=2+jj; |
7504 | addESP+=2+jj; |
7507 | addESP+=2+jj; |
7505 | nexttok(); |
7508 | nexttok(); |
7506 | } |
7509 | } |
7507 | else{ |
7510 | else{ |
7508 | if(tok>=tk_char&&tok<=tk_double){ |
7511 | if(tok>=tk_char&&tok<=tk_double){ |
7509 | vartype=tok; |
7512 | vartype=tok; |
7510 | getoperand(); |
7513 | getoperand(); |
7511 | } |
7514 | } |
7512 | else if(tok==tk_openbracket){ |
7515 | else if(tok==tk_openbracket){ |
7513 | nexttok(); |
7516 | nexttok(); |
7514 | if(tok>=tk_char&&tok<=tk_double)vartype=tok; |
7517 | if(tok>=tk_char&&tok<=tk_double)vartype=tok; |
7515 | nexttok(); |
7518 | nexttok(); |
7516 | expectingoperand(tk_closebracket); |
7519 | expectingoperand(tk_closebracket); |
7517 | } |
7520 | } |
7518 | else{ |
7521 | else{ |
7519 | if(ip==-1||vartype==tokens){ |
7522 | if(ip==-1||vartype==tokens){ |
7520 | switch(tok){ |
7523 | switch(tok){ |
7521 | case tk_longvar: vartype=tk_long; break; |
7524 | case tk_longvar: vartype=tk_long; break; |
7522 | case tk_floatvar: vartype=tk_float; break; |
7525 | case tk_floatvar: vartype=tk_float; break; |
7523 | case tk_dwordvar: vartype=tk_dword; break; |
7526 | case tk_dwordvar: vartype=tk_dword; break; |
7524 | case tk_doublevar: vartype=tk_double; break; |
7527 | case tk_doublevar: vartype=tk_double; break; |
7525 | case tk_qwordvar: vartype=tk_qword; break; |
7528 | case tk_qwordvar: vartype=tk_qword; break; |
7526 | case tk_number: |
7529 | case tk_number: |
7527 | vartype=(itok.rm==tk_float?tk_float:(am32==FALSE?tk_word:tk_dword)); |
7530 | vartype=(itok.rm==tk_float?tk_float:(am32==FALSE?tk_word:tk_dword)); |
7528 | break; |
7531 | break; |
7529 | case tk_reg32: vartype=tk_dword; break; |
7532 | case tk_reg32: vartype=tk_dword; break; |
7530 | case tk_reg64: vartype=tk_qword; break; |
7533 | case tk_reg64: vartype=tk_qword; break; |
7531 | case tk_minus: |
7534 | case tk_minus: |
7532 | if(tok2==tk_number){ |
7535 | if(tok2==tk_number){ |
7533 | vartype=itok2.rm==tk_float?tk_float:(am32==FALSE?tk_word:tk_dword); |
7536 | vartype=itok2.rm==tk_float?tk_float:(am32==FALSE?tk_word:tk_dword); |
7534 | break; |
7537 | break; |
7535 | } |
7538 | } |
7536 | default: vartype=(am32==FALSE?tk_word:tk_dword); break; |
7539 | default: vartype=(am32==FALSE?tk_word:tk_dword); break; |
7537 | } |
7540 | } |
7538 | } |
7541 | } |
7539 | } |
7542 | } |
7540 | if(tok==tk_minus&&tok2==tk_number&&vartype!=tk_float){ //ïðîâåðêà îòðèöàòåëüíîãî ÷èñëà |
7543 | if(tok==tk_minus&&tok2==tk_number&&vartype!=tk_float){ //ïðîâåðêà îòðèöàòåëüíîãî ÷èñëà |
7541 | nexttok(); |
7544 | nexttok(); |
7542 | itok.lnumber=-itok.lnumber; |
7545 | itok.lnumber=-itok.lnumber; |
7543 | } |
7546 | } |
7544 | int razr; |
7547 | int razr; |
7545 | if(ofsstr){ |
7548 | if(ofsstr){ |
7546 | razr=getrazr(vartype); |
7549 | razr=getrazr(vartype); |
7547 | int retr; |
7550 | int retr; |
7548 | if((retr=CheckIDZReg(ofsstr,AX,razr))!=NOINREG){ |
7551 | if((retr=CheckIDZReg(ofsstr,AX,razr))!=NOINREG){ |
7549 | // printf("reg=%d\n",retr); |
7552 | // printf("reg=%d\n",retr); |
7550 | GetEndLex(tk_camma,tk_closebracket); |
7553 | GetEndLex(tk_camma,tk_closebracket); |
7551 | if(razr==r8)razr=am32==0?r16:r32; |
7554 | if(razr==r8)razr=am32==0?r16:r32; |
7552 | if(retr==SKIPREG)retreg=AX; |
7555 | if(retr==SKIPREG)retreg=AX; |
7553 | else retreg=retr; |
7556 | else retreg=retr; |
7554 | op66(razr); |
7557 | op66(razr); |
7555 | op(0x50+retreg); |
7558 | op(0x50+retreg); |
7556 | useAX=TRUE; |
7559 | useAX=TRUE; |
7557 | stackpar+=razr; |
7560 | stackpar+=razr; |
7558 | addESP+=razr; |
7561 | addESP+=razr; |
7559 | goto endparam1; |
7562 | goto endparam1; |
7560 | } |
7563 | } |
7561 | // printf("reg=%d\n",retr); |
7564 | // printf("reg=%d\n",retr); |
7562 | } |
7565 | } |
7563 | razr=r32; |
7566 | razr=r32; |
7564 | if(itok2.type==tp_opperand||tok==tk_minus){ //ñîñòàâíîå |
7567 | if(itok2.type==tp_opperand||tok==tk_minus){ //ñîñòàâíîå |
7565 | switch(vartype){ |
7568 | switch(vartype){ |
7566 | case tk_struct: |
7569 | case tk_struct: |
7567 | i=structsize/((am32+1)*2); |
7570 | i=structsize/((am32+1)*2); |
7568 | do_e_axmath(0,r32,&ofsstr); |
7571 | do_e_axmath(0,r32,&ofsstr); |
7569 | ClearReg(AX); |
7572 | ClearReg(AX); |
7570 | if(am32){ |
7573 | if(am32){ |
7571 | i--; |
7574 | i--; |
7572 | itok.number=structsize; |
7575 | itok.number=structsize; |
7573 | for(;i>0;i--){ |
7576 | for(;i>0;i--){ |
7574 | itok.number-=4; |
7577 | itok.number-=4; |
7575 | outword(0x70FF); |
7578 | outword(0x70FF); |
7576 | op(itok.number); |
7579 | op(itok.number); |
7577 | } |
7580 | } |
7578 | outword(0x30FF); |
7581 | outword(0x30FF); |
7579 | } |
7582 | } |
7580 | else{ |
7583 | else{ |
7581 | ClearReg(BX); |
7584 | ClearReg(BX); |
7582 | warningreg(regs[1][BX]); |
7585 | warningreg(regs[1][BX]); |
7583 | outword(0xC389); |
7586 | outword(0xC389); |
7584 | i--; |
7587 | i--; |
7585 | itok.number=structsize; |
7588 | itok.number=structsize; |
7586 | for(;i>0;i--){ |
7589 | for(;i>0;i--){ |
7587 | itok.number-=2; |
7590 | itok.number-=2; |
7588 | outword(0x77FF); |
7591 | outword(0x77FF); |
7589 | op(itok.number); |
7592 | op(itok.number); |
7590 | } |
7593 | } |
7591 | outword(0x37FF); |
7594 | outword(0x37FF); |
7592 | } |
7595 | } |
7593 | stackpar+=structsize; |
7596 | stackpar+=structsize; |
7594 | addESP+=structsize; |
7597 | addESP+=structsize; |
7595 | break; |
7598 | break; |
7596 | case tk_char: i=1; |
7599 | case tk_char: i=1; |
7597 | case tk_byte: |
7600 | case tk_byte: |
7598 | stackpar+=jj; |
7601 | stackpar+=jj; |
7599 | doalmath((char)i,&ofsstr); |
7602 | doalmath((char)i,&ofsstr); |
7600 | addESP+=2+jj; |
7603 | addESP+=2+jj; |
7601 | break; |
7604 | break; |
7602 | case tk_int: i=1; |
7605 | case tk_int: i=1; |
7603 | case tk_word: |
7606 | case tk_word: |
7604 | if(am32==FALSE)razr=r16; |
7607 | if(am32==FALSE)razr=r16; |
7605 | stackpar+=jj; |
7608 | stackpar+=jj; |
7606 | goto blokl; |
7609 | goto blokl; |
7607 | case tk_long: i=1; |
7610 | case tk_long: i=1; |
7608 | case tk_dword: |
7611 | case tk_dword: |
7609 | if(cpu<3)cpu=3; |
7612 | if(cpu<3)cpu=3; |
7610 | stackpar+=2; |
7613 | stackpar+=2; |
7611 | blokl: |
7614 | blokl: |
7612 | if(chip>=2&&(!(optimizespeed&&(chip==5||chip==6)))&&(tok==tk_number |
7615 | if(chip>=2&&(!(optimizespeed&&(chip==5||chip==6)))&&(tok==tk_number |
7613 | ||tok==tk_undefofs||tok==tk_postnumber)){ |
7616 | ||tok==tk_undefofs||tok==tk_postnumber)){ |
7614 | int otok=tok; |
7617 | int otok=tok; |
7615 | ITOK oitok=itok; |
7618 | ITOK oitok=itok; |
7616 | tok=tk_number; |
7619 | tok=tk_number; |
7617 | if(OnlyNumber(i)){ |
7620 | if(OnlyNumber(i)){ |
7618 | op66(razr); |
7621 | op66(razr); |
7619 | if(otok==tk_number&&(postnumflag&f_reloc)==0&&short_ok(itok.number,razr==r16?FALSE:TRUE)!=0){ |
7622 | if(otok==tk_number&&(postnumflag&f_reloc)==0&&short_ok(itok.number,razr==r16?FALSE:TRUE)!=0){ |
7620 | op(0x6A); // PUSH 8 extend to 32 bit |
7623 | op(0x6A); // PUSH 8 extend to 32 bit |
7621 | op((unsigned int)itok.number); |
7624 | op((unsigned int)itok.number); |
7622 | } |
7625 | } |
7623 | else{ |
7626 | else{ |
7624 | op(0x68); // PUSH const |
7627 | op(0x68); // PUSH const |
7625 | if(otok==tk_undefofs)AddUndefOff(0,oitok.name); |
7628 | if(otok==tk_undefofs)AddUndefOff(0,oitok.name); |
7626 | else if(otok==tk_postnumber)(oitok.flag&f_extern)==0?setwordpost(&oitok):setwordext(&oitok.number); |
7629 | else if(otok==tk_postnumber)(oitok.flag&f_extern)==0?setwordpost(&oitok):setwordext(&oitok.number); |
7627 | else if((postnumflag&f_reloc)!=0)AddReloc(); |
7630 | else if((postnumflag&f_reloc)!=0)AddReloc(); |
7628 | if(razr==r16)outword(itok.number); |
7631 | if(razr==r16)outword(itok.number); |
7629 | else outdword(itok.number); |
7632 | else outdword(itok.number); |
7630 | } |
7633 | } |
7631 | addESP+=razr==r16?2:4; |
7634 | addESP+=razr==r16?2:4; |
7632 | goto nopush; |
7635 | goto nopush; |
7633 | } |
7636 | } |
7634 | tok=otok; |
7637 | tok=otok; |
7635 | } |
7638 | } |
7636 | do_e_axmath(i,razr,&ofsstr); |
7639 | do_e_axmath(i,razr,&ofsstr); |
7637 | addESP+=razr==r16?2:4; |
7640 | addESP+=razr==r16?2:4; |
7638 | op66(razr); |
7641 | op66(razr); |
7639 | break; |
7642 | break; |
7640 | case tk_double: |
7643 | case tk_double: |
7641 | if(doeaxfloatmath(tk_stackstart,0,4)!=tk_stackstart){ |
7644 | if(doeaxfloatmath(tk_stackstart,0,4)!=tk_stackstart){ |
7642 | op66(r32); |
7645 | op66(r32); |
7643 | op(0x50+EDX); // PUSH EDX |
7646 | op(0x50+EDX); // PUSH EDX |
7644 | op66(r32); |
7647 | op66(r32); |
7645 | op(0x50); //push eax |
7648 | op(0x50); //push eax |
7646 | useAX=TRUE; |
7649 | useAX=TRUE; |
7647 | } |
7650 | } |
7648 | if(cpu<3)cpu=3; |
7651 | if(cpu<3)cpu=3; |
7649 | stackpar+=6; |
7652 | stackpar+=6; |
7650 | addESP+=8; |
7653 | addESP+=8; |
7651 | goto nopush; |
7654 | goto nopush; |
7652 | case tk_float: |
7655 | case tk_float: |
7653 | if(doeaxfloatmath(tk_stackstart)!=tk_stackstart){ |
7656 | if(doeaxfloatmath(tk_stackstart)!=tk_stackstart){ |
7654 | op66(r32); |
7657 | op66(r32); |
7655 | if(!am32){ |
7658 | if(!am32){ |
7656 | op(0x89); // mov ssdword[bp+2]=eax |
7659 | op(0x89); // mov ssdword[bp+2]=eax |
7657 | op(0x46); |
7660 | op(0x46); |
7658 | op(2); |
7661 | op(2); |
7659 | Leave(); |
7662 | Leave(); |
7660 | } |
7663 | } |
7661 | else{ |
7664 | else{ |
7662 | op(0x50); //push eax |
7665 | op(0x50); //push eax |
7663 | useAX=TRUE; |
7666 | useAX=TRUE; |
7664 | } |
7667 | } |
7665 | } |
7668 | } |
7666 | if(cpu<3)cpu=3; |
7669 | if(cpu<3)cpu=3; |
7667 | stackpar+=2; |
7670 | stackpar+=2; |
7668 | addESP+=4; |
7671 | addESP+=4; |
7669 | goto nopush; |
7672 | goto nopush; |
7670 | case tk_qwordvar: |
7673 | case tk_qwordvar: |
7671 | i=EAX|(EDX*256); |
7674 | i=EAX|(EDX*256); |
7672 | getintoreg64(i); |
7675 | getintoreg64(i); |
7673 | doregmath64(i); |
7676 | doregmath64(i); |
7674 | op66(r32); |
7677 | op66(r32); |
7675 | op(0x50+EDX); // PUSH EDX |
7678 | op(0x50+EDX); // PUSH EDX |
7676 | op66(r32); |
7679 | op66(r32); |
7677 | next=0; |
7680 | next=0; |
7678 | if(cpu<3)cpu=3; |
7681 | if(cpu<3)cpu=3; |
7679 | stackpar+=6; |
7682 | stackpar+=6; |
7680 | addESP+=8; |
7683 | addESP+=8; |
7681 | break; |
7684 | break; |
7682 | default: goto deflt; |
7685 | default: goto deflt; |
7683 | } |
7686 | } |
7684 | op(0x50);/* PUSH AX or EAX */ |
7687 | op(0x50);/* PUSH AX or EAX */ |
7685 | useAX=TRUE; |
7688 | useAX=TRUE; |
7686 | nopush: |
7689 | nopush: |
7687 | stackpar+=2; |
7690 | stackpar+=2; |
7688 | } |
7691 | } |
7689 | else{ //îäèíî÷íîå |
7692 | else{ //îäèíî÷íîå |
7690 | // next=1; |
7693 | // next=1; |
7691 | // printf("vartype=%d\n",vartype); |
7694 | // printf("vartype=%d\n",vartype); |
7692 | if(vartype==tk_struct){ |
7695 | if(vartype==tk_struct){ |
7693 | // printf("tok=%d %s\n",tok,itok.name); |
7696 | // printf("tok=%d %s\n",tok,itok.name); |
7694 | i=structsize/((am32+1)*2); |
7697 | i=structsize/((am32+1)*2); |
7695 | switch(tok){ |
7698 | switch(tok){ |
7696 | case tk_structvar: |
7699 | case tk_structvar: |
7697 | ptrs=itok.rec; |
7700 | ptrs=itok.rec; |
7698 | if(ptrs->recpost==LOCAL){ |
7701 | if(ptrs->recpost==LOCAL){ |
7699 | if(ESPloc&&am32){ |
7702 | if(ESPloc&&am32){ |
7700 | itok.rm=rm_mod10|rm_sib; |
7703 | itok.rm=rm_mod10|rm_sib; |
7701 | itok.sib=0x24; |
7704 | itok.sib=0x24; |
7702 | itok.number+=addESP; |
7705 | itok.number+=addESP; |
7703 | } |
7706 | } |
7704 | else{ |
7707 | else{ |
7705 | itok.rm=rm_mod10|(am32==FALSE?rm_BP:rm_EBP); |
7708 | itok.rm=rm_mod10|(am32==FALSE?rm_BP:rm_EBP); |
7706 | } |
7709 | } |
7707 | itok.segm=SS; |
7710 | itok.segm=SS; |
7708 | itok.post=0; |
7711 | itok.post=0; |
7709 | compressoffset(&itok); |
7712 | compressoffset(&itok); |
7710 | } |
7713 | } |
7711 | else{ |
7714 | else{ |
7712 | itok.segm=DS; |
7715 | itok.segm=DS; |
7713 | itok.rm=(am32==FALSE?rm_d16:rm_d32); //óñòàíîâêè ïî óìîë÷àíèþ |
7716 | itok.rm=(am32==FALSE?rm_d16:rm_d32); //óñòàíîâêè ïî óìîë÷àíèþ |
7714 | itok.post=ptrs->recpost; |
7717 | itok.post=ptrs->recpost; |
7715 | if(i>1&&am32){ |
7718 | if(i>1&&am32){ |
7716 | outseg(&itok,1); |
7719 | outseg(&itok,1); |
7717 | op(0xB8); |
7720 | op(0xB8); |
7718 | outaddress(&itok); |
7721 | outaddress(&itok); |
7719 | ClearReg(AX); |
7722 | ClearReg(AX); |
7720 | i--; |
7723 | i--; |
7721 | itok.number=structsize; |
7724 | itok.number=structsize; |
7722 | for(;i>0;i--){ |
7725 | for(;i>0;i--){ |
7723 | itok.number-=4; |
7726 | itok.number-=4; |
7724 | outword(0x70FF); |
7727 | outword(0x70FF); |
7725 | op(itok.number); |
7728 | op(itok.number); |
7726 | } |
7729 | } |
7727 | outword(0x30FF); |
7730 | outword(0x30FF); |
7728 | break; |
7731 | break; |
7729 | } |
7732 | } |
7730 | } |
7733 | } |
7731 | itok.sib=(am32==FALSE?CODE16:CODE32); |
7734 | itok.sib=(am32==FALSE?CODE16:CODE32); |
7732 | itok.flag=ptrs->flag; |
7735 | itok.flag=ptrs->flag; |
7733 | itok.number+=structsize; |
7736 | itok.number+=structsize; |
7734 | for(;i>0;i--){ |
7737 | for(;i>0;i--){ |
7735 | itok.number-=(am32+1)*2; |
7738 | itok.number-=(am32+1)*2; |
7736 | outseg(&itok,2); |
7739 | outseg(&itok,2); |
7737 | op(0xFF); // PUSH [dword] |
7740 | op(0xFF); // PUSH [dword] |
7738 | op(0x30+itok.rm); |
7741 | op(0x30+itok.rm); |
7739 | outaddress(&itok); |
7742 | outaddress(&itok); |
7740 | } |
7743 | } |
7741 | break; |
7744 | break; |
7742 | case tk_rmnumber: |
7745 | case tk_rmnumber: |
7743 | itok.number+=structsize; |
7746 | itok.number+=structsize; |
7744 | for(;i>0;i--){ |
7747 | for(;i>0;i--){ |
7745 | itok.number-=(am32+1)*2; |
7748 | itok.number-=(am32+1)*2; |
7746 | outseg(&itok,2); |
7749 | outseg(&itok,2); |
7747 | op(0xFF); // PUSH [dword] |
7750 | op(0xFF); // PUSH [dword] |
7748 | op(0x30+itok.rm); |
7751 | op(0x30+itok.rm); |
7749 | outaddress(&itok); |
7752 | outaddress(&itok); |
7750 | } |
7753 | } |
7751 | break; |
7754 | break; |
7752 | case tk_undefofs: |
7755 | case tk_undefofs: |
7753 | itok.rm=(am32==FALSE?rm_d16:rm_d32); //óñòàíîâêè ïî óìîë÷àíèþ |
7756 | itok.rm=(am32==FALSE?rm_d16:rm_d32); //óñòàíîâêè ïî óìîë÷àíèþ |
7754 | case tk_postnumber: |
7757 | case tk_postnumber: |
7755 | if(i>1&&am32){ |
7758 | if(i>1&&am32){ |
7756 | if(tok!=tk_undefofs)outseg(&itok,1); |
7759 | if(tok!=tk_undefofs)outseg(&itok,1); |
7757 | op(0xB8); |
7760 | op(0xB8); |
7758 | if(tok==tk_undefofs){ |
7761 | if(tok==tk_undefofs){ |
7759 | AddUndefOff(0,(char *)string); |
7762 | AddUndefOff(0,(char *)string); |
7760 | outdword(itok.number); |
7763 | outdword(itok.number); |
7761 | } |
7764 | } |
7762 | else outaddress(&itok); |
7765 | else outaddress(&itok); |
7763 | ClearReg(AX); |
7766 | ClearReg(AX); |
7764 | i--; |
7767 | i--; |
7765 | itok.number=structsize; |
7768 | itok.number=structsize; |
7766 | for(;i>0;i--){ |
7769 | for(;i>0;i--){ |
7767 | itok.number-=4; |
7770 | itok.number-=4; |
7768 | outword(0x70FF); |
7771 | outword(0x70FF); |
7769 | op(itok.number); |
7772 | op(itok.number); |
7770 | } |
7773 | } |
7771 | outword(0x30FF); |
7774 | outword(0x30FF); |
7772 | break; |
7775 | break; |
7773 | } |
7776 | } |
7774 | itok.number+=structsize; |
7777 | itok.number+=structsize; |
7775 | for(;i>0;i--){ |
7778 | for(;i>0;i--){ |
7776 | itok.number-=(am32+1)*2; |
7779 | itok.number-=(am32+1)*2; |
7777 | if(tok!=tk_undefofs)outseg(&itok,2); |
7780 | if(tok!=tk_undefofs)outseg(&itok,2); |
7778 | op(0xFF); // PUSH [dword] |
7781 | op(0xFF); // PUSH [dword] |
7779 | op(0x30+itok.rm); |
7782 | op(0x30+itok.rm); |
7780 | if(tok==tk_undefofs){ |
7783 | if(tok==tk_undefofs){ |
7781 | AddUndefOff(0,(char *)string); |
7784 | AddUndefOff(0,(char *)string); |
7782 | outdword(itok.number); |
7785 | outdword(itok.number); |
7783 | } |
7786 | } |
7784 | else outaddress(&itok); |
7787 | else outaddress(&itok); |
7785 | } |
7788 | } |
7786 | break; |
7789 | break; |
7787 | case tk_reg32: |
7790 | case tk_reg32: |
7788 | i--; |
7791 | i--; |
7789 | itok.rm=structsize; |
7792 | itok.rm=structsize; |
7790 | for(;i>0;i--){ |
7793 | for(;i>0;i--){ |
7791 | itok.rm-=4; |
7794 | itok.rm-=4; |
7792 | op(0xFF); |
7795 | op(0xFF); |
7793 | op(0x70+itok.number); |
7796 | op(0x70+itok.number); |
7794 | op(itok.rm); |
7797 | op(itok.rm); |
7795 | } |
7798 | } |
7796 | op(0xFF); |
7799 | op(0xFF); |
7797 | op(0x30+itok.number); |
7800 | op(0x30+itok.number); |
7798 | break; |
7801 | break; |
7799 | default: |
7802 | default: |
7800 | // preerror("for parametr function required structure"); |
7803 | // preerror("for parametr function required structure"); |
7801 | do_e_axmath(0,r32,&ofsstr); |
7804 | do_e_axmath(0,r32,&ofsstr); |
7802 | ClearReg(AX); |
7805 | ClearReg(AX); |
7803 | if(am32){ |
7806 | if(am32){ |
7804 | i--; |
7807 | i--; |
7805 | itok.number=structsize; |
7808 | itok.number=structsize; |
7806 | for(;i>0;i--){ |
7809 | for(;i>0;i--){ |
7807 | itok.number-=4; |
7810 | itok.number-=4; |
7808 | outword(0x70FF); |
7811 | outword(0x70FF); |
7809 | op(itok.number); |
7812 | op(itok.number); |
7810 | } |
7813 | } |
7811 | outword(0x30FF); |
7814 | outword(0x30FF); |
7812 | } |
7815 | } |
7813 | else{ |
7816 | else{ |
7814 | ClearReg(BX); |
7817 | ClearReg(BX); |
7815 | warningreg(regs[1][BX]); |
7818 | warningreg(regs[1][BX]); |
7816 | outword(0xC389); |
7819 | outword(0xC389); |
7817 | i--; |
7820 | i--; |
7818 | itok.number=structsize; |
7821 | itok.number=structsize; |
7819 | for(;i>0;i--){ |
7822 | for(;i>0;i--){ |
7820 | itok.number-=2; |
7823 | itok.number-=2; |
7821 | outword(0x77FF); |
7824 | outword(0x77FF); |
7822 | op(itok.number); |
7825 | op(itok.number); |
7823 | } |
7826 | } |
7824 | outword(0x37FF); |
7827 | outword(0x37FF); |
7825 | } |
7828 | } |
7826 | break; |
7829 | break; |
7827 | } |
7830 | } |
7828 | stackpar+=structsize; |
7831 | stackpar+=structsize; |
7829 | addESP+=structsize; |
7832 | addESP+=structsize; |
7830 | } |
7833 | } |
7831 | else if(vartype |
7834 | else if(vartype |
7832 | #ifdef OPTVARCONST |
7835 | #ifdef OPTVARCONST |
7833 | CheckConstVar3(&tok,&itok,razr); |
7836 | CheckConstVar3(&tok,&itok,razr); |
7834 | #endif |
7837 | #endif |
7835 | switch(tok){ |
7838 | switch(tok){ |
7836 | case tk_reg: |
7839 | case tk_reg: |
7837 | op(0x50+(unsigned int)itok.number); |
7840 | op(0x50+(unsigned int)itok.number); |
7838 | break; |
7841 | break; |
7839 | case tk_beg: |
7842 | case tk_beg: |
7840 | if(vartype==tk_int||vartype==tk_word)goto deflt; |
7843 | if(vartype==tk_int||vartype==tk_word)goto deflt; |
7841 | if(itok.number |
7844 | if(itok.number |
7842 | op(0x50+(unsigned int)itok.number); |
7845 | op(0x50+(unsigned int)itok.number); |
7843 | break; |
7846 | break; |
7844 | } |
7847 | } |
7845 | op(0x88); |
7848 | op(0x88); |
7846 | op(0xC0+(unsigned int)itok.number*8); |
7849 | op(0xC0+(unsigned int)itok.number*8); |
7847 | op(0x50); |
7850 | op(0x50); |
7848 | useAX=TRUE; |
7851 | useAX=TRUE; |
7849 | break; |
7852 | break; |
7850 | case tk_seg: |
7853 | case tk_seg: |
7851 | if(am32)goto deflt; |
7854 | if(am32)goto deflt; |
7852 | if((unsigned int)itok.number |
7855 | if((unsigned int)itok.number |
7853 | else{ |
7856 | else{ |
7854 | op(0xF); op(0x80+(unsigned int)itok.number*8); |
7857 | op(0xF); op(0x80+(unsigned int)itok.number*8); |
7855 | if((unsigned int)itok.number<=GS)if(cpu<3)cpu=3; |
7858 | if((unsigned int)itok.number<=GS)if(cpu<3)cpu=3; |
7856 | } |
7859 | } |
7857 | break; |
7860 | break; |
7858 | case tk_longvar: |
7861 | case tk_longvar: |
7859 | case tk_dwordvar: |
7862 | case tk_dwordvar: |
7860 | // if(am32==FALSE)goto deflt; |
7863 | // if(am32==FALSE)goto deflt; |
7861 | i=2; |
7864 | i=2; |
7862 | case tk_intvar: |
7865 | case tk_intvar: |
7863 | case tk_wordvar: |
7866 | case tk_wordvar: |
7864 | i+=2; |
7867 | i+=2; |
7865 | CheckAllMassiv(bufrm,i,&strinf); |
7868 | CheckAllMassiv(bufrm,i,&strinf); |
7866 | outseg(&itok,2); |
7869 | outseg(&itok,2); |
7867 | op(0xFF); /* PUSH [word] */ |
7870 | op(0xFF); /* PUSH [word] */ |
7868 | op(0x30+itok.rm); |
7871 | op(0x30+itok.rm); |
7869 | outaddress(&itok); |
7872 | outaddress(&itok); |
7870 | break; |
7873 | break; |
7871 | case tk_number: |
7874 | case tk_number: |
7872 | if(chip>=2/*&&(!(optimizespeed&&(chip==5||chip==6)))*/){ //28.03.07 19:04 |
7875 | if(chip>=2/*&&(!(optimizespeed&&(chip==5||chip==6)))*/){ //28.03.07 19:04 |
7873 | if((itok.flag&f_reloc)==0&&short_ok(itok.number)){ |
7876 | if((itok.flag&f_reloc)==0&&short_ok(itok.number)){ |
7874 | op(0x6A); /* PUSH const */ |
7877 | op(0x6A); /* PUSH const */ |
7875 | op((unsigned int)itok.number); |
7878 | op((unsigned int)itok.number); |
7876 | } |
7879 | } |
7877 | else{ |
7880 | else{ |
7878 | op(0x68); /* PUSH const */ |
7881 | op(0x68); /* PUSH const */ |
7879 | if((itok.flag&f_reloc)!=0)AddReloc(); |
7882 | if((itok.flag&f_reloc)!=0)AddReloc(); |
7880 | if(am32==FALSE)outword((unsigned int)itok.number); |
7883 | if(am32==FALSE)outword((unsigned int)itok.number); |
7881 | else outdword(itok.number); |
7884 | else outdword(itok.number); |
7882 | } |
7885 | } |
7883 | if(cpu<2)cpu=2; |
7886 | if(cpu<2)cpu=2; |
7884 | } |
7887 | } |
7885 | else{ |
7888 | else{ |
7886 | MovRegNum(r16,itok.flag&f_reloc,itok.number,EAX); |
7889 | MovRegNum(r16,itok.flag&f_reloc,itok.number,EAX); |
7887 | op(0x50); |
7890 | op(0x50); |
7888 | } |
7891 | } |
7889 | break; |
7892 | break; |
7890 | case tk_apioffset: |
7893 | case tk_apioffset: |
7891 | op(0x68); // PUSH const |
7894 | op(0x68); // PUSH const |
7892 | AddApiToPost(itok.number); |
7895 | AddApiToPost(itok.number); |
7893 | break; |
7896 | break; |
7894 | case tk_postnumber: |
7897 | case tk_postnumber: |
7895 | case tk_undefofs: |
7898 | case tk_undefofs: |
7896 | if(chip>=2&&(!(optimizespeed&&(chip==5||chip==6)))){ |
7899 | if(chip>=2&&(!(optimizespeed&&(chip==5||chip==6)))){ |
7897 | op(0x68); // PUSH const |
7900 | op(0x68); // PUSH const |
7898 | if(tok==tk_undefofs)AddUndefOff(0,(char *)string); |
7901 | if(tok==tk_undefofs)AddUndefOff(0,(char *)string); |
7899 | else (itok.flag&f_extern)==0?setwordpost(&itok):setwordext(&itok.number); |
7902 | else (itok.flag&f_extern)==0?setwordpost(&itok):setwordext(&itok.number); |
7900 | if(am32==FALSE)outword((unsigned int)itok.number); |
7903 | if(am32==FALSE)outword((unsigned int)itok.number); |
7901 | else outdword(itok.number); |
7904 | else outdword(itok.number); |
7902 | break; |
7905 | break; |
7903 | } |
7906 | } |
7904 | default: |
7907 | default: |
7905 | deflt: |
7908 | deflt: |
7906 | //if(tok==tk_new)puts("monovar default"); |
7909 | //if(tok==tk_new)puts("monovar default"); |
7907 | switch(vartype){ |
7910 | switch(vartype){ |
7908 | case tk_int: i=1; |
7911 | case tk_int: i=1; |
7909 | case tk_word: do_e_axmath(i,r16,&ofsstr); break; |
7912 | case tk_word: do_e_axmath(i,r16,&ofsstr); break; |
7910 | case tk_char: i=1; |
7913 | case tk_char: i=1; |
7911 | case tk_byte: doalmath((char)i,&ofsstr); break; |
7914 | case tk_byte: doalmath((char)i,&ofsstr); break; |
7912 | default: beep(); break; |
7915 | default: beep(); break; |
7913 | } |
7916 | } |
7914 | op(0x50); /* PUSH AX */ |
7917 | op(0x50); /* PUSH AX */ |
7915 | useAX=TRUE; |
7918 | useAX=TRUE; |
7916 | next=0; |
7919 | next=0; |
7917 | break; |
7920 | break; |
7918 | } |
7921 | } |
7919 | stackpar+=2+jj; |
7922 | stackpar+=2+jj; |
7920 | addESP+=2+jj; |
7923 | addESP+=2+jj; |
7921 | } |
7924 | } |
7922 | else if(vartype |
7925 | else if(vartype |
7923 | #ifdef OPTVARCONST |
7926 | #ifdef OPTVARCONST |
7924 | CheckConstVar3(&tok,&itok,razr); |
7927 | CheckConstVar3(&tok,&itok,razr); |
7925 | #endif |
7928 | #endif |
7926 | // printf("tok=%d %s\n",tok,itok.name); |
7929 | // printf("tok=%d %s\n",tok,itok.name); |
7927 | switch(tok){ // long or dword or float |
7930 | switch(tok){ // long or dword or float |
7928 | case tk_reg32: |
7931 | case tk_reg32: |
7929 | op66(r32); |
7932 | op66(r32); |
7930 | op(0x50+(unsigned int)itok.number); |
7933 | op(0x50+(unsigned int)itok.number); |
7931 | break; |
7934 | break; |
7932 | case tk_floatvar: |
7935 | case tk_floatvar: |
7933 | if(vartype==tk_float)goto pushmem; |
7936 | if(vartype==tk_float)goto pushmem; |
7934 | case tk_qwordvar: |
7937 | case tk_qwordvar: |
7935 | case tk_dwordvar: |
7938 | case tk_dwordvar: |
7936 | case tk_longvar: |
7939 | case tk_longvar: |
7937 | if(optimizespeed&&(chip==5||chip==6))goto def; |
7940 | if(optimizespeed&&(chip==5||chip==6))goto def; |
7938 | pushmem: |
7941 | pushmem: |
7939 | CheckAllMassiv(bufrm,4,&strinf); |
7942 | CheckAllMassiv(bufrm,4,&strinf); |
7940 | op66(r32); |
7943 | op66(r32); |
7941 | outseg(&itok,2); |
7944 | outseg(&itok,2); |
7942 | op(0xFF); // PUSH [dword] |
7945 | op(0xFF); // PUSH [dword] |
7943 | op(0x30+itok.rm); |
7946 | op(0x30+itok.rm); |
7944 | // printf("push rm=%08X sib=%08X post=%u num=%08X rec=%08X flag=%08X %s\n",itok.rm,itok.sib,itok.post,itok.number,itok.rec,itok.flag,itok.name); |
7947 | // printf("push rm=%08X sib=%08X post=%u num=%08X rec=%08X flag=%08X %s\n",itok.rm,itok.sib,itok.post,itok.number,itok.rec,itok.flag,itok.name); |
7945 | outaddress(&itok); |
7948 | outaddress(&itok); |
7946 | break; |
7949 | break; |
7947 | case tk_number: |
7950 | case tk_number: |
7948 | if(optimizespeed&&(chip==5||chip==6))goto def; |
7951 | if(optimizespeed&&(chip==5||chip==6))goto def; |
7949 | if(vartype==tk_float){ |
7952 | if(vartype==tk_float){ |
7950 | itok.number=doconstfloatmath(); |
7953 | itok.number=doconstfloatmath(); |
7951 | next=0; |
7954 | next=0; |
7952 | } |
7955 | } |
7953 | else if(itok.rm==tk_double)itok.fnumber=itok.dnumber; |
7956 | else if(itok.rm==tk_double)itok.fnumber=itok.dnumber; |
7954 | op66(r32); |
7957 | op66(r32); |
7955 | if((itok.flag&f_reloc)==0&&short_ok(itok.number,TRUE)!=0){ |
7958 | if((itok.flag&f_reloc)==0&&short_ok(itok.number,TRUE)!=0){ |
7956 | op(0x6A); // PUSH 8 extend to 32 bit |
7959 | op(0x6A); // PUSH 8 extend to 32 bit |
7957 | op((unsigned int)itok.number); |
7960 | op((unsigned int)itok.number); |
7958 | } |
7961 | } |
7959 | else{ |
7962 | else{ |
7960 | op(0x68); // PUSH const |
7963 | op(0x68); // PUSH const |
7961 | if((itok.flag&f_reloc)!=0)AddReloc(); |
7964 | if((itok.flag&f_reloc)!=0)AddReloc(); |
7962 | outdword(itok.number); |
7965 | outdword(itok.number); |
7963 | } |
7966 | } |
7964 | break; |
7967 | break; |
7965 | case tk_apioffset: |
7968 | case tk_apioffset: |
7966 | op66(r32); |
7969 | op66(r32); |
7967 | op(0x68); // PUSH const |
7970 | op(0x68); // PUSH const |
7968 | AddApiToPost(itok.number); |
7971 | AddApiToPost(itok.number); |
7969 | break; |
7972 | break; |
7970 | case tk_postnumber: |
7973 | case tk_postnumber: |
7971 | case tk_undefofs: |
7974 | case tk_undefofs: |
7972 | if(optimizespeed&&(chip==5||chip==6))goto def; |
7975 | if(optimizespeed&&(chip==5||chip==6))goto def; |
7973 | op66(r32); |
7976 | op66(r32); |
7974 | op(0x68); // PUSH const |
7977 | op(0x68); // PUSH const |
7975 | if(tok==tk_undefofs)AddUndefOff(0,(char *)string); |
7978 | if(tok==tk_undefofs)AddUndefOff(0,(char *)string); |
7976 | else (itok.flag&f_extern)==0?setwordpost(&itok):setwordext(&itok.number); |
7979 | else (itok.flag&f_extern)==0?setwordpost(&itok):setwordext(&itok.number); |
7977 | outdword(itok.number); |
7980 | outdword(itok.number); |
7978 | break; |
7981 | break; |
7979 | default: |
7982 | default: |
7980 | def: |
7983 | def: |
7981 | if(vartype==tk_float)doeaxfloatmath(tk_stackstart); |
7984 | if(vartype==tk_float)doeaxfloatmath(tk_stackstart); |
7982 | else{ |
7985 | else{ |
7983 | if(vartype==tk_long)i=1; |
7986 | if(vartype==tk_long)i=1; |
7984 | // printf("tok=%d rm=%08X %s\n",tok,itok.rm,itok.name); |
7987 | // printf("tok=%d rm=%08X %s\n",tok,itok.rm,itok.name); |
7985 | if(tok==tk_rmnumber&&am32&&bufrm==NULL&&strinf.bufstr==NULL&& |
7988 | if(tok==tk_rmnumber&&am32&&bufrm==NULL&&strinf.bufstr==NULL&& |
7986 | ((itok.rm&7)!=4)&&((itok.rm&7)!=5)&& |
7989 | ((itok.rm&7)!=4)&&((itok.rm&7)!=5)&& |
7987 | ((itok.rm&rm_mod11)==rm_mod00)&&itok.number==0){ |
7990 | ((itok.rm&rm_mod11)==rm_mod00)&&itok.number==0){ |
7988 | op66(r32); |
7991 | op66(r32); |
7989 | op(0x50+(itok.rm&7)); // PUSH rm reg |
7992 | op(0x50+(itok.rm&7)); // PUSH rm reg |
7990 | break; |
7993 | break; |
7991 | 7994 | ||
7992 | } |
7995 | } |
7993 | do_e_axmath(i,r32,&ofsstr); |
7996 | do_e_axmath(i,r32,&ofsstr); |
7994 | op66(r32); |
7997 | op66(r32); |
7995 | op(0x50); // PUSH EAX |
7998 | op(0x50); // PUSH EAX |
7996 | useAX=TRUE; |
7999 | useAX=TRUE; |
7997 | } |
8000 | } |
7998 | next=0; |
8001 | next=0; |
7999 | break; |
8002 | break; |
8000 | } |
8003 | } |
8001 | stackpar+=4; |
8004 | stackpar+=4; |
8002 | addESP+=4; |
8005 | addESP+=4; |
8003 | if(cpu<3)cpu=3; |
8006 | if(cpu<3)cpu=3; |
8004 | } |
8007 | } |
8005 | else{ //qword or double |
8008 | else{ //qword or double |
8006 | #ifdef OPTVARCONST |
8009 | #ifdef OPTVARCONST |
8007 | CheckConstVar3(&tok,&itok,razr); |
8010 | CheckConstVar3(&tok,&itok,razr); |
8008 | #endif |
8011 | #endif |
8009 | switch(tok){ |
8012 | switch(tok){ |
8010 | case tk_reg64: |
8013 | case tk_reg64: |
8011 | op66(r32); |
8014 | op66(r32); |
8012 | op(0x50+(unsigned int)itok.number/256); |
8015 | op(0x50+(unsigned int)itok.number/256); |
8013 | op66(r32); |
8016 | op66(r32); |
8014 | op(0x50+(unsigned int)itok.number&255); |
8017 | op(0x50+(unsigned int)itok.number&255); |
8015 | break; |
8018 | break; |
8016 | case tk_doublevar: |
8019 | case tk_doublevar: |
8017 | case tk_qwordvar: |
8020 | case tk_qwordvar: |
8018 | itok.number+=4; |
8021 | itok.number+=4; |
8019 | compressoffset(&itok); |
8022 | compressoffset(&itok); |
8020 | CheckAllMassiv(bufrm,8,&strinf); |
8023 | CheckAllMassiv(bufrm,8,&strinf); |
8021 | for(i=0;i<2;i++){ |
8024 | for(i=0;i<2;i++){ |
8022 | op66(r32); |
8025 | op66(r32); |
8023 | outseg(&itok,2); |
8026 | outseg(&itok,2); |
8024 | op(0xFF); // PUSH [dword] |
8027 | op(0xFF); // PUSH [dword] |
8025 | op(0x30+itok.rm); |
8028 | op(0x30+itok.rm); |
8026 | outaddress(&itok); |
8029 | outaddress(&itok); |
8027 | if(i==1)break; |
8030 | if(i==1)break; |
8028 | itok.number-=4; |
8031 | itok.number-=4; |
8029 | compressoffset(&itok); |
8032 | compressoffset(&itok); |
8030 | } |
8033 | } |
8031 | break; |
8034 | break; |
8032 | case tk_reg32: |
8035 | case tk_reg32: |
8033 | op66(r32); |
8036 | op66(r32); |
8034 | outword(0x6A); // PUSH 8 extend to 32 bit |
8037 | outword(0x6A); // PUSH 8 extend to 32 bit |
8035 | op66(r32); |
8038 | op66(r32); |
8036 | op(0x50+(unsigned int)itok.number); |
8039 | op(0x50+(unsigned int)itok.number); |
8037 | break; |
8040 | break; |
8038 | case tk_number: |
8041 | case tk_number: |
8039 | long long lnumber; |
8042 | long long lnumber; |
8040 | lnumber=itok.lnumber; |
8043 | lnumber=itok.lnumber; |
8041 | itok.lnumber=lnumber>>32; |
8044 | itok.lnumber=lnumber>>32; |
8042 | for(i=0;i<2;i++){ |
8045 | for(i=0;i<2;i++){ |
8043 | op66(r32); |
8046 | op66(r32); |
8044 | if((i==0||(itok.flag&f_reloc)==0)&&short_ok(itok.number,TRUE)!=0){ |
8047 | if((i==0||(itok.flag&f_reloc)==0)&&short_ok(itok.number,TRUE)!=0){ |
8045 | op(0x6A); // PUSH 8 extend to 32 bit |
8048 | op(0x6A); // PUSH 8 extend to 32 bit |
8046 | op((unsigned int)itok.number); |
8049 | op((unsigned int)itok.number); |
8047 | } |
8050 | } |
8048 | else{ |
8051 | else{ |
8049 | op(0x68); // PUSH const |
8052 | op(0x68); // PUSH const |
8050 | if(i==1&&(itok.flag&f_reloc)!=0)AddReloc(); |
8053 | if(i==1&&(itok.flag&f_reloc)!=0)AddReloc(); |
8051 | outdword(itok.number); |
8054 | outdword(itok.number); |
8052 | } |
8055 | } |
8053 | if(i==1)break; |
8056 | if(i==1)break; |
8054 | itok.number=lnumber; |
8057 | itok.number=lnumber; |
8055 | } |
8058 | } |
8056 | break; |
8059 | break; |
8057 | case tk_postnumber: |
8060 | case tk_postnumber: |
8058 | case tk_undefofs: |
8061 | case tk_undefofs: |
8059 | op66(r32); |
8062 | op66(r32); |
8060 | outword(0x6A); // PUSH 8 extend to 32 bit |
8063 | outword(0x6A); // PUSH 8 extend to 32 bit |
8061 | op66(r32); |
8064 | op66(r32); |
8062 | op(0x68); // PUSH const |
8065 | op(0x68); // PUSH const |
8063 | if(tok==tk_undefofs)AddUndefOff(0,(char *)string); |
8066 | if(tok==tk_undefofs)AddUndefOff(0,(char *)string); |
8064 | else (itok.flag&f_extern)==0?setwordpost(&itok):setwordext(&itok.number); |
8067 | else (itok.flag&f_extern)==0?setwordpost(&itok):setwordext(&itok.number); |
8065 | outdword(itok.number); |
8068 | outdword(itok.number); |
8066 | break; |
8069 | break; |
8067 | default: |
8070 | default: |
8068 | if(vartype==tk_double)doeaxfloatmath(tk_stackstart,0,4); |
8071 | if(vartype==tk_double)doeaxfloatmath(tk_stackstart,0,4); |
8069 | else{ |
8072 | else{ |
8070 | op66(r32); |
8073 | op66(r32); |
8071 | outword(0x6A); |
8074 | outword(0x6A); |
8072 | do_e_axmath(0,r32,&ofsstr); |
8075 | do_e_axmath(0,r32,&ofsstr); |
8073 | op66(r32); |
8076 | op66(r32); |
8074 | op(0x50); // PUSH EAX |
8077 | op(0x50); // PUSH EAX |
8075 | useAX=TRUE; |
8078 | useAX=TRUE; |
8076 | } |
8079 | } |
8077 | next=0; |
8080 | next=0; |
8078 | break; |
8081 | break; |
8079 | } |
8082 | } |
8080 | stackpar+=8; |
8083 | stackpar+=8; |
8081 | addESP+=8; |
8084 | addESP+=8; |
8082 | if(cpu<3)cpu=3; |
8085 | if(cpu<3)cpu=3; |
8083 | } |
8086 | } |
8084 | endparam1: |
8087 | endparam1: |
8085 | if(next)nexttok(); |
8088 | if(next)nexttok(); |
8086 | 8089 | ||
8087 | } |
8090 | } |
8088 | } |
8091 | } |
8089 | endparam: |
8092 | endparam: |
8090 | if(ofsstr){ |
8093 | if(ofsstr){ |
8091 | if(useAX)IDZToReg(ofsstr,retreg,getrazr(vartype)); |
8094 | if(useAX)IDZToReg(ofsstr,retreg,getrazr(vartype)); |
8092 | free(ofsstr); |
8095 | free(ofsstr); |
8093 | ofsstr=NULL; |
8096 | ofsstr=NULL; |
8094 | } |
8097 | } |
8095 | if(tok==tk_camma){ |
8098 | if(tok==tk_camma){ |
8096 | ofsstr=GetLecsem(tk_camma,tk_closebracket); |
8099 | ofsstr=GetLecsem(tk_camma,tk_closebracket); |
8097 | getoperand(); |
8100 | getoperand(); |
8098 | } |
8101 | } |
8099 | else if(tok==tk_closebracket)done=1; |
8102 | else if(tok==tk_closebracket)done=1; |
8100 | else{ |
8103 | else{ |
8101 | expected(')'); |
8104 | expected(')'); |
8102 | done=1; |
8105 | done=1; |
8103 | } |
8106 | } |
8104 | } |
8107 | } |
8105 | } |
8108 | } |
8106 | if(ofsstr){ |
8109 | if(ofsstr){ |
8107 | if(useAX)IDZToReg(ofsstr,retreg,getrazr(vartype)); |
8110 | if(useAX)IDZToReg(ofsstr,retreg,getrazr(vartype)); |
8108 | free(ofsstr); |
8111 | free(ofsstr); |
8109 | } |
8112 | } |
8110 | if(ip!=-1&&bparam[ip]!=0&&bparam[ip]!='A'&&bparam[ip]!='V')missingpar(); |
8113 | if(ip!=-1&&bparam[ip]!=0&&bparam[ip]!='A'&&bparam[ip]!='V')missingpar(); |
8111 | free(bparam); |
8114 | free(bparam); |
8112 | setzeroflag=FALSE; |
8115 | setzeroflag=FALSE; |
8113 | addstack=oaddstack; |
8116 | addstack=oaddstack; |
8114 | useinline=oinline; |
8117 | useinline=oinline; |
8115 | return stackpar; |
8118 | return stackpar; |
8116 | } |
8119 | } |
8117 | 8120 | ||
8118 | void CheckDir() |
8121 | void CheckDir() |
8119 | { |
8122 | { |
8120 | do{ |
8123 | do{ |
8121 | switch(itok.number){ |
8124 | switch(itok.number){ |
8122 | case d_ifdef: |
8125 | case d_ifdef: |
8123 | case d_ifndef: |
8126 | case d_ifndef: |
8124 | case d_endif: |
8127 | case d_endif: |
8125 | case d_else: |
8128 | case d_else: |
8126 | case d_if: |
8129 | case d_if: |
8127 | case d_elif: |
8130 | case d_elif: |
8128 | inptr2=inptr; |
8131 | inptr2=inptr; |
8129 | cha2=cha; |
8132 | cha2=cha; |
8130 | linenum2=linenumber; |
8133 | linenum2=linenumber; |
8131 | directive(); |
8134 | directive(); |
8132 | inptr=inptr2; |
8135 | inptr=inptr2; |
8133 | cha=cha2; |
8136 | cha=cha2; |
8134 | break; |
8137 | break; |
8135 | default: |
8138 | default: |
8136 | FastTok(0); |
8139 | FastTok(0); |
8137 | break; |
8140 | break; |
8138 | } |
8141 | } |
8139 | if(tok==tk_eof)break; |
8142 | if(tok==tk_eof)break; |
8140 | }while(tok==tk_question); |
8143 | }while(tok==tk_question); |
8141 | } |
8144 | } |
8142 | 8145 | ||
8143 | char *dynamic_var() |
8146 | char *dynamic_var() |
8144 | { |
8147 | { |
8145 | int start,size; |
8148 | int start,size; |
8146 | char *bstring; |
8149 | char *bstring; |
8147 | int use_extract=FALSE; |
8150 | int use_extract=FALSE; |
8148 | 8151 | ||
8149 | #define TBUFSIZE 2048 |
8152 | #define TBUFSIZE 2048 |
8150 | #define MTBUFSIZE TBUFSIZE-IDLENGTH |
8153 | #define MTBUFSIZE TBUFSIZE-IDLENGTH |
8151 | int curbsize; |
8154 | int curbsize; |
8152 | COM_MOD *ocur_mod; |
8155 | COM_MOD *ocur_mod; |
8153 | bstring=(char *)MALLOC(TBUFSIZE); |
8156 | bstring=(char *)MALLOC(TBUFSIZE); |
8154 | curbsize=TBUFSIZE; |
8157 | curbsize=TBUFSIZE; |
8155 | size=0; |
8158 | size=0; |
8156 | if(tok2==tk_extract)use_extract=TRUE; |
8159 | if(tok2==tk_extract)use_extract=TRUE; |
8157 | do{ |
8160 | do{ |
8158 | start=inptr2-1; |
8161 | start=inptr2-1; |
8159 | ocur_mod=cur_mod; |
8162 | ocur_mod=cur_mod; |
8160 | if(size>(curbsize-IDLENGTH)){ |
8163 | if(size>(curbsize-IDLENGTH)){ |
8161 | curbsize+=TBUFSIZE; |
8164 | curbsize+=TBUFSIZE; |
8162 | bstring=(char *)REALLOC(bstring,curbsize); |
8165 | bstring=(char *)REALLOC(bstring,curbsize); |
8163 | } |
8166 | } |
8164 | nexttok(); |
8167 | nexttok(); |
8165 | if(tok==tk_openbrace){ |
8168 | if(tok==tk_openbrace){ |
8166 | bstring[size]='{'; |
8169 | bstring[size]='{'; |
8167 | size++; |
8170 | size++; |
8168 | do{ |
8171 | do{ |
8169 | start=inptr2-1; |
8172 | start=inptr2-1; |
8170 | ocur_mod=cur_mod; |
8173 | ocur_mod=cur_mod; |
8171 | if(size>(curbsize-IDLENGTH)){ |
8174 | if(size>(curbsize-IDLENGTH)){ |
8172 | curbsize+=TBUFSIZE; |
8175 | curbsize+=TBUFSIZE; |
8173 | bstring=(char *)REALLOC(bstring,curbsize); |
8176 | bstring=(char *)REALLOC(bstring,curbsize); |
8174 | } |
8177 | } |
8175 | nexttok(); |
8178 | nexttok(); |
8176 | if(tok==tk_number){ |
8179 | if(tok==tk_number){ |
8177 | switch(itok.rm){ |
8180 | switch(itok.rm){ |
8178 | case tk_double: |
8181 | case tk_double: |
8179 | case tk_float: |
8182 | case tk_float: |
8180 | sprintf(itok.name,"%e",itok.dnumber); |
8183 | sprintf(itok.name,"%e",itok.dnumber); |
8181 | break; |
8184 | break; |
8182 | case tk_qword: |
8185 | case tk_qword: |
8183 | sprintf(itok.name,"0x%X%08X",itok.lnumber>>16,itok.number); |
8186 | sprintf(itok.name,"0x%X%08X",itok.lnumber>>16,itok.number); |
8184 | break; |
8187 | break; |
8185 | default: |
8188 | default: |
8186 | sprintf(itok.name,"0x%X",itok.number); |
8189 | sprintf(itok.name,"0x%X",itok.number); |
8187 | break; |
8190 | break; |
8188 | } |
8191 | } |
8189 | } |
8192 | } |
8190 | if(itok.name[0]!=0){ |
8193 | if(itok.name[0]!=0){ |
8191 | strcpy(bstring+size,itok.name); |
8194 | strcpy(bstring+size,itok.name); |
8192 | size+=strlen(itok.name); |
8195 | size+=strlen(itok.name); |
8193 | } |
8196 | } |
8194 | else{ |
8197 | else{ |
8195 | if(cur_mod!=ocur_mod){ |
8198 | if(cur_mod!=ocur_mod){ |
8196 | start=inptr2-2; |
8199 | start=inptr2-2; |
8197 | if(start<0)start=0; |
8200 | if(start<0)start=0; |
8198 | } |
8201 | } |
8199 | strncpy(bstring+size,(char *)(input+start),inptr2-1-start); |
8202 | strncpy(bstring+size,(char *)(input+start),inptr2-1-start); |
8200 | size+=inptr2-1-start; |
8203 | size+=inptr2-1-start; |
8201 | } |
8204 | } |
8202 | }while(tok!=tk_closebrace&&tok!=tk_eof); |
8205 | }while(tok!=tk_closebrace&&tok!=tk_eof); |
8203 | if(tok!=tk_eof)continue; |
8206 | if(tok!=tk_eof)continue; |
8204 | } |
8207 | } |
8205 | if(tok==tk_number){ |
8208 | if(tok==tk_number){ |
8206 | switch(itok.rm){ |
8209 | switch(itok.rm){ |
8207 | case tk_double: |
8210 | case tk_double: |
8208 | case tk_float: |
8211 | case tk_float: |
8209 | sprintf(itok.name,"%e",itok.dnumber); |
8212 | sprintf(itok.name,"%e",itok.dnumber); |
8210 | break; |
8213 | break; |
8211 | case tk_qword: |
8214 | case tk_qword: |
8212 | sprintf(itok.name,"0x%X%08X",itok.lnumber>>16,itok.number); |
8215 | sprintf(itok.name,"0x%X%08X",itok.lnumber>>16,itok.number); |
8213 | break; |
8216 | break; |
8214 | default: |
8217 | default: |
8215 | sprintf(itok.name,"0x%X",itok.number); |
8218 | sprintf(itok.name,"0x%X",itok.number); |
8216 | break; |
8219 | break; |
8217 | } |
8220 | } |
8218 | } |
8221 | } |
8219 | if(itok.name[0]!=0){ |
8222 | if(itok.name[0]!=0){ |
8220 | strcpy(bstring+size,itok.name); |
8223 | strcpy(bstring+size,itok.name); |
8221 | size+=strlen(itok.name); |
8224 | size+=strlen(itok.name); |
8222 | } |
8225 | } |
8223 | else{ |
8226 | else{ |
8224 | if(cur_mod!=ocur_mod){ |
8227 | if(cur_mod!=ocur_mod){ |
8225 | start=inptr2-2; |
8228 | start=inptr2-2; |
8226 | if(start<0)start=0; |
8229 | if(start<0)start=0; |
8227 | } |
8230 | } |
8228 | strncpy(bstring+size,(char *)(input+start),inptr2-1-start); |
8231 | strncpy(bstring+size,(char *)(input+start),inptr2-1-start); |
8229 | size+=inptr2-1-start; |
8232 | size+=inptr2-1-start; |
8230 | } |
8233 | } |
8231 | if(tok==tk_eof){ |
8234 | if(tok==tk_eof){ |
8232 | unexpectedeof(); |
8235 | unexpectedeof(); |
8233 | return NULL; |
8236 | return NULL; |
8234 | } |
8237 | } |
8235 | if(tok==tk_camma&&use_extract==FALSE)break; |
8238 | if(tok==tk_camma&&use_extract==FALSE)break; |
8236 | }while(tok!=tk_semicolon); |
8239 | }while(tok!=tk_semicolon); |
8237 | // size++; |
8240 | // size++; |
8238 | bstring[size]=0; |
8241 | bstring[size]=0; |
8239 | return bstring; |
8242 | return bstring; |
8240 | } |
8243 | } |
8241 | 8244 | ||
8242 | int SkipBlock() |
8245 | int SkipBlock() |
8243 | { |
8246 | { |
8244 | for(int i=1;i!=0;){ |
8247 | for(int i=1;i!=0;){ |
8245 | FastTok(0); |
8248 | FastTok(0); |
8246 | if(tok==tk_question)CheckDir(); |
8249 | if(tok==tk_question)CheckDir(); |
8247 | switch(tok){ |
8250 | switch(tok){ |
8248 | case tk_eof: unexpectedeof(); return FALSE; |
8251 | case tk_eof: unexpectedeof(); return FALSE; |
8249 | case tk_openbrace: i++; break; |
8252 | case tk_openbrace: i++; break; |
8250 | case tk_closebrace: i--; break; |
8253 | case tk_closebrace: i--; break; |
8251 | } |
8254 | } |
8252 | } |
8255 | } |
8253 | return TRUE; |
8256 | return TRUE; |
8254 | } |
8257 | } |
8255 | 8258 | ||
8256 | int SkipParam() |
8259 | int SkipParam() |
8257 | { |
8260 | { |
8258 | for(int i=1;i!=0;){ |
8261 | for(int i=1;i!=0;){ |
8259 | FastTok(0); |
8262 | FastTok(0); |
8260 | if(tok==tk_question)CheckDir(); |
8263 | if(tok==tk_question)CheckDir(); |
8261 | switch(tok){ |
8264 | switch(tok){ |
8262 | case tk_openbracket: i++; break; |
8265 | case tk_openbracket: i++; break; |
8263 | case tk_closebracket: i--; break; |
8266 | case tk_closebracket: i--; break; |
8264 | case tk_eof: unexpectedeof(); return FALSE; |
8267 | case tk_eof: unexpectedeof(); return FALSE; |
8265 | } |
8268 | } |
8266 | } |
8269 | } |
8267 | return TRUE; |
8270 | return TRUE; |
8268 | } |
8271 | } |
8269 | 8272 | ||
8270 | int SkipLocalVar() |
8273 | int SkipLocalVar() |
8271 | { |
8274 | { |
8272 | while(tok!=tk_openbrace&&tok!=tk_eof){ |
8275 | while(tok!=tk_openbrace&&tok!=tk_eof){ |
8273 | if(tok==tk_question){ |
8276 | if(tok==tk_question){ |
8274 | CheckDir(); |
8277 | CheckDir(); |
8275 | continue; |
8278 | continue; |
8276 | } |
8279 | } |
8277 | if(tok==tk_id&&(strcmp(itok.name,"struct")==0||strcmp(itok.name,"union")==0)){ |
8280 | if(tok==tk_id&&(strcmp(itok.name,"struct")==0||strcmp(itok.name,"union")==0)){ |
8278 | do{ |
8281 | do{ |
8279 | FastTok(0); |
8282 | FastTok(0); |
8280 | if(tok==tk_eof){ |
8283 | if(tok==tk_eof){ |
8281 | unexpectedeof(); |
8284 | unexpectedeof(); |
8282 | return FALSE; |
8285 | return FALSE; |
8283 | } |
8286 | } |
8284 | }while(tok!=tk_semicolon&&tok!=tk_openbrace); |
8287 | }while(tok!=tk_semicolon&&tok!=tk_openbrace); |
8285 | if(tok==tk_openbrace){ |
8288 | if(tok==tk_openbrace){ |
8286 | FastTok(0); |
8289 | FastTok(0); |
8287 | if(!SkipBlock())return FALSE; |
8290 | if(!SkipBlock())return FALSE; |
8288 | } |
8291 | } |
8289 | } |
8292 | } |
8290 | FastTok(1); |
8293 | FastTok(1); |
8291 | } |
8294 | } |
8292 | return TRUE; |
8295 | return TRUE; |
8293 | } |
8296 | } |
8294 | 8297 | ||
8295 | SAVEPAR *SRparam(int save,SAVEPAR *par) //save or restore global param compiler |
8298 | SAVEPAR *SRparam(int save,SAVEPAR *par) //save or restore global param compiler |
8296 | { |
8299 | { |
8297 | if(save){ |
8300 | if(save){ |
8298 | par=(SAVEPAR *)MALLOC(sizeof(SAVEPAR)); |
8301 | par=(SAVEPAR *)MALLOC(sizeof(SAVEPAR)); |
8299 | par->ooptimizespeed=optimizespeed; |
8302 | par->ooptimizespeed=optimizespeed; |
8300 | par->owarning= warning; |
8303 | par->owarning= warning; |
8301 | par->odbg= dbg; |
8304 | par->odbg= dbg; |
8302 | par->odosstring= dosstring; |
8305 | par->odosstring= dosstring; |
8303 | par->ouseinline= useinline; |
8306 | par->ouseinline= useinline; |
8304 | par->oam32= am32; |
8307 | par->oam32= am32; |
8305 | par->oalignword= alignword; |
8308 | par->oalignword= alignword; |
8306 | par->oAlignCycle= AlignCycle; |
8309 | par->oAlignCycle= AlignCycle; |
8307 | par->oidasm= idasm; //àññ |
8310 | par->oidasm= idasm; //àññ |
8308 | par->ooptnumber= optnumber; |
8311 | par->ooptnumber= optnumber; |
8309 | par->odivexpand= divexpand; |
8312 | par->odivexpand= divexpand; |
8310 | par->ooptstr= optstr; //îï |
8313 | par->ooptstr= optstr; //îï |
8311 | par->ochip= chip; |
8314 | par->ochip= chip; |
8312 | par->oaligncycle= aligncycle; |
8315 | par->oaligncycle= aligncycle; |
8313 | par->ouselea= uselea; |
8316 | par->ouselea= uselea; |
8314 | par->oregoverstack= regoverstack; |
8317 | par->oregoverstack= regoverstack; |
8315 | return par; |
8318 | return par; |
8316 | } |
8319 | } |
8317 | if(par){ |
8320 | if(par){ |
8318 | optimizespeed=par->ooptimizespeed; |
8321 | optimizespeed=par->ooptimizespeed; |
8319 | warning= par->owarning; |
8322 | warning= par->owarning; |
8320 | dbg= par->odbg; |
8323 | dbg= par->odbg; |
8321 | dosstring= par->odosstring; |
8324 | dosstring= par->odosstring; |
8322 | useinline= par->ouseinline; |
8325 | useinline= par->ouseinline; |
8323 | am32= par->oam32; |
8326 | am32= par->oam32; |
8324 | alignword= par->oalignword; |
8327 | alignword= par->oalignword; |
8325 | AlignCycle= par->oAlignCycle; |
8328 | AlignCycle= par->oAlignCycle; |
8326 | idasm= par->oidasm; //àññ |
8329 | idasm= par->oidasm; //àññ |
8327 | optnumber= par->ooptnumber; |
8330 | optnumber= par->ooptnumber; |
8328 | divexpand= par->odivexpand; |
8331 | divexpand= par->odivexpand; |
8329 | optstr= par->ooptstr; //îï |
8332 | optstr= par->ooptstr; //îï |
8330 | chip= par->ochip; |
8333 | chip= par->ochip; |
8331 | aligncycle= par->oaligncycle; |
8334 | aligncycle= par->oaligncycle; |
8332 | uselea = par->ouselea; |
8335 | uselea = par->ouselea; |
8333 | regoverstack= par->oregoverstack; |
8336 | regoverstack= par->oregoverstack; |
8334 | free(par); |
8337 | free(par); |
8335 | } |
8338 | } |
8336 | return NULL; |
8339 | return NULL; |
8337 | } |
8340 | } |
8338 | 8341 | ||
8339 | void dynamic_proc() |
8342 | void dynamic_proc() |
8340 | { |
8343 | { |
8341 | int dtok,start,size,line; |
8344 | int dtok,start,size,line; |
8342 | ITOK otok; |
8345 | ITOK otok; |
8343 | char *bstring; |
8346 | char *bstring; |
8344 | idrec *ptr; |
8347 | idrec *ptr; |
8345 | _PROCINFO_ *pinfo; |
8348 | _PROCINFO_ *pinfo; |
8346 | if(itok.npointr)itok.rm=(am32==TRUE?tk_dword:tk_word); |
8349 | if(itok.npointr)itok.rm=(am32==TRUE?tk_dword:tk_word); |
8347 | dtok=tok; |
8350 | dtok=tok; |
8348 | otok=itok; |
8351 | otok=itok; |
8349 | line=linenum2; |
8352 | line=linenum2; |
8350 | switch(tok){ |
8353 | switch(tok){ |
8351 | case tk_id: |
8354 | case tk_id: |
8352 | case tk_ID: |
8355 | case tk_ID: |
8353 | string[0]=0; |
8356 | string[0]=0; |
8354 | case tk_undefproc: |
8357 | case tk_undefproc: |
8355 | case tk_declare: |
8358 | case tk_declare: |
8356 | break; |
8359 | break; |
8357 | default: idalreadydefined(); break; |
8360 | default: idalreadydefined(); break; |
8358 | } |
8361 | } |
8359 | if(itok.flag&f_export)preerror("'_export' not use in dynamic functions"); |
8362 | if(itok.flag&f_export)preerror("'_export' not use in dynamic functions"); |
8360 | bstring=BackString((char *)string); |
8363 | bstring=BackString((char *)string); |
8361 | start=inptr2-1; |
8364 | start=inptr2-1; |
8362 | pinfo=(_PROCINFO_ *)MALLOC(sizeof(_PROCINFO_)); |
8365 | pinfo=(_PROCINFO_ *)MALLOC(sizeof(_PROCINFO_)); |
8363 | if(itok.flag&f_classproc)pinfo->classteg=searchteg; |
8366 | if(itok.flag&f_classproc)pinfo->classteg=searchteg; |
8364 | else pinfo->classteg=NULL; |
8367 | else pinfo->classteg=NULL; |
8365 | pinfo->warn=warning; |
8368 | pinfo->warn=warning; |
8366 | pinfo->speed=optimizespeed; |
8369 | pinfo->speed=optimizespeed; |
8367 | pinfo->lst=(dbg&2)>>1; |
8370 | pinfo->lst=(dbg&2)>>1; |
8368 | pinfo->typestring=dosstring; |
8371 | pinfo->typestring=dosstring; |
8369 | pinfo->inlinest=useinline; |
8372 | pinfo->inlinest=useinline; |
8370 | pinfo->code32=am32; |
8373 | pinfo->code32=am32; |
8371 | pinfo->align=alignword; |
8374 | pinfo->align=alignword; |
8372 | pinfo->acycle=AlignCycle; |
8375 | pinfo->acycle=AlignCycle; |
8373 | pinfo->idasm=idasm; |
8376 | pinfo->idasm=idasm; |
8374 | pinfo->opnum=optnumber; |
8377 | pinfo->opnum=optnumber; |
8375 | pinfo->de=divexpand; |
8378 | pinfo->de=divexpand; |
8376 | pinfo->ostring=optstr; |
8379 | pinfo->ostring=optstr; |
8377 | pinfo->chip=chip; |
8380 | pinfo->chip=chip; |
8378 | pinfo->sizeacycle=aligncycle; |
8381 | pinfo->sizeacycle=aligncycle; |
8379 | pinfo->uselea=uselea; |
8382 | pinfo->uselea=uselea; |
8380 | pinfo->regoverstack=regoverstack; |
8383 | pinfo->regoverstack=regoverstack; |
8381 | nexttok(); |
8384 | nexttok(); |
8382 | if(dtok==tk_id||dtok==tk_ID){ |
8385 | if(dtok==tk_id||dtok==tk_ID){ |
8383 | param[0]=0; |
8386 | param[0]=0; |
8384 | if(tok2!=tk_closebracket&&(otok.flag&f_typeproc)==tp_fastcall){ |
8387 | if(tok2!=tk_closebracket&&(otok.flag&f_typeproc)==tp_fastcall){ |
8385 | nexttok(); //ïàðàìåòðû ðåãèñòðîâîé ïðîöåäóðû |
8388 | nexttok(); //ïàðàìåòðû ðåãèñòðîâîé ïðîöåäóðû |
8386 | declareparamreg(); |
8389 | declareparamreg(); |
8387 | free(bstring); |
8390 | free(bstring); |
8388 | bstring=BackString((char *)param); |
8391 | bstring=BackString((char *)param); |
8389 | nexttok(); |
8392 | nexttok(); |
8390 | inptr=inptr2; |
8393 | inptr=inptr2; |
8391 | cha=cha2; |
8394 | cha=cha2; |
8392 | linenumber=linenum2; |
8395 | linenumber=linenum2; |
8393 | } |
8396 | } |
8394 | } |
8397 | } |
8395 | else{ |
8398 | else{ |
8396 | inptr=inptr2; |
8399 | inptr=inptr2; |
8397 | cha=cha2; |
8400 | cha=cha2; |
8398 | if(!SkipParam()){ |
8401 | if(!SkipParam()){ |
8399 | free(bstring); |
8402 | free(bstring); |
8400 | return; |
8403 | return; |
8401 | } |
8404 | } |
8402 | FastTok(1); |
8405 | FastTok(1); |
8403 | } |
8406 | } |
8404 | if(tok==tk_semicolon)preerror("error declare dynamic function"); |
8407 | if(tok==tk_semicolon)preerror("error declare dynamic function"); |
8405 | if((!SkipLocalVar())||(!SkipBlock())){ |
8408 | if((!SkipLocalVar())||(!SkipBlock())){ |
8406 | free(bstring); |
8409 | free(bstring); |
8407 | return; |
8410 | return; |
8408 | } |
8411 | } |
8409 | size=inptr-start+1; |
8412 | size=inptr-start+1; |
8410 | inptr2=inptr; |
8413 | inptr2=inptr; |
8411 | cha2=cha; |
8414 | cha2=cha; |
8412 | linenum2=linenumber; |
8415 | linenum2=linenumber; |
8413 | linenumber=line; |
8416 | linenumber=line; |
8414 | itok=otok; |
8417 | itok=otok; |
8415 | strcpy((char *)string,bstring); |
8418 | strcpy((char *)string,bstring); |
8416 | free(bstring); |
8419 | free(bstring); |
8417 | bstring=(char *)MALLOC(size+1); |
8420 | bstring=(char *)MALLOC(size+1); |
8418 | strncpy(bstring,(char *)(input+start),size); |
8421 | strncpy(bstring,(char *)(input+start),size); |
8419 | bstring[size-1]=';'; |
8422 | bstring[size-1]=';'; |
8420 | bstring[size]=0; |
8423 | bstring[size]=0; |
8421 | 8424 | ||
8422 | // printf("tok=%d %s\n%s\n",dtok,itok.name,bstring); |
8425 | // printf("tok=%d %s\n%s\n",dtok,itok.name,bstring); |
8423 | itok.size=0; |
8426 | itok.size=0; |
8424 | tok=tk_proc; |
8427 | tok=tk_proc; |
8425 | itok.segm=DYNAMIC; |
8428 | itok.segm=DYNAMIC; |
8426 | if(dtok==tk_id||dtok==tk_ID){ |
8429 | if(dtok==tk_id||dtok==tk_ID){ |
8427 | int i; |
8430 | int i; |
8428 | itok.number=secondcallnum++; |
8431 | itok.number=secondcallnum++; |
8429 | itok.type=tp_ucnovn; |
8432 | itok.type=tp_ucnovn; |
8430 | if((i=FindUseName(itok.name))!=0)itok.segm=DYNAMIC_USED; |
8433 | if((i=FindUseName(itok.name))!=0)itok.segm=DYNAMIC_USED; |
8431 | ptr=addtotree(itok.name); |
8434 | ptr=addtotree(itok.name); |
8432 | if(i){ |
8435 | if(i){ |
8433 | ptr->count=i; |
8436 | ptr->count=i; |
8434 | ptr=itok.rec; |
8437 | ptr=itok.rec; |
8435 | AddDynamicList(ptr); |
8438 | AddDynamicList(ptr); |
8436 | } |
8439 | } |
8437 | } |
8440 | } |
8438 | else{ |
8441 | else{ |
8439 | if(dtok==tk_undefproc)itok.segm=DYNAMIC_USED; |
8442 | if(dtok==tk_undefproc)itok.segm=DYNAMIC_USED; |
8440 | updatetree(); |
8443 | updatetree(); |
8441 | ptr=itok.rec; |
8444 | ptr=itok.rec; |
8442 | //11.08.04 23:38 |
8445 | //11.08.04 23:38 |
8443 | strcpy(ptr->recid,itok.name); |
8446 | strcpy(ptr->recid,itok.name); |
8444 | 8447 | ||
8445 | if(dtok==tk_undefproc&&(itok.flag&f_classproc))AddDynamicList(ptr); |
8448 | if(dtok==tk_undefproc&&(itok.flag&f_classproc))AddDynamicList(ptr); |
8446 | } |
8449 | } |
8447 | ptr->line=linenumber; |
8450 | ptr->line=linenumber; |
8448 | ptr->file=currentfileinfo; |
8451 | ptr->file=currentfileinfo; |
8449 | pinfo->buf=bstring; |
8452 | pinfo->buf=bstring; |
8450 | ptr->pinfo=pinfo; |
8453 | ptr->pinfo=pinfo; |
8451 | // ptr->sbuf=bstring; |
8454 | // ptr->sbuf=bstring; |
8452 | // linenumber=linenum2; |
8455 | // linenumber=linenum2; |
8453 | if(searchteg)searchteg=NULL; |
8456 | if(searchteg)searchteg=NULL; |
8454 | nexttok(); |
8457 | nexttok(); |
8455 | } |
8458 | } |
8456 | 8459 | ||
8457 | /* ======= procedure handling ends here ======== */ |
8460 | /* ======= procedure handling ends here ======== */ |
8458 | 8461 | ||
8459 | int macros(int expectedreturn) |
8462 | int macros(int expectedreturn) |
8460 | { |
8463 | { |
8461 | int dynamicindex,actualreturn; |
8464 | int dynamicindex,actualreturn; |
8462 | ITOK otok; |
8465 | ITOK otok; |
8463 | int orettype; |
8466 | int orettype; |
8464 | unsigned int oproctype; |
8467 | unsigned int oproctype; |
8465 | int otok2; |
8468 | int otok2; |
8466 | unsigned int typep; |
8469 | unsigned int typep; |
8467 | int snum=0; |
8470 | int snum=0; |
8468 | actualreturn=(am32==FALSE?tk_word:tk_dword); |
8471 | actualreturn=(am32==FALSE?tk_word:tk_dword); |
8469 | switch(tok){ |
8472 | switch(tok){ |
8470 | case tk_ID: |
8473 | case tk_ID: |
8471 | case tk_id: |
8474 | case tk_id: |
8472 | dynamicindex=NOT_DYNAMIC; |
8475 | dynamicindex=NOT_DYNAMIC; |
8473 | break; |
8476 | break; |
8474 | case tk_proc: |
8477 | case tk_proc: |
8475 | case tk_undefproc: |
8478 | case tk_undefproc: |
8476 | case tk_declare: |
8479 | case tk_declare: |
8477 | dynamicindex=itok.segm; |
8480 | dynamicindex=itok.segm; |
8478 | actualreturn=itok.rm; |
8481 | actualreturn=itok.rm; |
8479 | break; |
8482 | break; |
8480 | default: |
8483 | default: |
8481 | idalreadydefined(); |
8484 | idalreadydefined(); |
8482 | return expectedreturn; |
8485 | return expectedreturn; |
8483 | } |
8486 | } |
8484 | typep=itok.flag; |
8487 | typep=itok.flag; |
8485 | otok=itok; |
8488 | otok=itok; |
8486 | if(tok==tk_ID)param[0]=0; |
8489 | if(tok==tk_ID)param[0]=0; |
8487 | else strcpy(param,(char *)string); |
8490 | else strcpy(param,(char *)string); |
8488 | nexttok(); |
8491 | nexttok(); |
8489 | orettype=returntype; |
8492 | orettype=returntype; |
8490 | returntype=actualreturn; //01.08.04 14:45 |
8493 | returntype=actualreturn; //01.08.04 14:45 |
8491 | oproctype=current_proc_type; |
8494 | oproctype=current_proc_type; |
8492 | if(dynamicindex==NOT_DYNAMIC)doregparams(); |
8495 | if(dynamicindex==NOT_DYNAMIC)doregparams(); |
8493 | else{ |
8496 | else{ |
8494 | switch(typep&f_typeproc){ |
8497 | switch(typep&f_typeproc){ |
8495 | case tp_cdecl: |
8498 | case tp_cdecl: |
8496 | case tp_stdcall: |
8499 | case tp_stdcall: |
8497 | snum=swapparam(); |
8500 | snum=swapparam(); |
8498 | break; |
8501 | break; |
8499 | case tp_pascal: |
8502 | case tp_pascal: |
8500 | snum=doparams(); |
8503 | snum=doparams(); |
8501 | break; |
8504 | break; |
8502 | case tp_fastcall: |
8505 | case tp_fastcall: |
8503 | doregparams(); |
8506 | doregparams(); |
8504 | break; |
8507 | break; |
8505 | } |
8508 | } |
8506 | } |
8509 | } |
8507 | itok=otok; |
8510 | itok=otok; |
8508 | otok2=tok2; |
8511 | otok2=tok2; |
8509 | if(dynamicindex==NOT_DYNAMIC){ |
8512 | if(dynamicindex==NOT_DYNAMIC){ |
8510 | if((actualreturn=includeit(0))==-1){ |
8513 | if((actualreturn=includeit(0))==-1){ |
8511 | char holdstr[IDLENGTH+16]; |
8514 | char holdstr[IDLENGTH+16]; |
8512 | sprintf(holdstr,"unknown macro '%s'",itok.name); |
8515 | sprintf(holdstr,"unknown macro '%s'",itok.name); |
8513 | preerror(holdstr); |
8516 | preerror(holdstr); |
8514 | } |
8517 | } |
8515 | } |
8518 | } |
8516 | else insert_dynamic(TRUE); |
8519 | else insert_dynamic(TRUE); |
8517 | if(actualreturn!=tk_void&&expectedreturn!=tk_ID)convert_returnvalue(expectedreturn,actualreturn); |
8520 | if(actualreturn!=tk_void&&expectedreturn!=tk_ID)convert_returnvalue(expectedreturn,actualreturn); |
8518 | returntype=orettype; |
8521 | returntype=orettype; |
8519 | current_proc_type=oproctype; |
8522 | current_proc_type=oproctype; |
8520 | if(snum!=0){ |
8523 | if(snum!=0){ |
8521 | if(typep&f_retproc)warningdestroyflags(); |
8524 | if(typep&f_retproc)warningdestroyflags(); |
8522 | CorrectStack(snum); |
8525 | CorrectStack(snum); |
8523 | } |
8526 | } |
8524 | tok2=otok2; |
8527 | tok2=otok2; |
8525 | return actualreturn; |
8528 | return actualreturn; |
8526 | } |
8529 | } |
8527 | 8530 | ||
8528 | int updatecall(unsigned int which,unsigned int where,unsigned int top) |
8531 | int updatecall(unsigned int which,unsigned int where,unsigned int top) |
8529 | /* update output with newly defined location, but only for addresses after |
8532 | /* update output with newly defined location, but only for addresses after |
8530 | and including top. return the number of addresses updated. |
8533 | and including top. return the number of addresses updated. |
8531 | which - àäðåñ ïðîöåäóðû |
8534 | which - àäðåñ ïðîöåäóðû |
8532 | where - òåêóùèé àäðåñ*/ |
8535 | where - òåêóùèé àäðåñ*/ |
8533 | { |
8536 | { |
8534 | unsigned int count=0; |
8537 | unsigned int count=0; |
8535 | long hold; |
8538 | long hold; |
8536 | int updates=0; |
8539 | int updates=0; |
8537 | while(count |
8540 | while(count |
8538 | if(((postbuf+count)->type>=CALL_SHORT&&(postbuf+count)->type<=CONTINUE_32)&& |
8541 | if(((postbuf+count)->type>=CALL_SHORT&&(postbuf+count)->type<=CONTINUE_32)&& |
8539 | (postbuf+count)->num==which&&(postbuf+count)->loc>=top){ |
8542 | (postbuf+count)->num==which&&(postbuf+count)->loc>=top){ |
8540 | hold=(long)where-(long)(postbuf+count)->loc; |
8543 | hold=(long)where-(long)(postbuf+count)->loc; |
8541 | if((postbuf+count)->type>=CALL_NEAR&&(postbuf+count)->type<=CONTINUE_NEAR){ //NEAR |
8544 | if((postbuf+count)->type>=CALL_NEAR&&(postbuf+count)->type<=CONTINUE_NEAR){ //NEAR |
8542 | hold-=2; |
8545 | hold-=2; |
8543 | *(unsigned short *)&output[(postbuf+count)->loc]=(unsigned short)hold; |
8546 | *(unsigned short *)&output[(postbuf+count)->loc]=(unsigned short)hold; |
8544 | } |
8547 | } |
8545 | else if((postbuf+count)->type>=CALL_32&&(postbuf+count)->type<=CONTINUE_32){//32-BIT |
8548 | else if((postbuf+count)->type>=CALL_32&&(postbuf+count)->type<=CONTINUE_32){//32-BIT |
8546 | hold-=4; |
8549 | hold-=4; |
8547 | *(unsigned long *)&output[(postbuf+count)->loc]=(unsigned long)hold; |
8550 | *(unsigned long *)&output[(postbuf+count)->loc]=(unsigned long)hold; |
8548 | } |
8551 | } |
8549 | else{ //SHORT |
8552 | else{ //SHORT |
8550 | hold--; // CALL_SHORT |
8553 | hold--; // CALL_SHORT |
8551 | if(short_ok(hold))output[(postbuf+count)->loc]=(unsigned char)hold; |
8554 | if(short_ok(hold))output[(postbuf+count)->loc]=(unsigned char)hold; |
8552 | else{ |
8555 | else{ |
8553 | if((postbuf+count)->type==BREAK_SHORT)preerror3("BREAK distance too large, use break",(postbuf+count)->line); |
8556 | if((postbuf+count)->type==BREAK_SHORT)preerror3("BREAK distance too large, use break",(postbuf+count)->line); |
8554 | else if((postbuf+count)->type==CONTINUE_SHORT)preerror3("CONTINUE distance too large, use continue",(postbuf+count)->line); |
8557 | else if((postbuf+count)->type==CONTINUE_SHORT)preerror3("CONTINUE distance too large, use continue",(postbuf+count)->line); |
8555 | else preerror3(shorterr,(postbuf+count)->line,(postbuf+count)->file); |
8558 | else preerror3(shorterr,(postbuf+count)->line,(postbuf+count)->file); |
8556 | } |
8559 | } |
8557 | } |
8560 | } |
8558 | if(hold<127){ |
8561 | if(hold<127){ |
8559 | if((postbuf+count)->type==JMP_NEAR||(postbuf+count)->type==JMP_32)warningjmp("GOTO",(postbuf+count)->line,(postbuf+count)->file); |
8562 | if((postbuf+count)->type==JMP_NEAR||(postbuf+count)->type==JMP_32)warningjmp("GOTO",(postbuf+count)->line,(postbuf+count)->file); |
8560 | if((postbuf+count)->type==BREAK_NEAR||(postbuf+count)->type==BREAK_32)warningjmp("BREAK",(postbuf+count)->line); |
8563 | if((postbuf+count)->type==BREAK_NEAR||(postbuf+count)->type==BREAK_32)warningjmp("BREAK",(postbuf+count)->line); |
8561 | if((postbuf+count)->type==CONTINUE_NEAR||(postbuf+count)->type==CONTINUE_32)warningjmp("CONTINUE",(postbuf+count)->line); |
8564 | if((postbuf+count)->type==CONTINUE_NEAR||(postbuf+count)->type==CONTINUE_32)warningjmp("CONTINUE",(postbuf+count)->line); |
8562 | } |
8565 | } |
8563 | killpost(count); |
8566 | killpost(count); |
8564 | updates++; |
8567 | updates++; |
8565 | } |
8568 | } |
8566 | else count++; |
8569 | else count++; |
8567 | } |
8570 | } |
8568 | if(updates==1&&hold==0)return -1; |
8571 | if(updates==1&&hold==0)return -1; |
8569 | return(updates); |
8572 | return(updates); |
8570 | } |
8573 | } |
8571 | 8574 | ||
8572 | void define_locallabel() |
8575 | void define_locallabel() |
8573 | { |
8576 | { |
8574 | FindOff(string,CS); |
8577 | FindOff(string,CS); |
8575 | updatecall((unsigned int)updatelocalvar((char *)string,tk_number,outptr),outptr,procedure_start); |
8578 | updatecall((unsigned int)updatelocalvar((char *)string,tk_number,outptr),outptr,procedure_start); |
8576 | nextexpecting2(tk_colon); |
8579 | nextexpecting2(tk_colon); |
8577 | RestoreStack(); |
8580 | RestoreStack(); |
8578 | clearregstat(); |
8581 | clearregstat(); |
8579 | #ifdef OPTVARCONST |
8582 | #ifdef OPTVARCONST |
8580 | ClearLVIC(); |
8583 | ClearLVIC(); |
8581 | #endif |
8584 | #endif |
8582 | } |
8585 | } |
8583 | 8586 | ||
8584 | void addacall(unsigned int idnum,unsigned char callkind) |
8587 | void addacall(unsigned int idnum,unsigned char callkind) |
8585 | { |
8588 | { |
8586 | CheckPosts(); |
8589 | CheckPosts(); |
8587 | (postbuf+posts)->num=idnum; |
8590 | (postbuf+posts)->num=idnum; |
8588 | (postbuf+posts)->loc=outptr+1; |
8591 | (postbuf+posts)->loc=outptr+1; |
8589 | (postbuf+posts)->type=callkind; |
8592 | (postbuf+posts)->type=callkind; |
8590 | (postbuf+posts)->line=(unsigned short)linenumber; |
8593 | (postbuf+posts)->line=(unsigned short)linenumber; |
8591 | (postbuf+posts)->file=(unsigned short)currentfileinfo; |
8594 | (postbuf+posts)->file=(unsigned short)currentfileinfo; |
8592 | posts++; |
8595 | posts++; |
8593 | } |
8596 | } |
8594 | 8597 | ||
8595 | unsigned int dofrom() // returns number of bytes read from FROM file |
8598 | unsigned int dofrom() // returns number of bytes read from FROM file |
8596 | { |
8599 | { |
8597 | int filehandle; |
8600 | int filehandle; |
8598 | long filesize; |
8601 | long filesize; |
8599 | if(tok!=tk_string){ |
8602 | if(tok!=tk_string){ |
8600 | stringexpected(); |
8603 | stringexpected(); |
8601 | return(0); |
8604 | return(0); |
8602 | } |
8605 | } |
- | 8606 | #ifndef _WIN32_ |
|
- | 8607 | for(char* p=(char *)string3; *p; ++p) if(*p=='\\') *p='/'; |
|
- | 8608 | #endif |
|
8603 | filehandle=open((char *)string3,O_BINARY|O_RDONLY); |
8609 | filehandle=open((char *)string3,O_BINARY|O_RDONLY); |
8604 | if(filehandle==-1){ |
8610 | if(filehandle==-1){ |
8605 | unableopenfile((char *)string3); |
8611 | unableopenfile((char *)string3); |
8606 | return(0); |
8612 | return(0); |
8607 | } |
8613 | } |
8608 | if((filesize=getfilelen(filehandle))==-1L){ |
8614 | if((filesize=getfilelen(filehandle))==-1L){ |
8609 | preerror("Unable to determine FROM file size"); |
8615 | preerror("Unable to determine FROM file size"); |
8610 | close(filehandle); |
8616 | close(filehandle); |
8611 | return(0); |
8617 | return(0); |
8612 | } |
8618 | } |
8613 | if(am32==FALSE&&filesize>=0xFFFFL){ |
8619 | if(am32==FALSE&&filesize>=0xFFFFL){ |
8614 | preerror("FROM file too large"); |
8620 | preerror("FROM file too large"); |
8615 | close(filehandle); |
8621 | close(filehandle); |
8616 | return(0); |
8622 | return(0); |
8617 | } |
8623 | } |
8618 | LoadData(filesize,filehandle); |
8624 | LoadData(filesize,filehandle); |
8619 | return filesize; |
8625 | return filesize; |
8620 | } |
8626 | } |
8621 | 8627 | ||
8622 | unsigned int doextract() // returns number of bytes EXTRACTed |
8628 | unsigned int doextract() // returns number of bytes EXTRACTed |
8623 | { |
8629 | { |
8624 | unsigned int sizetoread; |
8630 | unsigned int sizetoread; |
8625 | int filehandle; |
8631 | int filehandle; |
8626 | long filesize,startpos; |
8632 | long filesize,startpos; |
8627 | if(tok!=tk_string){ |
8633 | if(tok!=tk_string){ |
8628 | stringexpected(); |
8634 | stringexpected(); |
8629 | return(0); |
8635 | return(0); |
8630 | } |
8636 | } |
8631 | filehandle=open((char *)string3,O_BINARY|O_RDONLY); |
8637 | filehandle=open((char *)string3,O_BINARY|O_RDONLY); |
8632 | if(filehandle==-1){ |
8638 | if(filehandle==-1){ |
8633 | unableopenfile((char *)string3); |
8639 | unableopenfile((char *)string3); |
8634 | return(0); |
8640 | return(0); |
8635 | } |
8641 | } |
8636 | nexttok(); |
8642 | nexttok(); |
8637 | expecting(tk_camma); |
8643 | expecting(tk_camma); |
8638 | if(tok!=tk_number){ |
8644 | if(tok!=tk_number){ |
8639 | numexpected(); |
8645 | numexpected(); |
8640 | return(0); |
8646 | return(0); |
8641 | } |
8647 | } |
8642 | startpos=doconstlongmath(); |
8648 | startpos=doconstlongmath(); |
8643 | expecting(tk_camma); |
8649 | expecting(tk_camma); |
8644 | if(tok!=tk_number){ |
8650 | if(tok!=tk_number){ |
8645 | numexpected(); |
8651 | numexpected(); |
8646 | return(0); |
8652 | return(0); |
8647 | } |
8653 | } |
8648 | sizetoread=doconstlongmath(); |
8654 | sizetoread=doconstlongmath(); |
8649 | if((filesize=getfilelen(filehandle))==-1L){ |
8655 | if((filesize=getfilelen(filehandle))==-1L){ |
8650 | preerror("Unable to determine EXTRACT file size"); |
8656 | preerror("Unable to determine EXTRACT file size"); |
8651 | close(filehandle); |
8657 | close(filehandle); |
8652 | return(0); |
8658 | return(0); |
8653 | } |
8659 | } |
8654 | if(filesize<=startpos){ |
8660 | if(filesize<=startpos){ |
8655 | preerror("EXTRACT offset exceeds the length of the file"); |
8661 | preerror("EXTRACT offset exceeds the length of the file"); |
8656 | close(filehandle); |
8662 | close(filehandle); |
8657 | return(0); |
8663 | return(0); |
8658 | } |
8664 | } |
8659 | if(sizetoread==0)sizetoread=filesize-startpos; |
8665 | if(sizetoread==0)sizetoread=filesize-startpos; |
8660 | if(am32==FALSE&&sizetoread>=0xFFFFL){ |
8666 | if(am32==FALSE&&sizetoread>=0xFFFFL){ |
8661 | preerror("Block to EXTRACT exceeds 64K"); |
8667 | preerror("Block to EXTRACT exceeds 64K"); |
8662 | close(filehandle); |
8668 | close(filehandle); |
8663 | return(0); |
8669 | return(0); |
8664 | } |
8670 | } |
8665 | lseek(filehandle,startpos,0); // error checking required on this |
8671 | lseek(filehandle,startpos,0); // error checking required on this |
8666 | LoadData(sizetoread,filehandle); |
8672 | LoadData(sizetoread,filehandle); |
8667 | return sizetoread; |
8673 | return sizetoread; |
8668 | } |
8674 | } |
8669 | 8675 | ||
8670 | void LoadData(unsigned int size,int filehandle) |
8676 | void LoadData(unsigned int size,int filehandle) |
8671 | { |
8677 | { |
8672 | if(splitdata){ |
8678 | if(splitdata){ |
8673 | while(((unsigned long)size+(unsigned long)outptrdata)>=outdatasize){ |
8679 | while(((unsigned long)size+(unsigned long)outptrdata)>=outdatasize){ |
8674 | if(CheckDataSize()==0)break; |
8680 | if(CheckDataSize()==0)break; |
8675 | } |
8681 | } |
8676 | if((unsigned int)read(filehandle,outputdata+outptrdata,size)!=size)errorreadingfile((char *)string3); |
8682 | if((unsigned int)read(filehandle,outputdata+outptrdata,size)!=size)errorreadingfile((char *)string3); |
8677 | outptrdata+=size; |
8683 | outptrdata+=size; |
8678 | } |
8684 | } |
8679 | else{ |
8685 | else{ |
8680 | while(((unsigned long)size+(unsigned long)outptr)>=outptrsize){ |
8686 | while(((unsigned long)size+(unsigned long)outptr)>=outptrsize){ |
8681 | if(CheckCodeSize()==0)break; |
8687 | if(CheckCodeSize()==0)break; |
8682 | } |
8688 | } |
8683 | if((unsigned int)read(filehandle,output+outptr,size)!=size)errorreadingfile((char *)string3); |
8689 | if((unsigned int)read(filehandle,output+outptr,size)!=size)errorreadingfile((char *)string3); |
8684 | outptr+=size; |
8690 | outptr+=size; |
8685 | outptrdata=outptr; |
8691 | outptrdata=outptr; |
8686 | } |
8692 | } |
8687 | close(filehandle); |
8693 | close(filehandle); |
8688 | } |
8694 | } |
8689 | 8695 | ||
8690 | void op66(int ctok) |
8696 | void op66(int ctok) |
8691 | { |
8697 | { |
8692 | if((am32==FALSE&&ctok==r32)||(am32!=FALSE&&ctok==r16)){ |
8698 | if((am32==FALSE&&ctok==r32)||(am32!=FALSE&&ctok==r16)){ |
8693 | if(cpu<3)cpu=3; |
8699 | if(cpu<3)cpu=3; |
8694 | op(0x66); |
8700 | op(0x66); |
8695 | } |
8701 | } |
8696 | } |
8702 | } |
8697 | 8703 | ||
8698 | int op67(int ctok) |
8704 | int op67(int ctok) |
8699 | { |
8705 | { |
8700 | if((am32==FALSE&&ctok==r32)||(am32!=FALSE&&ctok==r16)){ |
8706 | if((am32==FALSE&&ctok==r32)||(am32!=FALSE&&ctok==r16)){ |
8701 | if(cpu<3)cpu=3; |
8707 | if(cpu<3)cpu=3; |
8702 | op(0x67); |
8708 | op(0x67); |
8703 | return TRUE; |
8709 | return TRUE; |
8704 | } |
8710 | } |
8705 | return FALSE; |
8711 | return FALSE; |
8706 | } |
8712 | } |
8707 | 8713 | ||
8708 | void outseg(ITOK *outtok,unsigned int locadd) |
8714 | void outseg(ITOK *outtok,unsigned int locadd) |
8709 | { |
8715 | { |
8710 | int rmm1; |
8716 | int rmm1; |
8711 | rmm1=outtok->rm&7; |
8717 | rmm1=outtok->rm&7; |
8712 | if(outtok->sib!=CODE16){ |
8718 | if(outtok->sib!=CODE16){ |
8713 | if(am32==FALSE)op(0x67); |
8719 | if(am32==FALSE)op(0x67); |
8714 | if(rmm1==4)locadd++; |
8720 | if(rmm1==4)locadd++; |
8715 | } |
8721 | } |
8716 | else if(am32!=FALSE)op(0x67); |
8722 | else if(am32!=FALSE)op(0x67); |
8717 | switch(outtok->segm){ |
8723 | switch(outtok->segm){ |
8718 | case ES: op(0x26); break; |
8724 | case ES: op(0x26); break; |
8719 | case CS: op(0x2E); break; |
8725 | case CS: op(0x2E); break; |
8720 | case FS: op(0x64); |
8726 | case FS: op(0x64); |
8721 | if(cpu<3)cpu=3; |
8727 | if(cpu<3)cpu=3; |
8722 | break; |
8728 | break; |
8723 | case GS: op(0x65); |
8729 | case GS: op(0x65); |
8724 | if(cpu<3)cpu=3; |
8730 | if(cpu<3)cpu=3; |
8725 | break; |
8731 | break; |
8726 | case SS: |
8732 | case SS: |
8727 | if(outtok->sib==CODE16){ |
8733 | if(outtok->sib==CODE16){ |
8728 | if(rmm1!=2&&rmm1!=3&&!(rmm1==6&&outtok->rm!=6))op(0x36); |
8734 | if(rmm1!=2&&rmm1!=3&&!(rmm1==6&&outtok->rm!=6))op(0x36); |
8729 | } |
8735 | } |
8730 | else{ |
8736 | else{ |
8731 | if(rmm1==4){ |
8737 | if(rmm1==4){ |
8732 | rmm1=outtok->sib&7; |
8738 | rmm1=outtok->sib&7; |
8733 | if(rmm1!=4){ |
8739 | if(rmm1!=4){ |
8734 | if(rmm1==5){ |
8740 | if(rmm1==5){ |
8735 | if(outtok->rm==4)op(0x36); |
8741 | if(outtok->rm==4)op(0x36); |
8736 | break; |
8742 | break; |
8737 | } |
8743 | } |
8738 | op(0x36); |
8744 | op(0x36); |
8739 | } |
8745 | } |
8740 | } |
8746 | } |
8741 | else if(rmm1==5){ |
8747 | else if(rmm1==5){ |
8742 | if(outtok->rm==5)op(0x36); |
8748 | if(outtok->rm==5)op(0x36); |
8743 | else break; |
8749 | else break; |
8744 | } |
8750 | } |
8745 | else op(0x36); |
8751 | else op(0x36); |
8746 | } |
8752 | } |
8747 | break; |
8753 | break; |
8748 | case DS: |
8754 | case DS: |
8749 | if(outtok->sib==CODE16){ |
8755 | if(outtok->sib==CODE16){ |
8750 | if(rmm1==2||rmm1==3||(rmm1==6&&outtok->rm!=6))op(0x3E); |
8756 | if(rmm1==2||rmm1==3||(rmm1==6&&outtok->rm!=6))op(0x3E); |
8751 | } |
8757 | } |
8752 | else{ |
8758 | else{ |
8753 | if(rmm1==4){ |
8759 | if(rmm1==4){ |
8754 | rmm1=outtok->sib&7; |
8760 | rmm1=outtok->sib&7; |
8755 | if(rmm1==4||(rmm1==5&&outtok->rm!=4))op(0x3e); |
8761 | if(rmm1==4||(rmm1==5&&outtok->rm!=4))op(0x3e); |
8756 | } |
8762 | } |
8757 | else if(rmm1==5&&outtok->rm!=5)op(0x3e); |
8763 | else if(rmm1==5&&outtok->rm!=5)op(0x3e); |
8758 | } |
8764 | } |
8759 | } |
8765 | } |
8760 | CheckPosts(); |
8766 | CheckPosts(); |
8761 | if(outtok->post!=0&&outtok->post!=UNDEF_OFSET){ |
8767 | if(outtok->post!=0&&outtok->post!=UNDEF_OFSET){ |
8762 | if((outtok->flag&f_extern)){ |
8768 | if((outtok->flag&f_extern)){ |
8763 | (postbuf+posts)->type=EXT_VAR; |
8769 | (postbuf+posts)->type=EXT_VAR; |
8764 | (postbuf+posts)->num=outtok->number&0xFFFF; |
8770 | (postbuf+posts)->num=outtok->number&0xFFFF; |
8765 | outtok->number>>=16; |
8771 | outtok->number>>=16; |
8766 | } |
8772 | } |
8767 | else if(outtok->post==USED_DIN_VAR){ |
8773 | else if(outtok->post==USED_DIN_VAR){ |
8768 | (postbuf+posts)->type=(unsigned short)(am32==0?DIN_VAR:DIN_VAR32); |
8774 | (postbuf+posts)->type=(unsigned short)(am32==0?DIN_VAR:DIN_VAR32); |
8769 | // printf("Add tok=%d %08X sib=%d %s\n",outtok->rec->rectok,outtok->rec->right,outtok->rec->recsib,outtok->rec->recid); |
8775 | // printf("Add tok=%d %08X sib=%d %s\n",outtok->rec->rectok,outtok->rec->right,outtok->rec->recsib,outtok->rec->recid); |
8770 | if(outtok->rec->rectok==tk_structvar&&outtok->rec->recsib==tp_gvar){ |
8776 | if(outtok->rec->rectok==tk_structvar&&outtok->rec->recsib==tp_gvar){ |
8771 | (postbuf+posts)->num=(int)outtok->rec;//02.09.05 17:10 ->right; |
8777 | (postbuf+posts)->num=(int)outtok->rec;//02.09.05 17:10 ->right; |
8772 | } |
8778 | } |
8773 | else (postbuf+posts)->num=(int)outtok->rec; |
8779 | else (postbuf+posts)->num=(int)outtok->rec; |
8774 | } |
8780 | } |
8775 | // else if((outtok->flag&f_dataseg))(postbuf+posts)->type=(unsigned short)(am32==0?DATABLOCK_VAR:DATABLOCK_VAR32); |
8781 | // else if((outtok->flag&f_dataseg))(postbuf+posts)->type=(unsigned short)(am32==0?DATABLOCK_VAR:DATABLOCK_VAR32); |
8776 | else (postbuf+posts)->type=(unsigned short)(am32==0?POST_VAR:POST_VAR32); |
8782 | else (postbuf+posts)->type=(unsigned short)(am32==0?POST_VAR:POST_VAR32); |
8777 | (postbuf+posts)->loc=outptr+locadd; |
8783 | (postbuf+posts)->loc=outptr+locadd; |
8778 | posts++; |
8784 | posts++; |
8779 | } |
8785 | } |
8780 | else if(outtok->flag&f_reloc){ |
8786 | else if(outtok->flag&f_reloc){ |
8781 | (postbuf+posts)->type=(unsigned short)(am32==0?FIX_VAR:FIX_VAR32); |
8787 | (postbuf+posts)->type=(unsigned short)(am32==0?FIX_VAR:FIX_VAR32); |
8782 | (postbuf+posts)->loc=outptr+locadd; |
8788 | (postbuf+posts)->loc=outptr+locadd; |
8783 | posts++; |
8789 | posts++; |
8784 | } |
8790 | } |
8785 | } |
8791 | } |
8786 | 8792 | ||
8787 | int addpoststring(int segm,int len,int term) /* add a string to the post queue */ |
8793 | int addpoststring(int segm,int len,int term) /* add a string to the post queue */ |
8788 | { |
8794 | { |
8789 | int i; |
8795 | int i; |
8790 | int returnvalue; |
8796 | int returnvalue; |
8791 | if((returnvalue=FindDublString(segm,len,term))!=-1)return returnvalue; |
8797 | if((returnvalue=FindDublString(segm,len,term))!=-1)return returnvalue; |
8792 | CheckPosts(); |
8798 | CheckPosts(); |
8793 | (postbuf+posts)->type=(unsigned short)(am32==FALSE?POST_STRING:POST_STRING32); |
8799 | (postbuf+posts)->type=(unsigned short)(am32==FALSE?POST_STRING:POST_STRING32); |
8794 | (postbuf+posts)->loc=(segm==CS?outptr:outptrdata); |
8800 | (postbuf+posts)->loc=(segm==CS?outptr:outptrdata); |
8795 | (postbuf+posts)->num=segm; |
8801 | (postbuf+posts)->num=segm; |
8796 | posts++; |
8802 | posts++; |
8797 | returnvalue=poststrptr; |
8803 | returnvalue=poststrptr; |
8798 | if((int)(len+poststrptr+1)>=sbufstr){ |
8804 | if((int)(len+poststrptr+1)>=sbufstr){ |
8799 | sbufstr+=SIZEBUF; |
8805 | sbufstr+=SIZEBUF; |
8800 | bufstr=(char *)REALLOC(bufstr,sbufstr); |
8806 | bufstr=(char *)REALLOC(bufstr,sbufstr); |
8801 | } |
8807 | } |
8802 | for(i=0;i |
8808 | for(i=0;i |
8803 | switch(term&3){ |
8809 | switch(term&3){ |
8804 | case zero_term: |
8810 | case zero_term: |
8805 | if(term&s_unicod){ |
8811 | if(term&s_unicod){ |
8806 | poststrptr++; |
8812 | poststrptr++; |
8807 | bufstr[poststrptr]=0; |
8813 | bufstr[poststrptr]=0; |
8808 | } |
8814 | } |
8809 | bufstr[poststrptr]=0; |
8815 | bufstr[poststrptr]=0; |
8810 | poststrptr++; |
8816 | poststrptr++; |
8811 | break; |
8817 | break; |
8812 | case dos_term: |
8818 | case dos_term: |
8813 | if(term&s_unicod){ |
8819 | if(term&s_unicod){ |
8814 | bufstr[poststrptr]=0; |
8820 | bufstr[poststrptr]=0; |
8815 | poststrptr++; |
8821 | poststrptr++; |
8816 | } |
8822 | } |
8817 | bufstr[poststrptr]='$'; |
8823 | bufstr[poststrptr]='$'; |
8818 | poststrptr++; |
8824 | poststrptr++; |
8819 | break; |
8825 | break; |
8820 | } |
8826 | } |
8821 | return(returnvalue); |
8827 | return(returnvalue); |
8822 | } |
8828 | } |
8823 | 8829 | ||
8824 | int FindDublString(int segm,unsigned int len,int term) |
8830 | int FindDublString(int segm,unsigned int len,int term) |
8825 | { |
8831 | { |
8826 | STRING_LIST ins,outs; |
8832 | STRING_LIST ins,outs; |
8827 | void *nextstr=liststring,*prevstr=NULL; |
8833 | void *nextstr=liststring,*prevstr=NULL; |
8828 | ins.len=len; |
8834 | ins.len=len; |
8829 | ins.next=NULL; |
8835 | ins.next=NULL; |
8830 | ins.type=term; |
8836 | ins.type=term; |
8831 | /* if(splitdata){ //ðàçäåëåíûå äàíûå è êîä |
8837 | /* if(splitdata){ //ðàçäåëåíûå äàíûå è êîä |
8832 | ins.plase=0; |
8838 | ins.plase=0; |
8833 | ins.ofs=outptrdata; |
8839 | ins.ofs=outptrdata; |
8834 | } |
8840 | } |
8835 | else{*/ |
8841 | else{*/ |
8836 | ins.plase=POST_STRING; |
8842 | ins.plase=POST_STRING; |
8837 | ins.ofs=poststrptr; |
8843 | ins.ofs=poststrptr; |
8838 | // } |
8844 | // } |
8839 | 8845 | ||
8840 | while(nextstr!=NULL){ |
8846 | while(nextstr!=NULL){ |
8841 | memcpy(&outs,nextstr,sizeof(STRING_LIST)); |
8847 | memcpy(&outs,nextstr,sizeof(STRING_LIST)); |
8842 | if(term==outs.type&&len<=outs.len){ |
8848 | if(term==outs.type&&len<=outs.len){ |
8843 | char *instr,*outstr; |
8849 | char *instr,*outstr; |
8844 | outstr=(char *)nextstr+sizeof(STRING_LIST)+outs.len-1; |
8850 | outstr=(char *)nextstr+sizeof(STRING_LIST)+outs.len-1; |
8845 | instr=(char *)string+len-1; |
8851 | instr=(char *)string+len-1; |
8846 | char c; |
8852 | char c; |
8847 | int i,j; |
8853 | int i,j; |
8848 | for(i=len,j=outs.len;i!=0;j--,i--,instr--,outstr--){ |
8854 | for(i=len,j=outs.len;i!=0;j--,i--,instr--,outstr--){ |
8849 | c=*instr; |
8855 | c=*instr; |
8850 | if(c!=*outstr)break; |
8856 | if(c!=*outstr)break; |
8851 | } |
8857 | } |
8852 | if(i==0){ //íàéäåíà ñòðîêà |
8858 | if(i==0){ //íàéäåíà ñòðîêà |
8853 | if(!optstr)return -1; |
8859 | if(!optstr)return -1; |
8854 | warningstring(); |
8860 | warningstring(); |
8855 | if(outs.plase==0){ //óæå â ôàéëå |
8861 | if(outs.plase==0){ //óæå â ôàéëå |
8856 | AddReloc(DS); |
8862 | AddReloc(DS); |
8857 | return outs.ofs+j; |
8863 | return outs.ofs+j; |
8858 | } |
8864 | } |
8859 | CheckPosts(); |
8865 | CheckPosts(); |
8860 | (postbuf+posts)->type=(unsigned short)(am32==FALSE?POST_STRING:POST_STRING32); |
8866 | (postbuf+posts)->type=(unsigned short)(am32==FALSE?POST_STRING:POST_STRING32); |
8861 | (postbuf+posts)->loc=(segm==CS?outptr:outptrdata); |
8867 | (postbuf+posts)->loc=(segm==CS?outptr:outptrdata); |
8862 | (postbuf+posts)->num=segm; |
8868 | (postbuf+posts)->num=segm; |
8863 | posts++; |
8869 | posts++; |
8864 | return outs.ofs+j; |
8870 | return outs.ofs+j; |
8865 | } |
8871 | } |
8866 | } |
8872 | } |
8867 | prevstr=nextstr; |
8873 | prevstr=nextstr; |
8868 | nextstr=outs.next; |
8874 | nextstr=outs.next; |
8869 | } |
8875 | } |
8870 | outs.next=(void *)MALLOC(sizeof(STRING_LIST)+len); |
8876 | outs.next=(void *)MALLOC(sizeof(STRING_LIST)+len); |
8871 | memcpy(outs.next,&ins,sizeof(STRING_LIST)); |
8877 | memcpy(outs.next,&ins,sizeof(STRING_LIST)); |
8872 | if(len!=0)memcpy((char *)outs.next+sizeof(STRING_LIST),&string,len); |
8878 | if(len!=0)memcpy((char *)outs.next+sizeof(STRING_LIST),&string,len); |
8873 | if(prevstr!=NULL)memcpy(prevstr,&outs,sizeof(STRING_LIST)); |
8879 | if(prevstr!=NULL)memcpy(prevstr,&outs,sizeof(STRING_LIST)); |
8874 | else liststring=outs.next; |
8880 | else liststring=outs.next; |
8875 | return -1; |
8881 | return -1; |
8876 | } |
8882 | } |
8877 | 8883 | ||
8878 | void killpost(unsigned int poz) |
8884 | void killpost(unsigned int poz) |
8879 | { |
8885 | { |
8880 | posts--; |
8886 | posts--; |
8881 | memcpy((postinfo *)(postbuf+poz),(postinfo *)(postbuf+posts),sizeof(postinfo)); |
8887 | memcpy((postinfo *)(postbuf+poz),(postinfo *)(postbuf+posts),sizeof(postinfo)); |
8882 | } |
8888 | } |
8883 | 8889 | ||
8884 | void dopoststrings() |
8890 | void dopoststrings() |
8885 | { |
8891 | { |
8886 | unsigned int addvalue,i; |
8892 | unsigned int addvalue,i; |
8887 | if(poststrptr==0)return; |
8893 | if(poststrptr==0)return; |
8888 | if(splitdata){ |
8894 | if(splitdata){ |
8889 | addvalue=outptrdata; |
8895 | addvalue=outptrdata; |
8890 | if((outptrdata+poststrptr)>=outdatasize)CheckDataSize(); |
8896 | if((outptrdata+poststrptr)>=outdatasize)CheckDataSize(); |
8891 | } |
8897 | } |
8892 | else{ |
8898 | else{ |
8893 | addvalue=outptr; |
8899 | addvalue=outptr; |
8894 | if((outptr+poststrptr)>=outptrsize)CheckCodeSize(); |
8900 | if((outptr+poststrptr)>=outptrsize)CheckCodeSize(); |
8895 | } |
8901 | } |
8896 | datasize+=poststrptr; |
8902 | datasize+=poststrptr; |
8897 | if(dbg&2)AddDataNullLine(3); |
8903 | if(dbg&2)AddDataNullLine(3); |
8898 | memcpy(&outputdata[outptrdata],bufstr,poststrptr); |
8904 | memcpy(&outputdata[outptrdata],bufstr,poststrptr); |
8899 | outptrdata+=poststrptr; |
8905 | outptrdata+=poststrptr; |
8900 | if(!splitdata)outptr=outptrdata; |
8906 | if(!splitdata)outptr=outptrdata; |
8901 | for(i=0;i |
8907 | for(i=0;i |
8902 | int segm=(postbuf+i)->num; |
8908 | int segm=(postbuf+i)->num; |
8903 | if((postbuf+i)->type==POST_STRING){ |
8909 | if((postbuf+i)->type==POST_STRING){ |
8904 | if(segm==CS)*(unsigned short *)&output[(postbuf+i)->loc]+=(unsigned short)addvalue; |
8910 | if(segm==CS)*(unsigned short *)&output[(postbuf+i)->loc]+=(unsigned short)addvalue; |
8905 | else *(unsigned short *)&outputdata[(postbuf+i)->loc]+=(unsigned short)addvalue; |
8911 | else *(unsigned short *)&outputdata[(postbuf+i)->loc]+=(unsigned short)addvalue; |
8906 | if(splitdata&&modelmem==TINY)(postbuf+i)->type=(unsigned short)DATABLOCK_VAR; |
8912 | if(splitdata&&modelmem==TINY)(postbuf+i)->type=(unsigned short)DATABLOCK_VAR; |
8907 | else if(FixUp==FALSE)killpost(i--); |
8913 | else if(FixUp==FALSE)killpost(i--); |
8908 | else (postbuf+i)->type=(unsigned short)(segm==DS?FIX_VAR:FIX_CODE); |
8914 | else (postbuf+i)->type=(unsigned short)(segm==DS?FIX_VAR:FIX_CODE); |
8909 | } |
8915 | } |
8910 | else if((postbuf+i)->type==POST_STRING32){ |
8916 | else if((postbuf+i)->type==POST_STRING32){ |
8911 | if(segm==CS)*(unsigned int *)&output[(postbuf+i)->loc]+=addvalue; |
8917 | if(segm==CS)*(unsigned int *)&output[(postbuf+i)->loc]+=addvalue; |
8912 | else *(unsigned int *)&outputdata[(postbuf+i)->loc]+=addvalue; |
8918 | else *(unsigned int *)&outputdata[(postbuf+i)->loc]+=addvalue; |
8913 | if(splitdata&&modelmem==TINY)(postbuf+i)->type=(unsigned short)DATABLOCK_VAR32; |
8919 | if(splitdata&&modelmem==TINY)(postbuf+i)->type=(unsigned short)DATABLOCK_VAR32; |
8914 | else if(FixUp==FALSE)killpost(i--); |
8920 | else if(FixUp==FALSE)killpost(i--); |
8915 | else (postbuf+i)->type=(unsigned short)(segm==DS?FIX_VAR32:FIX_CODE32); |
8921 | else (postbuf+i)->type=(unsigned short)(segm==DS?FIX_VAR32:FIX_CODE32); |
8916 | } |
8922 | } |
8917 | } |
8923 | } |
8918 | poststrptr=0; /* reset the poststrptr */ |
8924 | poststrptr=0; /* reset the poststrptr */ |
8919 | STRING_LIST ins; |
8925 | STRING_LIST ins; |
8920 | void *nextstr=liststring; |
8926 | void *nextstr=liststring; |
8921 | while(nextstr!=NULL){ |
8927 | while(nextstr!=NULL){ |
8922 | memcpy(&ins,nextstr,sizeof(STRING_LIST)); |
8928 | memcpy(&ins,nextstr,sizeof(STRING_LIST)); |
8923 | if(ins.plase!=0){ |
8929 | if(ins.plase!=0){ |
8924 | ins.plase=0; |
8930 | ins.plase=0; |
8925 | ins.ofs+=addvalue; |
8931 | ins.ofs+=addvalue; |
8926 | memcpy(nextstr,&ins,sizeof(STRING_LIST)); |
8932 | memcpy(nextstr,&ins,sizeof(STRING_LIST)); |
8927 | } |
8933 | } |
8928 | nextstr=ins.next; |
8934 | nextstr=ins.next; |
8929 | } |
8935 | } |
8930 | if(dbg&2)AddCodeNullLine(); |
8936 | if(dbg&2)AddCodeNullLine(); |
8931 | } |
8937 | } |
8932 | 8938 | ||
8933 | void insertcode() // force code procedure at specified location |
8939 | void insertcode() // force code procedure at specified location |
8934 | { |
8940 | { |
8935 | nexttok(); |
8941 | nexttok(); |
8936 | testInitVar(FALSE); |
8942 | testInitVar(FALSE); |
8937 | if((itok.flag&f_extern)!=0){ |
8943 | if((itok.flag&f_extern)!=0){ |
8938 | notexternfun(); |
8944 | notexternfun(); |
8939 | return; |
8945 | return; |
8940 | } |
8946 | } |
8941 | int tproc=itok.flag&f_typeproc; |
8947 | int tproc=itok.flag&f_typeproc; |
8942 | setuprm(); |
8948 | setuprm(); |
8943 | switch(tok){ |
8949 | switch(tok){ |
8944 | case tk_undefproc: |
8950 | case tk_undefproc: |
8945 | case tk_declare: |
8951 | case tk_declare: |
8946 | tok=tk_proc; |
8952 | tok=tk_proc; |
8947 | itok.number=outptr; |
8953 | itok.number=outptr; |
8948 | updatecall((unsigned int)updatetree(),(unsigned int)itok.number,0); |
8954 | updatecall((unsigned int)updatetree(),(unsigned int)itok.number,0); |
8949 | if(tproc==tp_fastcall){ |
8955 | if(tproc==tp_fastcall){ |
8950 | if(includeit(1)==-1)thisundefined(itok.name); |
8956 | if(includeit(1)==-1)thisundefined(itok.name); |
8951 | } |
8957 | } |
8952 | else if(includeproc()==-1)thisundefined(itok.name); |
8958 | else if(includeproc()==-1)thisundefined(itok.name); |
8953 | break; |
8959 | break; |
8954 | case tk_id: |
8960 | case tk_id: |
8955 | case tk_ID: |
8961 | case tk_ID: |
8956 | tok=tk_proc; |
8962 | tok=tk_proc; |
8957 | itok.number=outptr; |
8963 | itok.number=outptr; |
8958 | string[0]=0; |
8964 | string[0]=0; |
8959 | itok.type=tp_ucnovn; |
8965 | itok.type=tp_ucnovn; |
8960 | addtotree(itok.name); |
8966 | addtotree(itok.name); |
8961 | if(tproc==tp_fastcall){ |
8967 | if(tproc==tp_fastcall){ |
8962 | if(includeit(1)==-1)thisundefined(itok.name); |
8968 | if(includeit(1)==-1)thisundefined(itok.name); |
8963 | } |
8969 | } |
8964 | else if(includeproc()==-1)thisundefined(itok.name); |
8970 | else if(includeproc()==-1)thisundefined(itok.name); |
8965 | break; |
8971 | break; |
8966 | case tk_proc: |
8972 | case tk_proc: |
8967 | if(itok.segm |
8973 | if(itok.segm |
8968 | else preerror("Function already inserted in code"); |
8974 | else preerror("Function already inserted in code"); |
8969 | break; |
8975 | break; |
8970 | default: idalreadydefined(); break; |
8976 | default: idalreadydefined(); break; |
8971 | } |
8977 | } |
8972 | nextexpecting2(tk_openbracket); |
8978 | nextexpecting2(tk_openbracket); |
8973 | while(tok!=tk_eof&&tok!=tk_closebracket)nexttok(); |
8979 | while(tok!=tk_eof&&tok!=tk_closebracket)nexttok(); |
8974 | if(tok==tk_eof)unexpectedeof(); |
8980 | if(tok==tk_eof)unexpectedeof(); |
8975 | else nextseminext(); |
8981 | else nextseminext(); |
8976 | } |
8982 | } |
8977 | 8983 | ||
8978 | /************ some of the dynamic procedure support functions *************/ |
8984 | /************ some of the dynamic procedure support functions *************/ |
8979 | 8985 | ||
8980 | void insert_dynamic(int insert) |
8986 | void insert_dynamic(int insert) |
8981 | { |
8987 | { |
8982 | unsigned char *oinput; |
8988 | unsigned char *oinput; |
8983 | int oinptr; |
8989 | int oinptr; |
8984 | unsigned char ocha; |
8990 | unsigned char ocha; |
8985 | int oline; |
8991 | int oline; |
8986 | int ofile; |
8992 | int ofile; |
8987 | char *ostartline; |
8993 | char *ostartline; |
8988 | int oendinptr; |
8994 | int oendinptr; |
8989 | structteg *osearchteg; |
8995 | structteg *osearchteg; |
8990 | int oinsert; |
8996 | int oinsert; |
8991 | _PROCINFO_ *pinfo; |
8997 | _PROCINFO_ *pinfo; |
8992 | SAVEPAR *par; |
8998 | SAVEPAR *par; |
8993 | if(insert){ |
8999 | if(insert){ |
8994 | osearchteg=searchteg; |
9000 | osearchteg=searchteg; |
8995 | searchteg=NULL; |
9001 | searchteg=NULL; |
8996 | } |
9002 | } |
8997 | // printf("cur_mod=%08X\n",cur_mod); |
9003 | // printf("cur_mod=%08X\n",cur_mod); |
8998 | oinsert=insert; |
9004 | oinsert=insert; |
8999 | oinput=input; |
9005 | oinput=input; |
9000 | oinptr=inptr2; |
9006 | oinptr=inptr2; |
9001 | ocha=cha2; |
9007 | ocha=cha2; |
9002 | oline=linenum2; |
9008 | oline=linenum2; |
9003 | ofile=currentfileinfo; |
9009 | ofile=currentfileinfo; |
9004 | (startfileinfo+currentfileinfo)->stlist=staticlist; |
9010 | (startfileinfo+currentfileinfo)->stlist=staticlist; |
9005 | oendinptr=endinptr; |
9011 | oendinptr=endinptr; |
9006 | endoffile=0; |
9012 | endoffile=0; |
9007 | ostartline=startline; |
9013 | ostartline=startline; |
9008 | idrec *ptr=itok.rec; |
9014 | idrec *ptr=itok.rec; |
9009 | pinfo=ptr->pinfo; |
9015 | pinfo=ptr->pinfo; |
9010 | input=(unsigned char *)pinfo->buf; |
9016 | input=(unsigned char *)pinfo->buf; |
9011 | inptr2=1; |
9017 | inptr2=1; |
9012 | startline=(char *)input; |
9018 | startline=(char *)input; |
9013 | cha2=input[0]; |
9019 | cha2=input[0]; |
9014 | endinptr=strlen((char *)input); |
9020 | endinptr=strlen((char *)input); |
9015 | endinput=startline+endinptr; |
9021 | endinput=startline+endinptr; |
9016 | linenumber=linenum2=ptr->line; |
9022 | linenumber=linenum2=ptr->line; |
9017 | currentfileinfo=ptr->file; |
9023 | currentfileinfo=ptr->file; |
9018 | staticlist=(startfileinfo+currentfileinfo)->stlist; |
9024 | staticlist=(startfileinfo+currentfileinfo)->stlist; |
9019 | par=SRparam(TRUE,NULL); |
9025 | par=SRparam(TRUE,NULL); |
9020 | warning=pinfo->warn; |
9026 | warning=pinfo->warn; |
9021 | optimizespeed=pinfo->speed; |
9027 | optimizespeed=pinfo->speed; |
9022 | dosstring=pinfo->typestring; |
9028 | dosstring=pinfo->typestring; |
9023 | useinline=pinfo->inlinest; |
9029 | useinline=pinfo->inlinest; |
9024 | am32=pinfo->code32; |
9030 | am32=pinfo->code32; |
9025 | alignword=pinfo->align; |
9031 | alignword=pinfo->align; |
9026 | AlignCycle=pinfo->acycle; |
9032 | AlignCycle=pinfo->acycle; |
9027 | idasm=pinfo->idasm; |
9033 | idasm=pinfo->idasm; |
9028 | optnumber=pinfo->opnum; |
9034 | optnumber=pinfo->opnum; |
9029 | divexpand=pinfo->de; |
9035 | divexpand=pinfo->de; |
9030 | optstr=pinfo->ostring; |
9036 | optstr=pinfo->ostring; |
9031 | chip=pinfo->chip; |
9037 | chip=pinfo->chip; |
9032 | aligncycle=pinfo->sizeacycle; |
9038 | aligncycle=pinfo->sizeacycle; |
9033 | uselea=pinfo->uselea; |
9039 | uselea=pinfo->uselea; |
9034 | regoverstack=pinfo->regoverstack; |
9040 | regoverstack=pinfo->regoverstack; |
9035 | if(pinfo->classteg!=NULL){ |
9041 | if(pinfo->classteg!=NULL){ |
9036 | /*if((itok.flag&f_static)==0)*/searchteg=(structteg *)pinfo->classteg; |
9042 | /*if((itok.flag&f_static)==0)*/searchteg=(structteg *)pinfo->classteg; |
9037 | insert=0; |
9043 | insert=0; |
9038 | } |
9044 | } |
9039 | if(pinfo->lst)dbg|=2; |
9045 | if(pinfo->lst)dbg|=2; |
9040 | else dbg&=0xFD; |
9046 | else dbg&=0xFD; |
9041 | // puts(itok.name); |
9047 | // puts(itok.name); |
9042 | if(!insert){ |
9048 | if(!insert){ |
9043 | procedure_start=outptr; |
9049 | procedure_start=outptr; |
9044 | if(dbg){ |
9050 | if(dbg){ |
9045 | if(dbg&2){ |
9051 | if(dbg&2){ |
9046 | char m1[130]; |
9052 | char m1[130]; |
9047 | //11.08.04 23:39 |
9053 | //11.08.04 23:39 |
9048 | // if(searchteg)sprintf(m1,"%s::%s()",searchteg->name,itok.name); |
9054 | // if(searchteg)sprintf(m1,"%s::%s()",searchteg->name,itok.name); |
9049 | // else sprintf(m1,"%s()",itok.name); |
9055 | // else sprintf(m1,"%s()",itok.name); |
9050 | sprintf(m1,"%s()",itok.name); |
9056 | sprintf(m1,"%s()",itok.name); |
9051 | 9057 | ||
9052 | AddCodeNullLine(m1); |
9058 | AddCodeNullLine(m1); |
9053 | } |
9059 | } |
9054 | else AddLine(); |
9060 | else AddLine(); |
9055 | } |
9061 | } |
9056 | if(AlignProc)AlignCD(CS,alignproc); |
9062 | if(AlignProc)AlignCD(CS,alignproc); |
9057 | // puts((char *)input); |
9063 | // puts((char *)input); |
9058 | if(pinfo->classteg==NULL)itok.flag&=~f_static; |
9064 | if(pinfo->classteg==NULL)itok.flag&=~f_static; |
9059 | setproc(1); |
9065 | setproc(1); |
9060 | dopoststrings(); |
9066 | dopoststrings(); |
9061 | } |
9067 | } |
9062 | else insertproc(); |
9068 | else insertproc(); |
9063 | input=oinput; |
9069 | input=oinput; |
9064 | inptr2=oinptr; |
9070 | inptr2=oinptr; |
9065 | cha2=ocha; |
9071 | cha2=ocha; |
9066 | linenum2=oline; |
9072 | linenum2=oline; |
9067 | // printf("cur_mod=%08X\n",cur_mod); |
9073 | // printf("cur_mod=%08X\n",cur_mod); |
9068 | (startfileinfo+currentfileinfo)->stlist=staticlist; |
9074 | (startfileinfo+currentfileinfo)->stlist=staticlist; |
9069 | currentfileinfo=ofile; |
9075 | currentfileinfo=ofile; |
9070 | staticlist=(startfileinfo+currentfileinfo)->stlist; |
9076 | staticlist=(startfileinfo+currentfileinfo)->stlist; |
9071 | endinptr=oendinptr; |
9077 | endinptr=oendinptr; |
9072 | endoffile=0; |
9078 | endoffile=0; |
9073 | startline=ostartline; |
9079 | startline=ostartline; |
9074 | SRparam(FALSE,par); |
9080 | SRparam(FALSE,par); |
9075 | if(oinsert)searchteg=osearchteg; |
9081 | if(oinsert)searchteg=osearchteg; |
9076 | else searchteg=NULL; |
9082 | else searchteg=NULL; |
9077 | // if(insert)nexttok(); |
9083 | // if(insert)nexttok(); |
9078 | // printf("tok=%d %08X\n",tok,cur_mod); |
9084 | // printf("tok=%d %08X\n",tok,cur_mod); |
9079 | } |
9085 | } |
9080 | 9086 | ||
9081 | idrec *addtotree(char *keystring)//äîáàâèòü ñòðîêó â äåðåâî |
9087 | idrec *addtotree(char *keystring)//äîáàâèòü ñòðîêó â äåðåâî |
9082 | { |
9088 | { |
9083 | struct idrec *ptr,*newptr; |
9089 | struct idrec *ptr,*newptr; |
9084 | int cmpresult; |
9090 | int cmpresult; |
9085 | //âûäåëèòü ïàìÿòü ïîä íîâóþ ïðîö |
9091 | //âûäåëèòü ïàìÿòü ïîä íîâóþ ïðîö |
9086 | newptr=(struct idrec *)MALLOC(sizeof(struct idrec)); |
9092 | newptr=(struct idrec *)MALLOC(sizeof(struct idrec)); |
9087 | ptr=(itok.flag&f_static)!=0?staticlist:treestart; //íà÷àëî äåðåâà |
9093 | ptr=(itok.flag&f_static)!=0?staticlist:treestart; //íà÷àëî äåðåâà |
9088 | if(ptr==NULL)((itok.flag&f_static)!=0?staticlist:treestart)=newptr;//íà÷àëî äåðåâà |
9094 | if(ptr==NULL)((itok.flag&f_static)!=0?staticlist:treestart)=newptr;//íà÷àëî äåðåâà |
9089 | else{ //ïîèñê ñòðîêè â äåðåâå |
9095 | else{ //ïîèñê ñòðîêè â äåðåâå |
9090 | while(((cmpresult=strcmp(ptr->recid,keystring))<0&&ptr->left!=NULL)|| |
9096 | while(((cmpresult=strcmp(ptr->recid,keystring))<0&&ptr->left!=NULL)|| |
9091 | (cmpresult>0&&ptr->right!=NULL))ptr=(cmpresult<0?ptr->left:ptr->right); |
9097 | (cmpresult>0&&ptr->right!=NULL))ptr=(cmpresult<0?ptr->left:ptr->right); |
9092 | (cmpresult<0?ptr->left:ptr->right)=newptr; |
9098 | (cmpresult<0?ptr->left:ptr->right)=newptr; |
9093 | } |
9099 | } |
9094 | strcpy(newptr->recid,keystring);//ñêîïèð íàçâàíèå |
9100 | strcpy(newptr->recid,keystring);//ñêîïèð íàçâàíèå |
9095 | newptr->newid=NULL; |
9101 | newptr->newid=NULL; |
9096 | if(string[0]!=0)newptr->newid=BackString((char *)string); |
9102 | if(string[0]!=0)newptr->newid=BackString((char *)string); |
9097 | newptr->rectok=tok; |
9103 | newptr->rectok=tok; |
9098 | newptr->recnumber=itok.number; |
9104 | newptr->recnumber=itok.number; |
9099 | newptr->recsegm=itok.segm; |
9105 | newptr->recsegm=itok.segm; |
9100 | newptr->recrm=itok.rm; |
9106 | newptr->recrm=itok.rm; |
9101 | newptr->recpost=itok.post; |
9107 | newptr->recpost=itok.post; |
9102 | newptr->flag=itok.flag; |
9108 | newptr->flag=itok.flag; |
9103 | newptr->recsize=itok.size; |
9109 | newptr->recsize=itok.size; |
9104 | newptr->left=newptr->right=NULL; |
9110 | newptr->left=newptr->right=NULL; |
9105 | newptr->sbuf=NULL; |
9111 | newptr->sbuf=NULL; |
9106 | newptr->recsib=itok.sib; |
9112 | newptr->recsib=itok.sib; |
9107 | newptr->line=linenumber; |
9113 | newptr->line=linenumber; |
9108 | newptr->file=currentfileinfo; |
9114 | newptr->file=currentfileinfo; |
9109 | newptr->count=0; |
9115 | newptr->count=0; |
9110 | newptr->type=itok.type; |
9116 | newptr->type=itok.type; |
9111 | newptr->npointr=itok.npointr; |
9117 | newptr->npointr=itok.npointr; |
9112 | itok.rec=newptr; |
9118 | itok.rec=newptr; |
9113 | return newptr; |
9119 | return newptr; |
9114 | } |
9120 | } |
9115 | 9121 | ||
9116 | long updatetree() // returns the old number value |
9122 | long updatetree() // returns the old number value |
9117 | { |
9123 | { |
9118 | struct idrec *ptr; |
9124 | struct idrec *ptr; |
9119 | long hold; |
9125 | long hold; |
9120 | ptr=itok.rec; |
9126 | ptr=itok.rec; |
9121 | if(ptr==0)internalerror("address record not found when update tree"); |
9127 | if(ptr==0)internalerror("address record not found when update tree"); |
9122 | if(ptr->newid)free(ptr->newid); |
9128 | if(ptr->newid)free(ptr->newid); |
9123 | ptr->newid=NULL; |
9129 | ptr->newid=NULL; |
9124 | if(string[0]!=0)ptr->newid=BackString((char *)string); |
9130 | if(string[0]!=0)ptr->newid=BackString((char *)string); |
9125 | ptr->rectok=tok; |
9131 | ptr->rectok=tok; |
9126 | hold=ptr->recnumber; |
9132 | hold=ptr->recnumber; |
9127 | ptr->recnumber=itok.number; |
9133 | ptr->recnumber=itok.number; |
9128 | ptr->recsegm=itok.segm; |
9134 | ptr->recsegm=itok.segm; |
9129 | ptr->recrm=itok.rm; |
9135 | ptr->recrm=itok.rm; |
9130 | ptr->flag=itok.flag; |
9136 | ptr->flag=itok.flag; |
9131 | ptr->recsize=itok.size; |
9137 | ptr->recsize=itok.size; |
9132 | ptr->recsib=itok.sib; |
9138 | ptr->recsib=itok.sib; |
9133 | return hold; |
9139 | return hold; |
9134 | } |
9140 | } |
9135 | 9141 | ||
9136 | /* --------------- local variable handling starts here ----------------- */ |
9142 | /* --------------- local variable handling starts here ----------------- */ |
9137 | 9143 | ||
9138 | unsigned int updatelocalvar(char *str,int tok4,unsigned int num) |
9144 | unsigned int updatelocalvar(char *str,int tok4,unsigned int num) |
9139 | { |
9145 | { |
9140 | struct localrec *ptr; |
9146 | struct localrec *ptr; |
9141 | unsigned int retvalue; |
9147 | unsigned int retvalue; |
9142 | treelocalrec *ntlr=tlr; |
9148 | treelocalrec *ntlr=tlr; |
9143 | while(ntlr&&ntlr->level>1)ntlr=ntlr->next; |
9149 | while(ntlr&&ntlr->level>1)ntlr=ntlr->next; |
9144 | for(ptr=ntlr->lrec;;ptr=ptr->rec.next){ |
9150 | for(ptr=ntlr->lrec;;ptr=ptr->rec.next){ |
9145 | if(strcmp(ptr->rec.recid,str)==0){ |
9151 | if(strcmp(ptr->rec.recid,str)==0){ |
9146 | retvalue=ptr->rec.recnumber; |
9152 | retvalue=ptr->rec.recnumber; |
9147 | ptr->rec.rectok=tok4; |
9153 | ptr->rec.rectok=tok4; |
9148 | ptr->rec.recnumber=num; |
9154 | ptr->rec.recnumber=num; |
9149 | break; |
9155 | break; |
9150 | } |
9156 | } |
9151 | if(ptr->rec.next==NULL)break; |
9157 | if(ptr->rec.next==NULL)break; |
9152 | } |
9158 | } |
9153 | return(retvalue); |
9159 | return(retvalue); |
9154 | } |
9160 | } |
9155 | 9161 | ||
9156 | localrec * addlocalvar(char *str,int tok4,unsigned int num,int addmain) |
9162 | localrec * addlocalvar(char *str,int tok4,unsigned int num,int addmain) |
9157 | { |
9163 | { |
9158 | localrec *ptr,*newptr; |
9164 | localrec *ptr,*newptr; |
9159 | localrec *uptr; |
9165 | localrec *uptr; |
9160 | treelocalrec *ntlr; |
9166 | treelocalrec *ntlr; |
9161 | if(addmain){ |
9167 | if(addmain){ |
9162 | ntlr=tlr; |
9168 | ntlr=tlr; |
9163 | while(ntlr&&ntlr->level>1)ntlr=ntlr->next; |
9169 | while(ntlr&&ntlr->level>1)ntlr=ntlr->next; |
9164 | uptr=ntlr->lrec; |
9170 | uptr=ntlr->lrec; |
9165 | } |
9171 | } |
9166 | else uptr=tlr->lrec; |
9172 | else uptr=tlr->lrec; |
9167 | newptr=(struct localrec *)MALLOC(sizeof(struct localrec)); |
9173 | newptr=(struct localrec *)MALLOC(sizeof(struct localrec)); |
9168 | 9174 | ||
9169 | if(uptr==NULL){ |
9175 | if(uptr==NULL){ |
9170 | if(addmain)ntlr->lrec=newptr; |
9176 | if(addmain)ntlr->lrec=newptr; |
9171 | else tlr->lrec=newptr; |
9177 | else tlr->lrec=newptr; |
9172 | } |
9178 | } |
9173 | else{ |
9179 | else{ |
9174 | ptr=uptr; |
9180 | ptr=uptr; |
9175 | while(ptr->rec.next!=NULL)ptr=ptr->rec.next; |
9181 | while(ptr->rec.next!=NULL)ptr=ptr->rec.next; |
9176 | ptr->rec.next=newptr; |
9182 | ptr->rec.next=newptr; |
9177 | } |
9183 | } |
9178 | strcpy(newptr->rec.recid,str); |
9184 | strcpy(newptr->rec.recid,str); |
9179 | newptr->rec.rectok=tok4; |
9185 | newptr->rec.rectok=tok4; |
9180 | newptr->rec.recnumber=num; |
9186 | newptr->rec.recnumber=num; |
9181 | newptr->rec.next=NULL; |
9187 | newptr->rec.next=NULL; |
9182 | newptr->rec.right=NULL; |
9188 | newptr->rec.right=NULL; |
9183 | newptr->rec.recsize=0; |
9189 | newptr->rec.recsize=0; |
9184 | newptr->fuse=NOTINITVAR; |
9190 | newptr->fuse=NOTINITVAR; |
9185 | newptr->rec.type=tp_ucnovn; |
9191 | newptr->rec.type=tp_ucnovn; |
9186 | newptr->rec.flag=0; |
9192 | newptr->rec.flag=0; |
9187 | newptr->rec.npointr=0; |
9193 | newptr->rec.npointr=0; |
9188 | newptr->rec.recpost=LOCAL; |
9194 | newptr->rec.recpost=LOCAL; |
9189 | newptr->li.count=0; |
9195 | newptr->li.count=0; |
9190 | newptr->li.start=linenumber; |
9196 | newptr->li.start=linenumber; |
9191 | return newptr; |
9197 | return newptr; |
9192 | } |
9198 | } |
9193 | 9199 | ||
9194 | void KillTegList(structteg *tteg) |
9200 | void KillTegList(structteg *tteg) |
9195 | { |
9201 | { |
9196 | if(tteg){ |
9202 | if(tteg){ |
9197 | KillTegList(tteg->left); |
9203 | KillTegList(tteg->left); |
9198 | KillTegList(tteg->right); |
9204 | KillTegList(tteg->right); |
9199 | if(tteg->baza)free(tteg->baza); |
9205 | if(tteg->baza)free(tteg->baza); |
9200 | free(tteg); |
9206 | free(tteg); |
9201 | } |
9207 | } |
9202 | } |
9208 | } |
9203 | 9209 | ||
9204 | void killlocals(/*int endp*/) |
9210 | void killlocals(/*int endp*/) |
9205 | /* Clear and free the local linked list, check for any unresolved local |
9211 | /* Clear and free the local linked list, check for any unresolved local |
9206 | jump labels. */ |
9212 | jump labels. */ |
9207 | { |
9213 | { |
9208 | /* if(endp){ |
9214 | /* if(endp){ |
9209 | dopoststrings(); |
9215 | dopoststrings(); |
9210 | for(int i=0;i |
9216 | for(int i=0;i |
9211 | // printf("%d type=%d num=%08X\n",i+1,(postbuf+i)->type,(postbuf+i)->num); |
9217 | // printf("%d type=%d num=%08X\n",i+1,(postbuf+i)->type,(postbuf+i)->num); |
9212 | if((postbuf+i)->type==DIN_VAR||(postbuf+i)->type==DIN_VAR32){ |
9218 | if((postbuf+i)->type==DIN_VAR||(postbuf+i)->type==DIN_VAR32){ |
9213 | idrec *ptr=(idrec *)(postbuf+i)->num; |
9219 | idrec *ptr=(idrec *)(postbuf+i)->num; |
9214 | // printf("sib=%d num=%08X %s\n",ptr->recsib,ptr->recnumber,ptr->recid); |
9220 | // printf("sib=%d num=%08X %s\n",ptr->recsib,ptr->recnumber,ptr->recid); |
9215 | if(ptr->recsib!=tp_gvar)continue; |
9221 | if(ptr->recsib!=tp_gvar)continue; |
9216 | puts("recsib=tp_gvar"); |
9222 | puts("recsib=tp_gvar"); |
9217 | if(ptr->recpost==USED_DIN_VAR){ |
9223 | if(ptr->recpost==USED_DIN_VAR){ |
9218 | unsigned int otok,otok2; |
9224 | unsigned int otok,otok2; |
9219 | ITOK oitok; |
9225 | ITOK oitok; |
9220 | oitok=itok; |
9226 | oitok=itok; |
9221 | otok=tok; |
9227 | otok=tok; |
9222 | otok2=tok2; |
9228 | otok2=tok2; |
9223 | setdindata(ptr,i); |
9229 | setdindata(ptr,i); |
9224 | itok=oitok; |
9230 | itok=oitok; |
9225 | tok=otok; |
9231 | tok=otok; |
9226 | tok2=otok2; |
9232 | tok2=otok2; |
9227 | } |
9233 | } |
9228 | else{ |
9234 | else{ |
9229 | if((postbuf+i)->type==DIN_VAR)*(unsigned short *)&output[(postbuf+i)->loc]+=(unsigned short)(ptr->recnumber); |
9235 | if((postbuf+i)->type==DIN_VAR)*(unsigned short *)&output[(postbuf+i)->loc]+=(unsigned short)(ptr->recnumber); |
9230 | else *(unsigned long *)&output[(postbuf+i)->loc]+=ptr->recnumber; |
9236 | else *(unsigned long *)&output[(postbuf+i)->loc]+=ptr->recnumber; |
9231 | } |
9237 | } |
9232 | if(FixUp)(postbuf+i)->type=(unsigned short)((postbuf+i)->type==DIN_VAR?FIX_VAR:FIX_VAR32); |
9238 | if(FixUp)(postbuf+i)->type=(unsigned short)((postbuf+i)->type==DIN_VAR?FIX_VAR:FIX_VAR32); |
9233 | else killpost(i--); |
9239 | else killpost(i--); |
9234 | } |
9240 | } |
9235 | } |
9241 | } |
9236 | dopoststrings(); |
9242 | dopoststrings(); |
9237 | } |
9243 | } |
9238 | */ |
9244 | */ |
9239 | treelocalrec *ftlr,*ftlr1; |
9245 | treelocalrec *ftlr,*ftlr1; |
9240 | struct localrec *ptr, *ptr1; |
9246 | struct localrec *ptr, *ptr1; |
9241 | for(ftlr=btlr;ftlr!=NULL;){ |
9247 | for(ftlr=btlr;ftlr!=NULL;){ |
9242 | ftlr1=ftlr; |
9248 | ftlr1=ftlr; |
9243 | for(ptr=ftlr->lrec;ptr!=NULL;){ |
9249 | for(ptr=ftlr->lrec;ptr!=NULL;){ |
9244 | ptr1=ptr; |
9250 | ptr1=ptr; |
9245 | if(ptr->rec.rectok==tk_locallabel){ /* check for unresolved labels */ |
9251 | if(ptr->rec.rectok==tk_locallabel){ /* check for unresolved labels */ |
9246 | char holdstr[32+IDLENGTH]; |
9252 | char holdstr[32+IDLENGTH]; |
9247 | sprintf(holdstr,"local jump label '%s' unresolved",ptr1->rec.recid); |
9253 | sprintf(holdstr,"local jump label '%s' unresolved",ptr1->rec.recid); |
9248 | preerror(holdstr); |
9254 | preerror(holdstr); |
9249 | } |
9255 | } |
9250 | // printf("type=%d post=%08X %s\n",ptr->rec.type,ptr->rec.recpost,ptr->rec.recid); |
9256 | // printf("type=%d post=%08X %s\n",ptr->rec.type,ptr->rec.recpost,ptr->rec.recid); |
9251 | if(ptr->rec.rectok==tk_structvar){ |
9257 | if(ptr->rec.rectok==tk_structvar){ |
9252 | if(ptr->rec.count==0){ |
9258 | if(ptr->rec.count==0){ |
9253 | warningnotused(ptr->rec.recid,5); |
9259 | warningnotused(ptr->rec.recid,5); |
9254 | if(ptr->rec.type==tp_gvar)free(ptr->rec.sbuf); |
9260 | if(ptr->rec.type==tp_gvar)free(ptr->rec.sbuf); |
9255 | } |
9261 | } |
9256 | } |
9262 | } |
9257 | else if(ptr->fuse |
9263 | else if(ptr->fuse |
9258 | if(ptr->rec.type==tp_localvar||ptr->rec.type==tp_postvar||ptr->rec.type==tp_gvar)warningnotused(ptr->rec.recid,3); |
9264 | if(ptr->rec.type==tp_localvar||ptr->rec.type==tp_postvar||ptr->rec.type==tp_gvar)warningnotused(ptr->rec.recid,3); |
9259 | else if(ptr->rec.type==tp_paramvar)warningnotused(ptr->rec.recid,4); |
9265 | else if(ptr->rec.type==tp_paramvar)warningnotused(ptr->rec.recid,4); |
9260 | if(ptr->rec.type==tp_gvar)free(ptr->rec.sbuf); |
9266 | if(ptr->rec.type==tp_gvar)free(ptr->rec.sbuf); |
9261 | } |
9267 | } |
9262 | ptr=ptr->rec.next; |
9268 | ptr=ptr->rec.next; |
9263 | if(ptr1->rec.recpost!=USED_DIN_VAR)free(ptr1); |
9269 | if(ptr1->rec.recpost!=USED_DIN_VAR)free(ptr1); |
9264 | } |
9270 | } |
9265 | ftlr=ftlr->next; |
9271 | ftlr=ftlr->next; |
9266 | free(ftlr1); |
9272 | free(ftlr1); |
9267 | } |
9273 | } |
9268 | btlr=NULL; |
9274 | btlr=NULL; |
9269 | paramsize=0; |
9275 | paramsize=0; |
9270 | localsize=0; |
9276 | localsize=0; |
9271 | KillTegList(ltegtree); |
9277 | KillTegList(ltegtree); |
9272 | ltegtree=NULL; |
9278 | ltegtree=NULL; |
9273 | } |
9279 | } |
9274 | 9280 | ||
9275 | /* ================ input procedures start ================= */ |
9281 | /* ================ input procedures start ================= */ |
9276 | int loadinputfile(char *inpfile) //ñ÷èòûâàíèå ôàéëà â ïàìÿòü |
9282 | int loadinputfile(char *inpfile) //ñ÷èòûâàíèå ôàéëà â ïàìÿòü |
9277 | { |
9283 | { |
9278 | unsigned long size; |
9284 | unsigned long size; |
9279 | int filehandle; |
9285 | int filehandle; |
9280 | if((filehandle=open(inpfile,O_BINARY|O_RDONLY))==-1)return -2; |
9286 | if((filehandle=open(inpfile,O_BINARY|O_RDONLY))==-1)return -2; |
9281 | if((size=getfilelen(filehandle))==0){ |
9287 | if((size=getfilelen(filehandle))==0){ |
9282 | badinfile(inpfile); |
9288 | badinfile(inpfile); |
9283 | close(filehandle); |
9289 | close(filehandle); |
9284 | return(-1); |
9290 | return(-1); |
9285 | } |
9291 | } |
9286 | if(totalmodule==0){ |
9292 | if(totalmodule==0){ |
9287 | startfileinfo=(struct FILEINFO *)MALLOC(sizeof(FILEINFO)); |
9293 | startfileinfo=(struct FILEINFO *)MALLOC(sizeof(FILEINFO)); |
9288 | totalmodule=1; |
9294 | totalmodule=1; |
9289 | currentfileinfo=0; |
9295 | currentfileinfo=0; |
9290 | } |
9296 | } |
9291 | else{ //ïîèñê åìåíè ôàéëà â ñïèñêå îáðàáîòàííûõ |
9297 | else{ //ïîèñê åìåíè ôàéëà â ñïèñêå îáðàáîòàííûõ |
9292 | for(currentfileinfo=0;currentfileinfo |
9298 | for(currentfileinfo=0;currentfileinfo |
9293 | if(stricmp(inpfile,(startfileinfo+currentfileinfo)->filename)==0)break; |
9299 | if(stricmp(inpfile,(startfileinfo+currentfileinfo)->filename)==0)break; |
9294 | } |
9300 | } |
9295 | if(currentfileinfo!=totalmodule){ |
9301 | if(currentfileinfo!=totalmodule){ |
9296 | if(crif!=FALSE)return 1; |
9302 | if(crif!=FALSE)return 1; |
9297 | goto cont_load; |
9303 | goto cont_load; |
9298 | } |
9304 | } |
9299 | totalmodule++; |
9305 | totalmodule++; |
9300 | startfileinfo=(struct FILEINFO *)REALLOC(startfileinfo,sizeof(FILEINFO)*(totalmodule)); |
9306 | startfileinfo=(struct FILEINFO *)REALLOC(startfileinfo,sizeof(FILEINFO)*(totalmodule)); |
9301 | } |
9307 | } |
9302 | 9308 | ||
9303 | (startfileinfo+currentfileinfo)->stlist=NULL; |
9309 | (startfileinfo+currentfileinfo)->stlist=NULL; |
9304 | (startfileinfo+currentfileinfo)->filename=(char *)MALLOC(strlen(inpfile)+1); |
9310 | (startfileinfo+currentfileinfo)->filename=(char *)MALLOC(strlen(inpfile)+1); |
9305 | strcpy((startfileinfo+currentfileinfo)->filename,inpfile); |
9311 | strcpy((startfileinfo+currentfileinfo)->filename,inpfile); |
9306 | (startfileinfo+currentfileinfo)->numdline=0; |
9312 | (startfileinfo+currentfileinfo)->numdline=0; |
9307 | //GetFileTime(filehandle,&(startfileinfo+currentfileinfo)->time); // bug |
9313 | //GetFileTime(filehandle,&(startfileinfo+currentfileinfo)->time); // bug |
9308 | // getftime(filehandle,&(startfileinfo+currentfileinfo)->time); |
9314 | // getftime(filehandle,&(startfileinfo+currentfileinfo)->time); |
9309 | cont_load: |
9315 | cont_load: |
9310 | staticlist=(startfileinfo+currentfileinfo)->stlist; |
9316 | staticlist=(startfileinfo+currentfileinfo)->stlist; |
9311 | input=(unsigned char *)MALLOC(size+1); |
9317 | input=(unsigned char *)MALLOC(size+1); |
9312 | printf("%08lX %s %lu\n",input,inpfile,size); |
9318 | printf("%08lX %s %lu\n",input,inpfile,size); |
9313 | if((endinptr=read(filehandle,input,size))!=size){ |
9319 | if((endinptr=read(filehandle,input,size))!=size){ |
9314 | printf("%d\n",endinptr); |
9320 | printf("%d\n",endinptr); |
9315 | 9321 | ||
9316 | errorreadingfile(inpfile); |
9322 | errorreadingfile(inpfile); |
9317 | close(filehandle); |
9323 | close(filehandle); |
9318 | return(-1); |
9324 | return(-1); |
9319 | } |
9325 | } |
9320 | close(filehandle); |
9326 | close(filehandle); |
9321 | return(0); |
9327 | return(0); |
9322 | } |
9328 | } |
9323 | 9329 | ||
9324 | void notnegit(int notneg) |
9330 | void notnegit(int notneg) |
9325 | /* produce NOT .. or NEG .. */ |
9331 | /* produce NOT .. or NEG .. */ |
9326 | { |
9332 | { |
9327 | int wordadd=0,i=0; |
9333 | int wordadd=0,i=0; |
9328 | getoperand(); |
9334 | getoperand(); |
9329 | switch(tok){ |
9335 | switch(tok){ |
9330 | case tk_reg: wordadd=1; op66(r16); |
9336 | case tk_reg: wordadd=1; op66(r16); |
9331 | ClearReg(itok.number); |
9337 | ClearReg(itok.number); |
9332 | case tk_beg: |
9338 | case tk_beg: |
9333 | if(optimizespeed&&(chip==5||chip==6)){ |
9339 | if(optimizespeed&&(chip==5||chip==6)){ |
9334 | if(wordadd==0&&itok.number==AL)outword(0xFF34); |
9340 | if(wordadd==0&&itok.number==AL)outword(0xFF34); |
9335 | else{ |
9341 | else{ |
9336 | if(wordadd)op(0x83); |
9342 | if(wordadd)op(0x83); |
9337 | else op(0x80); |
9343 | else op(0x80); |
9338 | op(0xF0+itok.number); |
9344 | op(0xF0+itok.number); |
9339 | op(0xFF); |
9345 | op(0xFF); |
9340 | } |
9346 | } |
9341 | if(notneg){ |
9347 | if(notneg){ |
9342 | if(wordadd){ |
9348 | if(wordadd){ |
9343 | op66(r16); |
9349 | op66(r16); |
9344 | op(0x40+itok.number); |
9350 | op(0x40+itok.number); |
9345 | } |
9351 | } |
9346 | else{ |
9352 | else{ |
9347 | op(0xFE); |
9353 | op(0xFE); |
9348 | op(0xC0+itok.number); |
9354 | op(0xC0+itok.number); |
9349 | } |
9355 | } |
9350 | } |
9356 | } |
9351 | } |
9357 | } |
9352 | else{ |
9358 | else{ |
9353 | op(0xF6+wordadd); |
9359 | op(0xF6+wordadd); |
9354 | op(0xD0+notneg+itok.number); |
9360 | op(0xD0+notneg+itok.number); |
9355 | } |
9361 | } |
9356 | if(wordadd==0)ClearReg(itok.number&3); |
9362 | if(wordadd==0)ClearReg(itok.number&3); |
9357 | break; |
9363 | break; |
9358 | case tk_wordvar: |
9364 | case tk_wordvar: |
9359 | case tk_intvar: wordadd=1; |
9365 | case tk_intvar: wordadd=1; |
9360 | i=1; |
9366 | i=1; |
9361 | case tk_bytevar: |
9367 | case tk_bytevar: |
9362 | case tk_charvar: |
9368 | case tk_charvar: |
9363 | i++; |
9369 | i++; |
9364 | CheckAllMassiv(bufrm,i,&strinf); |
9370 | CheckAllMassiv(bufrm,i,&strinf); |
9365 | if(wordadd)op66(r16); |
9371 | if(wordadd)op66(r16); |
9366 | outseg(&itok,2); |
9372 | outseg(&itok,2); |
9367 | if((!notneg)&&optimizespeed&&(chip==5||chip==6)){ |
9373 | if((!notneg)&&optimizespeed&&(chip==5||chip==6)){ |
9368 | op(wordadd!=0?0x83:0x80); |
9374 | op(wordadd!=0?0x83:0x80); |
9369 | op(0x30+itok.rm); |
9375 | op(0x30+itok.rm); |
9370 | outaddress(&itok); |
9376 | outaddress(&itok); |
9371 | op(0xFF); |
9377 | op(0xFF); |
9372 | } |
9378 | } |
9373 | else{ |
9379 | else{ |
9374 | op(0xF6+wordadd); |
9380 | op(0xF6+wordadd); |
9375 | op(0x10+notneg+itok.rm); |
9381 | op(0x10+notneg+itok.rm); |
9376 | outaddress(&itok); |
9382 | outaddress(&itok); |
9377 | } |
9383 | } |
9378 | KillVar(itok.name); |
9384 | KillVar(itok.name); |
9379 | break; |
9385 | break; |
9380 | case tk_reg32: |
9386 | case tk_reg32: |
9381 | op66(r32); |
9387 | op66(r32); |
9382 | if(optimizespeed&&(chip==5||chip==6)){ |
9388 | if(optimizespeed&&(chip==5||chip==6)){ |
9383 | op(0x83); |
9389 | op(0x83); |
9384 | outword(0xFFF0+itok.number); |
9390 | outword(0xFFF0+itok.number); |
9385 | if(notneg){ |
9391 | if(notneg){ |
9386 | op66(r32); |
9392 | op66(r32); |
9387 | op(0x40+itok.number); |
9393 | op(0x40+itok.number); |
9388 | } |
9394 | } |
9389 | } |
9395 | } |
9390 | else{ |
9396 | else{ |
9391 | op(0xF7); |
9397 | op(0xF7); |
9392 | op(0xD0+notneg+itok.number); |
9398 | op(0xD0+notneg+itok.number); |
9393 | } |
9399 | } |
9394 | if(cpu<3)cpu=3; |
9400 | if(cpu<3)cpu=3; |
9395 | ClearReg(itok.number); |
9401 | ClearReg(itok.number); |
9396 | break; |
9402 | break; |
9397 | case tk_reg64: |
9403 | case tk_reg64: |
9398 | int r1,r2; |
9404 | int r1,r2; |
9399 | r1=itok.number&255; |
9405 | r1=itok.number&255; |
9400 | r2=itok.number/256; |
9406 | r2=itok.number/256; |
9401 | op66(r32); |
9407 | op66(r32); |
9402 | op(0xF7); |
9408 | op(0xF7); |
9403 | op(0xD0+notneg+r2); // NEG reg |
9409 | op(0xD0+notneg+r2); // NEG reg |
9404 | op66(r32); |
9410 | op66(r32); |
9405 | op(0xF7); |
9411 | op(0xF7); |
9406 | op(0xD0+notneg+r1); // NEG reg |
9412 | op(0xD0+notneg+r1); // NEG reg |
9407 | op66(r32); |
9413 | op66(r32); |
9408 | op(0x83); |
9414 | op(0x83); |
9409 | op(0xD8+r2); |
9415 | op(0xD8+r2); |
9410 | op(0); |
9416 | op(0); |
9411 | ClearReg(r1); |
9417 | ClearReg(r1); |
9412 | ClearReg(r2); |
9418 | ClearReg(r2); |
9413 | break; |
9419 | break; |
9414 | case tk_longvar: |
9420 | case tk_longvar: |
9415 | case tk_dwordvar: |
9421 | case tk_dwordvar: |
9416 | CheckAllMassiv(bufrm,4,&strinf); |
9422 | CheckAllMassiv(bufrm,4,&strinf); |
9417 | op66(r32); |
9423 | op66(r32); |
9418 | outseg(&itok,2); |
9424 | outseg(&itok,2); |
9419 | if((!notneg)&&optimizespeed&&(chip==5||chip==6)){ |
9425 | if((!notneg)&&optimizespeed&&(chip==5||chip==6)){ |
9420 | op(0x83); |
9426 | op(0x83); |
9421 | op(0x30+itok.rm); |
9427 | op(0x30+itok.rm); |
9422 | outaddress(&itok); |
9428 | outaddress(&itok); |
9423 | op(0xFF); |
9429 | op(0xFF); |
9424 | } |
9430 | } |
9425 | else{ |
9431 | else{ |
9426 | op(0xF7); |
9432 | op(0xF7); |
9427 | op(0x10+notneg+itok.rm); |
9433 | op(0x10+notneg+itok.rm); |
9428 | outaddress(&itok); |
9434 | outaddress(&itok); |
9429 | } |
9435 | } |
9430 | if(cpu<3)cpu=3; |
9436 | if(cpu<3)cpu=3; |
9431 | KillVar(itok.name); |
9437 | KillVar(itok.name); |
9432 | break; |
9438 | break; |
9433 | case tk_qword: |
9439 | case tk_qword: |
9434 | itok.number+=4; |
9440 | itok.number+=4; |
9435 | compressoffset(&itok); |
9441 | compressoffset(&itok); |
9436 | for(i=0;i<2;i++){ |
9442 | for(i=0;i<2;i++){ |
9437 | CheckAllMassiv(bufrm,8,&strinf); |
9443 | CheckAllMassiv(bufrm,8,&strinf); |
9438 | op66(r32); |
9444 | op66(r32); |
9439 | outseg(&itok,2); |
9445 | outseg(&itok,2); |
9440 | op(0xF7); |
9446 | op(0xF7); |
9441 | op(0x10+notneg+itok.rm); |
9447 | op(0x10+notneg+itok.rm); |
9442 | outaddress(&itok); |
9448 | outaddress(&itok); |
9443 | if(i==1)break; |
9449 | if(i==1)break; |
9444 | itok.number-=4; |
9450 | itok.number-=4; |
9445 | compressoffset(&itok); |
9451 | compressoffset(&itok); |
9446 | } |
9452 | } |
9447 | itok.number-=4; |
9453 | itok.number-=4; |
9448 | compressoffset(&itok); |
9454 | compressoffset(&itok); |
9449 | CheckAllMassiv(bufrm,8,&strinf); |
9455 | CheckAllMassiv(bufrm,8,&strinf); |
9450 | op66(r32); |
9456 | op66(r32); |
9451 | outseg(&itok,2); |
9457 | outseg(&itok,2); |
9452 | op(0x83); op(0x18+itok.rm); |
9458 | op(0x83); op(0x18+itok.rm); |
9453 | outaddress(&itok); |
9459 | outaddress(&itok); |
9454 | op(0); |
9460 | op(0); |
9455 | KillVar(itok.name); |
9461 | KillVar(itok.name); |
9456 | if(cpu<3)cpu=3; |
9462 | if(cpu<3)cpu=3; |
9457 | break; |
9463 | break; |
9458 | case tk_doublevar: |
9464 | case tk_doublevar: |
9459 | i=4; |
9465 | i=4; |
9460 | case tk_floatvar: |
9466 | case tk_floatvar: |
9461 | if(notneg!=8)illegalfloat(); |
9467 | if(notneg!=8)illegalfloat(); |
9462 | CheckAllMassiv(bufrm,4+i,&strinf); |
9468 | CheckAllMassiv(bufrm,4+i,&strinf); |
9463 | outseg(&itok,2); //fld var |
9469 | outseg(&itok,2); //fld var |
9464 | op(0xd9+i); |
9470 | op(0xd9+i); |
9465 | op(itok.rm); |
9471 | op(itok.rm); |
9466 | outaddress(&itok); |
9472 | outaddress(&itok); |
9467 | outword(0xe0d9); //fchs |
9473 | outword(0xe0d9); //fchs |
9468 | outseg(&itok,2);//fstp var |
9474 | outseg(&itok,2);//fstp var |
9469 | op(0xd9+i); |
9475 | op(0xd9+i); |
9470 | op(itok.rm+0x18); |
9476 | op(itok.rm+0x18); |
9471 | outaddress(&itok); |
9477 | outaddress(&itok); |
9472 | fwait3(); |
9478 | fwait3(); |
9473 | break; |
9479 | break; |
9474 | default: varexpected(0); |
9480 | default: varexpected(0); |
9475 | } |
9481 | } |
9476 | } |
9482 | } |
9477 | 9483 | ||
9478 | void setreturn() |
9484 | void setreturn() |
9479 | { |
9485 | { |
9480 | if(numreturn){ |
9486 | if(numreturn){ |
9481 | unsigned int pos,dist; |
9487 | unsigned int pos,dist; |
9482 | //int j=0; |
9488 | //int j=0; |
9483 | //restart: |
9489 | //restart: |
9484 | for(int i=0;i |
9490 | for(int i=0;i |
9485 | // if(!(listreturn+i)->use)continue; |
9491 | // if(!(listreturn+i)->use)continue; |
9486 | pos=(listreturn+i)->loc; |
9492 | pos=(listreturn+i)->loc; |
9487 | dist=outptr-pos; |
9493 | dist=outptr-pos; |
9488 | if((listreturn+i)->type==tk_RETURN){ |
9494 | if((listreturn+i)->type==tk_RETURN){ |
9489 | dist--; |
9495 | dist--; |
9490 | // if(dist){ |
9496 | // if(dist){ |
9491 | if(dist>127/*&&i>=j*/)jumperror((listreturn+i)->line,mesRETURN); |
9497 | if(dist>127/*&&i>=j*/)jumperror((listreturn+i)->line,mesRETURN); |
9492 | output[pos]=(unsigned char)dist; |
9498 | output[pos]=(unsigned char)dist; |
9493 | /* } |
9499 | /* } |
9494 | else{ |
9500 | else{ |
9495 | outptr-=2; |
9501 | outptr-=2; |
9496 | j=i; |
9502 | j=i; |
9497 | (listreturn+i)->use=FALSE; |
9503 | (listreturn+i)->use=FALSE; |
9498 | goto restart; |
9504 | goto restart; |
9499 | }*/ |
9505 | }*/ |
9500 | } |
9506 | } |
9501 | else{ |
9507 | else{ |
9502 | dist-=(am32==0?2:4); |
9508 | dist-=(am32==0?2:4); |
9503 | // if(dist){ |
9509 | // if(dist){ |
9504 | if(dist<128/*&&i>=j*/)warningjmp(mesRETURN,(listreturn+i)->line,currentfileinfo); |
9510 | if(dist<128/*&&i>=j*/)warningjmp(mesRETURN,(listreturn+i)->line,currentfileinfo); |
9505 | if(am32)*(unsigned long *)&output[pos]=dist; |
9511 | if(am32)*(unsigned long *)&output[pos]=dist; |
9506 | else*(unsigned short *)&output[pos]=(unsigned short)dist; |
9512 | else*(unsigned short *)&output[pos]=(unsigned short)dist; |
9507 | /* } |
9513 | /* } |
9508 | else{ |
9514 | else{ |
9509 | outptr-=3; |
9515 | outptr-=3; |
9510 | if(am32)outptr-=2; |
9516 | if(am32)outptr-=2; |
9511 | j=i; |
9517 | j=i; |
9512 | (listreturn+i)->use=FALSE; |
9518 | (listreturn+i)->use=FALSE; |
9513 | goto restart; |
9519 | goto restart; |
9514 | }*/ |
9520 | }*/ |
9515 | } |
9521 | } |
9516 | } |
9522 | } |
9517 | free(listreturn); |
9523 | free(listreturn); |
9518 | listreturn=NULL; |
9524 | listreturn=NULL; |
9519 | numreturn=0; |
9525 | numreturn=0; |
9520 | } |
9526 | } |
9521 | } |
9527 | } |
9522 | 9528 | ||
9523 | void RestoreSaveReg() |
9529 | void RestoreSaveReg() |
9524 | { |
9530 | { |
9525 | if(psavereg->all){ |
9531 | if(psavereg->all){ |
9526 | op(0x61); |
9532 | op(0x61); |
9527 | addESP-=am32==FALSE?16:32; |
9533 | addESP-=am32==FALSE?16:32; |
9528 | } |
9534 | } |
9529 | else{ |
9535 | else{ |
9530 | for(int i=7;i>=0;i--){ |
9536 | for(int i=7;i>=0;i--){ |
9531 | if(psavereg->reg[i]){ |
9537 | if(psavereg->reg[i]){ |
9532 | op66(psavereg->reg[i]); |
9538 | op66(psavereg->reg[i]); |
9533 | op(0x58+i); |
9539 | op(0x58+i); |
9534 | addESP-=am32==FALSE?2:4; |
9540 | addESP-=am32==FALSE?2:4; |
9535 | } |
9541 | } |
9536 | } |
9542 | } |
9537 | } |
9543 | } |
9538 | } |
9544 | } |
9539 | 9545 | ||
9540 | void AddRetList(int pos,int line,int type) |
9546 | void AddRetList(int pos,int line,int type) |
9541 | { |
9547 | { |
9542 | if(numreturn==0)listreturn=(RETLIST *)MALLOC(sizeof(RETLIST)); |
9548 | if(numreturn==0)listreturn=(RETLIST *)MALLOC(sizeof(RETLIST)); |
9543 | else listreturn=(RETLIST *)REALLOC(listreturn,sizeof(RETLIST)*(numreturn+1)); |
9549 | else listreturn=(RETLIST *)REALLOC(listreturn,sizeof(RETLIST)*(numreturn+1)); |
9544 | (listreturn+numreturn)->loc=pos; |
9550 | (listreturn+numreturn)->loc=pos; |
9545 | (listreturn+numreturn)->line=line; |
9551 | (listreturn+numreturn)->line=line; |
9546 | (listreturn+numreturn)->type=type; |
9552 | (listreturn+numreturn)->type=type; |
9547 | // (listreturn+numreturn)->use=TRUE; |
9553 | // (listreturn+numreturn)->use=TRUE; |
9548 | if(type==tk_return)jumploc0(); |
9554 | if(type==tk_return)jumploc0(); |
9549 | else outword(0x00EB); // JMP SHORT |
9555 | else outword(0x00EB); // JMP SHORT |
9550 | numreturn++; |
9556 | numreturn++; |
9551 | } |
9557 | } |
9552 | 9558 | ||
9553 | void RetProc() |
9559 | void RetProc() |
9554 | { |
9560 | { |
9555 | if((current_proc_type&f_far)){ |
9561 | if((current_proc_type&f_far)){ |
9556 | if((current_proc_type&f_typeproc)==tp_cdecl)retf(); |
9562 | if((current_proc_type&f_typeproc)==tp_cdecl)retf(); |
9557 | else{ |
9563 | else{ |
9558 | if(paramsize==0)retf(); /* RETF */ |
9564 | if(paramsize==0)retf(); /* RETF */ |
9559 | else{ |
9565 | else{ |
9560 | op(0xCA); |
9566 | op(0xCA); |
9561 | outword(paramsize); |
9567 | outword(paramsize); |
9562 | } |
9568 | } |
9563 | } |
9569 | } |
9564 | } |
9570 | } |
9565 | else{ |
9571 | else{ |
9566 | if((current_proc_type&f_typeproc)==tp_cdecl)ret(); |
9572 | if((current_proc_type&f_typeproc)==tp_cdecl)ret(); |
9567 | else if(current_proc_type==f_interrupt)op(0xCF);//interrupt procedure IRET |
9573 | else if(current_proc_type==f_interrupt)op(0xCF);//interrupt procedure IRET |
9568 | else{ |
9574 | else{ |
9569 | if(paramsize==0)ret(); /* RET */ |
9575 | if(paramsize==0)ret(); /* RET */ |
9570 | else{ |
9576 | else{ |
9571 | op(0xC2); |
9577 | op(0xC2); |
9572 | outword(paramsize); |
9578 | outword(paramsize); |
9573 | } |
9579 | } |
9574 | } |
9580 | } |
9575 | } |
9581 | } |
9576 | } |
9582 | } |
9577 | 9583 | ||
9578 | void doreturn(int typer) /* do return(...); */ |
9584 | void doreturn(int typer) /* do return(...); */ |
9579 | { |
9585 | { |
9580 | char sign=0; |
9586 | char sign=0; |
9581 | int line=linenumber; |
9587 | int line=linenumber; |
9582 | char *ofsstr=NULL; |
9588 | char *ofsstr=NULL; |
9583 | int i; |
9589 | int i; |
9584 | unsigned int oaddESP=addESP; |
9590 | unsigned int oaddESP=addESP; |
9585 | if(tok2==tk_openbracket)nexttok(); |
9591 | if(tok2==tk_openbracket)nexttok(); |
9586 | if((ofsstr=GetLecsem(tk_closebracket,tk_semicolon))){ |
9592 | if((ofsstr=GetLecsem(tk_closebracket,tk_semicolon))){ |
9587 | int retreg; |
9593 | int retreg; |
9588 | int razr=getrazr(returntype); |
9594 | int razr=getrazr(returntype); |
9589 | if((retreg=CheckIDZReg(ofsstr,AX,razr))!=NOINREG){ |
9595 | if((retreg=CheckIDZReg(ofsstr,AX,razr))!=NOINREG){ |
9590 | GetEndLex(tk_closebracket,tk_semicolon); |
9596 | GetEndLex(tk_closebracket,tk_semicolon); |
9591 | if(razr==r16)tok=tk_reg; |
9597 | if(razr==r16)tok=tk_reg; |
9592 | else if(razr==r32)tok=tk_reg32; |
9598 | else if(razr==r32)tok=tk_reg32; |
9593 | else tok=tk_beg; |
9599 | else tok=tk_beg; |
9594 | itok.number=retreg==SKIPREG?AX:retreg; |
9600 | itok.number=retreg==SKIPREG?AX:retreg; |
9595 | goto nn1; |
9601 | goto nn1; |
9596 | } |
9602 | } |
9597 | } |
9603 | } |
9598 | getoperand(); |
9604 | getoperand(); |
9599 | if(tok!=tk_closebracket&&tok!=tk_semicolon){ |
9605 | if(tok!=tk_closebracket&&tok!=tk_semicolon){ |
9600 | nn1: |
9606 | nn1: |
9601 | switch(returntype){ |
9607 | switch(returntype){ |
9602 | case tk_int: sign=1; |
9608 | case tk_int: sign=1; |
9603 | case tk_word: do_e_axmath(sign,r16,&ofsstr); break; |
9609 | case tk_word: do_e_axmath(sign,r16,&ofsstr); break; |
9604 | case tk_char: sign=1; |
9610 | case tk_char: sign=1; |
9605 | case tk_byte: doalmath(sign,&ofsstr); break; |
9611 | case tk_byte: doalmath(sign,&ofsstr); break; |
9606 | case tk_long: sign=1; |
9612 | case tk_long: sign=1; |
9607 | case tk_dword: do_e_axmath(sign,r32,&ofsstr); break; |
9613 | case tk_dword: do_e_axmath(sign,r32,&ofsstr); break; |
9608 | case tk_qword: |
9614 | case tk_qword: |
9609 | getintoreg64(EAX|(EDX*256)); |
9615 | getintoreg64(EAX|(EDX*256)); |
9610 | if(itok.type!=tp_stopper&&tok!=tk_eof&&itok.type!=tp_compare)doregmath64(EAX|(EDX*256)); |
9616 | if(itok.type!=tp_stopper&&tok!=tk_eof&&itok.type!=tp_compare)doregmath64(EAX|(EDX*256)); |
9611 | break; |
9617 | break; |
9612 | case tk_void: retvoid(); nexttok(); break; |
9618 | case tk_void: retvoid(); nexttok(); break; |
9613 | case tk_double: |
9619 | case tk_double: |
9614 | /* if(tok2==tk_closebracket)doregmath64(EAX|(EDX*256)); |
9620 | /* if(tok2==tk_closebracket)doregmath64(EAX|(EDX*256)); |
9615 | else doeaxfloatmath(tk_reg64); |
9621 | else doeaxfloatmath(tk_reg64); |
9616 | break;*/ |
9622 | break;*/ |
9617 | case tk_fpust: |
9623 | case tk_fpust: |
9618 | doeaxfloatmath(tk_fpust); |
9624 | doeaxfloatmath(tk_fpust); |
9619 | break; |
9625 | break; |
9620 | case tk_float: |
9626 | case tk_float: |
9621 | if(itok2.type==tp_stopper&&(tok==tk_floatvar||tok==tk_number)){ |
9627 | if(itok2.type==tp_stopper&&(tok==tk_floatvar||tok==tk_number)){ |
9622 | if(tok==tk_floatvar){ |
9628 | if(tok==tk_floatvar){ |
9623 | tok=tk_dwordvar; |
9629 | tok=tk_dwordvar; |
9624 | do_e_axmath(0,r32,&ofsstr); |
9630 | do_e_axmath(0,r32,&ofsstr); |
9625 | } |
9631 | } |
9626 | else doeaxfloatmath(tk_reg32,0,0); |
9632 | else doeaxfloatmath(tk_reg32,0,0); |
9627 | } |
9633 | } |
9628 | else{ |
9634 | else{ |
9629 | doeaxfloatmath(tk_stackstart,0,0); |
9635 | doeaxfloatmath(tk_stackstart,0,0); |
9630 | op66(r32); |
9636 | op66(r32); |
9631 | op(0x58); //pop eax |
9637 | op(0x58); //pop eax |
9632 | } |
9638 | } |
9633 | break; |
9639 | break; |
9634 | // default: |
9640 | // default: |
9635 | // printf("returntype=%d\n",returntype); |
9641 | // printf("returntype=%d\n",returntype); |
9636 | } |
9642 | } |
9637 | } |
9643 | } |
9638 | if(tok==tk_closebracket)nexttok(); |
9644 | if(tok==tk_closebracket)nexttok(); |
9639 | seminext(); |
9645 | seminext(); |
9640 | if(ofsstr)free(ofsstr); |
9646 | if(ofsstr)free(ofsstr); |
9641 | clearregstat(); |
9647 | clearregstat(); |
9642 | #ifdef OPTVARCONST |
9648 | #ifdef OPTVARCONST |
9643 | ClearLVIC(); |
9649 | ClearLVIC(); |
9644 | #endif |
9650 | #endif |
9645 | if(typer!=tokens){ |
9651 | if(typer!=tokens){ |
9646 | i=(am32==0?2:4); |
9652 | i=(am32==0?2:4); |
9647 | if(typer==tk_RETURN)i=1; |
9653 | if(typer==tk_RETURN)i=1; |
9648 | if(paramsize||localsize)i--; |
9654 | if(paramsize||localsize)i--; |
9649 | if(insertmode||((!optimizespeed)&¶msize&& |
9655 | if(insertmode||((!optimizespeed)&¶msize&& |
9650 | (current_proc_type&f_typeproc)!=tp_cdecl)||psavereg->size>i){ |
9656 | (current_proc_type&f_typeproc)!=tp_cdecl)||psavereg->size>i){ |
9651 | if(numblocks>1){ //çàìåíèòü return íà goto |
9657 | if(numblocks>1){ //çàìåíèòü return íà goto |
9652 | AddRetList(outptr+1,line,typer); |
9658 | AddRetList(outptr+1,line,typer); |
9653 | retproc=TRUE; |
9659 | retproc=TRUE; |
9654 | return; |
9660 | return; |
9655 | } |
9661 | } |
9656 | else{ |
9662 | else{ |
9657 | setreturn(); |
9663 | setreturn(); |
9658 | if(insertmode)return; |
9664 | if(insertmode)return; |
9659 | } |
9665 | } |
9660 | } |
9666 | } |
9661 | } |
9667 | } |
9662 | if(numblocks==1)setreturn(); //06.09.04 22:20 |
9668 | if(numblocks==1)setreturn(); //06.09.04 22:20 |
9663 | if(!inlineflag)leaveproc(); |
9669 | if(!inlineflag)leaveproc(); |
9664 | else{ |
9670 | else{ |
9665 | AutoDestructor(); |
9671 | AutoDestructor(); |
9666 | RestoreStack(); |
9672 | RestoreStack(); |
9667 | RestoreSaveReg(); |
9673 | RestoreSaveReg(); |
9668 | RetProc(); |
9674 | RetProc(); |
9669 | } |
9675 | } |
9670 | retproc=TRUE; |
9676 | retproc=TRUE; |
9671 | if(numblocks>1||(numblocks==1&&tok!=tk_closebrace))addESP=oaddESP; |
9677 | if(numblocks>1||(numblocks==1&&tok!=tk_closebrace))addESP=oaddESP; |
9672 | } |
9678 | } |
9673 | 9679 | ||
9674 | int IsSaveReg() |
9680 | int IsSaveReg() |
9675 | { |
9681 | { |
9676 | if(psavereg->all)return TRUE; |
9682 | if(psavereg->all)return TRUE; |
9677 | for(int i=7;i>=0;i--){ |
9683 | for(int i=7;i>=0;i--){ |
9678 | if(psavereg->reg[i])return TRUE; |
9684 | if(psavereg->reg[i])return TRUE; |
9679 | } |
9685 | } |
9680 | return FALSE; |
9686 | return FALSE; |
9681 | } |
9687 | } |
9682 | 9688 | ||
9683 | void leaveproc() |
9689 | void leaveproc() |
9684 | { |
9690 | { |
9685 | AutoDestructor(); |
9691 | AutoDestructor(); |
9686 | RestoreStack(); |
9692 | RestoreStack(); |
9687 | RestoreSaveReg(); |
9693 | RestoreSaveReg(); |
9688 | if(ESPloc==FALSE||am32==FALSE){ |
9694 | if(ESPloc==FALSE||am32==FALSE){ |
9689 | if(localsize)Leave(); |
9695 | if(localsize)Leave(); |
9690 | else if(paramsize)op(0x5D); /* POP BP */ |
9696 | else if(paramsize)op(0x5D); /* POP BP */ |
9691 | else if(initBP)Leave(); |
9697 | else if(initBP)Leave(); |
9692 | } |
9698 | } |
9693 | else if(localsize){ |
9699 | else if(localsize){ |
9694 | if(short_ok(localsize,TRUE)){ |
9700 | if(short_ok(localsize,TRUE)){ |
9695 | outword(0xC483); |
9701 | outword(0xC483); |
9696 | op(localsize); |
9702 | op(localsize); |
9697 | } |
9703 | } |
9698 | else{ |
9704 | else{ |
9699 | outword(0xC481); |
9705 | outword(0xC481); |
9700 | outdword(localsize); |
9706 | outdword(localsize); |
9701 | } |
9707 | } |
9702 | } |
9708 | } |
9703 | RetProc(); |
9709 | RetProc(); |
9704 | } |
9710 | } |
9705 | 9711 | ||
9706 | DLLLIST *FindDLL() |
9712 | DLLLIST *FindDLL() |
9707 | { |
9713 | { |
9708 | DLLLIST *newdll; |
9714 | DLLLIST *newdll; |
9709 | if(listdll!=NULL){ //ñïèñîê DLL íå ïóñò |
9715 | if(listdll!=NULL){ //ñïèñîê DLL íå ïóñò |
9710 | for(newdll=listdll;stricmp(newdll->name,(char *)string)!=0;newdll=newdll->next){ |
9716 | for(newdll=listdll;stricmp(newdll->name,(char *)string)!=0;newdll=newdll->next){ |
9711 | if(newdll->next==NULL){ //ïîñëåäíÿÿ â ñïèñêå |
9717 | if(newdll->next==NULL){ //ïîñëåäíÿÿ â ñïèñêå |
9712 | newdll->next=(DLLLIST *)MALLOC(sizeof(DLLLIST));//ñîçäàòü íîâóþ |
9718 | newdll->next=(DLLLIST *)MALLOC(sizeof(DLLLIST));//ñîçäàòü íîâóþ |
9713 | newdll=newdll->next; |
9719 | newdll=newdll->next; |
9714 | newdll->next=NULL; |
9720 | newdll->next=NULL; |
9715 | newdll->num=0; |
9721 | newdll->num=0; |
9716 | newdll->list=NULL; |
9722 | newdll->list=NULL; |
9717 | strcpy(newdll->name,(char *)string); |
9723 | strcpy(newdll->name,(char *)string); |
9718 | break; |
9724 | break; |
9719 | } |
9725 | } |
9720 | } |
9726 | } |
9721 | } |
9727 | } |
9722 | else{ |
9728 | else{ |
9723 | listdll=newdll=(DLLLIST *)MALLOC(sizeof(DLLLIST)); |
9729 | listdll=newdll=(DLLLIST *)MALLOC(sizeof(DLLLIST)); |
9724 | newdll->next=NULL; |
9730 | newdll->next=NULL; |
9725 | newdll->num=0; |
9731 | newdll->num=0; |
9726 | newdll->list=NULL; |
9732 | newdll->list=NULL; |
9727 | strcpy(newdll->name,(char *)string); |
9733 | strcpy(newdll->name,(char *)string); |
9728 | } |
9734 | } |
9729 | return newdll; |
9735 | return newdll; |
9730 | } |
9736 | } |
9731 | 9737 | ||
9732 | void declareextern() |
9738 | void declareextern() |
9733 | { |
9739 | { |
9734 | int next; |
9740 | int next; |
9735 | nexttok(); |
9741 | nexttok(); |
9736 | if(comfile==file_w32&&strcmp(itok.name,"WINAPI")==0){ |
9742 | if(comfile==file_w32&&strcmp(itok.name,"WINAPI")==0){ |
9737 | nexttok(); |
9743 | nexttok(); |
9738 | if(tok!=tk_string)stringexpected(); |
9744 | if(tok!=tk_string)stringexpected(); |
9739 | DLLLIST *newdll; |
9745 | DLLLIST *newdll; |
9740 | newdll=FindDLL(); |
9746 | newdll=FindDLL(); |
9741 | nextexpecting2(tk_openbrace); //îòêðûòèå ñïèñêà ïðîöåäóð |
9747 | nextexpecting2(tk_openbrace); //îòêðûòèå ñïèñêà ïðîöåäóð |
9742 | APIPROC *listapi=newdll->list; |
9748 | APIPROC *listapi=newdll->list; |
9743 | returntype=tk_declare; |
9749 | returntype=tk_declare; |
9744 | do{ |
9750 | do{ |
9745 | if(tok==tk_enum)doenum(); |
9751 | if(tok==tk_enum)doenum(); |
9746 | else if(tok==tk_struct)InitStruct(); |
9752 | else if(tok==tk_struct)InitStruct(); |
9747 | else{ |
9753 | else{ |
9748 | next=TRUE; |
9754 | next=TRUE; |
9749 | if(testInitVar(FALSE)!=FALSE)preerror("Error declare WINAPI"); |
9755 | if(testInitVar(FALSE)!=FALSE)preerror("Error declare WINAPI"); |
9750 | if(itok.rm==tokens)itok.rm=tk_dword; |
9756 | if(itok.rm==tokens)itok.rm=tk_dword; |
9751 | if(itok.npointr)itok.rm=(am32==TRUE?tk_dword:tk_word); |
9757 | if(itok.npointr)itok.rm=(am32==TRUE?tk_dword:tk_word); |
9752 | ITOK hitok=itok; |
9758 | ITOK hitok=itok; |
9753 | int htok=tok; |
9759 | int htok=tok; |
9754 | param[0]=0; |
9760 | param[0]=0; |
9755 | hitok.sib=hitok.size=-1; |
9761 | hitok.sib=hitok.size=-1; |
9756 | if(tok2==tk_period){ |
9762 | if(tok2==tk_period){ |
9757 | nexttok(); |
9763 | nexttok(); |
9758 | if(tok2==tk_number){ |
9764 | if(tok2==tk_number){ |
9759 | nexttok(); |
9765 | nexttok(); |
9760 | hitok.sib=itok.number; |
9766 | hitok.sib=itok.number; |
9761 | } |
9767 | } |
9762 | } |
9768 | } |
9763 | if(tok2==tk_at){ |
9769 | if(tok2==tk_at){ |
9764 | nexttok(); |
9770 | nexttok(); |
9765 | if(tok2==tk_number){ |
9771 | if(tok2==tk_number){ |
9766 | nexttok(); |
9772 | nexttok(); |
9767 | hitok.size=itok.number; |
9773 | hitok.size=itok.number; |
9768 | } |
9774 | } |
9769 | } |
9775 | } |
9770 | else{ |
9776 | else{ |
9771 | nextexpecting2(tk_openbracket); |
9777 | nextexpecting2(tk_openbracket); |
9772 | if((hitok.flag&f_typeproc)==tp_fastcall)declareparamreg(); |
9778 | if((hitok.flag&f_typeproc)==tp_fastcall)declareparamreg(); |
9773 | else declareparamstack(); |
9779 | else declareparamstack(); |
9774 | } |
9780 | } |
9775 | if(htok==tk_id||htok==tk_ID){ |
9781 | if(htok==tk_id||htok==tk_ID){ |
9776 | tok=tk_apiproc; |
9782 | tok=tk_apiproc; |
9777 | itok=hitok; |
9783 | itok=hitok; |
9778 | itok.number=secondcallnum++; |
9784 | itok.number=secondcallnum++; |
9779 | itok.segm=NOT_DYNAMIC; |
9785 | itok.segm=NOT_DYNAMIC; |
9780 | itok.post=dEBX|dEDI|dESI; //05.09.04 01:36 |
9786 | itok.post=dEBX|dEDI|dESI; //05.09.04 01:36 |
9781 | strcpy((char *)string,param); |
9787 | strcpy((char *)string,param); |
9782 | itok.type=tp_ucnovn; |
9788 | itok.type=tp_ucnovn; |
9783 | if(newdll->num==0)listapi=(APIPROC *)MALLOC(sizeof(APIPROC)); //ïåðâàÿ â ñïèñêå |
9789 | if(newdll->num==0)listapi=(APIPROC *)MALLOC(sizeof(APIPROC)); //ïåðâàÿ â ñïèñêå |
9784 | else listapi=(APIPROC *)REALLOC(listapi,sizeof(APIPROC)*(newdll->num+1)); |
9790 | else listapi=(APIPROC *)REALLOC(listapi,sizeof(APIPROC)*(newdll->num+1)); |
9785 | (listapi+newdll->num)->recapi=addtotree(itok.name); |
9791 | (listapi+newdll->num)->recapi=addtotree(itok.name); |
9786 | if(tok2==tk_openbracket){ |
9792 | if(tok2==tk_openbracket){ |
9787 | next=0; |
9793 | next=0; |
9788 | nexttok(); |
9794 | nexttok(); |
9789 | IsUses((listapi+newdll->num)->recapi); |
9795 | IsUses((listapi+newdll->num)->recapi); |
9790 | } |
9796 | } |
9791 | newdll->num++; |
9797 | newdll->num++; |
9792 | } |
9798 | } |
9793 | else warningdefined(hitok.name); |
9799 | else warningdefined(hitok.name); |
9794 | if(next)nexttok(); |
9800 | if(next)nexttok(); |
9795 | seminext(); |
9801 | seminext(); |
9796 | } |
9802 | } |
9797 | }while(tok!=tk_closebrace); |
9803 | }while(tok!=tk_closebrace); |
9798 | returntype=tokens; |
9804 | returntype=tokens; |
9799 | newdll->list=listapi; |
9805 | newdll->list=listapi; |
9800 | nexttok(); |
9806 | nexttok(); |
9801 | } |
9807 | } |
9802 | else{ |
9808 | else{ |
9803 | itok.flag=f_extern; |
9809 | itok.flag=f_extern; |
9804 | switch(tok){ |
9810 | switch(tok){ |
9805 | case tk_far: |
9811 | case tk_far: |
9806 | case tk_cdecl: |
9812 | case tk_cdecl: |
9807 | case tk_pascal: |
9813 | case tk_pascal: |
9808 | case tk_stdcall: |
9814 | case tk_stdcall: |
9809 | case tk_fastcall: |
9815 | case tk_fastcall: |
9810 | case tk_declare: |
9816 | case tk_declare: |
9811 | case tk_undefproc: |
9817 | case tk_undefproc: |
9812 | case tk_ID: |
9818 | case tk_ID: |
9813 | case tk_id: |
9819 | case tk_id: |
9814 | case tk_float: |
9820 | case tk_float: |
9815 | case tk_long: |
9821 | case tk_long: |
9816 | case tk_dword: |
9822 | case tk_dword: |
9817 | case tk_word: |
9823 | case tk_word: |
9818 | case tk_byte: |
9824 | case tk_byte: |
9819 | case tk_char: |
9825 | case tk_char: |
9820 | case tk_int: |
9826 | case tk_int: |
9821 | case tk_void: |
9827 | case tk_void: |
9822 | int j; |
9828 | int j; |
9823 | if((j=testInitVar())==FALSE)define_procedure(); |
9829 | if((j=testInitVar())==FALSE)define_procedure(); |
9824 | else if(j==TRUE)globalvar(); |
9830 | else if(j==TRUE)globalvar(); |
9825 | break; |
9831 | break; |
9826 | case tk_struct: InitStruct(); break; |
9832 | case tk_struct: InitStruct(); break; |
9827 | default: preerror("Error declare extern"); |
9833 | default: preerror("Error declare extern"); |
9828 | } |
9834 | } |
9829 | if((!fobj)&&(!sobj))preerror("extern using only for compilation obj files"); |
9835 | if((!fobj)&&(!sobj))preerror("extern using only for compilation obj files"); |
9830 | } |
9836 | } |
9831 | } |
9837 | } |
9832 | 9838 | ||
9833 | int testInitVar(int checkaldef) |
9839 | int testInitVar(int checkaldef) |
9834 | { |
9840 | { |
9835 | unsigned int ffar=0; |
9841 | unsigned int ffar=0; |
9836 | unsigned int fexport=0; |
9842 | unsigned int fexport=0; |
9837 | unsigned int tproc=0; |
9843 | unsigned int tproc=0; |
9838 | unsigned int fretproc=0; |
9844 | unsigned int fretproc=0; |
9839 | int rettype=tokens; |
9845 | int rettype=tokens; |
9840 | unsigned int flag=itok.flag; |
9846 | unsigned int flag=itok.flag; |
9841 | unsigned int npointr=0; |
9847 | unsigned int npointr=0; |
9842 | if(fstatic){ |
9848 | if(fstatic){ |
9843 | flag|=f_static; |
9849 | flag|=f_static; |
9844 | fstatic=FALSE; |
9850 | fstatic=FALSE; |
9845 | } |
9851 | } |
9846 | if(tok==tk_inline){ |
9852 | if(tok==tk_inline){ |
9847 | flag=f_inline; |
9853 | flag=f_inline; |
9848 | nexttok(); |
9854 | nexttok(); |
9849 | } |
9855 | } |
9850 | for(;;){ |
9856 | for(;;){ |
9851 | if(tok==tk_far)ffar=f_far; |
9857 | if(tok==tk_far)ffar=f_far; |
9852 | else if(tok==tk_export)fexport=f_export; |
9858 | else if(tok==tk_export)fexport=f_export; |
9853 | else if(tok>=tk_pascal&&tok<=tk_fastcall)tproc=tok; |
9859 | else if(tok>=tk_pascal&&tok<=tk_fastcall)tproc=tok; |
9854 | else if((tok>=tk_void&&tok<=tk_double)||tok==tk_fpust){ |
9860 | else if((tok>=tk_void&&tok<=tk_double)||tok==tk_fpust){ |
9855 | if(rettype!=tokens)unknowntype(); |
9861 | if(rettype!=tokens)unknowntype(); |
9856 | rettype=tok; |
9862 | rettype=tok; |
9857 | } |
9863 | } |
9858 | else if(tok==tk_id){ |
9864 | else if(tok==tk_id){ |
9859 | if(CheckDef())continue; |
9865 | if(CheckDef())continue; |
9860 | if(tok2==tk_dblcolon)goto classdecl; |
9866 | if(tok2==tk_dblcolon)goto classdecl; |
9861 | if(tproc==0)tproc=(comfile==file_w32?tp_stdcall:tp_pascal); //òèï ïðîö ïî óìîë÷àíèþ |
9867 | if(tproc==0)tproc=(comfile==file_w32?tp_stdcall:tp_pascal); //òèï ïðîö ïî óìîë÷àíèþ |
9862 | else tproc=(tproc-tk_pascal)*2; |
9868 | else tproc=(tproc-tk_pascal)*2; |
9863 | break; |
9869 | break; |
9864 | } |
9870 | } |
9865 | else if(tok==tk_ID){ |
9871 | else if(tok==tk_ID){ |
9866 | if(CheckDef())continue; |
9872 | if(CheckDef())continue; |
9867 | if(tok2==tk_dblcolon){ |
9873 | if(tok2==tk_dblcolon){ |
9868 | classdecl: |
9874 | classdecl: |
9869 | itok.flag=(unsigned int)(flag|ffar|fexport|fretproc|f_classproc); |
9875 | itok.flag=(unsigned int)(flag|ffar|fexport|fretproc|f_classproc); |
9870 | itok.rm=rettype; |
9876 | itok.rm=rettype; |
9871 | itok.npointr=(unsigned short)npointr; |
9877 | itok.npointr=(unsigned short)npointr; |
9872 | doclassproc(tproc); |
9878 | doclassproc(tproc); |
9873 | return 2; |
9879 | return 2; |
9874 | } |
9880 | } |
9875 | if(tproc==0)tproc=tp_fastcall; //òèï ïðîö ïî óìîë÷àíèþ |
9881 | if(tproc==0)tproc=tp_fastcall; //òèï ïðîö ïî óìîë÷àíèþ |
9876 | else tproc=(tproc-tk_pascal)*2; |
9882 | else tproc=(tproc-tk_pascal)*2; |
9877 | break; |
9883 | break; |
9878 | } |
9884 | } |
9879 | else if(tok==tk_undefproc||tok==tk_declare/*||tok==tk_apiproc*/){ |
9885 | else if(tok==tk_undefproc||tok==tk_declare/*||tok==tk_apiproc*/){ |
9880 | 9886 | ||
9881 | flag|=itok.flag; //new 18.04.07 12:19 |
9887 | flag|=itok.flag; //new 18.04.07 12:19 |
9882 | 9888 | ||
9883 | if(tproc==0){ |
9889 | if(tproc==0){ |
9884 | if(CidOrID()==tk_ID)tproc=tp_fastcall; |
9890 | if(CidOrID()==tk_ID)tproc=tp_fastcall; |
9885 | else tproc=(comfile==file_w32?tp_stdcall:tp_pascal); |
9891 | else tproc=(comfile==file_w32?tp_stdcall:tp_pascal); |
9886 | } |
9892 | } |
9887 | else tproc=(tproc-tk_pascal)*2; // 17.09.05 17:06 |
9893 | else tproc=(tproc-tk_pascal)*2; // 17.09.05 17:06 |
9888 | if((flag&f_extern)!=0||tproc!=(itok.flag&f_typeproc)|| |
9894 | if((flag&f_extern)!=0||tproc!=(itok.flag&f_typeproc)|| |
9889 | ffar!=(itok.flag&f_far)||(unsigned short)npointr!=itok.npointr|| |
9895 | ffar!=(itok.flag&f_far)||(unsigned short)npointr!=itok.npointr|| |
9890 | ((flag&f_static)&&(itok.flag&f_static)==0)){ |
9896 | ((flag&f_static)&&(itok.flag&f_static)==0)){ |
9891 | if(strcmp(itok.name,"main")){ |
9897 | if(strcmp(itok.name,"main")){ |
9892 | if(rettype==itok.rm||(rettype==tokens&&(itok.rm==(am32==0?tk_word:tk_dword))))break; |
9898 | if(rettype==itok.rm||(rettype==tokens&&(itok.rm==(am32==0?tk_word:tk_dword))))break; |
9893 | // printf("rm=%d rmnew=%d\n",itok.rm,rettype); |
9899 | // printf("rm=%d rmnew=%d\n",itok.rm,rettype); |
9894 | if(checkaldef)redeclare(itok.name); |
9900 | if(checkaldef)redeclare(itok.name); |
9895 | } |
9901 | } |
9896 | } |
9902 | } |
9897 | break; |
9903 | break; |
9898 | } |
9904 | } |
9899 | else if(tok==tk_proc||tok==tk_apiproc){ |
9905 | else if(tok==tk_proc||tok==tk_apiproc){ |
9900 | if(checkaldef)idalreadydefined(); |
9906 | if(checkaldef)idalreadydefined(); |
9901 | break; |
9907 | break; |
9902 | } |
9908 | } |
9903 | else if((tok>=tk_bits&&tok<=tk_doublevar)||tok==tk_structvar||tok==tk_pointer){ |
9909 | else if((tok>=tk_bits&&tok<=tk_doublevar)||tok==tk_structvar||tok==tk_pointer){ |
9904 | idalreadydefined(); |
9910 | idalreadydefined(); |
9905 | return 2; |
9911 | return 2; |
9906 | } |
9912 | } |
9907 | else if(tok==tk_mult){ |
9913 | else if(tok==tk_mult){ |
9908 | do{ |
9914 | do{ |
9909 | npointr++; |
9915 | npointr++; |
9910 | nexttok(); |
9916 | nexttok(); |
9911 | }while(tok==tk_mult); |
9917 | }while(tok==tk_mult); |
9912 | if(rettype==tokens)rettype=am32==FALSE?tk_word:tk_dword; |
9918 | if(rettype==tokens)rettype=am32==FALSE?tk_word:tk_dword; |
9913 | continue; |
9919 | continue; |
9914 | } |
9920 | } |
9915 | else if(tok==tk_openbracket){ |
9921 | else if(tok==tk_openbracket){ |
9916 | if(tok2!=tk_mult){ |
9922 | if(tok2!=tk_mult){ |
9917 | unuseableinput(); |
9923 | unuseableinput(); |
9918 | return 2; |
9924 | return 2; |
9919 | } |
9925 | } |
9920 | if(tproc!=0)tproc=(tproc-tk_pascal)*2; |
9926 | if(tproc!=0)tproc=(tproc-tk_pascal)*2; |
9921 | itok.flag=(unsigned int)(flag|ffar|tproc|fexport|fretproc); |
9927 | itok.flag=(unsigned int)(flag|ffar|tproc|fexport|fretproc); |
9922 | itok.rm=rettype; |
9928 | itok.rm=rettype; |
9923 | itok.npointr=(unsigned short)npointr; |
9929 | itok.npointr=(unsigned short)npointr; |
9924 | return TRUE; |
9930 | return TRUE; |
9925 | } |
9931 | } |
9926 | else if((tok>=tk_overflowflag&&tok<=tk_notzeroflag)||tok==tk_minusflag|| |
9932 | else if((tok>=tk_overflowflag&&tok<=tk_notzeroflag)||tok==tk_minusflag|| |
9927 | tok==tk_plusflag)fretproc=(tok-tk_overflowflag+1)*256; |
9933 | tok==tk_plusflag)fretproc=(tok-tk_overflowflag+1)*256; |
9928 | else if(tok==tk_static)flag|=f_static; |
9934 | else if(tok==tk_static)flag|=f_static; |
9929 | else if(tok==tk_fpust)rettype=tk_fpust; |
9935 | else if(tok==tk_fpust)rettype=tk_fpust; |
9930 | else{ |
9936 | else{ |
9931 | unuseableinput(); |
9937 | unuseableinput(); |
9932 | return 2; |
9938 | return 2; |
9933 | } |
9939 | } |
9934 | nexttok(); |
9940 | nexttok(); |
9935 | } |
9941 | } |
9936 | itok.flag=(unsigned int)(flag|ffar|tproc|fexport|fretproc); |
9942 | itok.flag=(unsigned int)(flag|ffar|tproc|fexport|fretproc); |
9937 | itok.rm=rettype; |
9943 | itok.rm=rettype; |
9938 | itok.npointr=(unsigned short)npointr; |
9944 | itok.npointr=(unsigned short)npointr; |
9939 | if(returntype==tk_declare&& |
9945 | if(returntype==tk_declare&& |
9940 | (tok2==tk_openbracket||tok2==tk_at||tok2==tk_period))return FALSE; |
9946 | (tok2==tk_openbracket||tok2==tk_at||tok2==tk_period))return FALSE; |
9941 | if(tok2==tk_openbracket)return CheckDeclareProc(); |
9947 | if(tok2==tk_openbracket)return CheckDeclareProc(); |
9942 | if(rettype==tokens){ |
9948 | if(rettype==tokens){ |
9943 | thisundefined(itok.name);//02.09.04 20:55 was unuseableinput(); |
9949 | thisundefined(itok.name);//02.09.04 20:55 was unuseableinput(); |
9944 | return 2; |
9950 | return 2; |
9945 | } |
9951 | } |
9946 | return TRUE; |
9952 | return TRUE; |
9947 | /*-----------------23.12.01 02:11------------------- |
9953 | /*-----------------23.12.01 02:11------------------- |
9948 | rerurn: |
9954 | rerurn: |
9949 | FALSE - åñëè îïðåäåëåíèå, âñòàâêà ïðîöåäóðû |
9955 | FALSE - åñëè îïðåäåëåíèå, âñòàâêà ïðîöåäóðû |
9950 | TRUE - ïåðåìåííàÿ èëè îáúÿâëåíèå ïðîöåäóðû |
9956 | TRUE - ïåðåìåííàÿ èëè îáúÿâëåíèå ïðîöåäóðû |
9951 | 2 - îøèáêà èëè îáðàáîòàíî - íèêàêèõ äåéñòâèé íå ïðåäïðèíèìàòü. |
9957 | 2 - îøèáêà èëè îáðàáîòàíî - íèêàêèõ äåéñòâèé íå ïðåäïðèíèìàòü. |
9952 | --------------------------------------------------*/ |
9958 | --------------------------------------------------*/ |
9953 | } |
9959 | } |
9954 | 9960 | ||
9955 | int CidOrID() |
9961 | int CidOrID() |
9956 | { |
9962 | { |
9957 | unsigned char cha; |
9963 | unsigned char cha; |
9958 | unsigned char *string4=(unsigned char *)itok.name; |
9964 | unsigned char *string4=(unsigned char *)itok.name; |
9959 | for(;;){ |
9965 | for(;;){ |
9960 | cha=*string4; |
9966 | cha=*string4; |
9961 | if(cha>='a'&&cha<='z')return tk_id; |
9967 | if(cha>='a'&&cha<='z')return tk_id; |
9962 | if(cha==0)break; |
9968 | if(cha==0)break; |
9963 | string4++; |
9969 | string4++; |
9964 | } |
9970 | } |
9965 | return tk_ID; |
9971 | return tk_ID; |
9966 | } |
9972 | } |
9967 | 9973 | ||
9968 | void unpackteg(structteg *tteg) |
9974 | void unpackteg(structteg *tteg) |
9969 | { |
9975 | { |
9970 | int i; |
9976 | int i; |
9971 | elementteg *bazael; |
9977 | elementteg *bazael; |
9972 | structteg *newteg; |
9978 | structteg *newteg; |
9973 | int ssize,count; |
9979 | int ssize,count; |
9974 | idrec *newrec,*ptr; |
9980 | idrec *newrec,*ptr; |
9975 | if(alignword){ //âûðîâíÿòü íà ÷åòíûé àäðåñ |
9981 | if(alignword){ //âûðîâíÿòü íà ÷åòíûé àäðåñ |
9976 | if(am32==0){ |
9982 | if(am32==0){ |
9977 | if(postsize%2==1)postsize++; |
9983 | if(postsize%2==1)postsize++; |
9978 | } |
9984 | } |
9979 | else if(ssize==4&&postsize%4!=0)postsize+=4-(postsize%4); |
9985 | else if(ssize==4&&postsize%4!=0)postsize+=4-(postsize%4); |
9980 | } |
9986 | } |
9981 | bazael=tteg->baza; |
9987 | bazael=tteg->baza; |
9982 | string[0]=0; |
9988 | string[0]=0; |
9983 | for(i=0;i |
9989 | for(i=0;i |
9984 | // printf("tok=%d %s\n",(bazael+i)->tok,(bazael+i)->name); |
9990 | // printf("tok=%d %s\n",(bazael+i)->tok,(bazael+i)->name); |
9985 | switch((bazael+i)->tok){ |
9991 | switch((bazael+i)->tok){ |
9986 | case tk_floatvar: |
9992 | case tk_floatvar: |
9987 | case tk_longvar: |
9993 | case tk_longvar: |
9988 | case tk_dwordvar: |
9994 | case tk_dwordvar: |
9989 | case tk_wordvar: |
9995 | case tk_wordvar: |
9990 | case tk_bytevar: |
9996 | case tk_bytevar: |
9991 | case tk_charvar: |
9997 | case tk_charvar: |
9992 | case tk_intvar: |
9998 | case tk_intvar: |
9993 | case tk_doublevar: |
9999 | case tk_doublevar: |
9994 | case tk_qwordvar: |
10000 | case tk_qwordvar: |
9995 | ssize=GetVarSize((bazael+i)->tok); //ðàçìåð ïåðåìåííîé |
10001 | ssize=GetVarSize((bazael+i)->tok); //ðàçìåð ïåðåìåííîé |
9996 | itok.type=tp_ucnovn; |
10002 | itok.type=tp_ucnovn; |
9997 | tok=(bazael+i)->tok; |
10003 | tok=(bazael+i)->tok; |
9998 | count=FindOff((unsigned char *)(bazael+i)->name,VARPOST); |
10004 | count=FindOff((unsigned char *)(bazael+i)->name,VARPOST); |
9999 | itok.post=1; |
10005 | itok.post=1; |
10000 | itok.segm=DS; |
10006 | itok.segm=DS; |
10001 | itok.number=postsize; |
10007 | itok.number=postsize; |
10002 | itok.flag=tteg->flag; |
10008 | itok.flag=tteg->flag; |
10003 | itok.size=(bazael+i)->numel*ssize; |
10009 | itok.size=(bazael+i)->numel*ssize; |
10004 | itok.rm=(am32==FALSE?rm_d16:rm_d32); |
10010 | itok.rm=(am32==FALSE?rm_d16:rm_d32); |
10005 | itok.npointr=0; |
10011 | itok.npointr=0; |
10006 | newrec=addtotree((bazael+i)->name); |
10012 | newrec=addtotree((bazael+i)->name); |
10007 | newrec->count=count; |
10013 | newrec->count=count; |
10008 | break; |
10014 | break; |
10009 | case tk_struct: |
10015 | case tk_struct: |
10010 | case tk_structvar: |
10016 | case tk_structvar: |
10011 | strcpy(itok.name,(bazael+i)->name); |
10017 | strcpy(itok.name,(bazael+i)->name); |
10012 | newteg=(structteg *)(bazael+i)->nteg; |
10018 | newteg=(structteg *)(bazael+i)->nteg; |
10013 | newrec=(struct idrec *)MALLOC(sizeof(struct idrec)); |
10019 | newrec=(struct idrec *)MALLOC(sizeof(struct idrec)); |
10014 | ptr=((tteg->flag&f_static)==0?treestart:staticlist); //íà÷àëî äåðåâà |
10020 | ptr=((tteg->flag&f_static)==0?treestart:staticlist); //íà÷àëî äåðåâà |
10015 | if(ptr==NULL)((tteg->flag&f_static)==0?treestart:staticlist)=newrec;//íà÷àëî äåðåâà |
10021 | if(ptr==NULL)((tteg->flag&f_static)==0?treestart:staticlist)=newrec;//íà÷àëî äåðåâà |
10016 | else{ //ïîèñê ñòðîêè â äåðåâå |
10022 | else{ //ïîèñê ñòðîêè â äåðåâå |
10017 | while(((ssize=strcmp(ptr->recid,itok.name))<0&&ptr->left!=NULL)||(ssize>0&&ptr->right!=NULL)){ |
10023 | while(((ssize=strcmp(ptr->recid,itok.name))<0&&ptr->left!=NULL)||(ssize>0&&ptr->right!=NULL)){ |
10018 | ptr=(ssize<0?ptr->left:ptr->right); |
10024 | ptr=(ssize<0?ptr->left:ptr->right); |
10019 | } |
10025 | } |
10020 | (ssize<0?ptr->left:ptr->right)=newrec; //ñòðîêà ìåíüøå |
10026 | (ssize<0?ptr->left:ptr->right)=newrec; //ñòðîêà ìåíüøå |
10021 | } |
10027 | } |
10022 | newrec->recsib=0; |
10028 | newrec->recsib=0; |
10023 | strcpy(newrec->recid,itok.name);//ñêîïèð íàçâàíèå |
10029 | strcpy(newrec->recid,itok.name);//ñêîïèð íàçâàíèå |
10024 | newrec->newid=(char *)newteg; |
10030 | newrec->newid=(char *)newteg; |
10025 | newrec->left=NULL; |
10031 | newrec->left=NULL; |
10026 | newrec->right=NULL; |
10032 | newrec->right=NULL; |
10027 | newrec->rectok=tk_structvar; |
10033 | newrec->rectok=tk_structvar; |
10028 | newrec->flag=tteg->flag|newteg->flag; |
10034 | newrec->flag=tteg->flag|newteg->flag; |
10029 | newrec->line=linenumber; |
10035 | newrec->line=linenumber; |
10030 | newrec->file=currentfileinfo; |
10036 | newrec->file=currentfileinfo; |
10031 | if(FixUp)newrec->flag|=f_reloc; |
10037 | if(FixUp)newrec->flag|=f_reloc; |
10032 | newrec->recrm=(bazael+i)->numel; |
10038 | newrec->recrm=(bazael+i)->numel; |
10033 | newrec->recsize=(bazael+i)->numel*newteg->size; |
10039 | newrec->recsize=(bazael+i)->numel*newteg->size; |
10034 | newrec->recpost=1; |
10040 | newrec->recpost=1; |
10035 | count=FindOff((unsigned char *)newrec->recid,VARPOST); |
10041 | count=FindOff((unsigned char *)newrec->recid,VARPOST); |
10036 | newrec->count=count; |
10042 | newrec->count=count; |
10037 | break; |
10043 | break; |
10038 | default: |
10044 | default: |
10039 | declareanonim(); |
10045 | declareanonim(); |
10040 | break; |
10046 | break; |
10041 | } |
10047 | } |
10042 | } |
10048 | } |
10043 | AddPostData(tteg->size); |
10049 | AddPostData(tteg->size); |
10044 | } |
10050 | } |
10045 | 10051 | ||
10046 | void unpackteg2(structteg *tteg) |
10052 | void unpackteg2(structteg *tteg) |
10047 | { |
10053 | { |
10048 | int i; |
10054 | int i; |
10049 | elementteg *bazael; |
10055 | elementteg *bazael; |
10050 | structteg *newteg; |
10056 | structteg *newteg; |
10051 | //idrec *newrec,*trec; |
10057 | //idrec *newrec,*trec; |
10052 | localrec *lrec; |
10058 | localrec *lrec; |
10053 | bazael=tteg->baza; |
10059 | bazael=tteg->baza; |
10054 | string[0]=0; |
10060 | string[0]=0; |
10055 | for(i=0;i |
10061 | for(i=0;i |
10056 | switch((bazael+i)->tok){ |
10062 | switch((bazael+i)->tok){ |
10057 | case tk_floatvar: |
10063 | case tk_floatvar: |
10058 | case tk_longvar: |
10064 | case tk_longvar: |
10059 | case tk_dwordvar: |
10065 | case tk_dwordvar: |
10060 | case tk_wordvar: |
10066 | case tk_wordvar: |
10061 | case tk_bytevar: |
10067 | case tk_bytevar: |
10062 | case tk_charvar: |
10068 | case tk_charvar: |
10063 | case tk_intvar: |
10069 | case tk_intvar: |
10064 | case tk_doublevar: |
10070 | case tk_doublevar: |
10065 | case tk_qwordvar: |
10071 | case tk_qwordvar: |
10066 | lrec=addlocalvar((bazael+i)->name,(bazael+i)->tok,localsize); |
10072 | lrec=addlocalvar((bazael+i)->name,(bazael+i)->tok,localsize); |
10067 | lrec->rec.recsize=(bazael+i)->numel*GetVarSize((bazael+i)->tok); |
10073 | lrec->rec.recsize=(bazael+i)->numel*GetVarSize((bazael+i)->tok); |
10068 | lrec->rec.type=tp_localvar; |
10074 | lrec->rec.type=tp_localvar; |
10069 | lrec->rec.npointr=0; |
10075 | lrec->rec.npointr=0; |
10070 | lrec->rec.recnumber=-lrec->rec.recnumber-Align(lrec->rec.recsize,(am32==FALSE?2:4)); |
10076 | lrec->rec.recnumber=-lrec->rec.recnumber-Align(lrec->rec.recsize,(am32==FALSE?2:4)); |
10071 | break; |
10077 | break; |
10072 | case tk_struct: |
10078 | case tk_struct: |
10073 | case tk_structvar: |
10079 | case tk_structvar: |
10074 | newteg=(structteg *)(bazael+i)->nteg; |
10080 | newteg=(structteg *)(bazael+i)->nteg; |
10075 | lrec=addlocalvar((bazael+i)->name,tk_structvar,localsize); |
10081 | lrec=addlocalvar((bazael+i)->name,tk_structvar,localsize); |
10076 | lrec->rec.newid=(char *)tteg; |
10082 | lrec->rec.newid=(char *)tteg; |
10077 | lrec->rec.flag=tteg->flag; |
10083 | lrec->rec.flag=tteg->flag; |
10078 | lrec->rec.type=tp_localvar; |
10084 | lrec->rec.type=tp_localvar; |
10079 | lrec->rec.recrm=(bazael+i)->numel; |
10085 | lrec->rec.recrm=(bazael+i)->numel; |
10080 | lrec->rec.recsize=(bazael+i)->numel*newteg->size; |
10086 | lrec->rec.recsize=(bazael+i)->numel*newteg->size; |
10081 | lrec->rec.recpost=LOCAL; |
10087 | lrec->rec.recpost=LOCAL; |
10082 | lrec->rec.recnumber=-lrec->rec.recnumber-Align(lrec->rec.recsize,(am32==FALSE?2:4)); |
10088 | lrec->rec.recnumber=-lrec->rec.recnumber-Align(lrec->rec.recsize,(am32==FALSE?2:4)); |
10083 | break; |
10089 | break; |
10084 | default: |
10090 | default: |
10085 | declareanonim(); |
10091 | declareanonim(); |
10086 | break; |
10092 | break; |
10087 | } |
10093 | } |
10088 | } |
10094 | } |
10089 | localsize+=tteg->size; |
10095 | localsize+=tteg->size; |
10090 | localsize=Align(localsize,(am32==FALSE?2:4)); |
10096 | localsize=Align(localsize,(am32==FALSE?2:4)); |
10091 | } |
10097 | } |
10092 | 10098 | ||
10093 | unsigned long dounion(int Global,int flag) |
10099 | unsigned long dounion(int Global,int flag) |
10094 | { |
10100 | { |
10095 | structteg *tteg; |
10101 | structteg *tteg; |
10096 | int noname=FALSE; |
10102 | int noname=FALSE; |
10097 | nexttok(); |
10103 | nexttok(); |
10098 | if(tok==tk_openbrace)noname=TRUE; |
10104 | if(tok==tk_openbrace)noname=TRUE; |
10099 | else if((tok!=tk_id&&tok!=tk_ID)||FindTeg(Global)||(Global==FALSE&&FindTeg(TRUE))){ |
10105 | else if((tok!=tk_id&&tok!=tk_ID)||FindTeg(Global)||(Global==FALSE&&FindTeg(TRUE))){ |
10100 | idalreadydefined(); |
10106 | idalreadydefined(); |
10101 | SkipBlock2(); |
10107 | SkipBlock2(); |
10102 | return 0; |
10108 | return 0; |
10103 | } |
10109 | } |
10104 | if((tteg=CreatTeg(Global,TRUE,noname))!=NULL){ |
10110 | if((tteg=CreatTeg(Global,TRUE,noname))!=NULL){ |
10105 | if(tok==tk_semicolon){ |
10111 | if(tok==tk_semicolon){ |
10106 | if(noname==TRUE){ |
10112 | if(noname==TRUE){ |
10107 | if(Global)unpackteg(tteg); |
10113 | if(Global)unpackteg(tteg); |
10108 | else unpackteg2(tteg); |
10114 | else unpackteg2(tteg); |
10109 | if(tteg->baza)free(tteg->baza); |
10115 | if(tteg->baza)free(tteg->baza); |
10110 | free(tteg); |
10116 | free(tteg); |
10111 | } |
10117 | } |
10112 | nexttok(); |
10118 | nexttok(); |
10113 | } |
10119 | } |
10114 | else{ |
10120 | else{ |
10115 | if(Global)InitStruct2(flag,tteg); |
10121 | if(Global)InitStruct2(flag,tteg); |
10116 | else return LocalStruct2(flag,0,0,0,tteg); |
10122 | else return LocalStruct2(flag,0,0,0,tteg); |
10117 | } |
10123 | } |
10118 | } |
10124 | } |
10119 | else declareunion(); |
10125 | else declareunion(); |
10120 | return 0; |
10126 | return 0; |
10121 | } |
10127 | } |
10122 | 10128 | ||
10123 | char *BackString(char *str) |
10129 | char *BackString(char *str) |
10124 | { |
10130 | { |
10125 | char *retbuf=(char *)MALLOC(strlen(str)+1); |
10131 | char *retbuf=(char *)MALLOC(strlen(str)+1); |
10126 | strcpy(retbuf,str); |
10132 | strcpy(retbuf,str); |
10127 | return retbuf; |
10133 | return retbuf; |
10128 | } |
10134 | } |
10129 | 10135 | ||
10130 | 10136 | ||
10131 | void GetFileTime(int fd,struct ftime *buf) |
10137 | void GetFileTime(int fd,struct ftime *buf) |
10132 | { |
10138 | { |
10133 | /* |
10139 | /* |
10134 | struct stat sb; |
10140 | struct stat sb; |
10135 | struct tm *tblock; |
10141 | struct tm *tblock; |
10136 | fstat(fd,&sb); |
10142 | fstat(fd,&sb); |
10137 | tblock=localtime(&sb.st_atime); |
10143 | tblock=localtime(&sb.st_atime); |
10138 | buf->ft_tsec=tblock->tm_sec; |
10144 | buf->ft_tsec=tblock->tm_sec; |
10139 | buf->ft_min=tblock->tm_min; |
10145 | buf->ft_min=tblock->tm_min; |
10140 | buf->ft_hour=tblock->tm_hour; |
10146 | buf->ft_hour=tblock->tm_hour; |
10141 | buf->ft_day=tblock->tm_mday; |
10147 | buf->ft_day=tblock->tm_mday; |
10142 | buf->ft_month=tblock->tm_mon; |
10148 | buf->ft_month=tblock->tm_mon; |
10143 | buf->ft_year=tblock->tm_year-80;*/ |
10149 | buf->ft_year=tblock->tm_year-80;*/ |
10144 | } |
10150 | } |
10145 | 10151 | ||
10146 | void CheckPosts() |
10152 | void CheckPosts() |
10147 | { |
10153 | { |
10148 | if(posts==maxposts){ |
10154 | if(posts==maxposts){ |
10149 | maxposts+=MAXPOSTS; |
10155 | maxposts+=MAXPOSTS; |
10150 | postbuf=(postinfo *)REALLOC(postbuf,maxposts*sizeof(postinfo)); |
10156 | postbuf=(postinfo *)REALLOC(postbuf,maxposts*sizeof(postinfo)); |
10151 | } |
10157 | } |
10152 | } |
10158 | } |
10153 | 10159 | ||
10154 | void CheckRealizable() |
10160 | void CheckRealizable() |
10155 | { |
10161 | { |
10156 | switch(tok){ |
10162 | switch(tok){ |
10157 | case tk_case: |
10163 | case tk_case: |
10158 | case tk_CASE: |
10164 | case tk_CASE: |
10159 | case tk_default: |
10165 | case tk_default: |
10160 | case tk_closebrace: |
10166 | case tk_closebrace: |
10161 | return; |
10167 | return; |
10162 | } |
10168 | } |
10163 | if(tok2==tk_colon)return; |
10169 | if(tok2==tk_colon)return; |
10164 | if(notunreach){ |
10170 | if(notunreach){ |
10165 | notunreach=FALSE; |
10171 | notunreach=FALSE; |
10166 | return; |
10172 | return; |
10167 | } |
10173 | } |
10168 | warningunreach(); |
10174 | warningunreach(); |
10169 | // preerror("Unreachable code"); |
10175 | // preerror("Unreachable code"); |
10170 | } |
10176 | } |
10171 | 10177 | ||
10172 | void AddRegistr(int razr,int reg) |
10178 | void AddRegistr(int razr,int reg) |
10173 | { |
10179 | { |
10174 | if(razr==r8&®>3)reg-=4; |
10180 | if(razr==r8&®>3)reg-=4; |
10175 | if(razr==r64){ |
10181 | if(razr==r64){ |
10176 | stat_reg[reg&255]=1; |
10182 | stat_reg[reg&255]=1; |
10177 | stat_reg[reg/256]=1; |
10183 | stat_reg[reg/256]=1; |
10178 | } |
10184 | } |
10179 | else stat_reg[reg]=1; |
10185 | else stat_reg[reg]=1; |
10180 | } |
10186 | } |
10181 | 10187 | ||
10182 | void ClearRegister() |
10188 | void ClearRegister() |
10183 | { |
10189 | { |
10184 | for(int i=0;i<8;i++)stat_reg[i]=0; |
10190 | for(int i=0;i<8;i++)stat_reg[i]=0; |
10185 | } |
10191 | } |
10186 | 10192 | ||
10187 | int GetRegister(int mode) |
10193 | int GetRegister(int mode) |
10188 | { |
10194 | { |
10189 | int reg=SI; |
10195 | int reg=SI; |
10190 | if(am32!=FALSE||mode){ |
10196 | if(am32!=FALSE||mode){ |
10191 | if(stat_reg[AX]==0)reg=AX; |
10197 | if(stat_reg[AX]==0)reg=AX; |
10192 | else if(stat_reg[SI]==0)reg=SI; |
10198 | else if(stat_reg[SI]==0)reg=SI; |
10193 | else if(stat_reg[DI]==0)reg=DI; |
10199 | else if(stat_reg[DI]==0)reg=DI; |
10194 | else if(stat_reg[BX]==0)reg=BX; |
10200 | else if(stat_reg[BX]==0)reg=BX; |
10195 | else if(stat_reg[CX]==0)reg=CX; |
10201 | else if(stat_reg[CX]==0)reg=CX; |
10196 | else if(stat_reg[DX]==0)reg=DX; |
10202 | else if(stat_reg[DX]==0)reg=DX; |
10197 | } |
10203 | } |
10198 | else{ |
10204 | else{ |
10199 | if(stat_reg[SI]==0)reg=SI; |
10205 | if(stat_reg[SI]==0)reg=SI; |
10200 | else if(stat_reg[DI]==0)reg=DI; |
10206 | else if(stat_reg[DI]==0)reg=DI; |
10201 | else if(stat_reg[BX]==0)reg=BX; |
10207 | else if(stat_reg[BX]==0)reg=BX; |
10202 | } |
10208 | } |
10203 | return reg; |
10209 | return reg; |
10204 | } |
10210 | } |
10205 | 10211 | ||
10206 | void RegAddNum(int reg) |
10212 | void RegAddNum(int reg) |
10207 | { |
10213 | { |
10208 | if((!structadr.post)&&optnumadd(structadr.number,reg,am32==FALSE?r16:r32,0)!=FALSE)return; |
10214 | if((!structadr.post)&&optnumadd(structadr.number,reg,am32==FALSE?r16:r32,0)!=FALSE)return; |
10209 | if(reg==AX)op(5); |
10215 | if(reg==AX)op(5); |
10210 | else{ |
10216 | else{ |
10211 | op(0x81); |
10217 | op(0x81); |
10212 | op(0xC0+reg); |
10218 | op(0xC0+reg); |
10213 | } |
10219 | } |
10214 | if(structadr.post)setwordpost(&structadr); |
10220 | if(structadr.post)setwordpost(&structadr); |
10215 | if(am32)outdword(structadr.number); |
10221 | if(am32)outdword(structadr.number); |
10216 | else outword(structadr.number); |
10222 | else outword(structadr.number); |
10217 | } |
10223 | } |
10218 | 10224 | ||
10219 | void RestoreStack() |
10225 | void RestoreStack() |
10220 | { |
10226 | { |
10221 | if(addstack&&sizestack){ |
10227 | if(addstack&&sizestack){ |
10222 | if(short_ok(sizestack,am32)){ |
10228 | if(short_ok(sizestack,am32)){ |
10223 | outword(0xC483); |
10229 | outword(0xC483); |
10224 | op(sizestack); |
10230 | op(sizestack); |
10225 | } |
10231 | } |
10226 | else{ |
10232 | else{ |
10227 | outword(0xC481); |
10233 | outword(0xC481); |
10228 | if(am32==FALSE)outword(sizestack); |
10234 | if(am32==FALSE)outword(sizestack); |
10229 | else outdword(sizestack); |
10235 | else outdword(sizestack); |
10230 | } |
10236 | } |
10231 | // printf("%s(%d)> Restore %d bytes stacks.\n",startfileinfo==NULL?"":(startfileinfo+currentfileinfo)->filename,linenumber,sizestack); |
10237 | // printf("%s(%d)> Restore %d bytes stacks.\n",startfileinfo==NULL?"":(startfileinfo+currentfileinfo)->filename,linenumber,sizestack); |
10232 | addESP-=sizestack; |
10238 | addESP-=sizestack; |
10233 | sizestack=0; |
10239 | sizestack=0; |
10234 | } |
10240 | } |
10235 | } |
10241 | } |
10236 | 10242 | ||
10237 | void startblock() |
10243 | void startblock() |
10238 | { |
10244 | { |
10239 | treelocalrec *nrec; |
10245 | treelocalrec *nrec; |
10240 | numblocks++; |
10246 | numblocks++; |
10241 | // printf("start block %d\n",numblocks); |
10247 | // printf("start block %d\n",numblocks); |
10242 | nrec=(treelocalrec*)MALLOC(sizeof(treelocalrec)); |
10248 | nrec=(treelocalrec*)MALLOC(sizeof(treelocalrec)); |
10243 | nrec->level=numblocks; |
10249 | nrec->level=numblocks; |
10244 | nrec->lrec=NULL; |
10250 | nrec->lrec=NULL; |
10245 | nrec->addesp=addESP; |
10251 | nrec->addesp=addESP; |
10246 | nrec->next=tlr; |
10252 | nrec->next=tlr; |
10247 | tlr=nrec; |
10253 | tlr=nrec; |
10248 | } |
10254 | } |
10249 | 10255 | ||
10250 | void endblock() |
10256 | void endblock() |
10251 | { |
10257 | { |
10252 | treelocalrec *orec; |
10258 | treelocalrec *orec; |
10253 | // printf("end block %d\n",numblocks); |
10259 | // printf("end block %d\n",numblocks); |
10254 | orec=tlr; |
10260 | orec=tlr; |
10255 | tlr=tlr->next; |
10261 | tlr=tlr->next; |
10256 | if(tlr)numblocks=tlr->level; |
10262 | if(tlr)numblocks=tlr->level; |
10257 | else numblocks=0; |
10263 | else numblocks=0; |
10258 | if(orec->lrec==NULL){ |
10264 | if(orec->lrec==NULL){ |
10259 | free(orec); |
10265 | free(orec); |
10260 | return; |
10266 | return; |
10261 | } |
10267 | } |
10262 | orec->endline=linenumber; |
10268 | orec->endline=linenumber; |
10263 | orec->next=btlr; |
10269 | orec->next=btlr; |
10264 | btlr=orec; |
10270 | btlr=orec; |
10265 | // if(addESP!=orec->addesp)??? |
10271 | // if(addESP!=orec->addesp)??? |
10266 | } |
10272 | } |
10267 | /* end of TOKC.C */8;i++)stat_reg[i]=0; |
10273 | /* end of TOKC.C */8;i++)stat_reg[i]=0; |
10268 | } |
10274 | } |
10269 | 10275 | ||
10270 | int>0?ptr->0?ptr->0&&ptr->='z')return>=tk_notzeroflag)||tok==tk_minusflag|| |
10276 | int>0?ptr->0?ptr->0&&ptr->='z')return>=tk_notzeroflag)||tok==tk_minusflag|| |
10271 | >=tk_doublevar)||tok==tk_structvar||tok==tk_pointer){ |
10277 | >=tk_doublevar)||tok==tk_structvar||tok==tk_pointer){ |
10272 | >=tk_double)||tok==tk_fpust){ |
10278 | >=tk_double)||tok==tk_fpust){ |
10273 | >=tk_fastcall)tproc=tok; |
10279 | >=tk_fastcall)tproc=tok; |
10274 | >128/*&&i> |
10280 | >128/*&&i> |
10275 | //>3)cpu=3; |
10281 | //>3)cpu=3; |
10276 | >2;i++){ |
10282 | >2;i++){ |
10277 | >3)cpu=3; |
10283 | >3)cpu=3; |
10278 | >3)cpu=3; |
10284 | >3)cpu=3; |
10279 | > |
10285 | > |
10280 | > |
10286 | > |
10281 | > |
10287 | > |
10282 | //>0?ptr->0?ptr->0&&ptr-> |
10288 | //>0?ptr->0?ptr->0&&ptr-> |
10283 | > |
10289 | > |
10284 | >=outs.len){ |
10290 | >=outs.len){ |
10285 | char> |
10291 | char> |
10286 | >3)cpu=3; |
10292 | >3)cpu=3; |
10287 | >3)cpu=3; |
10293 | >3)cpu=3; |
10288 | >3)cpu=3; |
10294 | >3)cpu=3; |
10289 | >3)cpu=3; |
10295 | >3)cpu=3; |
10290 | >=startpos){ |
10296 | >=startpos){ |
10291 | >127){ |
10297 | >127){ |
10292 | >=CONTINUE_32){//32-BIT |
10298 | >=CONTINUE_32){//32-BIT |
10293 | >=CONTINUE_NEAR){>=CONTINUE_32)&& |
10299 | >=CONTINUE_NEAR){>=CONTINUE_32)&& |
10294 | > |
10300 | > |
10295 | >0)start=0; |
10301 | >0)start=0; |
10296 | >0)start=0; |
10302 | >0)start=0; |
10297 | >3)cpu=3; |
10303 | >3)cpu=3; |
10298 | >2;i++){ |
10304 | >2;i++){ |
10299 | >2;i++){ |
10305 | >2;i++){ |
10300 | >3)cpu=3; |
10306 | >3)cpu=3; |
10301 | > |
10307 | > |
10302 | #ifdef>2)cpu=2; |
10308 | #ifdef>2)cpu=2; |
10303 | >3)cpu=3; |
10309 | >3)cpu=3; |
10304 | >=GS)if(cpu<3)cpu=3; |
10310 | >=GS)if(cpu<3)cpu=3; |
10305 | > |
10311 | > |
10306 | > |
10312 | > |
10307 | #ifdef>3)cpu=3; |
10313 | #ifdef>3)cpu=3; |
10308 | >3)cpu=3; |
10314 | >3)cpu=3; |
10309 | >3)cpu=3; |
10315 | >3)cpu=3; |
10310 | >3)cpu=3; |
10316 | >3)cpu=3; |
10311 | >=tk_double)vartype=tok; |
10317 | >=tk_double)vartype=tok; |
10312 | >=tk_double){ |
10318 | >=tk_double){ |
10313 | >2)cpu=2; |
10319 | >2)cpu=2; |
10314 | >2||(optimizespeed&&(chip==5||chip==6))){ |
10320 | >2||(optimizespeed&&(chip==5||chip==6))){ |
10315 | >='7'){ |
10321 | >='7'){ |
10316 | >0)break; |
10322 | >0)break; |
10317 | >='7'){ |
10323 | >='7'){ |
10318 | >=numpar){ |
10324 | >=numpar){ |
10319 | > |
10325 | > |
10320 | > |
10326 | > |
10321 | >8;i++){ |
10327 | >8;i++){ |
10322 | >128){ |
10328 | >128){ |
10323 | > |
10329 | > |
10324 | //>128){ |
10330 | //>128){ |
10325 | >3&&(type*(am32+1)*2)>=0)break; |
10331 | >3&&(type*(am32+1)*2)>=0)break; |
10326 | > |
10332 | > |
10327 | //>=0&&optimizespeed==0&&chip>=0)break; |
10333 | //>=0&&optimizespeed==0&&chip>=0)break; |
10328 | >=tk_doublevar)||tok==tk_pointer||tok==tk_proc |
10334 | >=tk_doublevar)||tok==tk_pointer||tok==tk_proc |
10329 | >0)return; |
10335 | >0)return; |
10330 | >=tk_floatvar&&numpointr==0) |
10336 | >=tk_floatvar&&numpointr==0) |
10331 | >=tk_double){ |
10337 | >=tk_double){ |
10332 | >=tk_double){ |
10338 | >=tk_double){ |
10333 | >=tk_double){ |
10339 | >=tk_double){ |
10334 | >4){ |
10340 | >4){ |
10335 | >4)edpip(num); |
10341 | >4)edpip(num); |
10336 | >=tk_double){ |
10342 | >=tk_double){ |
10337 | >=tk_double){ |
10343 | >=tk_double){ |
10338 | > |
10344 | > |
10339 | > |
10345 | > |
10340 | > |
10346 | > |
10341 | > |
10347 | > |
10342 | > |
10348 | > |
10343 | >6;i++){ |
10349 | >6;i++){ |
10344 | >=tk_double){ |
10350 | >=tk_double){ |
10345 | >=tk_double)def=tok; |
10351 | >=tk_double)def=tok; |
10346 | >=endStartup){ |
10352 | >=endStartup){ |
10347 | >=endStartup){ |
10353 | >=endStartup){ |
10348 | >=tk_float){ |
10354 | >=tk_float){ |
10349 | >=tk_double)tok=type+(tk_charvar-tk_char); |
10355 | >=tk_double)tok=type+(tk_charvar-tk_char); |
10350 | > |
10356 | > |
10351 | > |
10357 | > |
10352 | > |
10358 | > |
10353 | > |
10359 | > |
10354 | > |
10360 | > |
10355 | >=127)warningjmp(mesLOOPNZ,sline); |
10361 | >=127)warningjmp(mesLOOPNZ,sline); |
10356 | >3)cpu=3; |
10362 | >3)cpu=3; |
10357 | >3){ |
10363 | >3){ |
10358 | >3||optimizespeed==0)&& |
10364 | >3||optimizespeed==0)&& |
10359 | >=(127-3))&&(chip<3||optimizespeed==0)&& |
10365 | >=(127-3))&&(chip<3||optimizespeed==0)&& |
10360 | >3){ |
10366 | >3){ |
10361 | >7))){ |
10367 | >7))){ |
10362 | >3)cpu=3; |
10368 | >3)cpu=3; |
10363 | >3)cpu=3; |
10369 | >3)cpu=3; |
10364 | >=127)warningjmp(mesFOR,ifline); |
10370 | >=127)warningjmp(mesFOR,ifline); |
10365 | > |
10371 | > |
10366 | > |
10372 | > |
10367 | > |
10373 | > |
10368 | >=127)warningjmp(mesWHILE,olinenum); |
10374 | >=127)warningjmp(mesWHILE,olinenum); |
10369 | >=127)warningjmp(mesWHILE,ifline); |
10375 | >=127)warningjmp(mesWHILE,ifline); |
10370 | > |
10376 | > |
10371 | > |
10377 | > |
10372 | >3)cpu=3; |
10378 | >3)cpu=3; |
10373 | >3){ |
10379 | >3){ |
10374 | >=127)warningjmp(mesELSE,elseline); |
10380 | >=127)warningjmp(mesELSE,elseline); |
10375 | > |
10381 | > |
10376 | >*numcomp;i++){ |
10382 | >*numcomp;i++){ |
10377 | >3)cpu=3; |
10383 | >3)cpu=3; |
10378 | >127){ |
10384 | >127){ |
10379 | >128){ |
10385 | >128){ |
10380 | >*numcomp;i++){ |
10386 | >*numcomp;i++){ |
10381 | >*numcomp;i++){ |
10387 | >*numcomp;i++){ |
10382 | >*numcomp;i++){ |
10388 | >*numcomp;i++){ |
10383 | >=127)warningjmp(mesELSE,elseline); |
10389 | >=127)warningjmp(mesELSE,elseline); |
10384 | >=127)warningjmp(mesIF,ifline); |
10390 | >=127)warningjmp(mesIF,ifline); |
10385 | > |
10391 | > |
10386 | >=127)warningjmp(mesIF,ifline); |
10392 | >=127)warningjmp(mesIF,ifline); |
10387 | > |
10393 | > |
10388 | >0x90){ |
10394 | >0x90){ |
10389 | >*numcomp;i++){ |
10395 | >*numcomp;i++){ |
10390 | //>3)cpu=3; |
10396 | //>3)cpu=3; |
10391 | >*numcomp;i++){ |
10397 | >*numcomp;i++){ |
10392 | >*numcomp;i++){ |
10398 | >*numcomp;i++){ |
10393 | >3){ |
10399 | >3){ |
10394 | >=127)warningjmp(mesIF,ifline); |
10400 | >=127)warningjmp(mesIF,ifline); |
10395 | >*numcomp;i++){ |
10401 | >*numcomp;i++){ |
10396 | >*numcomp;i++){ |
10402 | >*numcomp;i++){ |
10397 | >=tk_doublevar&&ittok==tk_number&& |
10403 | >=tk_doublevar&&ittok==tk_number&& |
10398 | >=tk_doublevar&&ittok2==tk_number&& |
10404 | >=tk_doublevar&&ittok2==tk_number&& |
10399 | > |
10405 | > |
10400 | >=tk_floatvar){ |
10406 | >=tk_floatvar){ |
10401 | >=tk_plusflag)){ |
10407 | >=tk_plusflag)){ |
10402 | > |
10408 | > |
10403 | >=8)vops=r8; |
10409 | >=8)vops=r8; |
10404 | >=16)vops=r16; |
10410 | >=16)vops=r16; |
10405 | >=32)vops=r32; |
10411 | >=32)vops=r32; |
10406 | >=64)vops=r64; |
10412 | >=64)vops=r64; |
10407 | >=tk_doublevar))){ |
10413 | >=tk_doublevar))){ |
10408 | >=tk_doublevar&&(tok==tk_proc||tok==tk_id|| |
10414 | >=tk_doublevar&&(tok==tk_proc||tok==tk_id|| |
10409 | >=tk_double){ |
10415 | >=tk_double){ |
10410 | >=tk_doublevar){ |
10416 | >=tk_doublevar){ |
10411 | >=tk_plusflag))){ |
10417 | >=tk_plusflag))){ |
10412 | >=tk_plusflag)){ |
10418 | >=tk_plusflag)){ |
10413 | >=tk_plusflag)){ |
10419 | >=tk_plusflag)){ |
10414 | >=tk_plusflag)){ |
10420 | >=tk_plusflag)){ |
10415 | >=8){ |
10421 | >=8){ |
10416 | >=16){ |
10422 | >=16){ |
10417 | >=32){ |
10423 | >=32){ |
10418 | >=64){ |
10424 | >=64){ |
10419 | >7){ |
10425 | >7){ |
10420 | >7&&cstok2->7)||cstok2->=BX){>65536){ |
10426 | >7&&cstok2->7)||cstok2->=BX){>65536){ |
10421 | >65536&&>256){ |
10427 | >65536&&>256){ |
10422 | >256&&(unsigned>2;i++){ |
10428 | >256&&(unsigned>2;i++){ |
10423 | >2;i++){ |
10429 | >2;i++){ |
10424 | >2;i++){ |
10430 | >2;i++){ |
10425 | >2;i++){ |
10431 | >2;i++){ |
10426 | >2;i++){ |
10432 | >2;i++){ |
10427 | > |
10433 | > |
10428 | >3)cpu=3; |
10434 | >3)cpu=3; |
10429 | >3)cpu=3; |
10435 | >3)cpu=3; |
10430 | >3)cpu=3; |
10436 | >3)cpu=3; |
10431 | >4)op(0x9B); |
10437 | >4)op(0x9B); |
10432 | } |
10438 | } |
10433 | 10439 | ||
10434 | void>3)cpu=3; |
10440 | void>3)cpu=3; |
10435 | } |
10441 | } |
10436 | 10442 | ||
10437 | void>3)cpu=3; |
10443 | void>3)cpu=3; |
10438 | } |
10444 | } |
10439 | 10445 | ||
10440 | void>128?rm_mod01:rm_mod10); |
10446 | void>128?rm_mod01:rm_mod10); |
10441 | >(unsigned> |
10447 | >(unsigned> |
10442 | > |
10448 | > |
10443 | > |
10449 | > |
10444 | //> |
10450 | //> |
10445 | //> |
10451 | //> |
10446 | } |
10452 | } |
10447 | 10453 | ||
10448 | void> |
10454 | void> |
10449 | } |
10455 | } |
10450 | 10456 | ||
10451 | void>=numfindpath;i++){ |
10457 | void>=numfindpath;i++){ |
10452 | > |
10458 | > |