
bar

㭪             㬥 אַ㣮쭨.

⠪          #include <graphics.h>
                   #include <conio.h>
                   void far bar(int left,int top,int right,int
                                bottom);

, ᮤঠ騩   graphics.h
⨯

ᠭ           bar  嬥  אַ㣮쭨.
                   אַ㣮쭨 ,          ᯮ짮
                   ⥪饣 梥  蠡 .  bar  
                    אַ㣮쭨;   ⮣,  ⮡ ᮢ
                      嬥୮   אַ㣮쭨,  ᯮ
                   㭪 bar3d,  ࠬ஬ depth ࠢ 0.

                   孨    ࠢ  㣫  אַ㣮쭨
                      ࠬࠬ  (left,top)    (right,bottom)
                   ᮮ⢥⢥. न   ᥫ.

頥       .
祭

७ᨬ      㭪 㭨쭠  Borland C++.  㭪
                   ࠡ⠥ ⮫쪮   IBM PC  ᮢ⨬
                       ,   ᭠饭   ᯫ묨   ࠬ,
                   ন騬  ᪨  ०.   㭪   
                   ᮢ⨬  Windows.

 ⠪     bar3d, rectangle, setcolor, setfillstyle,
                   setlinestyle.

ਬ:

#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>

int main(void)
{
/*  ⮮। */
int graphdriver = DETECT, gmode, errorcode;
int midx,midy,i;

/* 樠 䨪   ६ */
initgraph(&graphdriver,&gmode,"");

/* 祭 १ 樠樨 */
errorcode = graphresult();
if(errorcode != grOk)  /* ᫨ 訡 */
{
   printf("訡 :%s\n",grapherrormessage(errorcode));
   printf(" ⠭   \n");
   getch();
   exit(1);  /* 襭   訡 */
}
midx = getmaxx() / 2;
midy = getmaxy() / 2;

/* 横  蠡  */
for(i=SOLID_FILL; i<USER_FILL; i++)
{
   /* ⠭ ⨯  */
   setfillstyle(i,getmaxcolor());

   /* ᮢ אַ㣮쭨 */
   bar(midx - 50, midy - 50, midx + 50, midy+50);

   getch();
}

/*  */
getch();
closegraph();
result 0;
}


bar3d

㭪             嬥 ⮫.

⠪          #include <graphics.h>
                   void far bar3d(int  left,  int  top,
                                    int right, int bottom,
                                     int depth, int topflag);
, ᮤঠ騩   graphics.h
⨯

ᠭ           bar3d  嬥 אַ㣮 ⮫,
                   ⥬ 訢  ,  ᯮ ⥪騩 蠡 
                   梥 . 嬥  ⮫ 
                   ⥪騬  梥⮬    ⨯ .  㡨 ⮫ 
                   窠 ࠭  ࠬ஬  depth.  ࠬ
                   topflag  ।,  㤥    ᮢ 設
                   嬥୮ ⮫.  ᫨ topflag    0,  設
                   ,    ⨢ 砥 設  .
                   (ᮧ  ⠢  ᪮쪮  ⮫殢
                     㣠.)

                   孨      ࠢ 㣮 אַ㣮쭨
                       (left,    top)          (right,bottom)
                   ᮮ⢥⢥.

                    ᫥  ⨯筮 㡨  bar3d 쬨
                   25% ਭ ⮫, ਬ:

                   bar3d(left,top,right,bottom,(right-left)/4,1)

頥       .
祭

७ᨬ      㭪 㭨쭠  Borland C++.  㭪
                   ࠡ⠥ ⮫쪮   IBM PC  ᮢ⨬
                       ,   ᭠饭   ᯫ묨   ࠬ,
                   ন騬 ᪨   ०.   㭪   
                   ᮢ⨬  Windows.

 ⠪     bar, rectangle, setcolor, setfillstyle,
                   setlinestyle.

ਬ:

#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>

int main(void)
{
/*  ⮮। */
int graphdriver = DETECT, gmode, errorcode;
int midx,midy,i;

/* 樠 䨪   ६ */
initgraph(&graphdriver,&gmode,"");

/* 祭 १ 樠樨 */
errorcode = graphresult();
if(errorcode != grOk)  /* ᫨ 訡 */
{
   printf("訡 :%s\n",grapherrormessage(errorcode));
   printf(" ⠭   \n");
   getch();
   exit(1);  /* 襭   訡 */
}
midx = getmaxx() / 2;
midy = getmaxy() / 2;

/* 横  蠡  */
for(i=SOLID_FILL; i<USER_FILL; i++)
{
   /* ⠭ ⨯  */
   setfillstyle(i,getmaxcolor());

   /* ᮢ 嬥 ⮫ */
   bar3d(midx - 50, midy - 50, midx + 50, midy+50, 10, 1);

   getch();
}

/*  */
closegraph();
result 0;
}


