Subversion Repositories Kolibri OS

Rev

Rev 666 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

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