Rev 370 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 370 | Rev 485 | ||
---|---|---|---|
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
2 | ;; ;; |
3 | ;; flat assembler source ;; |
3 | ;; flat assembler source ;; |
4 | ;; Copyright (c) 1999-2006, Tomasz Grysztar ;; |
4 | ;; Copyright (c) 1999-2006, Tomasz Grysztar ;; |
5 | ;; All rights reserved. ;; |
5 | ;; All rights reserved. ;; |
6 | ;; ;; |
6 | ;; ;; |
7 | ;; Menuet port by VT ;; |
7 | ;; Menuet port by VT ;; |
8 | ;; ;; |
8 | ;; ;; |
9 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
9 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
10 | 10 | ||
11 | NORMAL_MODE = 8 |
11 | NORMAL_MODE = 8 |
12 | CONSOLE_MODE = 32 |
12 | CONSOLE_MODE = 32 |
13 | 13 | ||
14 | MAGIC1 = 6*(text.line_size-1)+14 |
14 | MAGIC1 = 6*(text.line_size-1)+14 |
15 | MAX_PATH = 100 |
15 | MAX_PATH = 100 |
16 | 16 | ||
17 | APP_MEMORY = 0x00800000 |
17 | APP_MEMORY = 0x00800000 |
18 | 18 | ||
19 | ;; Menuet header |
19 | ;; Menuet header |
20 | 20 | ||
21 | appname equ "flat assembler " |
21 | appname equ "flat assembler " |
22 | 22 | ||
23 | use32 |
23 | use32 |
24 | 24 | ||
25 | org 0x0 |
25 | org 0x0 |
26 | db 'MENUET01' ; 8 byte id |
26 | db 'MENUET01' ; 8 byte id |
27 | dd 0x01 ; header version |
27 | dd 0x01 ; header version |
28 | dd START ; program start |
28 | dd START ; program start |
29 | dd program_end ; program image size |
29 | dd program_end ; program image size |
30 | dd APP_MEMORY ; required amount of memory |
30 | dd APP_MEMORY ; required amount of memory |
31 | dd 0xDFFF0 ; stack |
31 | dd 0xDFFF0 ; stack |
32 | dd params,0x0 ; parameters,icon |
32 | dd params,0x0 ; parameters,icon |
33 | 33 | ||
34 | include 'lang.inc' |
34 | include 'lang.inc' |
- | 35 | include '..\..\..\macros.inc' |
|
35 | include 'fasm.inc' |
36 | include 'fasm.inc' |
36 | 37 | ||
37 | center fix true |
38 | center fix true |
38 | 39 | ||
39 | START: ; Start of execution |
40 | START: ; Start of execution |
40 | mov edi, fileinfos |
41 | mov edi, fileinfos |
41 | mov ecx, (fileinfos_end-fileinfos)/4 |
42 | mov ecx, (fileinfos_end-fileinfos)/4 |
42 | or eax, -1 |
43 | or eax, -1 |
43 | rep stosd |
44 | rep stosd |
44 | 45 | ||
45 | cmp [params],0 |
46 | cmp [params],0 |
46 | jz red |
47 | jz red |
47 | 48 | ||
48 | mov ecx,10 |
49 | mov ecx,10 |
49 | mov al,' ' |
50 | mov al,' ' |
50 | mov edi,infile |
51 | mov edi,infile |
51 | push ecx |
52 | push ecx |
52 | cld |
53 | cld |
53 | rep stosd |
54 | rep stosd |
54 | mov ecx,[esp] |
55 | mov ecx,[esp] |
55 | mov edi,outfile |
56 | mov edi,outfile |
56 | rep stosd |
57 | rep stosd |
57 | pop ecx |
58 | pop ecx |
58 | mov edi,path |
59 | mov edi,path |
59 | rep stosd |
60 | rep stosd |
60 | 61 | ||
61 | mov esi,params |
62 | mov esi,params |
62 | ; DEBUGF "params: %s\n",esi |
63 | ; DEBUGF "params: %s\n",esi |
63 | mov edi,infile |
64 | mov edi,infile |
64 | call mov_param_str |
65 | call mov_param_str |
65 | ; mov edi,infile |
66 | ; mov edi,infile |
66 | ; DEBUGF " input: %s\n",edi |
67 | ; DEBUGF " input: %s\n",edi |
67 | inc esi |
68 | inc esi |
68 | mov edi,outfile |
69 | mov edi,outfile |
69 | call mov_param_str |
70 | call mov_param_str |
70 | ; mov edi,outfile |
71 | ; mov edi,outfile |
71 | ; DEBUGF "output: %s\n",edi |
72 | ; DEBUGF "output: %s\n",edi |
72 | inc esi |
73 | inc esi |
73 | mov edi,path |
74 | mov edi,path |
74 | call mov_param_str |
75 | call mov_param_str |
75 | ; mov edi,path |
76 | ; mov edi,path |
76 | ; DEBUGF " path: %s\n",edi |
77 | ; DEBUGF " path: %s\n",edi |
77 | 78 | ||
78 | cmp [esi], dword ',run' |
79 | cmp [esi], dword ',run' |
79 | jne @f |
80 | jne @f |
80 | mov [_run_outfile],1 |
81 | mov [_run_outfile],1 |
81 | @@: |
82 | @@: |
82 | 83 | ||
83 | mov [_mode],CONSOLE_MODE |
84 | mov [_mode],CONSOLE_MODE |
84 | jmp start |
85 | jmp start |
85 | 86 | ||
86 | 87 | ||
87 | red: ; Redraw |
88 | red: ; Redraw |
88 | call draw_window |
89 | call draw_window |
89 | 90 | ||
90 | still: |
91 | still: |
91 | push 10 ; Wait here for event |
92 | push 10 ; Wait here for event |
92 | pop eax |
93 | pop eax |
93 | int 40h |
94 | mcall |
94 | dec eax |
95 | dec eax |
95 | je red ; Redraw request |
96 | je red ; Redraw request |
96 | dec eax |
97 | dec eax |
97 | jne button ; Button in buffer |
98 | jne button ; Button in buffer |
98 | 99 | ||
99 | key: ; Key |
100 | key: ; Key |
100 | mov al,2 ; Read it and ignore |
101 | mov al,2 ; Read it and ignore |
101 | int 0x40 |
102 | mcall |
102 | jmp still |
103 | jmp still |
103 | 104 | ||
104 | button: ; Button in Window |
105 | button: ; Button in Window |
105 | 106 | ||
106 | mov al,17 |
107 | mov al,17 |
107 | int 0x40 |
108 | mcall |
108 | 109 | ||
109 | cmp ah,1 |
110 | cmp ah,1 |
110 | jne noclose |
111 | jne noclose |
111 | or eax,-1 |
112 | or eax,-1 |
112 | int 0x40 |
113 | mcall |
113 | 114 | ||
114 | noclose: |
115 | noclose: |
115 | cmp ah,2 ; Start compiling |
116 | cmp ah,2 ; Start compiling |
116 | je start |
117 | je start |
117 | cmp ah,3 ; Start compiled file |
118 | cmp ah,3 ; Start compiled file |
118 | jnz norunout |
119 | jnz norunout |
119 | 120 | ||
120 | mov edx,outfile |
121 | mov edx,outfile |
121 | call make_fullpaths |
122 | call make_fullpaths |
122 | mcall 70,file_info_start |
123 | mcall 70,file_info_start |
123 | ; xor ecx,ecx |
124 | ; xor ecx,ecx |
124 | jmp still |
125 | jmp still |
125 | norunout: |
126 | norunout: |
126 | 127 | ||
127 | mov ecx,5 |
128 | mov ecx,5 |
128 | mov [ya],ecx |
129 | mov [ya],ecx |
129 | 130 | ||
130 | cmp ah,11 ; Infile |
131 | cmp ah,11 ; Infile |
131 | je f1 |
132 | je f1 |
132 | cmp ah,12 ; Outfile |
133 | cmp ah,12 ; Outfile |
133 | je f2 |
134 | je f2 |
134 | cmp ah,13 ; Path |
135 | cmp ah,13 ; Path |
135 | je f3 |
136 | je f3 |
136 | 137 | ||
137 | jmp still |
138 | jmp still |
138 | 139 | ||
139 | 140 | ||
140 | draw_window: |
141 | draw_window: |
141 | 142 | ||
142 | pusha |
143 | pusha |
143 | 144 | ||
144 | mcall 12,1 ; Start of draw |
145 | mcall 12,1 ; Start of draw |
145 | 146 | ||
146 | get_sys_colors 1,0 |
147 | get_sys_colors 1,0 |
147 | 148 | ||
148 | xor eax,eax |
149 | xor eax,eax |
149 | mov ebx,50*65536+280 |
150 | mov ebx,50*65536+280 |
150 | mov ecx,50*65536+250 |
151 | mov ecx,50*65536+250 |
151 | mov edx,[sc.work] |
152 | mov edx,[sc.work] |
152 | or edx,0x33000000 |
153 | or edx,0x33000000 |
153 | mov edi,header ; Draw Window Label Text |
154 | mov edi,title ; Draw Window Label Text |
154 | int 0x40 |
155 | mcall |
155 | 156 | ||
156 | mcall 9,PROCESSINFO,-1 |
157 | mcall 9,PROCESSINFO,-1 |
157 | 158 | ||
158 | mpack ecx,1,1 |
159 | mpack ecx,1,1 |
159 | mov ebx,[pinfo.x_size] |
160 | mov ebx,[pinfo.box.left] |
160 | sub ebx,10 |
161 | sub ebx,10 |
161 | 162 | ||
162 | push ecx |
163 | push ecx |
163 | madd ecx, 14*3+2, 14*3+2 |
164 | madd ecx, 14*3+2, 14*3+2 |
164 | mcall 38,,,[sc.work_graph] |
165 | mcall 38,,,[sc.work_graph] |
165 | pop ecx |
166 | pop ecx |
166 | 167 | ||
167 | sub ebx,MAGIC1+3 |
168 | sub ebx,MAGIC1+3 |
168 | mcall |
169 | mcall |
169 | madd ecx, 14, 14 |
170 | madd ecx, 14, 14 |
170 | mcall |
171 | mcall |
171 | madd ecx, 14, 14 |
172 | madd ecx, 14, 14 |
172 | mcall |
173 | mcall |
173 | madd ecx, 14, 14 |
174 | madd ecx, 14, 14 |
174 | mcall |
175 | mcall |
175 | push ebx |
176 | push ebx |
176 | mpack ebx,MAGIC1,MAGIC1 |
177 | mpack ebx,MAGIC1,MAGIC1 |
177 | sub ecx, 14*3 |
178 | sub ecx, 14*3 |
178 | mcall |
179 | mcall |
179 | mov ebx,[esp-2] |
180 | mov ebx,[esp-2] |
180 | pop bx |
181 | pop bx |
181 | mcall |
182 | mcall |
182 | add esp,2 |
183 | add esp,2 |
183 | 184 | ||
184 | mpack ebx,0,MAGIC1-1 |
185 | mpack ebx,0,MAGIC1-1 |
185 | mpack ecx,1+1, 14-2 |
186 | mpack ecx,1+1, 14-2 |
186 | mcall 8,,,0x4000000B ; Button: Enter Infile |
187 | mcall 8,,,0x4000000B ; Button: Enter Infile |
187 | madd ecx, 14,0 |
188 | madd ecx, 14,0 |
188 | mcall ,,,0x4000000C ; Button: Enter Outfile |
189 | mcall ,,,0x4000000C ; Button: Enter Outfile |
189 | madd ecx, 14,0 |
190 | madd ecx, 14,0 |
190 | mcall ,,,0x4000000D ; Button: Enter Path |
191 | mcall ,,,0x4000000D ; Button: Enter Path |
191 | 192 | ||
192 | mpack ebx,[pinfo.x_size],MAGIC1 |
193 | mpack ebx,[pinfo.box.left],MAGIC1 |
193 | msub ebx,MAGIC1+10+1,0 |
194 | msub ebx,MAGIC1+10+1,0 |
194 | mpack ecx,0, 14*3/2-1 |
195 | mpack ecx,0, 14*3/2-1 |
195 | madd ecx,1,0 |
196 | madd ecx,1,0 |
196 | mcall ,,,0x00000002,[sc.work_button] |
197 | mcall ,,,0x00000002,[sc.work_button] |
197 | madd ecx, 14*3/2+1,0 |
198 | madd ecx, 14*3/2+1,0 |
198 | mcall ,,,0x00000003 |
199 | mcall ,,,0x00000003 |
199 | 200 | ||
200 | mpack ebx,6,0 ; Draw Window Text |
201 | mpack ebx,6,0 ; Draw Window Text |
201 | add ebx,1+ 14/2-3 |
202 | add ebx,1+ 14/2-3 |
202 | mov ecx,[sc.work_text] |
203 | mov ecx,[sc.work_text] |
203 | mov edx,text |
204 | mov edx,text |
204 | mov esi,text.line_size |
205 | mov esi,text.line_size |
205 | mov eax,4 |
206 | mov eax,4 |
206 | newline: |
207 | newline: |
207 | int 0x40 |
208 | mcall |
208 | add ebx, 14 |
209 | add ebx, 14 |
209 | add edx,text.line_size |
210 | add edx,text.line_size |
210 | cmp byte[edx],'x' |
211 | cmp byte[edx],'x' |
211 | jne newline |
212 | jne newline |
212 | 213 | ||
213 | mov ebx,[pinfo.x_size] |
214 | mov ebx,[pinfo.box.left] |
214 | sub ebx,MAGIC1+10+1-9 |
215 | sub ebx,MAGIC1+10+1-9 |
215 | shl ebx,16 |
216 | shl ebx,16 |
216 | add ebx,1+( 14*3/2-1)/2-3 |
217 | add ebx,1+( 14*3/2-1)/2-3 |
217 | mcall ,,[sc.work_button_text],s_compile,7 |
218 | mcall ,,[sc.work_button_text],s_compile,7 |
218 | add ebx,14*3/2+1 |
219 | add ebx,14*3/2+1 |
219 | mcall ,,,s_run |
220 | mcall ,,,s_run |
220 | 221 | ||
221 | mpack ebx,MAGIC1+6,0 |
222 | mpack ebx,MAGIC1+6,0 |
222 | add ebx,1+ 14/2-3+ 14*0 |
223 | add ebx,1+ 14/2-3+ 14*0 |
223 | mov esi,[pinfo.x_size] |
224 | mov esi,[pinfo.box.left] |
224 | sub esi,MAGIC1*2+5*2+6+3 |
225 | sub esi,MAGIC1*2+5*2+6+3 |
225 | mov eax,esi |
226 | mov eax,esi |
226 | mov cl,6 |
227 | mov cl,6 |
227 | div cl |
228 | div cl |
228 | cmp al,MAX_PATH |
229 | cmp al,MAX_PATH |
229 | jbe @f |
230 | jbe @f |
230 | mov al,MAX_PATH |
231 | mov al,MAX_PATH |
231 | @@: movzx esi,al |
232 | @@: movzx esi,al |
232 | mcall 4,,[sc.work_text],infile |
233 | mcall 4,,[sc.work_text],infile |
233 | add ebx,14 |
234 | add ebx,14 |
234 | mcall ,,,outfile |
235 | mcall ,,,outfile |
235 | add ebx,14 |
236 | add ebx,14 |
236 | mcall ,,,path |
237 | mcall ,,,path |
237 | 238 | ||
238 | call draw_messages |
239 | call draw_messages |
239 | 240 | ||
240 | mcall 12,2 ; End of Draw |
241 | mcall 12,2 ; End of Draw |
241 | 242 | ||
242 | popa |
243 | popa |
243 | ret |
244 | ret |
244 | 245 | ||
245 | bottom_right dd ? |
246 | bottom_right dd ? |
246 | 247 | ||
247 | draw_messages: |
248 | draw_messages: |
248 | mov eax,13 ; clear work area |
249 | mov eax,13 ; clear work area |
249 | mpack ebx,7-2,[pinfo.x_size] |
250 | mpack ebx,7-2,[pinfo.box.left] |
250 | sub ebx,5*2+7*2-1-2*2 |
251 | sub ebx,5*2+7*2-1-2*2 |
251 | mpack ecx,0,[pinfo.y_size] |
252 | mpack ecx,0,[pinfo.box.top] |
252 | madd ecx, 14*3+1+7+1,-( 14*3+1+7*2+25) |
253 | madd ecx, 14*3+1+7+1,-( 14*3+1+7*2+25) |
253 | mov word[bottom_right+2],bx |
254 | mov word[bottom_right+2],bx |
254 | mov word[bottom_right],cx |
255 | mov word[bottom_right],cx |
255 | msub [bottom_right],7,11 |
256 | msub [bottom_right],7,11 |
256 | add [bottom_right],7 shl 16 + 53 |
257 | add [bottom_right],7 shl 16 + 53 |
257 | mov edx,[sc.work] |
258 | mov edx,[sc.work] |
258 | int 0x40 |
259 | mcall |
259 | _cy = 0 |
260 | _cy = 0 |
260 | _sy = 2 |
261 | _sy = 2 |
261 | _cx = 4 |
262 | _cx = 4 |
262 | _sx = 6 |
263 | _sx = 6 |
263 | push ebx ecx |
264 | push ebx ecx |
264 | mpack ebx,4,5 |
265 | mpack ebx,4,5 |
265 | add bx,[esp+_cx] |
266 | add bx,[esp+_cx] |
266 | mov ecx,[esp+_sy-2] |
267 | mov ecx,[esp+_sy-2] |
267 | mov cx,[esp+_sy] |
268 | mov cx,[esp+_sy] |
268 | msub ecx,1,1 |
269 | msub ecx,1,1 |
269 | mcall 38,,,[sc.work_graph] |
270 | mcall 38,,,[sc.work_graph] |
270 | mov si,[esp+_cy] |
271 | mov si,[esp+_cy] |
271 | add cx,si |
272 | add cx,si |
272 | shl esi,16 |
273 | shl esi,16 |
273 | add ecx,esi |
274 | add ecx,esi |
274 | madd ecx,1,1 |
275 | madd ecx,1,1 |
275 | mcall |
276 | mcall |
276 | mpack ebx,4,4 |
277 | mpack ebx,4,4 |
277 | mov esi,[esp+_sy-2] |
278 | mov esi,[esp+_sy-2] |
278 | mov si,cx |
279 | mov si,cx |
279 | mov ecx,esi |
280 | mov ecx,esi |
280 | mcall |
281 | mcall |
281 | mov si,[esp+_cx] |
282 | mov si,[esp+_cx] |
282 | add bx,si |
283 | add bx,si |
283 | shl esi,16 |
284 | shl esi,16 |
284 | add ebx,esi |
285 | add ebx,esi |
285 | madd ebx,1,1 |
286 | madd ebx,1,1 |
286 | mcall |
287 | mcall |
287 | pop ecx ebx |
288 | pop ecx ebx |
288 | ret |
289 | ret |
289 | 290 | ||
290 | ; read string |
291 | ; read string |
291 | 292 | ||
292 | f1: mov [addr],infile |
293 | f1: mov [addr],infile |
293 | add [ya], 14*0 |
294 | add [ya], 14*0 |
294 | jmp rk |
295 | jmp rk |
295 | f2: mov [addr],outfile |
296 | f2: mov [addr],outfile |
296 | add [ya], 14*1 |
297 | add [ya], 14*1 |
297 | jmp rk |
298 | jmp rk |
298 | f3: mov [addr],path |
299 | f3: mov [addr],path |
299 | add [ya], 14*2 |
300 | add [ya], 14*2 |
300 | rk: |
301 | rk: |
301 | 302 | ||
302 | mov edi,[addr] |
303 | mov edi,[addr] |
303 | mov al,0 |
304 | mov al,0 |
304 | mov ecx,MAX_PATH |
305 | mov ecx,MAX_PATH |
305 | add edi,ecx |
306 | add edi,ecx |
306 | dec edi |
307 | dec edi |
307 | std |
308 | std |
308 | repe scasb |
309 | repe scasb |
309 | sub ecx,MAX_PATH |
310 | sub ecx,MAX_PATH |
310 | neg ecx |
311 | neg ecx |
311 | mov al,$1C ; '' |
312 | mov al,$1C ; '' |
312 | add edi,2 |
313 | add edi,2 |
313 | push edi |
314 | push edi |
314 | cld |
315 | cld |
315 | rep stosb |
316 | rep stosb |
316 | call print_text |
317 | call print_text |
317 | pop edi |
318 | pop edi |
318 | f11:mcall 10 |
319 | f11:mcall 10 |
319 | cmp eax,2 |
320 | cmp eax,2 |
320 | jne read_done |
321 | jne read_done |
321 | mcall; 2 |
322 | mcall; 2 |
322 | shr eax,8 |
323 | shr eax,8 |
323 | cmp al,13 |
324 | cmp al,13 |
324 | je read_done |
325 | je read_done |
325 | cmp al,8 |
326 | cmp al,8 |
326 | jne nobs |
327 | jne nobs |
327 | cmp edi,[addr] |
328 | cmp edi,[addr] |
328 | je f11 |
329 | je f11 |
329 | sub edi,1 |
330 | sub edi,1 |
330 | mov byte[edi],$1C ; '_' |
331 | mov byte[edi],$1C ; '_' |
331 | call print_text |
332 | call print_text |
332 | jmp f11 |
333 | jmp f11 |
333 | nobs: |
334 | nobs: |
334 | movzx ebx,al |
335 | movzx ebx,al |
335 | sub ebx,$20 |
336 | sub ebx,$20 |
336 | jle f11 |
337 | jle f11 |
337 | sub al,[sub_table+ebx] |
338 | sub al,[sub_table+ebx] |
338 | keyok: |
339 | keyok: |
339 | mov ecx,[addr] |
340 | mov ecx,[addr] |
340 | add ecx,MAX_PATH |
341 | add ecx,MAX_PATH |
341 | cmp edi,ecx |
342 | cmp edi,ecx |
342 | jae f11 |
343 | jae f11 |
343 | mov [edi],al |
344 | mov [edi],al |
344 | 345 | ||
345 | call print_text |
346 | call print_text |
346 | inc edi |
347 | inc edi |
347 | jmp f11 |
348 | jmp f11 |
348 | 349 | ||
349 | read_done: |
350 | read_done: |
350 | 351 | ||
351 | mov ecx,[addr] |
352 | mov ecx,[addr] |
352 | add ecx,MAX_PATH |
353 | add ecx,MAX_PATH |
353 | sub ecx,edi |
354 | sub ecx,edi |
354 | mov al,0;' ' |
355 | mov al,0;' ' |
355 | cld |
356 | cld |
356 | rep stosb |
357 | rep stosb |
357 | call print_text |
358 | call print_text |
358 | 359 | ||
359 | jmp still |
360 | jmp still |
360 | 361 | ||
361 | print_text: |
362 | print_text: |
362 | 363 | ||
363 | mpack ebx,MAGIC1+6,[pinfo.x_size] |
364 | mpack ebx,MAGIC1+6,[pinfo.box.left] |
364 | sub ebx,MAGIC1*2+19 |
365 | sub ebx,MAGIC1*2+19 |
365 | movzx esi,bx |
366 | movzx esi,bx |
366 | mov ecx,[ya-2] |
367 | mov ecx,[ya-2] |
367 | mov cx,8 |
368 | mov cx,8 |
368 | mcall 13,,,[sc.work] |
369 | mcall 13,,,[sc.work] |
369 | 370 | ||
370 | mpack ebx,MAGIC1+6,[ya] |
371 | mpack ebx,MAGIC1+6,[ya] |
371 | mov eax,esi |
372 | mov eax,esi |
372 | mov cl,6 |
373 | mov cl,6 |
373 | div cl |
374 | div cl |
374 | cmp al,MAX_PATH |
375 | cmp al,MAX_PATH |
375 | jbe @f |
376 | jbe @f |
376 | mov al,MAX_PATH |
377 | mov al,MAX_PATH |
377 | @@: movzx esi,al |
378 | @@: movzx esi,al |
378 | mcall 4,,[sc.work_text],[addr] |
379 | mcall 4,,[sc.work_text],[addr] |
379 | 380 | ||
380 | ret |
381 | ret |
381 | 382 | ||
382 | 383 | ||
383 | ; DATA |
384 | ; DATA |
384 | 385 | ||
385 | text: |
386 | text: |
386 | db ' INFILE:' |
387 | db ' INFILE:' |
387 | .line_size = $-text |
388 | .line_size = $-text |
388 | db 'OUTFILE:' |
389 | db 'OUTFILE:' |
389 | db ' PATH:' |
390 | db ' PATH:' |
390 | db 'x' |
391 | db 'x' |
391 | 392 | ||
392 | s_compile db 'COMPILE' |
393 | s_compile db 'COMPILE' |
393 | s_run db ' RUN ' |
394 | s_run db ' RUN ' |
394 | 395 | ||
395 | infile db 'example.asm' |
396 | infile db 'example.asm' |
396 | times MAX_PATH+$-infile db 0 |
397 | times MAX_PATH+$-infile db 0 |
397 | outfile db 'example' |
398 | outfile db 'example' |
398 | times MAX_PATH+$-outfile db 0 |
399 | times MAX_PATH+$-outfile db 0 |
399 | path db '/rd/1/' |
400 | path db '/rd/1/' |
400 | times MAX_PATH+$-path db 0 |
401 | times MAX_PATH+$-path db 0 |
401 | 402 | ||
402 | lf db 13,10,0 |
403 | lf db 13,10,0 |
403 | 404 | ||
404 | addr dd 0x0 |
405 | addr dd 0x0 |
405 | ya dd 0x0 |
406 | ya dd 0x0 |
406 | zero db 0x0 |
407 | zero db 0x0 |
407 | 408 | ||
408 | mov_param_str: |
409 | mov_param_str: |
409 | @@: |
410 | @@: |
410 | mov al,[esi] |
411 | mov al,[esi] |
411 | cmp al,',' |
412 | cmp al,',' |
412 | je @f |
413 | je @f |
413 | cmp al,0 |
414 | cmp al,0 |
414 | je @f |
415 | je @f |
415 | mov [edi],al |
416 | mov [edi],al |
416 | inc esi |
417 | inc esi |
417 | inc edi |
418 | inc edi |
418 | jmp @b |
419 | jmp @b |
419 | @@: |
420 | @@: |
420 | mov al,0 |
421 | mov al,0 |
421 | stosb |
422 | stosb |
422 | ret |
423 | ret |
423 | 424 | ||
424 | start: |
425 | start: |
425 | cmp [_mode],NORMAL_MODE |
426 | cmp [_mode],NORMAL_MODE |
426 | jne @f |
427 | jne @f |
427 | call draw_messages |
428 | call draw_messages |
428 | push 0 |
429 | push 0 |
429 | pop [textxy] |
430 | pop [textxy] |
430 | add [textxy],7 shl 16 + 53 |
431 | add [textxy],7 shl 16 + 53 |
431 | @@: |
432 | @@: |
432 | mov esi,_logo |
433 | mov esi,_logo |
433 | call display_string |
434 | call display_string |
434 | 435 | ||
435 | ; |
436 | ; |
436 | ; Fasm native code |
437 | ; Fasm native code |
437 | ; |
438 | ; |
438 | 439 | ||
439 | mov [input_file],infile |
440 | mov [input_file],infile |
440 | mov [output_file],outfile |
441 | mov [output_file],outfile |
441 | 442 | ||
442 | call init_memory |
443 | call init_memory |
443 | 444 | ||
444 | call make_timestamp |
445 | call make_timestamp |
445 | mov [start_time],eax |
446 | mov [start_time],eax |
446 | 447 | ||
447 | call preprocessor |
448 | call preprocessor |
448 | call parser |
449 | call parser |
449 | call assembler |
450 | call assembler |
450 | call formatter |
451 | call formatter |
451 | 452 | ||
452 | call display_user_messages |
453 | call display_user_messages |
453 | movzx eax,[current_pass] |
454 | movzx eax,[current_pass] |
454 | inc eax |
455 | inc eax |
455 | call display_number |
456 | call display_number |
456 | mov esi,_passes_suffix |
457 | mov esi,_passes_suffix |
457 | call display_string |
458 | call display_string |
458 | call make_timestamp |
459 | call make_timestamp |
459 | sub eax,[start_time] |
460 | sub eax,[start_time] |
460 | xor edx,edx |
461 | xor edx,edx |
461 | mov ebx,100 |
462 | mov ebx,100 |
462 | div ebx |
463 | div ebx |
463 | or eax,eax |
464 | or eax,eax |
464 | jz display_bytes_count |
465 | jz display_bytes_count |
465 | xor edx,edx |
466 | xor edx,edx |
466 | mov ebx,10 |
467 | mov ebx,10 |
467 | div ebx |
468 | div ebx |
468 | push edx |
469 | push edx |
469 | call display_number |
470 | call display_number |
470 | mov dl,'.' |
471 | mov dl,'.' |
471 | call display_character |
472 | call display_character |
472 | pop eax |
473 | pop eax |
473 | call display_number |
474 | call display_number |
474 | mov esi,_seconds_suffix |
475 | mov esi,_seconds_suffix |
475 | call display_string |
476 | call display_string |
476 | display_bytes_count: |
477 | display_bytes_count: |
477 | mov eax,[written_size] |
478 | mov eax,[written_size] |
478 | call display_number |
479 | call display_number |
479 | mov esi,_bytes_suffix |
480 | mov esi,_bytes_suffix |
480 | call display_string |
481 | call display_string |
481 | xor al,al |
482 | xor al,al |
482 | 483 | ||
483 | cmp [_run_outfile],0 |
484 | cmp [_run_outfile],0 |
484 | je @f |
485 | je @f |
485 | mov edx,outfile |
486 | mov edx,outfile |
486 | call make_fullpaths |
487 | call make_fullpaths |
487 | mov eax,70 |
488 | mov eax,70 |
488 | mov ebx,file_info_start |
489 | mov ebx,file_info_start |
489 | xor ecx,ecx |
490 | xor ecx,ecx |
490 | int 0x40 |
491 | mcall |
491 | @@: |
492 | @@: |
492 | jmp exit_program |
493 | jmp exit_program |
493 | 494 | ||
494 | 495 | ||
495 | include 'system.inc' |
496 | include 'system.inc' |
496 | include 'version.inc' |
497 | include 'version.inc' |
497 | include 'errors.inc' |
498 | include 'errors.inc' |
498 | include 'expressi.inc' |
499 | include 'expressi.inc' |
499 | include 'preproce.inc' |
500 | include 'preproce.inc' |
500 | include 'parser.inc' |
501 | include 'parser.inc' |
501 | include 'assemble.inc' |
502 | include 'assemble.inc' |
502 | include 'formats.inc' |
503 | include 'formats.inc' |
503 | include 'x86_64.inc' |
504 | include 'x86_64.inc' |
504 | include 'tables.inc' |
505 | include 'tables.inc' |
505 | 506 | ||
506 | header db appname,VERSION_STRING,0 |
507 | title db appname,VERSION_STRING,0 |
507 | 508 | ||
508 | _logo db 'flat assembler version ',VERSION_STRING,13,10,0 |
509 | _logo db 'flat assembler version ',VERSION_STRING,13,10,0 |
509 | 510 | ||
510 | _passes_suffix db ' passes, ',0 |
511 | _passes_suffix db ' passes, ',0 |
511 | _seconds_suffix db ' seconds, ',0 |
512 | _seconds_suffix db ' seconds, ',0 |
512 | _bytes_suffix db ' bytes.',13,10,0 |
513 | _bytes_suffix db ' bytes.',13,10,0 |
513 | 514 | ||
514 | _include db 'INCLUDE',0 |
515 | _include db 'INCLUDE',0 |
515 | 516 | ||
516 | _counter db 4,'0000' |
517 | _counter db 4,'0000' |
517 | 518 | ||
518 | _mode dd NORMAL_MODE |
519 | _mode dd NORMAL_MODE |
519 | _run_outfile dd 0 |
520 | _run_outfile dd 0 |
520 | 521 | ||
521 | sub_table: |
522 | sub_table: |
522 | times $41 db $00 |
523 | times $41 db $00 |
523 | times $1A db $20 |
524 | times $1A db $20 |
524 | times $25 db $00 |
525 | times $25 db $00 |
525 | times $10 db $20 |
526 | times $10 db $20 |
526 | times $30 db $00 |
527 | times $30 db $00 |
527 | times $10 db $50 |
528 | times $10 db $50 |
528 | times $04 db $00,$01 |
529 | times $04 db $00,$01 |
529 | times $08 db $00 |
530 | times $08 db $00 |
530 | 531 | ||
531 | ;include_debug_strings |
532 | ;include_debug_strings |
532 | 533 | ||
533 | params db 0 ; 'TINYPAD.ASM,TINYPAD,/HD/1/TPAD4/', |
534 | params db 0 ; 'TINYPAD.ASM,TINYPAD,/HD/1/TPAD4/', |
534 | program_end: |
535 | program_end: |
535 | rb 1000h |
536 | rb 1000h |
536 | 537 | ||
537 | align 4 |
538 | align 4 |
538 | 539 | ||
539 | include 'variable.inc' |
540 | include 'variable.inc' |
540 | 541 | ||
541 | program_base dd ? |
542 | program_base dd ? |
542 | buffer_address dd ? |
543 | buffer_address dd ? |
543 | memory_setting dd ? |
544 | memory_setting dd ? |
544 | start_time dd ? |
545 | start_time dd ? |
545 | 546 | ||
546 | sc system_colors |
547 | sc system_colors |
547 | max_handles = 8 |
548 | max_handles = 8 |
548 | fileinfos rb (4+20+MAX_PATH)*max_handles |
549 | fileinfos rb (4+20+MAX_PATH)*max_handles |
549 | fileinfos_end: |
550 | fileinfos_end: |
550 | pinfo process_information |
551 | pinfo process_information |