bcd

㭪            ८ࠧ ᫮  筮- .

⠪          #include<bcd.h>
                   bcd bcd(int x);
                   bcd bcd(double x);
                   bcd bcd(double x, int decimals);

, ᮤঠ騩   bcd.h
⨯

ᠭ             䬥᪨ 樨 ८।
                    ࠡ        ᫠      筮-筮
                   ஢  (BCD).
                   
                   BCD ᫠     17    ࠧ冷  
                         ।⠢    110^-125  
                   1x10^125.
                   
                    ८ࠧ ᫠  BCD ஢  ⭮
                       float,    double      long   double   
                   ᯮ짮 㭪樥  real.
                   
                   㬥 desimals   易⥫.      ।
                   ᪮쪮   室   ࠭   ࠧ冷   ᫥
                   筮   窨      ८ࠧ.
                   
                   ᫮ 㣫     ᮮ⢥⢨      ࠢ
                   㣫 ,    ᫮ 㣫
                    襣 楫 ᫠,   ⮪  㣫
                    ⭮ .

頥       筮-   ᫠.
祭

७ᨬ      bcd 㭨쭠  Borland C++;  ࠡ⠥ ⮫쪮 
                   ++.

 ⠪       real.

ਬ:

#include<iostream.h>
#include<bcd.h>

double x = 1000.0;  //   ஢
bcd  a  = bcd(x/3,2); //  , 㣫 
                      //  ⮩
int main(void)
{
   cout << " = $" << a << "\n";
   return 0;
}


bdos

㭪              ⥬ 맮 DOS.

⠪          #include <dos.h>
                   int bdos(int dosfun, unsigned dosdx,
                                             unsigned dosal);

, ᮤঠ騩   dos.h
⨯

ᠭ           bdos ᯥ稢 אַ   
                   ⥬ 맮  DOS.  ᠭ     ⥬
                   맮            㬥  "ࠢ筮
                   㪮⢮  DOS".

                    ⥬  맮,  ॡ  楫   㬥,
                   ᯮ 㭪 bdos; ᫨  ⢥ 㬥
                     ॡ  㪠⥫,    ᯮ   㭪
                   bdosptr.    large (compact,  large,
                   huge) ।⥫쭥 ᯮ짮    ⥬
                   맮  㭪  bdosptr    bdos   
                   㪠⥫  ⢥ 㬥.

                   dosfun  ᠭ   㬥 "ࠢ筮 㪮⢮
                    DOS".

                   dosdx  祭 ॣ DX.

                   dosal  祭 ॣ AL.

頥       㭪 bdos 頥 祭 ॣ AX,
祭           ⠭  ⥬ 맮.

७ᨬ      bdos 㭨쭠  DOS.

 ⠪     bdosptr, geninterrupt, int86, int86x, intdos,
                   intdosx.

ਬ:

#include <stdio.h>
#include <dos.h>

/* 祭 ⥪饣 ன⢠,  'A','B',...*/
char current_drive(void)
{
  char curdrive;
  /* 祭 ⥪饣 ᪠,  0,1,...*/
  curdrive = bdos(0x19,0,0);
  return('A' + curdrive);
}

main()
{
   printf("騩 ᪮ %c:\n",current_drive());
   return(0);
}


騩 ᪮ C:


bdosptr

㭪              ⥬ 맮 DOS.

⠪          #include <dos.h>
                   int bdosptr(int dosfun, void * argument,
                                   unsigned dosal);

, ᮤঠ騩   dos.h
⨯

ᠭ           bdosptr ᯥ稢 אַ   
                   ⥬ 맮   DOS.  ᠭ    ⥬
                   맮           㬥   "ࠢ筮
                   㪮⢮  DOS".

                    ⥬   맮,  ॡ  楫  㬥,
                   ᯮ 㭪 bdos; ᫨  ⢥ 㬥
                   㭪樨 ॡ  㪠⥫,   ᯮ 㭪
                   bdosptr.    large (compact,  large,
                   huge)  ।⥫쭥  ᯮ짮  ⥬
                   맮 㭪  bdosptr    bdos    
                   㪠⥫   ⢥ 㬥.    
                   ⨯ small ࠬ argument  bdosptr  DX; 
                     ⨯ large   祭 DS:DX,
                   ᯮ㥬  ⥬ 맮.

                   dosfun ᠭ  㬥  "ࠢ筮  㪮⢮
                    DOS".

                   dosal  祭 ॣ AL.

