Subversion Repositories Kolibri OS

Rev

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