Subversion Repositories Kolibri OS

Rev

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

Rev 9472 Rev 9604
1
@^ fix macro comment {
1
@^ fix macro comment {
2
^@ fix }
2
^@ fix }
3
 
3
 
4
; --------------------------
4
; --------------------------
5
macro library [lname,fname]
5
macro library [lname,fname]
6
{
6
{
7
  forward
7
  forward
8
    dd __#lname#_library_table__,__#lname#_library_name__
8
    dd __#lname#_library_table__,__#lname#_library_name__
9
  common
9
  common
10
    dd 0
10
    dd 0
11
  forward
11
  forward
12
    align 4
12
    align 4
13
    __#lname#_library_name__ db fname,0
13
    __#lname#_library_name__ db fname,0
14
}
14
}
15
 
15
 
16
macro import lname,[name,sname]
16
macro import lname,[name,sname]
17
{
17
{
18
  common
18
  common
19
    align 4
19
    align 4
20
    __#lname#_library_table__:
20
    __#lname#_library_table__:
21
  forward
21
  forward
22
    if used name
22
    if used name
23
      name dd __#name#_import_name__
23
      name dd __#name#_import_name__
24
    end if
24
    end if
25
  common
25
  common
26
    dd 0
26
    dd 0
27
  forward
27
  forward
28
    if used name
28
    if used name
29
      align 4
29
      align 4
30
      __#name#_import_name__ db sname,0
30
      __#name#_import_name__ db sname,0
31
    end if
31
    end if
32
}
32
}
33
 
33
 
34
macro export [name,sname]
34
macro export [name,sname]
35
{
35
{
36
  forward
36
  forward
37
    dd __#name#_export_name__,name
37
    dd __#name#_export_name__,name
38
  common
38
  common
39
    dd 0
39
    dd 0
40
  forward
40
  forward
41
    align 4
41
    align 4
42
    __#name#_export_name__ db sname,0
42
    __#name#_export_name__ db sname,0
43
}
43
}
44
; -------------------------
44
; -------------------------
45
 
45
 
46
macro m2m dest,src {
46
macro m2m dest,src {
47
 push src
47
 push src
48
 pop  dest
48
 pop  dest
49
}
49
}
50
 
50
 
51
 
51
 