頥       㭪 bdosptr 頥 祭 ॣ AX
祭            ᯥ譮 襭  祭 -1  㤠筮
                   襭.   ⮬ 砥 ⠭ 祭
                   ६ errno  _doserrno.

७ᨬ      bdosptr 㭨쭠  DOS.

 ⠪     bdos, geninterrupt, int86, int86x, intdos, intdosx.

ਬ:

#include <stdio.h>
#include <dos.h>

/* 祭 ⥪饣 ன⢠,  'A','B',...*/
char current_drive(void)
{
  char curdrive;
  /* 祭 ⥪饣 ᪠,  0,1,...*/
  curdrive = bdos(0x19,0,0);
  return('A' + curdrive);
}

main()
{
   printf("騩 ᪮ %c:\n",current_drive());
   return(0);
}

/* ਬ砭 .    訡.  䠩 dop.aga ਢ
   ਬ,  ᯮ짮   㭪樨  Turbo C++. */
   

bioscom

㭪            믮 /뢮  ᫥⥫쭮 .

⠪          #include<bios.h>
                   int bioscom(int cmd, char abyte, int port);

, ᮤঠ騩   bios.h
⨯

ᠭ           㭪 bioscom 믮 ࠧࠧ  १
                   RS232    /뢮, 㪠뢠 
                   㬥 port.

                   祭 0  㬥  port   ᮮ⢥   COM1,
                   祭 1 ᮮ⢥ COM2  ..

                   祭 㬥   cmd           
                   ᫥:

                   0 - ⠭ ࠬ 裡  abyte;
                   1 - 뫠 ᨬ  abyte   裡;
                   2 - 砥 ᨬ   裡;
                   3 - 頥 ⥪饥 ﭨ 㭨樮
                       .

                   abyte   樥  ᫥  ⮢   (
                    㯯 롨ࠥ  祭):

                   0x02 - 7 ⮢             0x00    110 
                   0x03 - 8 ⮢             0x20    150 

                   0x00 - 1 ⮯-                0x40    300 
                   0x04 - 2 ⮯-               0x60    600 
                   0x00 -  ஢ન  ⭮  0x80    1200 
                   0x08 - ஢ઠ  ⭮    0xA0    2400 
                   0x18 - ஢ઠ  ⭮      0xC0    4800 
                                                    0xE0    9600 

                   ਬ, ᫨  abyte  ᫥饥 祭 0xEB
                   (0xE0|0x08|0x00|0x03),      ⠭  
                   㭨樮  ᪮ । 9600 ,
                   ஫   ⭮,  1  ⮯-,    8  ⮢
                   . bioscom ᯮ 뢠 BIOS 0x14.

頥         祭 cmd bioscom 頥 ⭠-
祭           ⨡⮢ 楫 ᫮,  8   -  
                   ﭨ,    8      ⮢     
                   ᨬ    祭  cmd.  訥      
                   頥 祭  ᫥騥 祭:

                    15 - ⠩;
                    14 - ।騩 ᤢ ॣ :
                    13 - ।騩 ॣ ࠭ ;
                    12 - 㦥 뢠;
                    11 - 訡 ନ஢  ᨭ஭樨;
                    10 - 訡 ⭮;
                    9  - 訡 ९;
                    8  - ⮢ .

                   ᫨ 祭    abyte    ।,   
                   ⠭  15.   㣨  訥 
                   訥      ⠭    ᮮ⢥騬
                   ࠧ.    ਬ,  ᫨    訡 
                   ᨭ஭樨,  ⠭  11.

                   ᫨ cmd   祭  2,    뢠  
                   室      ,  ᫨  뫮 訡.
                   ᫨    ந諠  訡,  ⠭,   
                   ࠩ ,     . ᫨   
                      ⠭,     祭
                    訡.

                   ᫨ cmd    祭 0  3,   頥
                   祭  ᮤন  訥  ,       뫨
                   ।   ,     訥    ।
                   ᫥騬 ࠧ:

                    7 - ਥ 㦥  ᨣ;
                    6 - 楢 ;
                    5 -   ⮢;
                    4 - ⮢  ।;
                    3 -   ਥ ⥪ 
                           ᨣ;
                    2 - 騩 楢 ⥪;
                    1 -   ⮢  ;
                    0 -   ⮢  ।.

