Subversion Repositories Kolibri OS

Rev

Rev 1361 | 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
 
1363 IgorA 268
    mov eax,dword[pinfo.box.width]
269
    cmp eax,250
270
    jge @f
271
      mov eax,250
272
    @@:
273
    sub eax,127
274
    mov dword[edit1.width],eax
275
    mov dword[edit2.width],eax
276
    mov dword[edit3.width],eax
277
 
1361 IgorA 278
    push dword edit1
279
    call [edit_box_draw]
280
    push dword edit2
281
    call [edit_box_draw]
282
    push dword edit3
283
    call [edit_box_draw]
31 halyavin 284
 
285
    mcall  12,2 ; End of Draw
286
 
287
    popa
288
    ret
289
 
290
bottom_right dd ?
291
 
542 diamond 292
draw_checkbox:
1361 IgorA 293
	mcall	8,<5,10>,<14*3+5,10>,14,[sc.work_button]
294
	cmp	[bGenerateDebugInfo], 0
295
	jz	@f
296
	mov	edx, [sc.work_button_text]
297
	mcall	38,<7,13>,<14*3+7,14*3+13>
298
	mcall	38,,<14*3+13,14*3+7>
542 diamond 299
@@:
1361 IgorA 300
	mov	ecx, [sc.work_text]
301
	or	ecx, 0x80000000
302
	mcall	4,<20,14*3+7>,,s_dbgdescr
303
	ret
542 diamond 304
 
31 halyavin 305
draw_messages:
306
    mov    eax,13      ; clear work area
502 heavyiron 307
    mpack  ebx,7-2,[pinfo.box.width]
370 heavyiron 308
    sub    ebx,5*2+7*2-1-2*2
502 heavyiron 309
    mpack  ecx,0,[pinfo.box.height]
542 diamond 310
    madd   ecx, 14*3+16+1+7+1,-( 14*3+16+1+7*2+25)
31 halyavin 311
    mov    word[bottom_right+2],bx
312
    mov    word[bottom_right],cx
313
    msub   [bottom_right],7,11
370 heavyiron 314
    add    [bottom_right],7 shl 16 + 53
31 halyavin 315
    mov    edx,[sc.work]
485 heavyiron 316
    mcall
31 halyavin 317
_cy = 0
318
_sy = 2
319
_cx = 4
320
_sx = 6
321
    push   ebx ecx
370 heavyiron 322
    mpack  ebx,4,5
31 halyavin 323
    add    bx,[esp+_cx]
324
    mov    ecx,[esp+_sy-2]
325
    mov    cx,[esp+_sy]
326
    msub   ecx,1,1
327
    mcall  38,,,[sc.work_graph]
328
    mov    si,[esp+_cy]
329
    add    cx,si
330
    shl    esi,16
331
    add    ecx,esi
332
    madd   ecx,1,1
333
    mcall
370 heavyiron 334
    mpack  ebx,4,4
31 halyavin 335
    mov    esi,[esp+_sy-2]
336
    mov    si,cx
337
    mov    ecx,esi
338
    mcall
339
    mov    si,[esp+_cx]
340
    add    bx,si
341
    shl    esi,16
342
    add    ebx,esi
343
    madd   ebx,1,1
344
    mcall
345
    pop    ecx ebx
346
    ret
347
 
348
 
1361 IgorA 349
; DATA
31 halyavin 350
 
1361 IgorA 351
if lang eq ru
352
text:
353
  db ' ВхФайл:'
354
.line_size = $-text
355
  db 'ВыхФайл:'
356
  db '   Путь:'
357
  db 'x'
31 halyavin 358
 
1361 IgorA 359
  s_compile db 'Компил.'
360
  s_run     db ' Пуск  '
361
  s_debug   db 'Отладка'
362
  s_dbgdescr	  db	  'Создавать отладочную информацию',0
31 halyavin 363
 
1361 IgorA 364
  err_message_import db 'Ошибка при импорте box_lib.obj',0
365
  err_message_found_lib db 'Ошибка при поиске box_lib.obj',0 ;строка, которая будет в сформированном окне, если библиотека не будет найдена
366
  head_f_i:
367
  head_f_l db 'Системная ошибка',0 ;заголовок окна, при возникновении ошибки