52
macro iglobal {
52
macro iglobal {
53
  IGlobals equ IGlobals,
53
  IGlobals equ IGlobals,
54
  macro __IGlobalBlock { }
54
  macro __IGlobalBlock { }
55
 
55
 
56
macro uglobal {
56
macro uglobal {
57
  UGlobals equ UGlobals,
57
  UGlobals equ UGlobals,
58
  macro __UGlobalBlock { }
58
  macro __UGlobalBlock { }
59
 
59
 
60
endg fix }      ; Use endg for ending iglobal and uglobal blocks.
60
endg fix }      ; Use endg for ending iglobal and uglobal blocks.
61
 
61
 
62
 
62
 
63
macro IncludeIGlobals{
63
macro IncludeIGlobals{
64
  macro IGlobals dummy,[n] \{ __IGlobalBlock
64
  macro IGlobals dummy,[n] \{ __IGlobalBlock
65
     purge __IGlobalBlock  \}
65
     purge __IGlobalBlock  \}
66
  match I, IGlobals \{ I \} }
66
  match I, IGlobals \{ I \} }
67
 
67
 
68
macro IncludeUGlobals{
68
macro IncludeUGlobals{
69
  macro UGlobals dummy,[n] \{
69
  macro UGlobals dummy,[n] \{
70
    \common
70
    \common
71
      \local begin, size
71
      \local begin, size
72
      begin = $
72
      begin = $
73
      virtual at $
73
      virtual at $
74
    \forward
74
    \forward
75
      __UGlobalBlock
75
      __UGlobalBlock
76
      purge __UGlobalBlock
76
      purge __UGlobalBlock
77
    \common
77
    \common
78
      size = $ - begin
78
      size = $ - begin
79
    end virtual
79
    end virtual
80
    rb size
80
    rb size
81
  \}
81
  \}
82
  match U, UGlobals \{ U \} }
82
  match U, UGlobals \{ U \} }
83
 
83
 
84
uglobal
84
uglobal
85
endg
85
endg
86
 
86
 
87
iglobal
87
iglobal
88
endg
88
endg
89
 
89
 
90
 
90
 
91
; new application structure
91
; new application structure
92
macro meos_app_start
92
macro meos_app_start
93
 {
93
 {
94
  use32
94
  use32
95
  org 0x0
95
  org 0x0
96
 
96
 
97
  db 'MENUET01'
97
  db 'MENUET01'
98
  dd 0x01
98
  dd 0x01
99
  dd __start
99
  dd __start
100
  dd __end
100
  dd __end
101
  dd __memory
101
  dd __memory
102
  dd __stack
102
  dd __stack
103
 
103
 
104
  if used __params & ~defined __params
104
  if used __params & ~defined __params
105
    dd __params
105
    dd __params
106
  else
106
  else
107
    dd 0x0
107
    dd 0x0
108
  end if
108
  end if
109
 
109
 
110
  dd 0x0
110
  dd 0x0
111
 }
111
 }
112
MEOS_APP_START fix meos_app_start
112
MEOS_APP_START fix meos_app_start
113
KOS_APP_START fix meos_app_start
113
KOS_APP_START fix meos_app_start
114
 
114
 
115
macro code
115
macro code
116
 {
116
 {
117
  __start:
117
  __start:
118
 }
118
 }
119
CODE fix code
119
CODE fix code
120
 
120
 
121
macro data
121
macro data
122
 {
122
 {
123
  __data:
123
  __data:
124
  IncludeIGlobals
124
  IncludeIGlobals
125
 }
125
 }
126
DATA fix data
126
DATA fix data
127
 
127
 
128
macro udata
128
macro udata
129
 {
129
 {
130
  if used __params & ~defined __params
130
  if used __params & ~defined __params
131
    __params:
131
    __params:
132
      db 0
132
      db 0
133
    __end:
133
    __end:
134
      rb 255
134
      rb 255
135
  else
135
  else
136
    __end:
136
    __end:
137
  end if
137
  end if
138
  __udata:
138
  __udata:
139
  IncludeUGlobals
139
  IncludeUGlobals
140
 }
140
 }
141
UDATA fix udata
141
UDATA fix udata
142
 
142
 
143
macro meos_app_end
143
macro meos_app_end
144
 {
144
 {
145
  align 32
145
  align 32
146
  rb 2048
146
  rb 2048
147
  __stack:
147
  __stack:
148
  __memory:
148
  __memory:
149
 }
149
 }
150
MEOS_APP_END fix meos_app_end
150
MEOS_APP_END fix meos_app_end
151
KOS_APP_END fix meos_app_end
151
KOS_APP_END fix meos_app_end
152
 
152
 
153
 
153
 
154
; macro for defining multiline text data
154
; macro for defining multiline text data
155
struc mstr [sstring]
155
struc mstr [sstring]
156
 {
156
 {
157
  forward
157
  forward
158
    local ssize
158
    local ssize
159
    virtual at 0
159
    virtual at 0
160
      db sstring
160
      db sstring
161
      ssize = $
161
      ssize = $
162
    end virtual
162
    end virtual
163
    dd ssize
163
    dd ssize
164
    db sstring
164
    db sstring
165
  common
165
  common
166
    dd -1
166
    dd -1
167
 }
167
 }
168
 
168
 
169
; macro for defining multiline text data
169
; macro for defining multiline text data
170
struc mls [sstring]
170
struc mls [sstring]
171
 {
171
 {
172
  forward
172
  forward
173
    local ssize
173
    local ssize
174
    virtual at 0
174
    virtual at 0
175
      db sstring  ; mod
175
      db sstring  ; mod
176
      ssize = $
176
      ssize = $
177
    end virtual
177
    end virtual
178
    db ssize
178
    db ssize
179
    db sstring
179
    db sstring
180
  common
180
  common
181
    db -1         ; mod
181
    db -1         ; mod
182
 }
182
 }
183
 
183
 
184
 
184
 
185
 
185
 
186
; strings
186
; strings
187
macro sz name,[data] {       ; [mike.dld]
187
macro sz name,[data] {       ; [mike.dld]
188
 common
188
 common
189
  if used name
189
  if used name
190
   name db data
190
   name db data
191
   .size = $-name
191
   .size = $-name
192
  end if
192
  end if
193
}
193
}
194
 
194
 
195
macro szZ name,[data] {      ; same as sz, but for zero terminated string [dunkaist]
195
macro szZ name,[data] {      ; same as sz, but for zero terminated string [dunkaist]
196
 common
196
 common
197
  if used name
197
  if used name
198
   name db data,0
198
   name db data,0
199
   .size = $-name-1
199
   .size = $-name-1
200
  end if
200
  end if
201
}
201
}
202
sz0 fix szZ
202
sz0 fix szZ
203
 
203
 
204
macro lsz name,[lng,data] {  ; [mike.dld]
204
macro lsz name,[lng,data] {  ; [mike.dld]
205
 common
205
 common
206
  if used name
206
  if used name
207
   label name
207
   label name
208
 forward
208
 forward
209
  if lang eq lng
209
  if lang eq lng
210
   db data
210
   db data
211
  end if
211
  end if
212
 common
212
 common
213
   .size = $-name
213
   .size = $-name
214
  end if
214
  end if
215
}
215
}
216
 
216
 
217
macro szc name,elsz,[data] {     ; [mike.dld]
217
macro szc name,elsz,[data] {     ; [mike.dld]
218
 common
218
 common
219
  local s,m
219
  local s,m
220
  m = 0
220
  m = 0
221
  if used name
221
  if used name
222
   label name
222
   label name
223
 forward
223
 forward
224
   virtual at 0
224
   virtual at 0
225
    db data
225
    db data
226
    s = $
226
    s = $
227
   end virtual
227
   end virtual
228
   d#elsz s
228
   d#elsz s
229
   if m < s
229
   if m < s
230
    m = s
230
    m = s
231
   end if
231
   end if
232
   db data
232
   db data
233
 common
233
 common
234
   .size = $-name
234
   .size = $-name
235
   .maxl = m
235
   .maxl = m
236
  end if
236
  end if
237
}
237
}
238
 
238
 
239
macro lszc name,elsz,[lng,data] {  ; [mike.dld]
239
macro lszc name,elsz,[lng,data] {  ; [mike.dld]
240
 common
240
 common
241
  local s,m,c
241
  local s,m,c
242
  m = 0
242
  m = 0
243
  c = 0
243
  c = 0
244
  if used name
244
  if used name
245
   label name
245
   label name
246
 forward
246
 forward
247
  if lang eq lng
247
  if lang eq lng
248
   virtual at 0
248
   virtual at 0
249
    db data
249
    db data
250
    s = $
250
    s = $
251
   end virtual
251
   end virtual
252
   d#elsz s
252
   d#elsz s
253
   if m < s
253
   if m < s
254
    m = s
254
    m = s
255
   end if
255
   end if
256
   db data
256
   db data
257
   c = c+1
257
   c = c+1
258
  end if
258
  end if
259
 common
259
 common
260
   .size  = $-name
260
   .size  = $-name
261
   .maxl  = m
261
   .maxl  = m
262
   .count = c
262
   .count = c
263
  end if
263
  end if
264
}
264
}
265
 
265
 
266
 
266
 
267
; easy system call macro
267
; easy system call macro
268
macro mpack dest, hsrc, lsrc
268
macro mpack dest, hsrc, lsrc
269
{
269
{
270
  if (hsrc eqtype 0) & (lsrc eqtype 0)
270
  if (hsrc eqtype 0) & (lsrc eqtype 0)
271
    mov dest, (hsrc) shl 16 + lsrc
271
    mov dest, (hsrc) shl 16 + lsrc
272
  else
272
  else
273
    if (hsrc eqtype 0) & (~lsrc eqtype 0)
273
    if (hsrc eqtype 0) & (~lsrc eqtype 0)
274
      mov dest, (hsrc) shl 16
274
      mov dest, (hsrc) shl 16
275
      add dest, lsrc
275
      add dest, lsrc
276
    else
276
    else
277
      mov dest, hsrc
277
      mov dest, hsrc
278
      shl dest, 16
278
      shl dest, 16
279
      add dest, lsrc
279
      add dest, lsrc
280
    end if
280
    end if
281
  end if
281
  end if
282
}
282
}
283
 
283
 
284
macro __mov reg,a,b {       ; mike.dld
284
macro __mov reg,a,b {       ; mike.dld
285
 if (~a eq)&(~b eq)
285
 if (~a eq)&(~b eq)
286
   mpack reg,a,b
286
   mpack reg,a,b
287
 else if (~a eq)&(b eq)
287
 else if (~a eq)&(b eq)
288
   mov reg,a
288
   mov reg,a
289
 end if
289
 end if
290
}
290
}
291
 
291
 
292
 
292
 
293
include 'config.inc'
293
;include 'config.inc'
294
;__CPU_type equ p5
294
__CPU_type equ p5
295
SYSENTER_VAR    equ 0
295
SYSENTER_VAR    equ 0
296
 
296
 
297
macro mcall a,b,c,d,e,f,g {   ; [mike.dld], [Ghost]
297
macro mcall a,b,c,d,e,f,g {   ; [mike.dld], [Ghost]
298
 local  ..ret_point
298
 local  ..ret_point
299
 __mov eax,a
299
 __mov eax,a
300
 __mov ebx,b
300
 __mov ebx,b
301
 __mov ecx,c
301
 __mov ecx,c
302
 __mov edx,d
302
 __mov edx,d
303
 __mov esi,e
303
 __mov esi,e
304
 __mov edi,f
304
 __mov edi,f
305
 __mov ebp,g
305
 __mov ebp,g
306
 
306
 
307
 if __CPU_type eq p5
307
 if __CPU_type eq p5
308
        int     0x40
308
        int     0x40
309
 else
309
 else
310
  if __CPU_type eq p6
310
  if __CPU_type eq p6
311
        push    ebp
311
        push    ebp
312
        mov     ebp, esp
312
        mov     ebp, esp
313
        push    ..ret_point     ; it may be 2 or 5 byte
313
        push    ..ret_point     ; it may be 2 or 5 byte
314
        sysenter
314
        sysenter
315
 ..ret_point:
315
 ..ret_point:
316
        pop     edx
316
        pop     edx
317
        pop     ecx
317
        pop     ecx
318
 
318
 
319
  else
319
  else
320
   if __CPU_type eq k6
320
   if __CPU_type eq k6
321
        push    ecx
321
        push    ecx
322
        syscall
322
        syscall
323
        pop     ecx
323
        pop     ecx
324
   else
324
   else
325
        display 'ERROR : unknown CPU type (set to p5)', 10, 13
325
        display 'ERROR : unknown CPU type (set to p5)', 10, 13
326
        __CPU_type equ p5
326
        __CPU_type equ p5
327
        int     0x40
327
        int     0x40
328
   end if
328
   end if
329
  end if
329
  end if
330
 end if
330
 end if
331
}
331
}
332
 
332
 
333
 
333
 
334
; -------------------------
334
; -------------------------
335
macro __header a,[b] {
335
macro __header a,[b] {
336
 common
336
 common
337
  use32
337
  use32
338
  org 0
338
  org 0
339
  db 'MENUET',a
339
  db 'MENUET',a
340
 forward
340
 forward
341
  if b eq
341
  if b eq
342
   dd 0
342
   dd 0
343
  else
343
  else
344
   dd b
344
   dd b
345
  end if
345
  end if
346
}
346
}
347
 
347
 
348
macro __section name {
348
macro __section name {
349
 align 16
349
 align 16
350
 label name
350
 label name
351
}
351
}
352
 
352
 
353
macro __func name {
353
macro __func name {
354
 if ~used name
354
 if ~used name
355
  display 'FUNC NOT USED: ',`name,13,10
355
  display 'FUNC NOT USED: ',`name,13,10
356
 else
356
 else
357
  align 4
357
  align 4
358
  name:
358
  name:
359
  ;diff16 `name,0,name
359
  ;diff16 `name,0,name
360
}
360
}
361
 
361
 
362
macro endf { end if }
362
macro endf { end if }
363
 
363
 
364
macro diff16 title,l1,l2
364
macro diff16 title,l1,l2
365
 {
365
 {
366
  local s,d
366
  local s,d
367
  s = l2-l1
367
  s = l2-l1
368
  display title,': 0x'
368
  display title,': 0x'
369
  repeat 8
369
  repeat 8
370
   d = '0' + s shr ((8-%) shl 2) and $0F
370
   d = '0' + s shr ((8-%) shl 2) and $0F
371
   if d > '9'
371
   if d > '9'
372
    d = d + 'A'-'9'-1
372
    d = d + 'A'-'9'-1
373
   end if
373
   end if
374
   display d
374
   display d
375
  end repeat
375
  end repeat
376
  display 13,10
376
  display 13,10
377
 }
377
 }
378
 
378
 
379
macro diff10 title,l1,l2
379
macro diff10 title,l1,l2
380
 {
380
 {
381
  local s,d,z,m
381
  local s,d,z,m
382
  s = l2-l1
382
  s = l2-l1
383
  z = 0
383
  z = 0
384
  m = 1000000000
384
  m = 1000000000
385
  display title,': '
385
  display title,': '
386
  repeat 10
386
  repeat 10
387
   d = '0' + s / m
387
   d = '0' + s / m
388
   s = s - (s/m)*m
388
   s = s - (s/m)*m
389
   m = m / 10
389
   m = m / 10
390
   if d <> '0'
390
   if d <> '0'
391
    z = 1
391
    z = 1
392
   end if
392
   end if
393
   if z <> 0
393
   if z <> 0
394
    display d
394
    display d
395
   end if
395
   end if
396
  end repeat
396
  end repeat
397
  display 13,10
397
  display 13,10
398
 }
398
 }
399
 
399
 
400
 
400
 
401
macro movi arg1,arg2
401
macro movi arg1,arg2
402
{
402
{
403
if (arg1 in ) & ((arg2 eqtype 0) | (arg2 eqtype '0'))
403
if (arg1 in ) & ((arg2 eqtype 0) | (arg2 eqtype '0'))
404
  if (arg2) = 0
404
  if (arg2) = 0
405
    xor arg1,arg1
405
    xor arg1,arg1
406
  else if (arg2) = 1
406
  else if (arg2) = 1
407
    xor arg1,arg1
407
    xor arg1,arg1
408
    inc arg1
408
    inc arg1
409
  else if (arg2) = -1
409
  else if (arg2) = -1
410
    or arg1,-1
410
    or arg1,-1
411
  else if (arg2) >= -128 & (arg2) <= 127
411
  else if (arg2) >= -128 & (arg2) <= 127
412
    push arg2
412
    push arg2
413
    pop arg1
413
    pop arg1
414
  else
414
  else
415
    mov arg1,arg2
415
    mov arg1,arg2
416
  end if
416
  end if
417
else
417
else
418
  mov arg1,arg2
418
  mov arg1,arg2
419
end if
419
end if
420
}
420
}
421
 
421
 
422
 
422
 
423
macro RGB [a] {
423
macro RGB [a] {
424
 common
424
 common
425
  match (r=,g=,b),a \{
425
  match (r=,g=,b),a \{
426
   \dd ((r) shl 16) or ((g) shl 8) or (b)
426
   \dd ((r) shl 16) or ((g) shl 8) or (b)
427
  \}
427
  \}
428
}
428
}
429
 
429
 
430
 
430
 
431
struc POINT _t,_dx,_dy {
431
struc POINT _t,_dx,_dy {
432
 .x _t _dx
432
 .x _t _dx
433
 .y _t _dy
433
 .y _t _dy
434
}
434
}
435
 
435
 
436
; structure definition helper
436
; structure definition helper
437
include 'struct.inc'
437
include 'struct.inc'
438
 
438
 
439
struct RECT
439
struct RECT
440
  left   dd ?
440
  left   dd ?
441
  top    dd ?
441
  top    dd ?
442
  right  dd ?
442
  right  dd ?
443
  bottom dd ?
443
  bottom dd ?
444
ends
444
ends
445
 
445
 
446
struct BOX
446
struct BOX
447
  left   dd ?
447
  left   dd ?
448
  top    dd ?
448
  top    dd ?
449
  width  dd ?
449
  width  dd ?
450
  height dd ?
450
  height dd ?
451
ends
451
ends
452
 
452
 
453
; structures used in KolibriOS
453
; structures used in KolibriOS
454
struct process_information
454
struct process_information
455
  cpu_usage               dd ?  ; +0
455
  cpu_usage               dd ?  ; +0
456
  window_stack_position   dw ?  ; +4
456
  window_stack_position   dw ?  ; +4
457
  window_stack_value      dw ?  ; +6
457
  window_stack_value      dw ?  ; +6
458
                          dw ?  ; +8
458
                          dw ?  ; +8
459
  process_name            rb 12 ; +10
459
  process_name            rb 12 ; +10
460
  memory_start            dd ?  ; +22
460
  memory_start            dd ?  ; +22
461
  used_memory             dd ?  ; +26
461
  used_memory             dd ?  ; +26
462
  PID                     dd ?  ; +30
462
  PID                     dd ?  ; +30
463
  box                     BOX   ; +34
463
  box                     BOX   ; +34
464
  slot_state              dw ?  ; +50
464
  slot_state              dw ?  ; +50
465
                          dw ?  ; +52
465
                          dw ?  ; +52
466
  client_box              BOX   ; +54
466
  client_box              BOX   ; +54
467
  wnd_state               db ?  ; +70
467
  wnd_state               db ?  ; +70
468
  rb (1024-71)
468
  rb (1024-71)
469
ends
469
ends
470
 
470
 
471
struct system_colors
471
struct system_colors
472
  frame            dd ? ;nonset1
472
  frame            dd ? ;nonset1
473
  grab             dd ? ;nonset2
473
  grab             dd ? ;nonset2
474
  work_dark        dd ?
474
  work_dark        dd ?
475
  work_light       dd ?
475
  work_light       dd ?
476
  grab_text        dd ? ;window_title
476
  grab_text        dd ? ;window_title
477
  work             dd ?
477
  work             dd ?
478
  work_button      dd ?
478
  work_button      dd ?
479
  work_button_text dd ?
479
  work_button_text dd ?
480
  work_text        dd ?
480
  work_text        dd ?
481
  work_graph       dd ?
481
  work_graph       dd ?
482
ends
482
ends
483
 
483
 
484
struct FILEDATE
484
struct FILEDATE
485
  Second db ?
485
  Second db ?
486
  Minute db ?
486
  Minute db ?
487
  Hour   db ?
487
  Hour   db ?
488
         db ?
488
         db ?
489
  Day    db ?
489
  Day    db ?
490
  Month  db ?
490
  Month  db ?
491
  Year   dw ?
491
  Year   dw ?
492
ends
492
ends
493
 
493
 
494
struct FILEINFO
494
struct FILEINFO
495
  Attributes dd ?
495
  Attributes dd ?
496
  IsUnicode  db ?
496
  IsUnicode  db ?
497
             db 3 dup(?)
497
             db 3 dup(?)
498
  DateCreate FILEDATE
498
  DateCreate FILEDATE
499
  DateAccess FILEDATE
499
  DateAccess FILEDATE
500
  DateModify FILEDATE
500
  DateModify FILEDATE
501
  Size       dq ?
501
  Size       dq ?
502
ends
502
ends
503
 
503
 
504
cmove   fix     cmovz
504
cmove   fix     cmovz
505
 
505
 
506
macro cmovz reg1, reg2 {
506
macro cmovz reg1, reg2 {
507
 
507
 
508
        local   ..jumpaddr
508
        local   ..jumpaddr
509
 
509
 
510
if __CPU_type eq p5             ; CMOVcc isnt supported on the P5
510
if __CPU_type eq p5             ; CMOVcc isnt supported on the P5
511
        jnz     ..jumpaddr
511
        jnz     ..jumpaddr
512
        mov     reg1, reg2
512
        mov     reg1, reg2
513
  ..jumpaddr:
513
  ..jumpaddr:
514
else
514
else
515
        cmovz   reg1, reg2
515
        cmovz   reg1, reg2
516
end if
516
end if
517
 
517
 
518
}
518
}
519
 
519
 
520
cmovne  fix     cmovnz
520
cmovne  fix     cmovnz
521
 
521
 
522
macro cmovnz reg1, reg2 {
522
macro cmovnz reg1, reg2 {
523
 
523
 
524
        local   ..jumpaddr
524
        local   ..jumpaddr
525
 
525
 
526
if __CPU_type eq p5             ; CMOVcc isnt supported on the P5
526
if __CPU_type eq p5             ; CMOVcc isnt supported on the P5
527
        jz      ..jumpaddr
527
        jz      ..jumpaddr
528
        mov     reg1, reg2
528
        mov     reg1, reg2
529
  ..jumpaddr:
529
  ..jumpaddr:
530
else
530
else
531
        cmovnz  reg1, reg2
531
        cmovnz  reg1, reg2
532
end if
532
end if
533
 
533
 
534
}
534
}
535
 
535
 
536
macro cmovg reg1, reg2 {
536
macro cmovg reg1, reg2 {
537
 
537
 
538
        local   ..jumpaddr
538
        local   ..jumpaddr
539
 
539
 
540
if __CPU_type eq p5             ; CMOVcc isnt supported on the P5
540
if __CPU_type eq p5             ; CMOVcc isnt supported on the P5
541
        jle     ..jumpaddr
541
        jle     ..jumpaddr
542
        mov     reg1, reg2
542
        mov     reg1, reg2
543
  ..jumpaddr:
543
  ..jumpaddr:
544
else
544
else
545
        cmovg   reg1, reg2
545
        cmovg   reg1, reg2
546
end if
546
end if
547
}
547
}
548
 
548
 
549
macro cmovl reg1, reg2 {
549
macro cmovl reg1, reg2 {
550
 
550
 
551
        local   ..jumpaddr
551
        local   ..jumpaddr
552
 
552
 
553
if __CPU_type eq p5             ; CMOVcc isnt supported on the P5
553
if __CPU_type eq p5             ; CMOVcc isnt supported on the P5
554
        jge     ..jumpaddr
554
        jge     ..jumpaddr
555
        mov     reg1, reg2
555
        mov     reg1, reg2
556
  ..jumpaddr:
556
  ..jumpaddr:
557
else
557
else
558
        cmovl   reg1, reg2
558
        cmovl   reg1, reg2
559
end if
559
end if
560
}
560
}
561
 
561
 
562
; replaces /programs/cmp.inc
562
; replaces /programs/cmp.inc
563
irp cond, e, ne, g, ng, l, nl, ge, le {
563
irp cond, e, ne, g, ng, l, nl, ge, le {
564
  macro cmp#cond a, b, c\{
564
  macro cmp#cond a, b, c\{
565
    cmp a, b
565
    cmp a, b
566
    j#cond c
566
    j#cond c
567
  \}
567
  \}
568
}
568
}
569
 
