Subversion Repositories Kolibri OS

Rev

Rev 332 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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