७ᨬ      bioscom ন ⮫쪮  
                   IBM PC  ᮢ⨬  .

ਬ:

#include <bois.h>
#include <conio.h>

#define COM1 0
#define DATA_READY 0x100
#define TRUE 1
#define FALSE 0
#define SETTINGS (0x80|0x02|0x00|0x00)

int main(void)
{
    int in, out, status,DONE=FALSE;
    bioscom(0, SETTINGS, COM1);
    cprintf("... BIOSCOM [ESC] to exit ...\n");
    while (!DONE)
    {
       status = bioscom(3, 0, COM1);
       if (status & DATA_READY)
          if ((out=bioscom(2, 0, COM1) & 0x7F) != 0)
               putch(out);
           if (kbhit())
           {
              if ( (in = getch()) == '\x1B')
              DONE = TRUE;
              bioscom(1, in, COM1);
           }
      }
    return 0;
}


biosdisk

㭪            ᪮ 㭪樨 BIOS.

⠪          #include<bios.h>
                   int biosdisk(int cmd, int drive, int head,
                    int track, int sector, int nsects, void * buffer);

, ᮤঠ騩   bios.h
⨯

ᠭ           biosdisk ᯮ  뢠 0x13  ⮣,
                   ⮡ ।   믮    ᪮    権
                   ।⢥ ⥬ BIOS.

                   drive ।⠢   ᮡ  ᫮,  ஥  
                   ᯮ㥬 ᪮: 0  1- ன⢠ 
                   ᪮,  1  2- ன⢠  ᪮, 3 
                   3-  ன⢠    ..     ⪨   ᪮
                   ன   祭   drive   0x80    
                   ᪮, 祭 0x81 - ன ᪮, 祭
                   0x82 - ⨩  ..

                    ⪨     ᪮    㪠뢠    䨧᪮
                   ன⢮,    ࠧ ᪠.    室
                   ਪ  ணࠬ    㤥 ᠬ⥫쭮
                   ஢ ⠡ ࠧ.

                   cmd 砥 믮塞 .   ᨬ
                      祭   cmd   ⠫   㬥   
                   ॡ  .

                    ᫥     祭   cmd   
                   ஢ IBM PC,  XT, AT, PS/2  ᮢ⨬ 
                   .

                   0     ᪮ ஫. 
                       ⠫ ࠬ .
                       
                   1   頥  ᫥ ᪮ 樨.
                        ⠫ ࠬ .
                       
                   2   뢠     ᪮쪮 ᥪ஢
                       ᪠. 砫 ᥪ, 騩 뢠,
                         㬥⠬  head,  track    sector.
                       ᫮  뢠 ᥪ஢  㬥⮬
                       nsects.   뢠    buffer    512
                         ᥪ.
                       
                   3   뢠         
                       ᪮ ᥪ஢.  砫  ᥪ  
                       㬥⠬   head,   track     sector.  ᫮
                       ᥪ஢ । 㬥⮬ nsects. 
                       뢠      buffer  512  
                       ᥪ.
                       
                   4   ந 䨪   
                       ᥪ஢. 砫     ᥪ     ।
                       㬥⠬ head,  track   sector.  ⢮
                       ᥪ஢   nsects.
                       
                   5   ଠ ஦. ஦ ।
                       㬥⠬ head    track.   buffer   
                           㪠⥫   ⠡   ਯ஢
                       ᥪ஢,         뢠   
                       㪠   ஦.       㬥
                       "孨᪮ ࠢ筮 㪮⢮  IBM PC",
                         ஬  ஡  ᠭ   ⠡ 
                        ଠ஢.

                   쪮   ஢  ⨯  XT,   AT,   PS/2   
                   ᮢ⨬      ࠧ襭  ᫥騥 祭
                   㬥 cmd:

                   6   ଠ ஦  ⠭ 䫠
                        ᥪ஢.
                       
                   7   ଠ , 稭   ஦.
                   
                   8   頥 ࠬ ⥪饣 ᪮.
                        ଠ  뢠     buffer   
                         .
                       
                   9    ࠪ⨪  ன.
                   
                  10   ந 㤫 뢠, 
                       ⠥ 512   4  ⥫  
                         ᥪ.
                       
                  11   믮 㤫 ,  뢠
                       512   4 ⥫    
                       ᥪ.
                       
                  12   믮 ᪮  .
                  
                  13   ୠ⨢  ᪠.
                  
                  14   뢠  ᥪ.
                  
                  15   뢠  ᥪ.
                  
                  16   ஢ ⮢  ᪠.
                  
                  17    .
                  
                  18   ந ⨪  ஫ RAM.
                  
                  19   ந ⨪ ᪮.
                  
                  20   ந ७ ⨪ ஫.

                   ਬ砭. biosdisk ࠡ⠥  䠩 ⥬
                   -  ந ᥪ, ⮬  ࠧ
                   ᮤন 䠩  ४਩  ⪮ ᪥.