569
 
570
; constants
570
; constants
571
 
571
 
572
; button flags
572
; button flags
573
BT_DEL         = 0x80000000
573
BT_DEL         = 0x80000000
574
BT_HIDE        = 0x40000000
574
BT_HIDE        = 0x40000000
575
BT_NOFRAME     = 0x20000000
575
BT_NOFRAME     = 0x20000000
576
 
576
 
577
; events
577
; events
578
EV_IDLE        = 0
578
EV_IDLE        = 0
579
EV_TIMER       = 0
579
EV_TIMER       = 0
580
EV_REDRAW      = 1
580
EV_REDRAW      = 1
581
EV_KEY         = 2
581
EV_KEY         = 2
582
EV_BUTTON      = 3
582
EV_BUTTON      = 3
583
EV_EXIT        = 4
583
EV_EXIT        = 4
584
EV_BACKGROUND  = 5
584
EV_BACKGROUND  = 5
585
EV_MOUSE       = 6
585
EV_MOUSE       = 6
586
EV_IPC         = 7
586
EV_IPC         = 7
587
EV_STACK       = 8
587
EV_STACK       = 8
588
 
588
 
589
; event mask bits for function 40
589
; event mask bits for function 40
590
EVM_REDRAW     =          1b
590
EVM_REDRAW     =          1b
591
EVM_KEY        =         10b
591
EVM_KEY        =         10b
592
EVM_BUTTON     =        100b
592
EVM_BUTTON     =        100b
593
EVM_EXIT       =       1000b
593
EVM_EXIT       =       1000b
594
EVM_BACKGROUND =      10000b
594
EVM_BACKGROUND =      10000b
595
EVM_MOUSE      =     100000b
595
EVM_MOUSE      =     100000b
596
EVM_IPC        =    1000000b
596
EVM_IPC        =    1000000b
597
EVM_STACK      =   10000000b
597
EVM_STACK      =   10000000b
598
EVM_DEBUG      =  100000000b
598
EVM_DEBUG      =  100000000b
599
EVM_STACK2     = 1000000000b
599
EVM_STACK2     = 1000000000b
600
 
600
 
601
EVM_MOUSE_FILTER  = 0x80000000
601
EVM_MOUSE_FILTER  = 0x80000000
602
EVM_CURSOR_FILTER = 0x40000000
602
EVM_CURSOR_FILTER = 0x40000000