Subversion Repositories Kolibri OS

Rev

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

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