Subversion Repositories Kolibri OS

Rev

Rev 949 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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