Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
6446 | GerdtR | 1 | #include "tok.h" |
2 | |||
3 | |||
4 | |||
5 | |||
6 | |||
7 | { |
||
8 | |||
9 | |||
10 | |||
11 | return l|h; |
||
12 | |||
13 | |||
14 | |||
15 | { |
||
16 | |||
17 | if(fwrite(output,outptr,1,hout)!=1){ |
||
18 | |||
19 | fclose(hout); |
||
20 | |||
21 | return(-1); |
||
22 | |||
23 | return 0; |
||
24 | |||
25 | |||
26 | |||
27 | { |
||
28 | |||
29 | int bb=tk_id; |
||
30 | |||
31 | btok.number=0; |
||
32 | |||
33 | if(bb==tk_id)btok.number=0; |
||
34 | |||
35 | btok.number+=outptrdata; |
||
36 | |||
37 | } |
||
38 | |||
39 | } |
||
40 | |||
41 | int MakeMEOS() |
||
42 | |||
43 | MEOSheader hdr; |
||
44 | |||
45 | strcpy((char *)hdr.sign,"MENUET01"); |
||
46 | |||
47 | hdr.start=EntryPoint(); |
||
48 | |||
49 | |||
50 | |||
51 | hdr.I_Param=EntryParamStr(); |
||
52 | |||
53 | memcpy(output+startptr,&hdr,sizeof(MEOSheader)); |
||
54 | |||
55 | ErrWrite(); |
||
56 | |||
57 | hout=NULL; |
||
58 | |||
59 | } |
||
60 | |||
61 | } |
||
62 | |||
63 | int MakeLE() |
||
64 | |||
65 | LE_Header hdr; |
||
66 | |||
67 | Page_Map_Table *pmt; |
||
68 | |||
69 | int headerofs; |
||
70 | |||
71 | unsigned long *fpto; |
||
72 | |||
73 | CreatStub(stubfile); |
||
74 | |||
75 | #ifdef _WC_ |
||
76 | |||
77 | #else |
||
78 | |||
79 | |||
80 | |||
81 | hdr.Target_OS=1; |
||
82 | |||
83 | hdr.Number_Of_Memory_Pages=outptr/0x1000+1; |
||
84 | |||
85 | hdr.Initial_EI=EntryPoint(); |
||
86 | |||
87 | hdr.Initial_ESP=stacksize; |
||
88 | |||
89 | hdr.Bytes_On_Last_Page=outptr%0x1000; |
||
90 | |||
91 | hdr.Object_Table_Entries=2; |
||
92 | |||
93 | if(fwrite(&hdr,sizeof(LE_Header),1,hout)!=1){ |
||
94 | |||
95 | ErrWrite(); |
||
96 | |||
97 | hout=NULL; |
||
98 | |||
99 | } |
||
100 | |||
101 | ot[0].Virtual_Segment_Size=outptr+postsize;//hdr.Initial_ESP; |
||
102 | |||
103 | ot[0].ObjTableFlags=0x2045; |
||
104 | |||
105 | ot[0].Page_MAP_Entries=hdr.Number_Of_Memory_Pages; |
||
106 | |||
107 | ot[1].Relocation_Base_Address=Align(outptr+postsize,0x10000)+0x10000; |
||
108 | |||
109 | ot[1].Page_MAP_Index=2; |
||
110 | |||
111 | if(fwrite(&ot,sizeof(Object_Table)*2,1,hout)!=1)goto errwrite; |
||
112 | |||
113 | |||
114 | |||
115 | pmt=(Page_Map_Table *)MALLOC(sizeb); |
||
116 | |||
117 | (pmt+i)->High_Page_Number=swapshort(((i+1)/256)); |
||
118 | |||
119 | (pmt+i)->FLAGS=0; |
||
120 | |||
121 | if(fwrite(pmt,sizeb,1,hout)!=1)goto errwrite; |
||
122 | |||
123 | |||
124 | |||
125 | i=strlen(rawfilename); |
||
126 | |||
127 | strcpy((char *)&string2[1],rawfilename); |
||
128 | |||
129 | if(fwrite(string2,i+5,1,hout)!=1)goto errwrite; |
||
130 | |||
131 | hdr.Entry_Table_Offset=headsize+=i+4; |
||
132 | |||
133 | sizeb=sizeof(unsigned long)*(hdr.Number_Of_Memory_Pages+1); |
||
134 | |||
135 | hdr.Fixup_Page_Table_Offset=headsize; |
||
136 | |||
137 | // for(i=0;i<(hdr.Number_Of_Memory_Pages+1);i++){ |
||
138 | |||
139 | // } |
||
140 | |||
141 | headsize+=sizeb; |
||
142 | |||
143 | //Fixup_Record_Table |
||
144 | |||
145 | hdr.Fixup_Record_Table_Offset=headsize; |
||
146 | |||
147 | unsigned int startblc=i*4096; //адрес первого блока |
||
148 | |||
149 | if(((postbuf+j)->type==CALL_32I|| |
||
150 | |||
151 | (postbuf+j)->loc>=startblc&&(postbuf+j)->loc<(startblc+4096)){ |
||
152 | |||
153 | string2[0]=7; |
||
154 | |||
155 | string2[4]=1; |
||
156 | |||
157 | if(val<65536){ |
||
158 | |||
159 | *(unsigned short *)&string2[5]=(unsigned short)val; |
||
160 | |||
161 | } |
||
162 | |||
163 | string2[1]=0x10; |
||
164 | |||
165 | sizerec=9; |
||
166 | |||
167 | sizefixpage+=sizerec; |
||
168 | |||
169 | } |
||
170 | |||
171 | } |
||
172 | |||
173 | headsize+=sizefixpage; |
||
174 | |||
175 | //Imported_Procedure_Name_Table |
||
176 | |||
177 | hdr.Imported_Procedure_Name_Table_Offset=headsize; |
||
178 | |||
179 | if(fwrite(string2,1,1,hout)!=1)goto errwrite; |
||
180 | |||
181 | |||
182 | |||
183 | hdr.Fixup_Section_Size=headsize-hdr.Fixup_Page_Table_Offset;//9+sizefixpage; |
||
184 | |||
185 | hdr.Automatic_Data_Object=2; |
||
186 | |||
187 | ChSize(hdr.Data_Pages_Offset); |
||
188 | |||
189 | fseek(hout,headerofs,SEEK_SET); |
||
190 | |||
191 | fseek(hout,headerofs+hdr.Fixup_Page_Table_Offset,SEEK_SET); |
||
192 | |||
193 | free(fpto); |
||
194 | |||
195 | fseek(hout,0,SEEK_END); |
||
196 | |||
197 | }65536){ |
||
198 | |||
199 | |||
200 | |||
201 | >(hdr.Number_Of_Memory_Pages+1);i++){ |
||
202 | |||
203 | >8; |
||
204 | |||
205 | > |
||
206 |