Subversion Repositories Kolibri OS

Rev

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