368
  system_path db '/sys/lib/'
369
  library_name db 'box_lib.obj',0
370
else
371
text:
372
  db ' INFILE:'
373
.line_size = $-text
374
  db 'OUTFILE:'
375
  db '   PATH:'
376
  db 'x'
31 halyavin 377
 
1361 IgorA 378
  s_compile db 'COMPILE'
379
  s_run     db '  RUN  '
380
  s_debug   db ' DEBUG '
381
  s_dbgdescr	  db	  'Generate debug information',0
31 halyavin 382
 
1361 IgorA 383
  err_message_import db 'Error on load import library box_lib.obj',0
384
  err_message_found_lib db 'Sorry I cannot found library box_lib.obj',0 ;строка, которая будет в сформированном окне, если библиотека не будет найдена
385
  head_f_i:
386
  head_f_l db 'System error',0 ;заголовок окна, при возникновении ошибки
387
  system_path db '/sys/lib/'
388
  library_name db 'box_lib.obj',0
389
end if
31 halyavin 390
 
1361 IgorA 391
myimport:
392
  edit_box_draw  dd aEdit_box_draw
393
  edit_box_key	 dd aEdit_box_key
394
  edit_box_mouse dd aEdit_box_mouse
395
  ;version_ed     dd aVersion_ed
31 halyavin 396
 
1361 IgorA 397
  ;check_box_draw  dd aCheck_box_draw
398
  ;check_box_mouse dd aCheck_box_mouse
399
  ;version_ch      dd aVersion_ch
31 halyavin 400
 
1361 IgorA 401
  dd 0,0
31 halyavin 402
 
1361 IgorA 403
  aEdit_box_draw  db 'edit_box',0
404
  aEdit_box_key   db 'edit_box_key',0
405
  aEdit_box_mouse db 'edit_box_mouse',0
406
  ;aVersion_ed     db 'version_ed',0
31 halyavin 407
 
1361 IgorA 408
  ;aCheck_box_draw  db 'check_box_draw',0
409
  ;aCheck_box_mouse db 'check_box_mouse',0
410
  ;aVersion_ch      db 'version_ch',0
31 halyavin 411
 
1363 IgorA 412
edit1 edit_box 153, 56, 1, 0xffffff, 0xff, 0x80ff, 0, 0xa000, MAX_PATH+$, infile, mouse_dd, 0, 11,11
413
edit2 edit_box 153, 56, 17, 0xffffff, 0xff, 0x80ff, 0, 0xa000, MAX_PATH+$, outfile, mouse_dd, 0, 7,7
414
edit3 edit_box 153, 56, 33, 0xffffff, 0xff, 0x80ff, 0, 0xa000, MAX_PATH+$, path, mouse_dd, 0, 6,6
31 halyavin 415
 
1361 IgorA 416
mouse_dd dd 0 ;эєцэю фы  Shift-р т editbox
31 halyavin 417
 
205 heavyiron 418
infile	  db 'example.asm'
31 halyavin 419
  times MAX_PATH+$-infile  db 0
205 heavyiron 420
outfile db 'example'
31 halyavin 421
  times MAX_PATH+$-outfile db 0
542 diamond 422
path	db '/rd/1/'
31 halyavin 423
  times MAX_PATH+$-path    db 0
424
 
425
lf db 13,10,0
426
 
427
addr dd 0x0
428
ya   dd 0x0
429
zero db 0x0
430
 
431
mov_param_str:
432
  @@:
433
    mov    al,[esi]
434
    cmp    al,','
109 heavyiron 435
    je	     @f
31 halyavin 436
    cmp    al,0
109 heavyiron 437
    je	     @f
31 halyavin 438
    mov    [edi],al
439
    inc    esi
440
    inc    edi
441
    jmp    @b
442
  @@:
443
    mov    al,0
444
    stosb
445
ret
446
 
447
start:
448
    cmp    [_mode],NORMAL_MODE
449
    jne    @f
450
    call   draw_messages
542 diamond 451
    mov    [textxy],7 shl 16 + 70
31 halyavin 452
@@:
453
    mov    esi,_logo
454
    call   display_string
455
 
456
 ;
457
 ;   Fasm native code
458
 ;
459
 
460
    mov    [input_file],infile
461
    mov    [output_file],outfile