頥       biosdisk 頥  ﭨ, 騩
祭            ᫥ :

                   0x00   ᯥ譠 .
                   0x01   ୠ .
                   0x02    થ  .
                   0x03   ⪠   , 饭  .
                   0x04   ᥪ  .
                   0x05   㤠  ( ⪮ ᪠).
                   0x06     ᫥ ᫥ 樨.
                   0x07   ᡮ ࠬ ⨢ ᪮.
                   0x08   䫨  ࠡ DMA.
                   0x09   ⪠ 饭  DMA  ࠭楩 64.
                   0x0A   㦥 䥪 ᥪ.
                   0x0B   㦥 䥪⭠ ஦.
                   0x0C   ন ஦.
                   0x10   訡 CRC/ECC  ⥭ ᪠.
                   0x11   訡 CRC/ECC  ४஢ .
                   0x20   ᡮ  ࠡ ஫.
                   0x40   ᡮ  樨 ᪠.
                   0x80   㧥 ᮥ  ⢥砥.
                   0xAA   ன⢮  ⮢ (⮫쪮  ⪮
                          ᪠).
                   0xBB   ந諠 ᯮ 訡 (⮫쪮
                           ⪮ ᪠).
                   0xCC   ந襫 ᡮ  .
                   0xE0   訡 .
                   0xFF   ᡮ 樨 ᯮ.

                   ⨬,      0x11         訡,
                   ᪮   ४묨. 頥
                   祭  뤠      砥,  ⮡   
                       ਪ    ணࠬ   ࠡ
                   襭.

७ᨬ       㭪 ন ⮫쪮  
                   IBM PC  ᮢ⨬  .

 ⠪     absread, abswrite.

ਬ:

#include<bios.h>
#include<stdio.h>

int main(void)
{
   #define CMD     2 /*  ⥭ ᥪ */
   #define DRIVE   0 /*  ᪮  A: */
   #define HEAD    0 /*   */
   #define TRACK   1 /*  ஦ */
   #define SECT    1 /*  ᥪ஢ */
   #define NSECT   1 /* ᫮ ᥪ஢ */

   int result;
   char buffer[512];
   printf("⪠ ⥭ ᪮ A:\n");
   result = biosdisk(CMD,DRIVE,HEAD,TRACK,SECT,NSECT,buffer);
   if(result==0)
      printf("ᯥ譮 ⥭ ᪠  ᪮ A:");
   else
      printf("⪠ ⥭ ᪮ A: 㤠\n");
   return 0;
}


biosequip

㭪            ஢ 㤮.

⠪          #include<bios.h>
                   int biosequip(void);

, ᮤঠ騩   bios.h
⨯

ᠭ           biosequip 頥 楫 ᫮, 뢠饥
                   㤮, ᮥ   ⥬.    ⮩
                   楫 ᯮ 뢠 0x11 BIOS.

頥       頥 㭪樥 祭 ।⠢ ᮡ
祭            ⮢ .   IBM PC 
                    㤥 ᫥騬:

                    14-15  ⢮ ⠭ ࠫ
                               ਭ஢.
                               
                               00 = 0 ਭ஢
                               01 = 1 ਭ
                               10 = 2 ਭ
                               11 = 3 ਭ
                               
                    13      ᮥ ᫥⥫쭮
                               ਭ.
                               
                    12      ᮥ ஢ ஫.
                   
                    9-11   ⢮ ⮢ । .
                               000 = 0 ⮢
                               001 = 1 
                               010 = 2 
                               011 = 3 
                               100 = 4 
                               101 = 5 ⮢
                               110 = 6 ⮢
                               111 = 7 ⮢
                               
                    8       DMA (אַ   )
                               0=  DMA.
                               1=   DMA; ਬ,
                               PCJr.
                               
                    6-7    ⢮ ᪮
                               00=1 ᪮
                               01=2 ᪮
                               10=3 ᪮
                               11=4 ᪮ (⮫쪮, ᫨  0 = 1)
                   
                    4-5     室 -०
                               00 =  ᯮ
                               01 = 4025 BW  梥⭮ ⮩
                               10 = 8025 BW  梥⭮ ⮩
                               11 = 8025 BW  ஬ ⮩
                   
                    2-3     RAM  ਭ᪮ 
                               00 = 16
                               01 = 32
                               10 = 48
                               11 = 64
                   
                    1       ᮯ  饩 窮
                   
                    0       㧪  ᪠.
                   
