   
 
                           .

          -
      -
,         
  .   , , 
,    PC MagNET,   
 "":   ,     
   ,     -
 -    ,  ,  - 
    , ..   
 .     BIX  
    80x86   80x88    
        
   .
           , -
        80x86
 80x88   .   1989 ,    
       , 
      
       .     ,
          
  ,   ,   , 
      .    -
,     ,    . 
     ,    -
    -        -
.
            
 .    ,  
        .
    ,     
 ,         .
       "-
" .    :  , -
   ,     
   .     ,  
        -
  -  :   ,     ,
      ,   -
       
    ,    -
.          
:  "      -
 ".

        , 
    ,  - , 
   -     .                      



               1.   .

       ,     -
 , ,   ,  ,   -
 ,     
.         
        
 .       ,  -
      (   ,
      ),  -   :  
     . -
   "",       (,
  )    (,  )
   ,      
  .
     ,       
,  ,      , -  -
  ,     .    
    ,   
,   ,    -
,    80386  80486,   
      .  
   ,   DOS, - -
   ,       
  -       
    ,       ,
      .   -
    ,    
    ,    -
 ,      ,     -
      .
     ,   ,  -
        .   
   -    ,
 ,    -   -
,  ,     :     -
            -
.         
        .  
          -
,   ,     -
 "" MASM,  TASM    OPTASM.  
 ,  ,     -
 ,      -
,        -
.
               
 ,      . -
    - "     "  "-
  ",      -
        .  
     .

   -       -
      ,       
         (  ).

   -     :   -
               
        ;    
     ,       
      ,      ; -
             -
      ;  ,  
         ,   ("-
       "  "  ")   -
     .

   -  ,        
         ,  -
       ""  ,     
       ,    (" ").

   -        ,  
            ,   
     ,         ,
                
         (   
      ).

   -      -
     ,        
             ,
         80186,  80188, 80286, 80386 
     80486.    -    ,
         32-    64--
       32- ,      -
      80386  80486.    , ,
            .

     80x86,   80x88, , ,  -
        -
       ,  
   ,    .
 8088  80188 -  8-       
      ,    
      (1 ,  8 ); -
  8086,  80186  80286 -  16-    "-
"   ,     (2 ,
16  );    80386  -  32- ,   
      (4 , 32
);  -       - 
80486,    32- ,  ,  -
     (16 , 96 ).
         ,      
,  ,    , -
     ,  ,
  ,   ""  .   
       ,
           
,     ,   
,       .  -
,        -
   ,  Microsoft, Borland
 Lotus,      ,  
 Windows 3.0  3.1,  Programmer's Workbench, Microsoft C 6.0,
 Microsoft C++ 7.0,  Borland C++ 3.0  Borland C++ 3.1, Borland
Pascal 7.0,    Lotus 1-2-3 3/G, -     
.

+--------------------------------------------------------------+
  ,          
 ,    .             
+--------------------------------------------------------------+



                   2.   .

           -
,     ,       
  -     ,  
 ,      -
.         ,  
   -     .
            ,  
        -
.    ,    
          
     ,  ,  
   .    
     ,   , -
    ,     -
      ,     -
 ,   /   
    .
           -
             
.         -
,       . 
         
         ,
    .      -
     ,   
  ,      
 ,        -
.   ,     ,  -
  ,      , -
 ,       ,  
       .
         -  
     ,      .
-,          -
    ,    
       ( ).  
     ,    
    ,  ,  ,  
,       . -,
         
        ,
       .    
    ,   -
,       .   
   ,   -
,       , -
     .
      ,     ,   --
   ,       -
 .        -
   ,     -
    .    -
    ,  ""  .
     ""    
          
         -
.  , ,     -
      -
   " ",      -
      .  Quick
BASIC,  Excel  Brief -     -
   ,    .
     ,      -
  ,          ()
   - .   
  :     -
 ,   DOS 5.0  OS/2 2.0  
   (   640  );  
    ,     -
 80386  80486,       
          8086,
8088,  80186,  80188  80286; /    
  DOS.

+--------------------------------------------------------------+
     -       , 
    .                           
+--------------------------------------------------------------+



                  3.    ?

            -
,   , :

   -         -
     ;

   -          
           ;

   -        
       .

      ,     
     ,    
