Subversion Repositories Kolibri OS

Rev

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

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