Subversion Repositories Kolibri OS

Rev

Rev 485 | Rev 1567 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 485 Rev 510
1
@^ fix macro comment {
1
@^ fix macro comment {
2
^@ fix }
2
^@ fix }
3
 
3
 
4
 
4
 
5
macro m2m dest,src {
5
macro m2m dest,src {
6
 push src
6
 push src
7
 pop  dest
7
 pop  dest
8
}
8
}
9
 
9
 
10
 
10
 
11
macro iglobal {
11
macro iglobal {
12
  IGlobals equ IGlobals,
12
  IGlobals equ IGlobals,
13
  macro __IGlobalBlock { }
13
  macro __IGlobalBlock { }
14
  
14
  
15
macro uglobal {
15
macro uglobal {
16
  UGlobals equ UGlobals,
16
  UGlobals equ UGlobals,
17
  macro __UGlobalBlock { }
17
  macro __UGlobalBlock { }
18
 
18
 
19
endg fix }      ; Use endg for ending iglobal and uglobal blocks.
19
endg fix }      ; Use endg for ending iglobal and uglobal blocks.
20
 
20
 
21
 
21
 
22
macro IncludeIGlobals{
22
macro IncludeIGlobals{
23
  macro IGlobals dummy,[n] \{ __IGlobalBlock
23
  macro IGlobals dummy,[n] \{ __IGlobalBlock
24
     purge __IGlobalBlock  \}
24
     purge __IGlobalBlock  \}
25
  match I, IGlobals \{ I \} }
25
  match I, IGlobals \{ I \} }
26
 
26
 
27
macro IncludeUGlobals{
27
macro IncludeUGlobals{
28
  macro UGlobals dummy,[n] \{
28
  macro UGlobals dummy,[n] \{
29
    \common
29
    \common
30
      \local begin, size
30
      \local begin, size
31
      begin = $
31
      begin = $
32
      virtual at $
32
      virtual at $
33
    \forward
33
    \forward
34
      __UGlobalBlock
34
      __UGlobalBlock
35
      purge __UGlobalBlock
35
      purge __UGlobalBlock
36
    \common
36
    \common
37
      size = $ - begin
37
      size = $ - begin
38
    end virtual
38
    end virtual
39
    rb size
39
    rb size
40
  \}
40
  \}
41
  match U, UGlobals \{ U \} }
41
  match U, UGlobals \{ U \} }
42
 
42
 
43
uglobal
43
uglobal
44
endg
44
endg
45
  
45
  
46
iglobal
46
iglobal
47
endg
47
endg
48
 
48
 
49
 
49
 
50
; new application structure
50
; new application structure
51
macro meos_app_start
51
macro meos_app_start
52
 {
52
 {
53
  use32
53
  use32
54
  org 0x0
54
  org 0x0
55
 
55
 
56
  db 'MENUET01'
56
  db 'MENUET01'
57
  dd 0x01
57
  dd 0x01
58
  dd __start
58
  dd __start
59
  dd __end
59
  dd __end
60
  dd __memory
60
  dd __memory
61
  dd __stack
61
  dd __stack
62
 
62
 
63
  if used __params & ~defined __params
63
  if used __params & ~defined __params
64
    dd __params
64
    dd __params
65
  else
65
  else
66
    dd 0x0
66
    dd 0x0
67
  end if
67
  end if
68
 
68
 
69
  dd 0x0
69
  dd 0x0
70
 }
70
 }
71
MEOS_APP_START fix meos_app_start
71
MEOS_APP_START fix meos_app_start
72
 
72
 
73
macro code
73
macro code
74
 {
74
 {
75
  __start:
75
  __start:
76
 }
76
 }
77
CODE fix code
77
CODE fix code
78
 
78
 
79
macro data
79
macro data
80
 {
80
 {
81
  __data:
81
  __data:
82
  IncludeIGlobals
82
  IncludeIGlobals
83
 }
83
 }
84
DATA fix data
84
DATA fix data
85
 
85
 
86
macro udata
86
macro udata
87
 {
87
 {
88
  if used __params & ~defined __params
88
  if used __params & ~defined __params
89
    __params:
89
    __params:
90
      db 0
90
      db 0
91
    __end:
91
    __end:
92
      rb 255
92
      rb 255
93
  else
93
  else
94
    __end:
94
    __end:
95
  end if
95
  end if
96
  __udata:
96
  __udata:
97
  IncludeUGlobals
97
  IncludeUGlobals
98
 }
98
 }
99
UDATA fix udata
99
UDATA fix udata
100
 
100
 
101
macro meos_app_end
101
macro meos_app_end
102
 {
102
 {
103
  align 32
103
  align 32
104
  rb 2048
104
  rb 2048
105
  __stack:
105
  __stack:
106
  __memory:
106
  __memory:
107
 }
107
 }
108
MEOS_APP_END fix meos_app_end
108
MEOS_APP_END fix meos_app_end
109
 
109
 
110
 
110
 
111
; macro for defining multiline text data
111
; macro for defining multiline text data
112
struc mstr [sstring]
112
struc mstr [sstring]
113
 {
113
 {
114
  forward
114
  forward
115
    local ssize
115
    local ssize
116
    virtual at 0
116
    virtual at 0
117
      db sstring
117
      db sstring
118
      ssize = $
118
      ssize = $
119
    end virtual
119
    end virtual
120
    dd ssize
120
    dd ssize
121
    db sstring
121
    db sstring
122
  common
122
  common
123
    dd -1
123
    dd -1
124
 }
124
 }
125
 
125
 
126
; macro for defining multiline text data
126
; macro for defining multiline text data
127
struc mls [sstring]
127
struc mls [sstring]
128
 {
128
 {
129
  forward
129
  forward
130
    local ssize
130
    local ssize
131
    virtual at 0
131
    virtual at 0
132
      db sstring  ; mod
132
      db sstring  ; mod
133
      ssize = $
133
      ssize = $
134
    end virtual
134
    end virtual
135
    db ssize
135
    db ssize
136
    db sstring
136
    db sstring
137
  common
137
  common
138
    db -1         ; mod
138
    db -1         ; mod
139
 }
139
 }
140
 
140
 
141
 
141
 
142
 
142
 
143
; strings
143
; strings
144
macro sz name,[data] {	     ; from MFAR [mike.dld]
144
macro sz name,[data] {	     ; from MFAR [mike.dld]
145
 common
145
 common
146
  if used name
146
  if used name
147
   name db data
147
   name db data
148
   .size = $-name
148
   .size = $-name
149
  end if
149
  end if
150
}
150
}
151
 
151
 
152
macro lsz name,[lng,data] {  ; from MFAR [mike.dld]
152
macro lsz name,[lng,data] {  ; from MFAR [mike.dld]
153
 common
153
 common
154
  if used name
154
  if used name
155
   label name
155
   label name
156
 forward
156
 forward
157
  if lang eq lng
157
  if lang eq lng
158
   db data
158
   db data
159
  end if
159
  end if
160
 common
160
 common
161
   .size = $-name
161
   .size = $-name
162
  end if
162
  end if
163
}
163
}
164
 
164
 
165
macro szc name,elsz,[data] {	     ; from MFAR [mike.dld]
165
macro szc name,elsz,[data] {	     ; from MFAR [mike.dld]
166
 common
166
 common
167
  local s,m
167
  local s,m
168
  m = 0
168
  m = 0
169
  if used name
169
  if used name
170
   label name
170
   label name
171
 forward
171
 forward
172
   virtual at 0
172
   virtual at 0
173
    db data
173
    db data
174
    s = $
174
    s = $
175
   end virtual
175
   end virtual
176
   d#elsz s
176
   d#elsz s
177
   if m < s
177
   if m < s
178
    m = s
178
    m = s
179
   end if
179
   end if
180
   db data
180
   db data
181
 common
181
 common
182
   .size = $-name
182
   .size = $-name
183
   .maxl = m
183
   .maxl = m
184
  end if
184
  end if
185
}
185
}
186
 
186
 
187
macro lszc name,elsz,[lng,data] {  ; from MFAR [mike.dld]
187
macro lszc name,elsz,[lng,data] {  ; from MFAR [mike.dld]
188
 common
188
 common
189
  local s,m,c
189
  local s,m,c
190
  m = 0
190
  m = 0
191
  c = 0
191
  c = 0
192
  if used name
192
  if used name
193
   label name
193
   label name
194
 forward
194
 forward
195
  if lang eq lng
195
  if lang eq lng
196
   virtual at 0
196
   virtual at 0
197
    db data
197
    db data
198
    s = $
198
    s = $
199
   end virtual
199
   end virtual
200
   d#elsz s
200
   d#elsz s
201
   if m < s
201
   if m < s
202
    m = s
202
    m = s
203
   end if
203
   end if
204
   db data
204
   db data
205
   c = c+1
205
   c = c+1
206
  end if
206
  end if
207
 common
207
 common
208
   .size  = $-name
208
   .size  = $-name
209
   .maxl  = m
209
   .maxl  = m
210
   .count = c
210
   .count = c
211
  end if
211
  end if
212
}
212
}
213
 
213
 
214
 
214
 
215
; easy system call macro
215
; easy system call macro
216
macro mpack dest, hsrc, lsrc
216
macro mpack dest, hsrc, lsrc
217
{
217
{
218
  if (hsrc eqtype 0) & (lsrc eqtype 0)
218
  if (hsrc eqtype 0) & (lsrc eqtype 0)
219
    mov dest, (hsrc) shl 16 + lsrc
219
    mov dest, (hsrc) shl 16 + lsrc
220
  else
220
  else
221
    if (hsrc eqtype 0) & (~lsrc eqtype 0)
221
    if (hsrc eqtype 0) & (~lsrc eqtype 0)
222
      mov dest, (hsrc) shl 16
222
      mov dest, (hsrc) shl 16
223
      add dest, lsrc
223
      add dest, lsrc
224
    else
224
    else
225
      mov dest, hsrc
225
      mov dest, hsrc
226
      shl dest, 16
226
      shl dest, 16
227
      add dest, lsrc
227
      add dest, lsrc
228
    end if
228
    end if
229
  end if
229
  end if
230
}
230
}
231
 
231
 
232
macro __mov reg,a,b {	    ; mike.dld
232
macro __mov reg,a,b {	    ; mike.dld
233
 if (~a eq)&(~b eq)
233
 if (~a eq)&(~b eq)
234
   mpack reg,a,b
234
   mpack reg,a,b
235
 else if (~a eq)&(b eq)
235
 else if (~a eq)&(b eq)
236
   mov reg,a
236
   mov reg,a
237
 end if
237
 end if
238
}
238
}
239
 
239
 
240
 
240
 
241
include 'config.inc'
241
include 'config.inc'
242
;__CPU_type	equ	p5
242
;__CPU_type	equ	p5
243
SYSENTER_VAR	equ	0
243
SYSENTER_VAR	equ	0
244
 
244
 
245
macro mcall a,b,c,d,e,f {   ; mike.dld, updated by Ghost for Fast System Calls
245
macro mcall a,b,c,d,e,f {   ; mike.dld, updated by Ghost for Fast System Calls
246
 local	..ret_point
246
 local	..ret_point
247
 __mov eax,a
247
 __mov eax,a
248
 __mov ebx,b
248
 __mov ebx,b
249
 __mov ecx,c
249
 __mov ecx,c
250
 __mov edx,d
250
 __mov edx,d
251
 __mov esi,e
251
 __mov esi,e
252
 __mov edi,f
252
 __mov edi,f
253
 
253
 
254
 if __CPU_type eq p5
254
 if __CPU_type eq p5
255
	int	0x40
255
	int	0x40
256
 else
256
 else
257
  if __CPU_type eq p6
257
  if __CPU_type eq p6
258
	push	ebp
258
	push	ebp
259
	mov	ebp, esp
259
	mov	ebp, esp
260
	push	..ret_point	; it may be 2 or 5 byte
260
	push	..ret_point	; it may be 2 or 5 byte
261
	sysenter
261
	sysenter
262
 ..ret_point:
262
 ..ret_point:
263
	pop	edx
263
	pop	edx
264
	pop	ecx
264
	pop	ecx
265
 
265
 
266
  else
266
  else
267
   if __CPU_type eq k6
267
   if __CPU_type eq k6
268
	push	ecx
268
	push	ecx
269
	syscall
269
	syscall
270
	pop	ecx
270
	pop	ecx
271
   else
271
   else
272
	display 'ERROR : unknown CPU type'
272
	display 'ERROR : unknown CPU type (set to p5)', 10, 13
-
 
273
	__CPU_type equ p5
273
	int	0x40
274
	int	0x40
274
   end if
275
   end if
275
  end if
276
  end if
276
 end if
277
 end if
277
}
278
}
278
 
279
 
279
 
280
 
280
; -------------------------
281
; -------------------------
281
macro header a,[b] {
282
macro header a,[b] {
282
 common
283
 common
283
  use32
284
  use32
284
  org 0
285
  org 0
285
  db 'MENUET',a
286
  db 'MENUET',a
286
 forward
287
 forward
287
  if b eq
288
  if b eq
288
   dd 0
289
   dd 0
289
  else
290
  else
290
   dd b
291
   dd b
291
  end if }
292
  end if }
292
macro section name { align 16
293
macro section name { align 16
293
 label name }
294
 label name }
294
macro func name {
295
macro func name {
295
 if ~used name
296
 if ~used name
296
  display 'FUNC NOT USED: ',`name,13,10
297
  display 'FUNC NOT USED: ',`name,13,10
297
 else
298
 else
298
  align 4
299
  align 4
299
  name:
300
  name:
300
  ;diff16 `name,0,name
301
  ;diff16 `name,0,name
301
;pushad
302
;pushad
302
;pushfd
303
;pushfd
303
;dps `name
304
;dps `name
304
;newline
305
;newline
305
;mcall 5,1
306
;mcall 5,1
306
;popfd
307
;popfd
307
;popad
308
;popad
308
}
309
}
309
macro endf { end if }
310
macro endf { end if }
310
 
311
 
311
macro diff16 title,l1,l2
312
macro diff16 title,l1,l2
312
 {
313
 {
313
  local s,d
314
  local s,d
314
  s = l2-l1
315
  s = l2-l1
315
  display title,': 0x'
316
  display title,': 0x'
316
  repeat 8
317
  repeat 8
317
   d = '0' + s shr ((8-%) shl 2) and $0F
318
   d = '0' + s shr ((8-%) shl 2) and $0F
318
   if d > '9'
319
   if d > '9'
319
    d = d + 'A'-'9'-1
320
    d = d + 'A'-'9'-1
320
   end if
321
   end if
321
   display d
322
   display d
322
  end repeat
323
  end repeat
323
  display 13,10
324
  display 13,10
324
 }
325
 }
325
 
326
 
326
macro diff10 title,l1,l2
327
macro diff10 title,l1,l2
327
 {
328
 {
328
  local s,d,z,m
329
  local s,d,z,m
329
  s = l2-l1
330
  s = l2-l1
330
  z = 0
331
  z = 0
331
  m = 1000000000
332
  m = 1000000000
332
  display title,': '
333
  display title,': '
333
  repeat 10
334
  repeat 10
334
   d = '0' + s / m
335
   d = '0' + s / m
335
   s = s - (s/m)*m
336
   s = s - (s/m)*m
336
   m = m / 10
337
   m = m / 10
337
   if d <> '0'
338
   if d <> '0'
338
    z = 1
339
    z = 1
339
   end if
340
   end if
340
   if z <> 0
341
   if z <> 0
341
    display d
342
    display d
342
   end if
343
   end if
343
  end repeat
344
  end repeat
344
  display 13,10
345
  display 13,10
345
 }
346
 }
346
 
347
 
347
; optimize the code for size
348
; optimize the code for size
348
__regs fix 
349
__regs fix 
349
 
350
 
350
macro add arg1,arg2
351
macro add arg1,arg2
351
 {
352
 {
352
   if (arg2 eqtype 0)
353
   if (arg2 eqtype 0)
353
      if (arg2) = 1
354
      if (arg2) = 1
354
	 inc arg1
355
	 inc arg1
355
      else
356
      else
356
	 add arg1,arg2
357
	 add arg1,arg2
357
      end if
358
      end if
358
   else
359
   else
359
      add arg1,arg2
360
      add arg1,arg2
360
   end if
361
   end if
361
 }
362
 }
362
 
363
 
363
macro sub arg1,arg2
364
macro sub arg1,arg2
364
 {
365
 {
365
   if (arg2 eqtype 0)
366
   if (arg2 eqtype 0)
366
      if (arg2) = 1
367
      if (arg2) = 1
367
	 dec arg1
368
	 dec arg1
368
      else
369
      else
369
	 sub arg1,arg2
370
	 sub arg1,arg2
370
      end if
371
      end if
371
   else
372
   else
372
      sub arg1,arg2
373
      sub arg1,arg2
373
   end if
374
   end if
374
 }
375
 }
375
 
376
 
376
macro mov arg1,arg2
377
macro mov arg1,arg2
377
 {
378
 {
378
   if (arg1 in __regs) & ((arg2 eqtype 0) | (arg2 eqtype '0'))
379
   if (arg1 in __regs) & ((arg2 eqtype 0) | (arg2 eqtype '0'))
379
      if (arg2) = 0
380
      if (arg2) = 0
380
	 xor arg1,arg1
381
	 xor arg1,arg1
381
      else if (arg2) = 1
382
      else if (arg2) = 1
382
	 xor arg1,arg1
383
	 xor arg1,arg1
383
	 inc arg1
384
	 inc arg1
384
      else if (arg2) = -1
385
      else if (arg2) = -1
385
	 or  arg1,-1
386
	 or  arg1,-1
386
      else if (arg2) > -128 & (arg2) < 128
387
      else if (arg2) > -128 & (arg2) < 128
387
	 push arg2
388
	 push arg2
388
	 pop  arg1
389
	 pop  arg1
389
      else
390
      else
390
	 mov  arg1,arg2
391
	 mov  arg1,arg2
391
      end if
392
      end if
392
   else
393
   else
393
      mov arg1,arg2
394
      mov arg1,arg2
394
   end if
395
   end if
395
 }
396
 }
396
 
397
 
397
 
398
 
398
macro RGB [a] {
399
macro RGB [a] {
399
 common
400
 common
400
  match (r=,g=,b),a \{
401
  match (r=,g=,b),a \{
401
   \dd ((r) shl 16) or ((g) shl 8) or (b)
402
   \dd ((r) shl 16) or ((g) shl 8) or (b)
402
  \}
403
  \}
403
}
404
}
404
 
405
 
405
 
406
 
406
struc POINT _t,_dx,_dy {
407
struc POINT _t,_dx,_dy {
407
 .x _t _dx
408
 .x _t _dx
408
 .y _t _dy
409
 .y _t _dy
409
}
410
}
410
 
411
 
411
; structure definition helper
412
; structure definition helper
412
include 'struct.inc'
413
include 'struct.inc'
413
 
414
 
414
struct RECT
415
struct RECT
415
  left	 dd ?
416
  left	 dd ?
416
  top	 dd ?
417
  top	 dd ?
417
  right  dd ?
418
  right  dd ?
418
  bottom dd ?
419
  bottom dd ?
419
ends
420
ends
420
 
421
 
421
struct BOX
422
struct BOX
422
  left	 dd ?
423
  left	 dd ?
423
  top	 dd ?
424
  top	 dd ?
424
  width  dd ?
425
  width  dd ?
425
  height dd ?
426
  height dd ?
426
ends
427
ends
427
 
428
 
428
; structures used in MeOS
429
; structures used in MeOS
429
struct process_information
430
struct process_information
430
  cpu_usage		  dd ?	; +0
431
  cpu_usage		  dd ?	; +0
431
  window_stack_position   dw ?	; +4
432
  window_stack_position   dw ?	; +4
432
  window_stack_value	  dw ?	; +6
433
  window_stack_value	  dw ?	; +6
433
			  dw ?	; +8
434
			  dw ?	; +8
434
  process_name		  rb 12 ; +10
435
  process_name		  rb 12 ; +10
435
  memory_start		  dd ?	; +22
436
  memory_start		  dd ?	; +22
436
  used_memory		  dd ?	; +26
437
  used_memory		  dd ?	; +26
437
  PID			  dd ?	; +30
438
  PID			  dd ?	; +30
438
  box			  BOX	; +34
439
  box			  BOX	; +34
439
  slot_state		  dw ?	; +50
440
  slot_state		  dw ?	; +50
440
			  dw ?	; +52
441
			  dw ?	; +52
441
  client_box		  BOX	; +54
442
  client_box		  BOX	; +54
442
  wnd_state               db ?  ; +70
443
  wnd_state               db ?  ; +70
443
  rb (1024-71)
444
  rb (1024-71)
444
ends
445
ends
445
 
446
 
446
struct system_colors
447
struct system_colors
447
  frame 	   dd ?
448
  frame 	   dd ?
448
  grab		   dd ?
449
  grab		   dd ?
449
  grab_button	   dd ?
450
  grab_button	   dd ?
450
  grab_button_text dd ?
451
  grab_button_text dd ?
451
  grab_text	   dd ?
452
  grab_text	   dd ?
452
  work		   dd ?
453
  work		   dd ?
453
  work_button	   dd ?
454
  work_button	   dd ?
454
  work_button_text dd ?
455
  work_button_text dd ?
455
  work_text	   dd ?
456
  work_text	   dd ?
456
  work_graph	   dd ?
457
  work_graph	   dd ?
457
ends
458
ends
458
 
459
 
459
struct FILEDATE
460
struct FILEDATE
460
  Second db ?
461
  Second db ?
461
  Minute db ?
462
  Minute db ?
462
  Hour	 db ?
463
  Hour	 db ?
463
	 db ?
464
	 db ?
464
  Day	 db ?
465
  Day	 db ?
465
  Month  db ?
466
  Month  db ?
466
  Year	 dw ?
467
  Year	 dw ?
467
ends
468
ends
468
 
469
 
469
struct FILEINFO
470
struct FILEINFO
470
  Attributes dd ?
471
  Attributes dd ?
471
  IsUnicode  db ?
472
  IsUnicode  db ?
472
	     db 3 dup(?)
473
	     db 3 dup(?)
473
  DateCreate FILEDATE
474
  DateCreate FILEDATE
474
  DateAccess FILEDATE
475
  DateAccess FILEDATE
475
  DateModify FILEDATE
476
  DateModify FILEDATE
476
  Size	     dq ?
477
  Size	     dq ?
477
ends
478
ends
478
 
479
 
479
; constants
480
; constants
480
 
481
 
481
; events
482
; events
482
EV_IDLE        = 0
483
EV_IDLE        = 0
483
EV_TIMER       = 0
484
EV_TIMER       = 0
484
EV_REDRAW      = 1
485
EV_REDRAW      = 1
485
EV_KEY	       = 2
486
EV_KEY	       = 2
486
EV_BUTTON      = 3
487
EV_BUTTON      = 3
487
EV_EXIT        = 4
488
EV_EXIT        = 4
488
EV_BACKGROUND  = 5
489
EV_BACKGROUND  = 5
489
EV_MOUSE       = 6
490
EV_MOUSE       = 6
490
EV_IPC	       = 7
491
EV_IPC	       = 7
491
EV_STACK       = 8
492
EV_STACK       = 8
492
 
493
 
493
; event mask bits for function 40
494
; event mask bits for function 40
494
EVM_REDRAW     =	1b
495
EVM_REDRAW     =	1b
495
EVM_KEY        =       10b
496
EVM_KEY        =       10b
496
EVM_BUTTON     =      100b
497
EVM_BUTTON     =      100b
497
EVM_EXIT       =     1000b
498
EVM_EXIT       =     1000b
498
EVM_BACKGROUND =    10000b
499
EVM_BACKGROUND =    10000b
499
EVM_MOUSE      =   100000b
500
EVM_MOUSE      =   100000b
500
EVM_IPC        =  1000000b
501
EVM_IPC        =  1000000b
501
EVM_STACK      = 10000000b
502
EVM_STACK      = 10000000b