.        -
  ,       -
        DX  -
 AX (,    ):

                xchg    ax,dx

                mov     ax,dx

     80x86  80x88  MOV   2    
 2   ,    XCHG
 1 ,    3 .      :
      .     -
     ,   -
      ,    
-    ,         ,
     ,     
   .   ,  
      -
      Intel,    
  80386  80486,      -
  , -    -
   ,     -
    .
           -
         
          ,
   ,      -
    .   ,  -
,    ,   ,   
   .    : " 
       ".
       ,  ,  
   ,       
        ,  -
 ,    ,      
.
        ,  ,  -
  ,         
    -    -
.        -
        2-3    
         -
     .   :  - -
     ,     -
         -  
         -
    (    -
       80x86  80x88,  
   ),        
    .
     ,       -
         :
    ? 
   : " ,  -
,   ,    ".  ,  
      ,  
   ,   ,     
 .       ToolBook.
,   ,       
   ,   ,   -
      .  -
     "" ,   
-  , ,   -
       , 
       - .
            
   ,     ,  -
            -
.        :
 ,   ,    
  ,   .  ,  
/,    ,     -
   .        
,        , 
        -
  :         
  .   ,    -,  
    ,   
    - , , -
.
       "  " 
       Bell Labs -
,       :
   "   60-      -
  ,     -
   -   
.      (  -
  ,        -
 ,       ),  -
  .      -
    .      
 .       -
        
.      ,   
     ""      
     ,   
".
     3  :     -
    ,       ,
        , 
  ;       -
;        ,
 ,     .
           :   
       ,  (-
     Bell Labs)  ,  ,  
      .      
 -   ,       
             
       
      .

+--------------------------------------------------------------+
           - 
    ,    
       "" .  
+--------------------------------------------------------------+



                  4.   .

            
  ,    -
 (  )      
  .   4-  8-
         -
,          
 ,       -
  .   16- , , 
8086, 8088  68000,    
    ,    
   :   8086  8088,
 ,    32-   16- -
  150 .
           -
          -
,     ,     -
.          ,
  "  ".   
          
(      )  
          -
.
          
.      ,  -
        ()
.   ,  , ,  ,  -
      -
 MyVar  8:

                mov     ax,MyVar
                mov     bx,8
                mul     bx
                mov     MyVar,ax

     8086  8088     -
   ""  :

                mov     ax,MyVar
                shl     ax,1
                shl     ax,1
                shl     ax,1
                mov     MyVar,ax

   :

                shl     MyVar,1
                shl     MyVar,1
                shl     MyVar,1

          ,   
       .  
   ,       -
     
    -      
 .
      -       -
,  !      80x86
 80x88,    ,     
  ,       -  
    .   -
          
     "        CL
 ":

                mov     ax,MyVar
                mov     cl,3
                shl     ax,cl
                mov     MyVar,ax

      80186,  80188,  80286,  80386  80486 
 "   ,    -
",   :

                shl     MyVar,3

              
  16 ,        
   . ,  
32-   DX:AX  4  :

                shl     ax,1
                rcl     dx,1
                shl     ax,1
                rcl     dx,1

       ,   -
          .  
      AX  10:

                mov     bx,ax
                shl     ax,1
                shl     ax,1
                add     ax,bx
                shl     ax,1

         
  .      ,  ,  
.     ,     
       (  
   ).           
      .      -
        
  ,  ,    ,  
         -
.            ,  
.           
    .    
    ,     .
,        4  -
 AX  :

                shr     ax,1
                shr     ax,1

   80186, 80188, 80286, 80386  80486  -
   :

                shr     ax,2

            4  -
  :

                and     ax,0003h

    !
        4 ,  ,  -
:

                sar     ax,1
                sar     ax,1

   80186, 80188, 80286, 80386  80486:

                sar     ax,2

          ( )
 SHR     (  )    SAR
  ,   SHR  ,    -
,       ,    SAR,
      ,   
 .
             
, ,      .   -
     ( )  -
  ,    ,   
       -    ;  
""        ,   -
-        
    .  (    ,  
  SHL  SAL      
     ,   ?)
             
  ,       ,  -
.  ,       8 
  DX:AX   :

                sar     dx,1
                rcr     ax,1
                sar     dx,1
                rcr     ax,1
                sar     dx,1
                rcr     ax,1

   ,      ,    
         
 ,   3  10,     -
   .      -
     10,     -