७ᨬ      biosequip ন ⮫쪮  
                   IBM PC  ᮢ⨬  .

ਬ:

#include <stdio..h>
#include <bios.h>

#define CO_PROCESSOR_MASK 0x0002

int main(void)
{
   int equip_check;
   /*  ⥪ 䨣 㤮 */
   equip_check = biosequip();
   /*   ᮯ? */
   if(equip_check & CO_PROCESSOR_MASK)
      printf(" ⠭\n");
   else
      printf("  ⠭\n");
   return 0;
}


bioskey

㭪            䥩  ன   㭪権 BIOS.

⠪          #include<bios.h>
                   int bioskey(int cmd);

, ᮤঠ騩   bios.h
⨯

ᠭ           bioskey ।⢮ 뢠 BIOS 0x16 믮
                   ࠧ 樨  c  ன.  ࠬ   cmd
                   । .

頥       祭, 頥 㭪樥 bioskey,  
祭           믮塞 樨,  ।
                   㬥⮬ cmd:

                   
                   cmd    
                   
                   0      ᫨ 訥 8   㫥, bioskey
                          頥    ASCII   ᫥饩   ⮩
                          , 饩  ।. ᫨ 訥 8
                          ⮢  ࠢ 0,   訥 8 ⮢ ᮤঠ
                          ७      ,    ᠭ
                                        㬥
                          "孨᪮ ࠢ筮 㪮⢮    IBM
                          PC".

                   1      ந ஢ઠ,   
                          ⨥ .    ᫨         ஢થ
                          頥 祭 0,   砥,  
                            뫠 .   ⨢  砥
                          頥   祭   ।  ⮩
                          .         ।   ⮩
                            ࠭    㤥 饭 
                          ᫥饬   맮   㭪樨   bioskey   
                          祭 ࠬ cmd, ࠢ .

                   2      訢  ⥪騩    ⨯
                          SHIFT. 祭  砥    ᪮
                          ᫮ ᫥  (樨 "")
                   
                           7  0x80     INSERT  
                           6  0x40     CAPS 
                           5  0x20     NUM LOCK 
                           4  0x10     SCROLL LOCK 
                           3  0x08     ALT  
                           2  0x04     CTRL  
                           1  0x02     LEFT SHIFT 
                           0  0x01     RIGHT SHIFT 

७ᨬ      bioskey ন ⮫쪮   IBM PC
                    ᮢ⨬  .

ਬ:

#include <stdio.h>
#include <bios.h>
#include <ctype.h>

#define RIGHT 0x0001
#define LEFT  0x0002
#define CTRL  0x0004
#define ALT   0x0008

int main(void)
{
  int key, modifiers;

  /* 㭪 1 頥 0,   㤥
   .   . */;                                                                           /* now use function 0 to get return value of
  while (bioskey(1) == 0);

  /*  ᯮ㥬 㭪 0, ⮡ 
  祭   */
  key = bioskey(0);

  /* ᯮ㥬 㭪 2, ⮡ ।,
  ᯮ   ⨯ SHIFT */.
  modifiers = bioskey(2);
  if (modifiers) {
     printf("[");
     if (modifiers & RIGHT) printf("RIGHT ");
     if (modifiers & LEFT ) printf("LEFT ");
     if (modifiers & CTRL ) printf("CTRL ");
     if (modifiers & ALT  ) printf("ALT ");
     printf("] ");
}
/* 뢥 ᨬ ⮩  */
if (isalnum(key & 0xFF))
   printf("'%c'\n",key);
else
   printf("%#02x\n",key);
}


biosmemory

㭪            頥 ࠧ ⨢ .

⠪          #include<bios.h>
                   int biosmemory(void);

