Rev 763 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
616 | bw | 1 | {cp866} |
2 | |||
3 | { User interface } |
||
4 | procedure kos_definewindow(x, y, w, h: Word; style, header, clframe: DWord); assembler; register; |
||
5 | asm |
||
6 | pushl %ebx |
||
7 | pushl %ecx |
||
8 | pushl %edx |
||
9 | pushl %esi |
||
10 | pushl %edi |
||
11 | movl %eax, %ebx |
||
12 | xchgl %edx, %ecx |
||
13 | movl header, %esi |
||
14 | shll $16, %ebx |
||
15 | shll $16, %ecx |
||
16 | movl clframe, %edi |
||
17 | movw %dx, %bx |
||
18 | movw h, %cx |
||
19 | xorl %eax, %eax |
||
20 | movl style, %edx |
||
21 | decl %ebx {уменьшить ширину на 1} |
||
22 | decl %ecx {уменьшить высоту на 1} |
||
623 | bw | 23 | andl $0xEFFFFFFF, %edx |
616 | bw | 24 | int $0x40 |
25 | popl %edi |
||
26 | popl %esi |
||
27 | popl %edx |
||
28 | popl %ecx |
||
29 | popl %ebx |
||
30 | end; |
||
31 | |||
32 | procedure kos_movewindow(x, y, w, h: DWord); assembler; register; |
||
33 | asm |
||
34 | pushl %eax |
||
35 | pushl %ebx |
||
36 | pushl %ecx |
||
37 | pushl %edx |
||
38 | pushl %esi |
||
39 | movl %eax, %ebx |
||
40 | xchgl %ecx, %edx |
||
41 | movl $67, %eax |
||
42 | movl h, %esi |
||
43 | decl %edx {уменьшить ширину на 1} |
||
44 | decl %esi {уменьшить высоту на 1} |
||
45 | int $0x40 |
||
46 | popl %esi |
||
47 | popl %edx |
||
48 | popl %ecx |
||
49 | popl %ebx |
||
50 | popl %eax |
||
51 | end; |
||
52 | |||
53 | function kos_getkey(): DWord; assembler; register; |
||
54 | asm |
||
55 | movl $2, %eax |
||
56 | int $0x40 |
||
57 | end; |
||
58 | |||
59 | function kos_getevent(wait: Boolean = True): DWord; assembler; register; |
||
60 | asm |
||
61 | andl $1, %eax |
||
62 | xorb $1, %al |
||
63 | addl $10, %eax |
||
64 | int $0x40 |
||
65 | end; |
||
66 | |||
67 | function kos_waitevent(timeout: DWord): DWord; assembler; register; |
||
68 | asm |
||
69 | pushl %ebx |
||
70 | movl $23, %ebx |
||
71 | xchgl %eax, %ebx |
||
72 | int $0x40 |
||
73 | popl %ebx |
||
74 | end; |
||
75 | |||
76 | function kos_getbutton(): DWord; assembler; register; |
||
77 | asm |
||
78 | movl $17, %eax |
||
79 | int $0x40 |
||
80 | shrl $8, %eax |
||
81 | andl $0xFF, %eax |
||
82 | end; |
||
83 | |||
84 | function kos_getmousepos(): TKosPoint; assembler; register; |
||
85 | {@return: x*65536 + y} |
||
86 | asm |
||
87 | pushl %eax |
||
88 | pushl %ebx |
||
89 | pushl %ecx |
||
90 | pushl %eax |
||
91 | movl $37, %eax |
||
92 | xorl %ebx, %ebx |
||
93 | int $0x40 |
||
94 | movswl %ax, %ecx |
||
95 | popl %ebx |
||
96 | shrl $16, %eax |
||
775 | bw | 97 | movswl %ax, %eax |
616 | bw | 98 | movl %ecx, TKosPoint.Y(%ebx) |
99 | movl %eax, TKosPoint.X(%ebx) |
||
100 | popl %ecx |
||
101 | popl %ebx |
||
102 | popl %eax |
||
103 | end; |
||
104 | |||
105 | function kos_getmousewinpos(): TKosPoint; assembler; register; |
||
106 | {@return: x*65536 + y} |
||
107 | asm |
||
108 | pushl %eax |
||
109 | pushl %ebx |
||
110 | pushl %ecx |
||
111 | pushl %eax |
||
112 | movl $37, %eax |
||
113 | movl $1, %ebx |
||
114 | int $0x40 |
||
115 | movswl %ax, %ecx |
||
116 | popl %ebx |
||
117 | shrl $16, %eax |
||
775 | bw | 118 | movswl %ax, %eax |
616 | bw | 119 | movl %ecx, TKosPoint.Y(%ebx) |
120 | movl %eax, TKosPoint.X(%ebx) |
||
121 | popl %ecx |
||
122 | popl %ebx |
||
123 | popl %eax |
||
124 | end; |
||
125 | |||
126 | function kos_getmousebuttons(): DWord; assembler; register; |
||
127 | {@return: |
||
128 | бит 0 установлен = левая кнопка нажата |
||
129 | бит 1 установлен = правая кнопка нажата |
||
130 | бит 2 установлен = средняя кнопка нажата |
||
131 | бит 3 установлен = 4-я кнопка нажата |
||
132 | бит 4 установлен = 5-я кнопка нажата} |
||
133 | asm |
||
134 | pushl %ebx |
||
135 | movl $37, %eax |
||
136 | movl $2, %ebx |
||
137 | int $0x40 |
||
138 | popl %ebx |
||
139 | end; |
||
140 | |||
141 | procedure kos_maskevents(mask: DWord); assembler; register; |
||
142 | asm |
||
143 | pushl %ebx |
||
144 | xchgl %eax, %ebx |
||
145 | movl $40, %eax |
||
146 | int $0x40 |
||
147 | xchgl %eax, %ebx |
||
148 | popl %ebx |
||
149 | end; |
||
150 | |||
763 | bw | 151 | procedure kos_setkeyboardmode(mode: DWord); assembler; register; |
152 | asm |
||
153 | pushl %eax |
||
154 | pushl %ebx |
||
155 | movl $66, %ecx |
||
156 | movl $1, %ebx |
||
157 | xchgl %eax, %ecx |
||
158 | int $0x40 |
||
159 | xchgl %eax, %ecx |
||
160 | popl %ebx |
||
161 | popl %eax |
||
162 | end; |
||
163 | |||
164 | function kos_getkeyboardmode(): DWord; assembler; register; |
||
165 | asm |
||
166 | pushl %ebx |
||
167 | movl $66, %eax |
||
168 | movl $2, %ebx |
||
169 | int $0x40 |
||
170 | popl %ebx |
||
171 | end; |
||
172 | |||
616 | bw | 173 | procedure kos_setcaption(caption: PChar); assembler; register; |
174 | asm |
||
175 | pushl %ecx |
||
176 | pushl %ebx |
||
177 | xchgl %eax, %ecx |
||
178 | movl $1, %ebx |
||
179 | movl $71, %eax |
||
180 | int $0x40 |
||
181 | xchgl %eax, %ecx |
||
182 | popl %ebx |
||
183 | popl %ecx |
||
184 | end; |
||
185 | |||
186 | |||
187 | { Graphics } |
||
188 | |||
619 | bw | 189 | function kos_screensize(): TKosPoint; assembler; register; |
190 | asm |
||
191 | pushl %eax |
||
192 | pushl %ecx |
||
193 | pushl %eax |
||
194 | movl $14, %eax |
||
195 | int $0x40 |
||
196 | movswl %ax, %ecx |
||
197 | popl %ebx |
||
198 | shrl $16, %eax |
||
199 | movl %ecx, TKosPoint.Y(%ebx) |
||
200 | movl %eax, TKosPoint.X(%ebx) |
||
201 | popl %ecx |
||
202 | popl %eax |
||
203 | end; |
||
204 | |||
616 | bw | 205 | procedure kos_begindraw(); assembler; register; |
206 | asm |
||
207 | pushl %ebx |
||
208 | movl $12, %eax |
||
209 | movl $1, %ebx |
||
210 | int $0x40 |
||
211 | popl %ebx |
||
212 | end; |
||
213 | |||
214 | procedure kos_enddraw(); assembler; register; |
||
215 | asm |
||
216 | pushl %ebx |
||
217 | movl $12, %eax |
||
218 | movl $2, %ebx |
||
219 | int $0x40 |
||
220 | popl %ebx |
||
221 | end; |
||
222 | |||
223 | procedure kos_putpixel(x, y: Word; color: DWord); assembler; register; |
||
224 | asm |
||
225 | pushl %ebx |
||
226 | movl %eax, %ebx |
||
227 | xchgl %edx, %ecx |
||
228 | movl $1, %eax |
||
229 | int $0x40 |
||
230 | xchgl %edx, %ecx |
||
231 | popl %ebx |
||
232 | end; |
||
233 | |||
234 | procedure kos_drawtext(x, y: Word; text: String; flags, bgcolor: DWord); assembler; register; |
||
235 | label nobg; |
||
236 | asm |
||
237 | pusha |
||
238 | shll $16, %eax |
||
239 | pushl %ecx |
||
240 | movl flags, %ecx {флаги, цвет} |
||
241 | movl bgcolor, %edi |
||
242 | movw %dx, %ax |
||
243 | andl $0x7FFFFFFF, %ecx |
||
244 | btl $31, %edi |
||
245 | jnc nobg |
||
246 | orl $0x40000000, %ecx |
||
247 | nobg: |
||
248 | popl %edx |
||
249 | movl %eax, %ebx {координаты} |
||
250 | movzbl (%edx), %esi {длина строки} |
||
251 | movl $4, %eax {номер функции} |
||
252 | incl %edx {указатель на строку} |
||
253 | andl $0xFFFFFF, %edi |
||
254 | int $0x40 |
||
255 | popa |
||
256 | end; |
||
257 | |||
258 | procedure kos_drawrect(x, y, w, h: Word; color: DWord); assembler; register; |
||
259 | asm |
||
260 | pushl %eax |
||
261 | pushl %ebx |
||
262 | pushl %ecx |
||
263 | pushl %edx |
||
264 | movl %eax, %ebx |
||
265 | xchgl %edx, %ecx |
||
266 | shll $16, %ebx |
||
267 | shll $16, %ecx |
||
268 | movl $13, %eax |
||
269 | movw %dx, %bx |
||
270 | movw h, %cx |
||
271 | movl color, %edx |
||
272 | int $0x40 |
||
273 | popl %edx |
||
274 | popl %ecx |
||
275 | popl %ebx |
||
276 | popl %eax |
||
277 | end; |
||
278 | |||
279 | procedure kos_drawline(x1, y1, x2, y2: Word; color: DWord = $000000); assembler; register; |
||
280 | asm |
||
281 | pushl %eax |
||
282 | pushl %ebx |
||
283 | pushl %ecx |
||
284 | pushl %edx |
||
285 | |||
286 | xchgl %eax, %ecx |
||
287 | xchgl %ecx, %edx |
||
288 | movl color, %ebx |
||
289 | {eax - x2, ebx - color, ecx - y1, edx - x1} |
||
290 | shll $16, %ecx |
||
291 | shll $16, %edx |
||
292 | movw %ax, %dx |
||
293 | movw y2, %cx |
||
294 | movl $38, %eax |
||
295 | xchgl %ebx, %edx |
||
296 | int $0x40 |
||
297 | |||
298 | popl %edx |
||
299 | popl %ecx |
||
300 | popl %ebx |
||
301 | popl %eax |
||
302 | end; |
||
303 | |||
304 | procedure kos_drawimage(x, y, w, h, depth: DWord; image: Pointer; palette: Pointer; xoffset: DWord); assembler; register; |
||
305 | asm |
||
306 | pusha |
||
307 | shll $16, %eax |
||
308 | shll $16, %ecx |
||
309 | orl %eax, %edx |
||
310 | orl h, %ecx |
||
311 | movl depth, %esi |
||
312 | movl image, %ebx |
||
313 | movl palette, %edi |
||
314 | movl xoffset, %ebp |
||
315 | movl $65, %eax |
||
316 | int $0x40 |
||
317 | popa |
||
318 | end; |
||
319 | |||
320 | procedure kos_drawimage24(x, y, w, h: DWord; image: Pointer); assembler; register; |
||
321 | asm |
||
322 | pushl %eax |
||
323 | pushl %ebx |
||
324 | pushl %ecx |
||
325 | pushl %edx |
||
326 | shll $16, %eax |
||
327 | shll $16, %ecx |
||
328 | orl %eax, %edx |
||
329 | orl h, %ecx |
||
330 | movl image, %ebx |
||
331 | movl $7, %eax |
||
332 | int $0x40 |
||
333 | popl %edx |
||
334 | popl %ecx |
||
335 | popl %ebx |
||
336 | popl %eax |
||
337 | end; |
||
338 | |||
339 | |||
340 | { Work with system } |
||
341 | |||
342 | { Work with system - System services } |
||
343 | |||
344 | function kos_killthread(tid: TThreadID): Boolean; assembler; register; |
||
345 | asm |
||
346 | pushl %ecx |
||
347 | pushl %ebx |
||
348 | movl $18, %ecx |
||
349 | movl $18, %ebx |
||
350 | xchgl %eax, %ecx |
||
351 | int $0x40 |
||
352 | andl $1, %eax |
||
353 | popl %ebx |
||
354 | popl %ecx |
||
355 | xorb $1, %al |
||
356 | end; |
||
357 | |||
358 | procedure kos_setactivewindow(slot: TThreadSlot); assembler; register; |
||
359 | asm |
||
360 | pushl %ecx |
||
361 | pushl %ebx |
||
362 | movl $18, %ecx |
||
363 | movl $3, %ebx |
||
364 | xchgl %eax, %ecx |
||
365 | int $0x40 |
||
366 | xchgl %eax, %ecx |
||
367 | popl %ebx |
||
368 | popl %ecx |
||
369 | end; |
||
370 | |||
371 | {$ifdef EMULATOR} |
||
372 | function kos_getthreadslot(tid: TThreadID): TThreadSlot; |
||
373 | var |
||
374 | ThreadInfo: TKosThreadInfo; |
||
375 | HighThreadSlot: TThreadSlot; |
||
376 | begin |
||
377 | Result := 0; |
||
378 | repeat |
||
379 | Inc(Result); |
||
380 | HighThreadSlot := kos_threadinfo(@ThreadInfo, Result); |
||
381 | until (Result > HighThreadSlot) or (ThreadInfo.ThreadID = tid); |
||
382 | end; |
||
383 | |||
384 | {$else} |
||
385 | |||
386 | function kos_getthreadslot(tid: TThreadID): TThreadSlot; assembler; register; |
||
387 | asm |
||
388 | pushl %ecx |
||
389 | pushl %ebx |
||
390 | movl $18, %ecx |
||
391 | movl $21, %ebx |
||
392 | xchgl %eax, %ecx |
||
393 | int $0x40 |
||
394 | popl %ebx |
||
395 | popl %ecx |
||
396 | end; |
||
397 | {$endif} |
||
398 | |||
399 | { Work with system - Set system parameters } |
||
400 | |||
401 | procedure kos_enablepci(); assembler; register; |
||
402 | asm |
||
403 | pushl %eax |
||
404 | pushl %ebx |
||
405 | pushl %ecx |
||
406 | movl $21, %eax |
||
407 | movl $12, %ebx |
||
408 | movl $1, %ecx |
||
409 | int $0x40 |
||
410 | popl %ecx |
||
411 | popl %ebx |
||
412 | popl %eax |
||
413 | end; |
||
414 | |||
666 | bw | 415 | { Work with system - Get system parameters } |
416 | |||
417 | function kos_timecounter(): DWord; assembler; register; |
||
418 | asm |
||
419 | pushl %ebx |
||
420 | movl $26, %eax |
||
421 | movl $9, %ebx |
||
422 | int $0x40 |
||
423 | popl %ebx |
||
424 | end; |
||
425 | |||
616 | bw | 426 | { Work with system - Internal system services } |
427 | |||
428 | procedure kos_switchthread(); assembler; register; |
||
429 | asm |
||
430 | pushl %eax |
||
431 | pushl %ebx |
||
432 | movl $68, %eax |
||
433 | movl $1, %ebx |
||
434 | int $0x40 |
||
435 | popl %ebx |
||
436 | popl %eax |
||
437 | end; |
||
438 | |||
439 | function kos_initheap(): DWord; assembler; register; |
||
440 | asm |
||
441 | pushl %ebx |
||
442 | movl $68, %eax |
||
443 | movl $11, %ebx |
||
444 | int $0x40 |
||
445 | popl %ebx |
||
446 | end; |
||
447 | |||
448 | function kos_alloc(size: DWord): Pointer; assembler; register; |
||
449 | asm |
||
450 | pushl %ebx |
||
451 | pushl %ecx |
||
452 | movl %eax, %ecx |
||
453 | movl $68, %eax |
||
454 | movl $12, %ebx |
||
455 | int $0x40 |
||
456 | popl %ecx |
||
457 | popl %ebx |
||
458 | end; |
||
459 | |||
460 | function kos_free(ptr: Pointer): Boolean; assembler; register; |
||
461 | asm |
||
462 | pushl %ebx |
||
463 | pushl %ecx |
||
464 | movl %eax, %ecx |
||
465 | movl $68, %eax |
||
466 | movl $13, %ebx |
||
467 | int $0x40 |
||
468 | popl %ecx |
||
469 | popl %ebx |
||
470 | end; |
||
471 | |||
472 | function kos_loaddriver(name: PChar): THandle; assembler; register; |
||
473 | asm |
||
474 | pushl %ebx |
||
475 | pushl %ecx |
||
476 | movl %eax, %ecx |
||
477 | movl $68, %eax |
||
478 | movl $16, %ebx |
||
479 | int $0x40 |
||
480 | popl %ecx |
||
481 | popl %ebx |
||
482 | end; |
||
483 | |||
484 | |||
485 | { Processes and threads } |
||
486 | |||
487 | function kos_threadinfo(info: PKosThreadInfo; slot: TThreadSlot): DWord; assembler; register; |
||
488 | asm |
||
489 | pushl %ebx |
||
490 | movl %eax, %ebx |
||
491 | xchgl %edx, %ecx |
||
492 | movl $9, %eax |
||
493 | int $0x40 |
||
494 | xchgl %edx, %ecx |
||
495 | popl %ebx |
||
496 | end; |
||
497 | |||
498 | function kos_newthread(entry, stack: Pointer): TThreadID; assembler; register; |
||
499 | asm |
||
500 | pushl %ebx |
||
501 | pushl %ecx |
||
502 | movl $1, %ebx |
||
503 | movl %eax, %ecx |
||
504 | movl $51, %eax |
||
505 | int $0x40 |
||
506 | popl %ecx |
||
507 | popl %ebx |
||
508 | end; |
||
509 | |||
510 | procedure kos_initipc(ipc: PKosIPC; size: DWord); assembler; register; |
||
511 | asm |
||
512 | pushl %ebx |
||
513 | pushl %ecx |
||
514 | movl $60, %ecx |
||
515 | movl $1, %ebx |
||
516 | xchgl %eax, %ecx |
||
517 | int $0x40 |
||
518 | popl %ecx |
||
519 | popl %ebx |
||
520 | end; |
||
521 | |||
522 | function kos_sendmsg(tid: TThreadID; msg: Pointer; size: DWord): DWord; assembler; register; |
||
523 | {@return: |
||
524 | |||
525 | 1 - приёмник не определил буфер для IPC-сообщений |
||
526 | (может быть, ещё не успел, а может быть, это не тот поток, который нужен) |
||
527 | 2 - приёмник заблокировал IPC-буфер; попробуйте немного подождать |
||
528 | 3 - переполнение IPC-буфера приёмника |
||
529 | 4 - процесса/потока с таким PID не существует} |
||
530 | asm |
||
531 | pushl %esi |
||
532 | pushl %ebx |
||
533 | movl $60, %esi |
||
534 | movl $2, %ebx |
||
535 | xchgl %ecx, %esi |
||
536 | xchgl %eax, %ecx |
||
537 | int $0x40 |
||
538 | xchgl %ecx, %esi |
||
539 | popl %ebx |
||
540 | popl %esi |
||
541 | end; |
||
542 | |||
543 | function kos_resizemem(size: DWord): Boolean; assembler; register; |
||
544 | asm |
||
545 | pushl %ebx |
||
546 | pushl %ecx |
||
547 | movl %eax, %ecx |
||
548 | movl $64, %eax |
||
549 | movl $1, %ebx |
||
550 | int $0x40 |
||
551 | xorb $1, %al |
||
552 | popl %ecx |
||
553 | popl %ebx |
||
554 | end; |
||
555 | |||
556 | |||
557 | { File system } |
||
558 | { File system - Work with the current folder } |
||
559 | |||
560 | procedure kos_setdir(path: PChar); assembler; register; |
||
561 | asm |
||
562 | pushl %ecx |
||
563 | pushl %ebx |
||
564 | movl $30, %ecx |
||
565 | movl $1, %ebx |
||
566 | xchgl %eax, %ecx |
||
567 | int $0x40 |
||
568 | popl %ebx |
||
569 | popl %ecx |
||
570 | end; |
||
571 | |||
572 | function kos_getdir(path: PChar; size: DWord): DWord; assembler; register; |
||
573 | asm |
||
574 | pushl %ecx |
||
575 | pushl %ebx |
||
576 | movl $30, %ecx |
||
577 | movl $2, %ebx |
||
578 | xchgl %eax, %ecx |
||
579 | int $0x40 |
||
580 | popl %ebx |
||
581 | popl %ecx |
||
582 | end; |
||
583 | |||
584 | { File system - Work with file system with long names support } |
||
585 | |||
586 | function kos_readfile(kosfile: PKosFile; var readed: Longint): DWord; assembler; register; |
||
587 | asm |
||
588 | pushl %ebx |
||
589 | movl $70, %ebx |
||
590 | xchgl %eax, %ebx |
||
591 | movl $0, (%ebx) |
||
592 | int $0x40 |
||
593 | movl %ebx, (%edx) |
||
594 | popl %ebx |
||
595 | end; |
||
596 | |||
597 | function kos_rewritefile(kosfile: PKosFile; var writed: Longint): DWord; assembler; register; |
||
598 | asm |
||
599 | pushl %ebx |
||
600 | movl $70, %ebx |
||
601 | xchgl %eax, %ebx |
||
602 | movl $2, (%ebx) |
||
603 | int $0x40 |
||
604 | movl %ebx, (%edx) |
||
605 | popl %ebx |
||
606 | end; |
||
607 | |||
608 | function kos_writefile(kosfile: PKosFile; var writed: Longint): DWord; assembler; register; |
||
609 | asm |
||
610 | pushl %ebx |
||
611 | movl $70, %ebx |
||
612 | xchgl %eax, %ebx |
||
613 | movl $3, (%ebx) |
||
614 | int $0x40 |
||
615 | movl %ebx, (%edx) |
||
616 | popl %ebx |
||
617 | end; |
||
618 | |||
619 | function kos_fileinfo(kosfile: PKosFile): DWord; assembler; register; |
||
620 | asm |
||
621 | pushl %ebx |
||
622 | movl $70, %ebx |
||
623 | xchgl %eax, %ebx |
||
624 | movl $5, (%ebx) |
||
625 | int $0x40 |
||
626 | popl %ebx |
||
627 | end; |
||
628 | |||
629 | |||
623 | bw | 630 | { Sound } |
631 | |||
643 | bw | 632 | function kos_speaker(notes: Pointer): Boolean; assembler; register; |
623 | bw | 633 | asm |
634 | pushl %esi |
||
635 | pushl %ebx |
||
636 | movl $55, %esi |
||
637 | movl %esi, %ebx |
||
638 | xchgl %eax, %esi |
||
639 | int $0x40 |
||
640 | {eax = 55 - ошибка} |
||
641 | andl $1, %eax |
||
642 | popl %ebx |
||
643 | popl %esi |
||
644 | xorb $1, %al |
||
645 | end; |
||
646 | |||
647 | |||
616 | bw | 648 | { Work with hardware } |
649 | |||
650 | function kos_readport(index: DWord): DWord; assembler; register; |
||
651 | label ok, exit; |
||
652 | asm |
||
653 | pushl %ecx |
||
654 | pushl %ebx |
||
655 | xchgl %eax, %ecx {index} |
||
656 | movl $43, %eax |
||
657 | orl $0x80000000, %ecx {index} |
||
658 | int $0x40 |
||
659 | orl %eax, %eax |
||
660 | jzl ok |
||
661 | movl $-1, %eax |
||
662 | jmp exit |
||
663 | ok: |
||
664 | movl %ebx, %eax |
||
665 | exit: |
||
666 | popl %ebx |
||
667 | popl %ecx |
||
668 | end; |
||
669 | |||
670 | procedure kos_writeport(index, value: DWord); assembler; register; |
||
671 | asm |
||
672 | pushl %eax |
||
673 | pushl %ebx |
||
674 | pushl %ecx |
||
675 | xchgl %edx, %ebx {value} |
||
676 | xchgl %eax, %ecx {index} |
||
677 | movl $43, %eax |
||
678 | int $0x40 |
||
679 | xchgl %edx, %ebx |
||
680 | popl %ecx |
||
681 | popl %ebx |
||
682 | popl %eax |
||
683 | end; |
||
684 | |||
685 | function kos_reserveport(port: DWord): Boolean; assembler; register; |
||
686 | asm |
||
687 | pushl %ebx |
||
688 | pushl %ecx |
||
689 | pushl %edx |
||
690 | movl %eax, %ecx {port} |
||
691 | movl $46, %eax |
||
692 | movl %ecx, %edx {port} |
||
693 | xorl %ebx, %ebx |
||
694 | int $0x40 |
||
695 | xorb $1, %al |
||
696 | popl %edx |
||
697 | popl %ecx |
||
698 | popl %ebx |
||
699 | end; |
||
700 | |||
701 | { Work with hardware - Low-level access to PCI} |
||
702 | |||
703 | function kos_lastpcibus(): Byte; assembler; register; |
||
704 | asm |
||
705 | pushl %ebx |
||
706 | movl $62, %eax |
||
707 | movl $1, %ebx |
||
708 | int $0x40 |
||
709 | popl %ebx |
||
710 | end; |
||
711 | |||
712 | function kos_readpcib(bus, dev, func, reg: Byte): Byte; assembler; register; |
||
713 | asm |
||
714 | pushl %ebx |
||
715 | pushl %ecx |
||
716 | pushl %edx |
||
717 | shlb $3, %dl {dev} |
||
718 | movb %al, %bh {bus} |
||
719 | shlw $8, %cx {func} |
||
720 | movb $4, %bl |
||
721 | movb reg, %cl {func} |
||
722 | andb $7, %ch {func} |
||
723 | movl $62, %eax |
||
724 | orb %dl, %ch {dev/func} |
||
725 | int $0x40 |
||
726 | popl %edx |
||
727 | popl %ecx |
||
728 | popl %ebx |
||
729 | end; |
||
730 | |||
731 | function kos_readpciw(bus, dev, func, reg: Byte): Word; assembler; register; |
||
732 | asm |
||
733 | pushl %ebx |
||
734 | pushl %ecx |
||
735 | pushl %edx |
||
736 | shlb $3, %dl {dev} |
||
737 | movb %al, %bh {bus} |
||
738 | shlw $8, %cx {func} |
||
739 | movb $5, %bl |
||
740 | movb reg, %cl {reg} |
||
741 | andb $7, %ch {func} |
||
742 | movl $62, %eax |
||
743 | orb %dl, %ch {dev/func} |
||
744 | int $0x40 |
||
745 | popl %edx |
||
746 | popl %ecx |
||
747 | popl %ebx |
||
748 | end; |
||
749 | |||
750 | function kos_readpcid(bus, dev, func, reg: Byte): DWord; assembler; register; |
||
751 | asm |
||
752 | pushl %ebx |
||
753 | pushl %ecx |
||
754 | pushl %edx |
||
755 | shlb $3, %dl {dev} |
||
756 | movb %al, %bh {bus} |
||
757 | shlw $8, %cx {func} |
||
758 | movb $6, %bl |
||
759 | movb reg, %cl {reg} |
||
760 | andb $7, %ch {func} |
||
761 | movl $62, %eax |
||
762 | orb %dl, %ch {dev/func} |
||
763 | int $0x40 |
||
764 | popl %edx |
||
765 | popl %ecx |
||
766 | popl %ebx |
||
767 | end; |
||
768 | |||
769 | |||
770 | { Other } |
||
771 | procedure kos_delay(ms: DWord); assembler; register; |
||
772 | asm |
||
773 | pushl %ebx |
||
774 | movl %eax, %ebx |
||
775 | movl $5, %eax |
||
776 | int $0x40 |
||
777 | popl %ebx |
||
778 | end; |