,         10,  
 ,     - , 
,  ,  , -    90% , -
      ,  
  .      
         -
,      "" .
             ,   
   ,   -
  ,     2.x  3.x 
MS-DOS.         
 AX  512:

                shr     ax,1
                xchg    ah,al
                cbw

   ,      ,    -
     ,    -
          -
 :  256, 512   ,   -
  XCHG  MOV.



        5.     .

    ,     
 ,     ,    
  80x86  80x88 - .    
 ,    -  
    ,     ,
   .    -
,    ,       ,
      Intel.
         -
  ,       ,
  :   (BIU - Bus Interface
Unit),       (EU -
Execution Unit).       -
 (,      , 
   ),    
            ,
      -
   .    -
    ,    
      :    
  ,       
 ,      .
           
   ?   ,  
     ,  
        
    .     
    ,      
,        .     
  ""   ,      -
  .   ,    , -
         -
,         -
.     ,      
   ,  ,    
    .      ,
           
 .     4     
  32     .    
,      
        
    .  ,    
       "-
" .          -
         .
          
 -     . -
,    8086  16-      
     16    ,    
,        -
     ,   
    .
            -
   :  ,      
         ,
       . 
,      (WORD  DWORD) 
     ALIGN   -
.  8088  80188  8-  , 
     .   -
          
   8088  80188,   -
  ,      -
,    .
      ,       -
     8086,  80186  80286, -
     WORD,    -
   80386  80486 -    
 DWORD. (  80486,    
-,  ,     16- ,
     8       -
  .)
     ,     -
,   :    ,   -
.      ,   -
      .      
  ,     ,  
,       .  -
       ,    -
   ,   .  ,
         -
,  ,    ,  
           "
",       
    .     -
     ,    -
         -
           -
.
        ,  
      ,   -
   ,   .   
       .  ,  
     ,    
      ,    -
,    ,    ""
      :

                cmp     Balance,0
                jl      Lab1

   ,       
      ,  -
    ,      
        :

                cmp     ax,High
                jne     Lab1
                ...
                jmp     Lab3
Lab1:           cmp     ax,Medium
                jne     Lab2
                ...
                jmp     Lab3
Lab2:           cmp     ax,Low
                jne     Lab3
                ...
Lab3:           ...

             ,
        ,  
      , -
        - 
    ,   ,  
        
(, , ),  (    -
  )     -
,    .     ,  
       .  
  ,        
 " ".  ,   ,
   AL  ASCII-    -
,      .  
      , -
   ASCII- ,   
    :

Table           dw      Routine_00
                dw      Routine_01
                ...
                dw      Routine_FE
                dw      Routine_FF
                ...
                mov     bl,al
                xor     bh,bh
                shl     bx,1
                jmp     Table[bx]

        ,     
,        "-
"        -
 " "  "   ".
         :
       ,   -
,          
     .      -  
    CALL,    
  RET,     JMP.  ,  -
:

Proc1           proc    near
                ...
                call    Proc2
                ret
Proc1           endp

Proc2           proc    near
                ...
                ret
Proc2           endp

   :

Proc1           proc    near
                ...
                jmp     Proc2
Proc1           endp

Proc2           proc    near
                ...
                ret
Proc2           endp

       :    -
,    PROC1,         PROC2,
 PROC2        -
,         CALL  RET.  
 PROC2    (  )      
PROC1,       JMP PROC2,   -
 PROC1     PROC2.
             
.          
        
RET  ,       ,  
 ,        .
, :

Proc1           proc    near
                ...
                cmp     ax,MyVar
                je      Exit
                call    Proc1
Exit:           ret
Proc1           endp

   :

Proc1           proc    near
                ...
                cmp     ax,MyVar
                jne     Proc1
                ret
Proc1           endp

           -
      .



                     6.  .

         -
 ,      -
: " ", "   ", "-
  ",   ",  "
"   .       
      :

   -       ,   
       .

   - ,   ,    
      .

         ,  ,  
90%      10%  . 
    10%,   ,  
    .   ,   ,
     ,  -   
 " "           -
   .      -
   ,   LOOP,
