Subversion Repositories Kolibri OS

Rev

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

Rev 587 Rev 1937
1
;~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
1
;~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
2
macro iglobal {
2
macro iglobal {
3
  IGlobals equ IGlobals,
3
  IGlobals equ IGlobals,
4
  macro __IGlobalBlock { }
4
  macro __IGlobalBlock { }
5
  
5
  
6
macro uglobal {
6
macro uglobal {
7
  UGlobals equ UGlobals,
7
  UGlobals equ UGlobals,
8
  macro __UGlobalBlock { }
8
  macro __UGlobalBlock { }
9
 
9
 
10
endg fix }      ; Use endg for ending iglobal and uglobal blocks.
10
endg fix }      ; Use endg for ending iglobal and uglobal blocks.
11
 
11
 
12
 
12
 
13
macro IncludeIGlobals{
13
macro IncludeIGlobals{
14
  macro IGlobals dummy,[n] \{ __IGlobalBlock
14
  macro IGlobals dummy,[n] \{ __IGlobalBlock
15
     purge __IGlobalBlock  \}
15
     purge __IGlobalBlock  \}
16
  match I, IGlobals \{ I \} }
16
  match I, IGlobals \{ I \} }
17
 
17
 
18
macro IncludeUGlobals{
18
macro IncludeUGlobals{
19
  macro UGlobals dummy,[n] \{
19
  macro UGlobals dummy,[n] \{
20
    \common
20
    \common
21
      \local begin, size
21
      \local begin, size
22
      begin = $
22
      begin = $
23
      virtual at $
23
      virtual at $
24
    \forward
24
    \forward
25
      __UGlobalBlock
25
      __UGlobalBlock
26
      purge __UGlobalBlock
26
      purge __UGlobalBlock
27
    \common
27
    \common
28
      size = $ - begin
28
      size = $ - begin
29
    end virtual
29
    end virtual
30
    rb size
30
    rb size
31
  \}
31
  \}
32
  match U, UGlobals \{ U \} }
32
  match U, UGlobals \{ U \} }
33
 
33
 
34
uglobal
34
uglobal
35
endg
35
endg
36
  
36
  
37
iglobal
37
iglobal
38
endg
38
endg
39
 
39
 
40
;~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
40
;~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
41
; new application structure
41
; new application structure
42
macro meos_app_start
42
macro meos_app_start
43
 {
43
 {
44
  use32
44
  use32
45
  org 0x0
45
  org 0x0
46
 
46
 
47
  db 'MENUET01'
47
  db 'MENUET01'
48
  dd 0x01
48
  dd 0x01
49
  dd __start
49
  dd __start
50
  dd __end
50
  dd __end
51
  dd __memory
51
  dd __memory
52
  dd __stack
52
  dd __stack
53
 
53
 
54
  if used __params & ~defined __params
54
  if used __params & ~defined __params
55
    dd __params
55
    dd __params
56
  else
56
  else
57
    dd 0x0
57
    dd 0x0
58
  end if
58
  end if
59
 
59
 
60
  dd 0x0
60
  dd 0x0
61
 }
61
 }
62
MEOS_APP_START fix meos_app_start
62
MEOS_APP_START fix meos_app_start
63
 
63
 
64
macro code
64
macro code
65
 {
65
 {
66
  __start:
66
  __start:
67
 }
67
 }
68
CODE fix code
68
CODE fix code
69
 
69
 
70
macro data
70
macro data
71
 {
71
 {
72
  __data:
72
  __data:
73
  IncludeIGlobals
73
  IncludeIGlobals
74
 }
74
 }
75
DATA fix data
75
DATA fix data
76
 
76
 
77
macro udata
77
macro udata
78
 {
78
 {
79
  if used __params & ~defined __params
79
  if used __params & ~defined __params
80
    __params:
80
    __params:
81
      db 0
81
      db 0
82
    __end:
82
    __end:
83
      rb 255
83
      rb 255
84
  else
84
  else
85
    __end:
85
    __end:
86
  end if
86
  end if
87
  __udata:
87
  __udata:
88
  IncludeUGlobals
88
  IncludeUGlobals
89
 }
89
 }
90
UDATA fix udata
90
UDATA fix udata
91
 
91
 
92
macro meos_app_end
92
macro meos_app_end
93
 {
93
 {
94
  align 32
94
  align 32
95
  rb 2048
95
  rb 2048
96
  __stack:
96
  __stack:
97
  __memory:
97
  __memory:
98
 }
98
 }
99
MEOS_APP_END fix meos_app_end
99
MEOS_APP_END fix meos_app_end
100
 
100
 
101
 
101
 
102
; macro for defining multiline text data
102
; macro for defining multiline text data
103
struc mstr [sstring]
103
struc mstr [sstring]
104
 {
104
 {
105
  forward
105
  forward
106
    local ssize
106
    local ssize
107
    virtual at 0
107
    virtual at 0
108
      db sstring
108
      db sstring
109
      ssize = $
109
      ssize = $
110
    end virtual
110
    end virtual
111
    dd ssize
111
    dd ssize
112
    db sstring
112
    db sstring
113
  common
113
  common
114
    dd -1
114
    dd -1
115
 }
115
 }
116
 
116
 
117
; macro for defining multiline text data
117
; macro for defining multiline text data
118
struc mls [sstring] {
118
struc mls [sstring] {
119
	forward
119
	forward
120
	local ssize
120
	local ssize
121
	virtual at 0
121
	virtual at 0
122
		db sstring	; mod
122
		db sstring	; mod
123
		ssize = $
123
		ssize = $
124
	end virtual
124
	end virtual
125
	db ssize
125
	db ssize
126
	db sstring
126
	db sstring
127
	common
127
	common
128
 
128
 
129
	db -1			; mod
129
	db -1			; mod
130
}
130
}
131
 
131
 
132
 
132
 
133
 
133
 
134
; strings
134
; strings
135
macro sz name,[data] {       ; from MFAR [mike.dld]
135
macro sz name,[data] {       ; from MFAR [mike.dld]
136
  common
136
  common
137
   if used name
137
   if used name
138
    label name
138
    label name
139
   end if
139
   end if
140
  forward
140
  forward
141
   if used name
141
   if used name
142
    db data
142
    db data
143
   end if
143
   end if
144
  common
144
  common
145
   if used name
145
   if used name
146
    .size = $-name
146
    .size = $-name
147
   end if
147
   end if
148
}
148
}
149
 
149
 
150
macro lsz name,[lng,data] {  ; from MFAR [mike.dld]
150
macro lsz name,[lng,data] {  ; from MFAR [mike.dld]
151
  common
151
  common
152
   if used name
152
   if used name
153
    label name
153
    label name
154
   end if
154
   end if
155
  forward
155
  forward
156
   if (used name)&(lang eq lng)
156
   if (used name)&(lang eq lng)
157
    db data
157
    db data
158
   end if
158
   end if
159
  common
159
  common
160
   if used name
160
   if used name
161
    .size = $-name
161
    .size = $-name
162
   end if
162
   end if
163
}
163
}
164
 
164
 
165
 
165
 
166
 
166
 
167
; easy system call macro
167
; easy system call macro
168
macro mpack dest, hsrc, lsrc
168
macro mpack dest, hsrc, lsrc
169
{
169
{
170
  if (hsrc eqtype 0) & (lsrc eqtype 0)
170
  if (hsrc eqtype 0) & (lsrc eqtype 0)
171
    mov dest, (hsrc) shl 16 + lsrc
171
    mov dest, (hsrc) shl 16 + lsrc
172
  else
172
  else
173
    if (hsrc eqtype 0) & (~lsrc eqtype 0)
173
    if (hsrc eqtype 0) & (~lsrc eqtype 0)
174
      mov dest, (hsrc) shl 16
174
      mov dest, (hsrc) shl 16
175
      add dest, lsrc
175
      add dest, lsrc
176
    else
176
    else
177
      mov dest, hsrc
177
      mov dest, hsrc
178
      shl dest, 16
178
      shl dest, 16
179
      add dest, lsrc
179
      add dest, lsrc
180
    end if
180
    end if
181
  end if
181
  end if
182
}
182
}
183
 
183
 
184
macro __mov reg,a,b {         ; mike.dld
184
macro __mov reg,a,b {         ; mike.dld
185
 if (~a eq)&(~b eq)
185
 if (~a eq)&(~b eq)
186
   mpack reg,a,b
186
   mpack reg,a,b
187
 else if (~a eq)&(b eq)
187
 else if (~a eq)&(b eq)
188
   mov reg,a
188
   mov reg,a
189
 end if
189
 end if
190
}
190
}
191
 
191
 
192
__CPU_type	equ	p5
192
__CPU_type	equ	p5
193
SYSENTER_VAR	equ	0
193
SYSENTER_VAR	equ	0
194
 
194
 
195
macro mcall a,b,c,d,e,f {   ; mike.dld, updated by Ghost for Fast System Calls
195
macro mcall a,b,c,d,e,f {   ; mike.dld
196
 local	..ret_point
-
 
197
 __mov eax,a
196
 __mov eax,a
198
 __mov ebx,b
197
 __mov ebx,b
199
 __mov ecx,c
198
 __mov ecx,c
200
 __mov edx,d
199
 __mov edx,d
201
 __mov esi,e
200
 __mov esi,e
202
 __mov edi,f
201
 __mov edi,f
203
 
202
 
204
 if __CPU_type eq p5
-
 
205
	int	0x40
203
	int	0x40
206
 else
-
 
207
  if __CPU_type eq p6
-
 
208
	push	ebp
-
 
209
	mov	ebp, esp
-
 
210
	push	..ret_point	; it may be 2 or 5 byte
-
 
211
	sysenter
-
 
212
 ..ret_point:
-
 
213
	pop	edx
-
 
214
	pop	ecx
-
 
215
 
-
 
216
  else
-
 
217
   if __CPU_type eq k6
-
 
218
	push	ecx
-
 
219
	syscall
-
 
220
	pop	ecx
-
 
221
   else
-
 
222
	display 'ERROR : unknown CPU type'
-
 
223
	int	0x40
-
 
224
   end if
-
 
225
  end if
-
 
226
 end if
-
 
227
}
204
}
228
 
205
 
229
 
206
 
230
 
207
 
231
 
208
 
232
; optimize the code for size
209
; optimize the code for size
233
__regs fix 
210
__regs fix 
234
 
211
 
235
macro add arg1,arg2
212
macro add arg1,arg2
236
 {
213
 {
237
   if (arg2 eqtype 0)
214
   if (arg2 eqtype 0)
238
      if (arg2) = 1
215
      if (arg2) = 1
239
         inc arg1
216
         inc arg1
240
      else
217
      else
241
         add arg1,arg2
218
         add arg1,arg2
242
      end if
219
      end if
243
   else
220
   else
244
      add arg1,arg2
221
      add arg1,arg2
245
   end if
222
   end if
246
 }
223
 }
247
 
224
 
248
macro sub arg1,arg2
225
macro sub arg1,arg2
249
 {
226
 {
250
   if (arg2 eqtype 0)
227
   if (arg2 eqtype 0)
251
      if (arg2) = 1
228
      if (arg2) = 1
252
         dec arg1
229
         dec arg1
253
      else
230
      else
254
         sub arg1,arg2
231
         sub arg1,arg2
255
      end if
232
      end if
256
   else
233
   else
257
      sub arg1,arg2
234
      sub arg1,arg2
258
   end if
235
   end if
259
 }
236
 }
260
 
237
 
261
macro mov arg1,arg2
238
macro mov arg1,arg2
262
 {
239
 {
263
   if (arg1 in __regs) & ((arg2 eqtype 0) | (arg2 eqtype '0'))
240
   if (arg1 in __regs) & ((arg2 eqtype 0) | (arg2 eqtype '0'))
264
      if (arg2) = 0
241
      if (arg2) = 0
265
         xor arg1,arg1
242
         xor arg1,arg1
266
      else if (arg2) = 1
243
      else if (arg2) = 1
267
         xor arg1,arg1
244
         xor arg1,arg1
268
         inc arg1
245
         inc arg1
269
      else if (arg2) = -1
246
      else if (arg2) = -1
270
         or  arg1,-1
247
         or  arg1,-1
271
      else if (arg2) > -128 & (arg2) < 128
248
      else if (arg2) > -128 & (arg2) < 128
272
         push arg2
249
         push arg2
273
         pop  arg1
250
         pop  arg1
274
      else
251
      else
275
         mov  arg1,arg2
252
         mov  arg1,arg2
276
      end if
253
      end if
277
   else
254
   else
278
      mov arg1,arg2
255
      mov arg1,arg2
279
   end if
256
   end if
280
 }
257
 }
281
 
258
 
282
 
259
 
283
macro struct name
260
macro struct name
284
 {
261
 {
285
  virtual at 0
262
  virtual at 0
286
   name name
263
   name name
287
   sizeof.#name = $ - name
264
   sizeof.#name = $ - name
288
  end virtual
265
  end virtual
289
 }
266
 }
290
 
267
 
291
; structures used in MeOS
268
; structures used in MeOS
292
struc process_information
269
struc process_information
293
 {
270
 {
294
  .cpu_usage               dd ?  ; +0
271
  .cpu_usage               dd ?  ; +0
295
  .window_stack_position   dw ?  ; +4
272
  .window_stack_position   dw ?  ; +4
296
  .window_stack_value      dw ?  ; +6
273
  .window_stack_value      dw ?  ; +6
297
  .not_used1               dw ?  ; +8
274
  .not_used1               dw ?  ; +8
298
  .process_name            rb 12 ; +10
275
  .process_name            rb 12 ; +10
299
  .memory_start            dd ?  ; +22
276
  .memory_start            dd ?  ; +22
300
  .used_memory             dd ?  ; +26
277
  .used_memory             dd ?  ; +26
301
  .PID                     dd ?  ; +30
278
  .PID                     dd ?  ; +30
302
  .x_start                 dd ?  ; +34
279
  .x_start                 dd ?  ; +34
303
  .y_start                 dd ?  ; +38
280
  .y_start                 dd ?  ; +38
304
  .x_size                  dd ?  ; +42
281
  .x_size                  dd ?  ; +42
305
  .y_size                  dd ?  ; +46
282
  .y_size                  dd ?  ; +46
306
  .slot_state              dw ?  ; +50
283
  .slot_state              dw ?  ; +50
307
                           dw ?  ; +52 - reserved
284
                           dw ?  ; +52 - reserved
308
  .client_left             dd ?  ; +54
285
  .client_left             dd ?  ; +54
309
  .client_top              dd ?  ; +58
286
  .client_top              dd ?  ; +58
310
  .client_width            dd ?  ; +62
287
  .client_width            dd ?  ; +62
311
  .client_height           dd ?  ; +66
288
  .client_height           dd ?  ; +66
312
  .wnd_state               db ?  ; +70
289
  .wnd_state               db ?  ; +70
313
  rb (1024-71)
290
  rb (1024-71)
314
 }
291
 }
315
struct process_information
292
struct process_information
316
 
293
 
317
struc system_colors
294
struc system_colors
318
 {
295
 {
319
  .frame            dd ?
296
  .frame            dd ?
320
  .grab             dd ?
297
  .grab             dd ?
321
  .grab_button      dd ?
298
  .grab_button      dd ?
322
  .grab_button_text dd ?
299
  .grab_button_text dd ?
323
  .grab_text        dd ?
300
  .grab_text        dd ?
324
  .work             dd ?
301
  .work             dd ?
325
  .work_button      dd ?
302
  .work_button      dd ?
326
  .work_button_text dd ?
303
  .work_button_text dd ?
327
  .work_text        dd ?
304
  .work_text        dd ?
328
  .work_graph       dd ?
305
  .work_graph       dd ?
329
 }
306
 }
330
struct system_colors
307
struct system_colors
331
 
308
 
332
 
309
 
333
; constants
310
; constants
334
 
311
 
335
; events
312
; events
336
EV_IDLE        = 0
313
EV_IDLE        = 0
337
EV_TIMER       = 0
314
EV_TIMER       = 0
338
EV_REDRAW      = 1
315
EV_REDRAW      = 1
339
EV_KEY         = 2
316
EV_KEY         = 2
340
EV_BUTTON      = 3
317
EV_BUTTON      = 3
341
EV_EXIT        = 4
318
EV_EXIT        = 4
342
EV_BACKGROUND  = 5
319
EV_BACKGROUND  = 5
343
EV_MOUSE       = 6
320
EV_MOUSE       = 6
344
EV_IPC         = 7
321
EV_IPC         = 7
345
EV_STACK       = 8
322
EV_STACK       = 8
346
 
323
 
347
; event mask bits for function 40
324
; event mask bits for function 40
348
EVM_REDRAW     =        1b
325
EVM_REDRAW     =        1b
349
EVM_KEY        =       10b
326
EVM_KEY        =       10b
350
EVM_BUTTON     =      100b
327
EVM_BUTTON     =      100b
351
EVM_EXIT       =     1000b
328
EVM_EXIT       =     1000b
352
EVM_BACKGROUND =    10000b
329
EVM_BACKGROUND =    10000b
353
EVM_MOUSE      =   100000b
330
EVM_MOUSE      =   100000b
354
EVM_IPC        =  1000000b
331
EVM_IPC        =  1000000b
355
EVM_STACK      = 10000000b
332
EVM_STACK      = 10000000b