,ᮤঠ騩    bios.h
⨯

ᠭ           biosmemory   뢠 BIOS 0x12
                   砥 祭,   ࠢ   ࠧ   ⨢
                   .    祭    砥  -,
                   ७   ⥫ .

頥       biosmemory  頥 ࠧ ⨢ 
祭              1.

७ᨬ      biosmemory ন ⮫쪮  
                   IBM PC  ᮢ⨬  .

ਬ:

#include<stdio.h>
#include<bios.h>
int main(void)
{
   int memory_size;
   memory_size = biosmemory(); /* 頥  640 */
   printf("⨢ : %dK\n",memory_size);
   return 0;
}


biosprint

㭪            /뢮  ਭ   BIOS.

⠪          #include<bios.h>
                   int biosprint(int cmd, int abyte, int port);

, ᮤঠ騩   bios.h
⨯

ᠭ           biosprint 믮 ࠧ 樨  
                   ਭ஬, ।塞 㬥⮬ port,  
                   뢠 BIOS 0x17.

                   祭 㬥  port  =  0  ᮮ⢥ LPT1;
                   port = 1 ᮮ⢥ LPT2  ...

                   祭 㬥  cmd            
                   ᫥:
                   
                   0    ᨬ, ᮤঠ饣  abyte.
                   
                   1   樠  ਭ.
                   
                   2   뢠  ਭ.
                   
                   祭 㬥  abyte    ।  0
                    255.

頥       祭, 頥 㭪樥 biosprint  
祭            ᠭ  権, ।⠢ ᮡ
                    ਭ,  砥  ।⢮  樨
                   ""  ᫥騬 ⮢묨 祭ﬨ:
                   
                    0   0x01  ன⢠.
                    3   0x08 訡 /뢮.
                    4   0x10 祭.
                    5   0x20  㬠.
                    6   0x40 ⢥ত ਥ.
                    7   0x80  .

७ᨬ      biosprint ন ⮫쪮  
                   IBM PC  ᮢ⨬  .

ਬ:

#include<stdio.h>
#include<conio.h>
#include<bios.h>