LOOPZ  LOOPNZ ( ,  ,   -
  ,  - );     , -
       
   .
        :   
,      - 
  ,    - ,    
 .       
 ,  , ,     -
   .      
        -
 ,        
   ,      -
   .  ,  ,  
        
   ,      -
         .     
    -        
" ".
          
.           
  ,       
,        (  -
        ).
         ,
   ,     -
   ,     -
    ,    -
     "" .
  -      -
 ,     , -
          -
 , ..  .
            ,
    5     -
      AX:

Items           equ     100

Array           dw      Items dup(?)

                xor     cx,cx
                xor     ax,ax
Lab1:           mov     bx,cx
                add     bx,bx
                add     bx,bx
                add     bx,bx
                add     bx,bx
                add     ax,Array[bx]
                inc     cx
                cmp     cx,Items/5
                jne     Lab1

  ,  :

Items           equ     100

Array           dw      Items dup(?)

                xor     ax,ax
                mov     bx,offset Array
Lab1:           add     ax,[bx]
                add     bx,10
                cmp     bx,offset Array + Items/5
                jb      Lab1

            
  ,   ,    - -
         -
.    ,       -
,      .    ,
    80x86  80x88  Intel -
    ,   -
 ,    ,   
        ,   -
 ,      -
    .        
      ,   -
          
,   .      
 ,        -
     .       
     "",    ,
       , -
   Intel.
           
 ,    .    
 ,       -
   . ,    :

                mov     cx,100
Lab1:           xor     ax,ax
                ...
                loop    Lab1
                mov     cx,100
Lab2:           xor     bx,bx
                ...
                loop    Lab2

   :

                mov     cx,100
Lab1:           xor     ax,ax
                ...
                xor     bx,bx
                ...
                loop    Lab1

           - "" ,  ..
    ,  
       .    
    ,   ,   
  ,   ,   -
 ,  .  :

                mov     cx,3
Lab1:           mov     ax,[bx]
                add     bx,2
                loop    Lab1

  :

                add     ax,[bx]
                add     bx,2
                add     ax,[bx]
                add     bx,2
                add     ax,[bx]

  :

                add     ax,[bx+0]
                add     ax,[bx+2]
                add     ax,[bx+4]

   ""  -    -
     .  ,  
,       ,   -
,          
          -
 .   ""    -
   .  ,   ,  -
        -
 80x86  80x88,    ,  
      -
.        
  :

                mov     cx,3
                mov     si,offset String1
                mov     di,offset String2
                rep     movsw

        ,    -
.     REP    
    ,      REP 
  ,     :

Lab1:           movsw
                loop    Lab1

         Intel   -
         -
 REP,      :

                movsw
                movsw
                movsw

       ,    ,  
             
.      
  ,       ,
            ,  
   :   ,
    ,   ( ) 
 -    .

         , 
       .         
                    7.  .

     ,       -
       (  ""  -
    ),      
 ,       .    
     ,   
     ,       
  ,      -
  ,     -
           .
          
  .
     ,     -
      .   
,       
,        -
.   , ,    
  .         
         ,    
      ,   
     "" .  , -
         
,            
  :      -
   (32 )   8  
,        4  5 (  
  1024x768  ).
          ,
         1    -
  4  .
       ,     -
      ,   
-   ,   10.000:

Table           label   word
                dw      0
                dw      175
                dw      349
                ...

     ,         
  ,    -
     0  359    AX,   -
         
  :

Sine            proc    near
                push    bx
                mov     bx,ax
                add     bx,bx
                mov     ax,Table[bx]
                pop     bx
                ret
Sine            endp

          
   ,   -
   ,   .  . 1 -
        -
  .

. 1.    ,    -
             .    -
                -
               -
                 0  359
         .
----------------------------------------------------------------
;
; ITRIG.ASM -   .
; (C) Copyright 1991 Ray Duncan
;

                title   ITRIG - Integer Trig Lookup

                name    ITRIG
                model   small,c
                dataseg

