Subversion Repositories Kolibri OS

Rev

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