int main(void)
{
   #define STATUS  2 /*    ਭ */
   #define PORTNUM 0 /* LPT1 */

   int status,abyte = 0;

   printf(", 몫 ਭ.  த 
               \n");
   getch();
   status = biosprint(STATUS,abute,PORTNUM);
   if(status & 0x01)
     printf(" ன⢠\n");
   if(status & 0x08)
     printf("訡 /뢮\n");
   if(status & 0x10)
     printf("祭\n");
   if(status & 0x20)
     printf(" 㬠\n");
   if(status & 0x40)
     printf("⢥ত ਥ\n");
   if(status & 0x80)
     printf(" \n");
   return 0;
}


biostime

㭪            뢠  ⠭ ⠩ BIOS.

⠪          #include <bios.h>
                   long biostime(int cmd, long newtime);

, ᮤঠ騩   bios.h
⨯

ᠭ           biostime  뢠,  ⠭
                   ⠩ BIOS.  ⠩ 뢠 ६, 襤襥
                    㭮,   ⨪ (ਡ⥫쭮  18.2  ⨪  
                   ᥪ㭤). biostime ᯮ 뢠 BIOS 0x1A.

                   ᫨ 㬥 cmd = 0,  biostime 頥 ⥪饥
                   祭 ⠩.   cmd  =  1  祭  ⠩
                   ⠭  㬥 newtime  ⨯ long.

頥        㭪 biostime ࠡ⠥  ० ⥭
祭           ⠩ BIOS (cmd = 0),  頥 祭
                   ।⠢ ᮡ ⥪饥 祭 ⠩.

७ᨬ      biostime ন ⮫쪮  
                   IBM PC  ᮢ⨬  .

ਬ:

#include<bios.h>
#include<time.h>
#include<conio.h>

int main(void)
{
   long bios_time;
   clrscr();
   cprintf("᫮ ⨪,  㭮:\r\n");
   cprintf("᫮ ᥪ㭤,  㭮:\r\n");
   cprintf("᫮ ,  㭮:\r\n");
   cprintf("᫮ ᮢ,  㭮:\r\n");
   cprintf("\r\n 室   ");
   while(!kbhit())
   {
      bios_time = biostime(0L);
      gotoxy(50,1);
      cprintf("%lu",bios_time);
      gotoxy(50,2);
      cprintf("%lu",bios_time/CLK_TCK);
      gotoxy(50,3);
      cprintf("%lu",bios_time/CLK_TCK/60);
      gotoxy(50,4);
      cprintf("%lu",bios_time/CLK_TCK/3600);
   }
   return(0);
}


brk

㭪             ࠧ饭   ᥣ .

⠪          #include<alloc.h>
                   int brk(void * addr);

, ᮤঠ騩   alloc.h
⨯

ᠭ           㭪 brk ᯮ  ᪮
                    ⢠  ,  ।  
                   ᥣ      뢠   ணࠬ.  
                       ந    ।⢮     
                   ணࠬ    "祭    뢠",   ஥
                       ᮬ  ᫥      ᥣ
                   .  ࠧ, ⢮ ⢥ 
                   㤥 㢥祭,  ᫨  㤥  㢥祭  "祭
                   뢠".

                   brk ⠭       "祭       뢠"
                   ᮮ⢥⢥ ࠬ addr   筮  
                   ⢮ .

                   ᫨   㤮⢮७  㤥 筮
                   ,  㭪   訡  
                   । .

頥        ᯥ譮 襭 㭪 brk 頥 -
祭           祭, ࠢ 0.  訡 頥 祭
                   -1    쭮  ६  errno  ᢠ
                   祭:

                     ENOMEM -  墠⠥ .

७ᨬ      brk ন    ⥬  UNIX.  㭪 
                   ᮢ⨬  Windows.

 ⠪     coreleft, sbrk.

ਬ:

#include<stdio.h>
#include<alloc.h>
                   
int main(void)
{
   char *ptr;
   printf(" ꥬ 뤥    brk");
   ptr = malloc(1);
   printf("। 맮 brk() ᢮ %lu \n",coreleft());
   brk(ptr+1000);
   printf("᫥ 맮 brk() ᢮ %lu \n",coreleft());
   return 0;
}


bsearch

㭪               ᨢ.

⠪          #include <stdlib.h>
                   void * bsearch(const void * key, const void * base,
                          size_t  nelem, size_t width,
                          int (*fcmp) (const void *, const void *));

, ᮤঠ騩   stdlib.h
⨯

ᠭ           bsearch ⢫   ⠡ (ᨢ) 
                   ⮢ nelem  頥  ࢮ 
                    ⠡,   ᮮ⢥  蠡  ᪠.
                   ᫨ ᮮ⢥⢨  ,  bsearch 頥
                   祭, ࠢ 0.  ⨬,  ᪮ 㭪
                   믮  ,   ᮮ⢥騩
                     易⥫쭮  㤥    ⮬  
                   ⠡.

                    size_t ।  unsigned int.

                   - nelem  ⢮ ⮢ ⠡.
                   
                   - width    ⢮     
                     ⠡.

                   㭪 ࠢ   fcmp   뢠        
                   㬥⠬:   elem1      elem2.    㬥
                   㪠뢠      ࠢ   .    㭪
                   ࠢ     ࠢ    ,    㥬
                   㪠⥫ﬨ (*elem1  *elem2)    頥  楫
                   祭, 饥  १⮢ ࠢ.

                    bsearch *fcmp 頥 ᫥騥 祭:
                   
                     < 0   *elem1 <  *elem2
                     ==0   *elem1 == *elem2
                     > 0   *elem1 >  *elem2

頥       bsearch 頥  ࢮ  ⠡,
祭           ᮮ⢥饣     ᪠.    ᫨    ⠪
                   ᮮ⢥⢨  ,   頥 祭,
                   ࠢ 0.

७ᨬ      ন  ⥬ UNIX  । 
                   ANSI C.

 ⠪     lfind, lsearch, qsort.

ਬ:

#include <stdlib.h>
#include <stdio.h>

#define NELEMS(arr)   (sizeof(arr) / sizeoff(arr[0]))
                   
int numarray[] = {123, 145, 512, 627, 800, 993};
int numeric(int *pl, int *p2)
{
   return(*p1 - *p2);
}
int lookup(int key)
{
   int *itemptr;
   /*  ८ࠧ
      室  ᪫祭 訡 ᮢ ⨯, -
      饩  ६ 樨 */
   itemptr = bsearch(&key, numarray, NELEMS(numarray),
       sizeof(int), (int (*)(const void *,const void *))numeric);
   return (itemptr != NULL);
}
int main(void)
{
   if(lookup(512))
      printf(" ⠡   512\n");
   else
      printf(" ⠡   512\n");
   return 0;
}