Table           label   word
                dw         0,  175,  349,  523,  698
                dw       872, 1045, 1219, 1392, 1564
                dw      1736, 1908, 2079, 2250, 2419
                dw      2588, 2756, 2924, 3090, 3256
                dw      3420, 3584, 3746, 3907, 4067
                dw      4226, 4384, 4540, 4695, 4848
                dw      5000, 5150, 5299, 5446, 5592
                dw      5736, 5878, 6018, 6157, 6293
                dw      6428, 6561, 6691, 6820, 6947
                dw      7071, 7193, 7314, 7431, 7547
                dw      7660, 7771, 7880, 7986, 8090
                dw      8192, 8290, 8387, 8480, 8572
                dw      8660, 8746, 8829, 8910, 8988
                dw      9063, 9135, 9205, 9272, 9336
                dw      9397, 9456, 9511, 9563, 9613
                dw      9659, 9703, 9744, 9781, 9816
                dw      9848, 9877, 9903, 9925, 9945
                dw      9962, 9976, 9986, 9994, 9998
                dw      10000

                codeseg

                public  Cosine
                public  Sine

;
; TRIG -     SIN  COS.
;
;  :
;   AX -     0  180.
;  :
;   AX -  .
;  :
;   BX -  .
;

Trig            proc    near
                mov     bx,ax
                cmp     bx,90
                jle     @@1
                sub     bx,180
                neg     bx
@@1:            sal     bx,1
                mov     ax,Table[bx]
                ret
Trig            endp

;
; COSINE -   .
;
;  :
;   AX -     0  360.
;  :
;   AX -     10.000.
;  :
;   
;

Cosine          proc    near
                add     ax,90
Cosine          endp

;
; SINE -   .
;
;  :
;   AX -     0  360.
;  :
;   AX -     10.000.
;  :
;   
;

Sine            proc    near
                push    bx dx
                cwd
                mov     bx,360
                idiv    bx
                mov     ax,dx
                or      ax,ax
                jns     @@1
                add     ax,360
@@1:            cmp     ax,180
                jle     @@2
                sub     ax,180
                call    Trig
                neg     ax
                jmp     short @@3
@@2:            call    Trig
@@3:            pop     dx bx
                ret
Sine            endp

                end
----------------------------------------------------------------

          -
   ,          .
,  ,     ,  
      .   -
    ,      
    .   -
    ,    -
    -  0  255,    
  -          
 :

Table           label   byte
                db      0
                db      1
                db      1
                db      2
                ...
Bits            proc    near
                push    bx
                mov     bl,al
                xor     bh,bh
                mov     ax,Table[bx]
                pop     bx
                ret
Bits            endp

    ,     ,  -
         -
 ,   .      -
 ,    MOV   -
 XLAT.      ,  
       . 
        
(   ),      64
         -
 .   ,     
        
        HPFS -
  OS/2.



       8.     .

            -
     ,     -
         ,
      -
   .
       8086  8088,   -
 80186, 80188  80286  .    -
    :

   -         -
     ,   .

   -  PUSH   .

   -      .

   -        -  PUSHA
      POPA.

   -   ENTER    LEAVE     
     .

   -      BOUND.

   -      .

           
 80186,  80286,  80386  80486,   -
             
  .      -
          -
  . (    8086 -
       ,    
  80188   80188 -  8-  -  -
.)
       80386  80486   -
,     16- -
,       -
 80188,  80188  80286 ,  ,   
     32- ,  -
     :

   - 32-  (     -
     ,         
         DOS,   -
       DOS  OS/2   1.3).

   -        
     (MOVZX  MOVSX).

   - 64-  (  ) -  SHLD
      SHRD.

   -     ""  ""  -
          ,  -
           (SETZ,  SETC
       ).

   -  ,  , ,   -
       (BT, BTC, BTR, BTS, BSF  BSR).

   -         -
      .

   -      LEA   
       .

   - ""  .

   -   32-       64-
       32-.

   -    (FS  GS).

   -     SS,  FS  GS (LSS, LFS
      LGS).

   ,     80386    80486
    DOS   OS/2 2.0, 
   32-  .    
    32- ,   -
      4 .
     80486     -
,      80386       -
   :

   -        32--
         (BSWAP).

   -    (CMPXCHG).

   -    (XADD).

       ,     ,
  80486   ,     80286  
80386.   ,   ,    
      .   ,  
,        8086 
8088,  ,      80486, 
 ,      
80286  80386.   .  ,  -,    -
,     80486:   - -
 8 ,     ,   -
   ,     -
 .   ,    Intel -
 80486SX    ,  
        -
          
- .