462
 
463
    call   init_memory
464
 
465
    call   make_timestamp
466
    mov    [start_time],eax
467
 
468
    call   preprocessor
469
    call   parser
470
    call   assembler
542 diamond 471
    cmp    [bGenerateDebugInfo], 0
1361 IgorA 472
    jz	   @f
542 diamond 473
    call   symbol_dump
474
@@:
31 halyavin 475
    call   formatter
476
 
477
    call   display_user_messages
478
    movzx  eax,[current_pass]
479
    inc    eax
480
    call   display_number
481
    mov    esi,_passes_suffix
482
    call   display_string
483
    call   make_timestamp
484
    sub    eax,[start_time]
485
    xor    edx,edx
486
    mov    ebx,100
487
    div    ebx
109 heavyiron 488
    or	     eax,eax
489
    jz	     display_bytes_count
31 halyavin 490
    xor    edx,edx
491
    mov    ebx,10
492
    div    ebx
493
    push   edx
494
    call   display_number
495
    mov    dl,'.'
496
    call   display_character
497
    pop    eax
498
    call   display_number
499
    mov    esi,_seconds_suffix
500
    call   display_string
501
  display_bytes_count:
502
    mov    eax,[written_size]
503
    call   display_number
504
    mov    esi,_bytes_suffix
505
    call   display_string
506
    xor    al,al
507
 
508
    cmp    [_run_outfile],0
1361 IgorA 509
    je	   @f
31 halyavin 510
    mov    edx,outfile
511
    call   make_fullpaths
174 heavyiron 512
    mov    eax,70
31 halyavin 513
    mov    ebx,file_info_start
514
    xor    ecx,ecx
485 heavyiron 515
    mcall
31 halyavin 516
@@:
517
    jmp    exit_program
518
 
519
 
520
include 'system.inc'
521
include 'version.inc'
522
include 'errors.inc'
523
include 'expressi.inc'
524
include 'preproce.inc'
525
include 'parser.inc'
526
include 'assemble.inc'
527
include 'formats.inc'
528
include 'x86_64.inc'
109 heavyiron 529
include 'tables.inc'
542 diamond 530
include 'symbdump.inc'
692 heavyiron 531
include 'messages.inc'
31 halyavin 532
 
485 heavyiron 533
title db appname,VERSION_STRING,0
196 heavyiron 534
 
31 halyavin 535
_logo db 'flat assembler  version ',VERSION_STRING,13,10,0
536
 
537
_passes_suffix db ' passes, ',0
538
_seconds_suffix db ' seconds, ',0
539
_bytes_suffix db ' bytes.',13,10,0
540
 
541
_include db 'INCLUDE',0
542
 
543
_counter db 4,'0000'
544
 
109 heavyiron 545
_mode	       dd NORMAL_MODE
31 halyavin 546
_run_outfile  dd 0
542 diamond 547
bGenerateDebugInfo db 0
31 halyavin 548
 
549
sub_table:
550
times $41 db $00
551
times $1A db $20
552
times $25 db $00
553
times $10 db $20
554
times $30 db $00
555
times $10 db $50
556
times $04 db $00,$01
557
times $08 db $00
558
 
559
;include_debug_strings
560
 
1361 IgorA 561
  params db 0 ; 'TINYPAD.ASM,TINYPAD,/HD/1/TPAD4/',
562
  cur_dir_path rb 4096
563
  library_path rb 4096
564
 
31 halyavin 565
program_end:
1361 IgorA 566
 
31 halyavin 567
rb 1000h
568
align 4
569
 
570
include 'variable.inc'
571
 
572
program_base dd ?
573
buffer_address dd ?
574
memory_setting dd ?
575
start_time dd ?
755 diamond 576
memblock	dd	?
31 halyavin 577
 
692 heavyiron 578
predefinitions rb 1000h
579
 
1361 IgorA 580
dbgfilename	rb	MAX_PATH+4
542 diamond 581
 
31 halyavin 582
sc    system_colors
332 diamond 583
max_handles = 8
584
fileinfos rb (4+20+MAX_PATH)*max_handles
585
fileinfos_end:
31 halyavin 586
pinfo process_information
635 diamond 587
 
588
align 1000h
589
rb 1000h
590
stacktop: