Ŀ
 Presents
  ڿĴ VMag, Issue 2, 1 June 1998
  

                           Memory Control Blocks.


             ᪥    ணࠬ ᮧ   
             -    ᮡ⢥  ணࠬ   
       㦥.     㦥  㧭 
       ᬥ饭  2Ch    砫 PSP. DOS ।⠢  㭪樨
        ࠡ   :
         ah=48h   ,
         ah=49h   ⮦, 
         ah=4Ah    ࠧ .
             㭪 ah=58h  ࠡ  ⥣ ।
       . ஡ -   㭠.
               뤥   DOS ᮧ ⠪ 뢠
         ࠢ    (Memory  Control  Block  -  MCB).
       ⠥,    ࠡ     MCB      ᪫⥫쭮
       ண⨢   DOS  ;)      ⮬   㬥஢   
       樠  筨.  MCB  ᯮ ।⢥
       ।  ,    ஬  ⭮.    ४⭮
       襭    MCB     筮   ⭮
       맮  㦥  ⥪  "Memory allocation error",  
       ᥣ  ⠫쭮.
                               ଠ MCB:
           0    1    2   3   4   5   6   7   8   9   A...E   F
           Ŀ
            Reserved   ணࠬ      
           
                 
           'M' : ஬ 
           'Z' : ᫥ 
           'D' :  ࠩ
           'F' :   ⮬    ࠭  ଠ   
                 䠩
           'X' : - // -,     FCB
           'B' :  室 DOS' 
           'L' : DOS ࠭  ⮬  ଠ   ᪥
           'S' : -, 易  ⥪.

           ,    祬- ;) ᠭ  ⨯ 'M'
         'Z' - 樠 "客 " MicroSoft Mark Zbikovski,
       ⠫쭮  -      祬  뢠騥  ,
       ᭮  ᠬ .
                '' -  ᥣ   ,
       ஬  "ਭ"      .      ਭ
       䨪஢ 祭
           0   :  ᢮
           8   : DOS-
              ᥣ   㣮 ,  ⮬ ᫥
           (  ᮡ ᠬ). ᫨    ᨫ 
       ᮡ  ᮢ  ;),      ''  㦮
       ,      '  ணࠬ'  DOS    - ⠬
       室 直 .
                      ࠣ,  ᫨    
       ᫥,    ᫥騩  MCB       ᥣ⭮
          old_MCB++1,    ᫥    祭
       old_MCB++1 ⥮᪨  ࠢ A000.
                १ࢨ஢      (筥, 
          ਤ㬠  ਬ)  ᯮ짮 
       㣮.
                '  ணࠬ' ᯮ   䠩 
       ७    孨 ॣ.
           饭          楯窥 MCB. 
       ࢮ  MCB  ࠭  ७ ६ DOS,  
        祭   㬥஢ 㭪樨
         ah=52h       "ᯨ᪠  ᯨ᪮",  頥 
       es:bx  List of lists,  ᫮  ᬥ饭 es:[bx-2] 
       ᥣ ᮬ ࢮ MCB.
            뫠 ⥮...  ᠥ ࠪ᪮ ਬ
        ⮣ ᥣ ।, 
        1.   ⨯ MCB,  ⭮ 'M'- -  'Z',  
       ⮬  砥    DOS        ᫥騥 
       (  ⮬       ࠧ "⥮᪨
        ࠢ A000").
        2.   ࠧ  ᫥  ('Z')    ਢ 
       㬥襭 ॠ쭮 ꥬ ᢮   DOS, 祬
        孨  ⠭ ⮪ "祩" ,  
         DOS.
ਬ: ⠭ ⮣ ࠡ稪 int 1Ch
----------------
.model tiny
.code
.startup
                mov     ax,ds
                dec     ax
                mov     es,ax                   ;MCB
                xor     di,di
                mov     byte ptr es:[di],'Z'    ;ન஢  ᫥,
                                                ; ᫨    ⠪
                dec     word ptr es:[di+3]      ;㬥 ࠧ 
                                                ; 1 ࠣ
                mov     ax,cs
                add     ax,word ptr es:[di+3]
                mov     ds,ax                   ;ds:0 - 砫 "祩" 
                mov     byte ptr ds:[di],0CFh   ;iret
                xor     dx,dx
                mov     ax,251Ch
                int     21h
                int     20h
end
----------------
        3. ᪨஢    DOS- -     '' 8.
        4. ⭠  ⮤  । ᢮ ( 㦮, ᫨
         )   १⭮            
       ᪠஢  MCB-楯窨.    ᯮᮡ ᮡ 㠫 
       १  ᪠    PSP,  室 
           १⭮  樨.  ᯮᮡ 㡨ࠥ
       ᪮쪮  ,  㦭     ࠡ⪨   堭   ⨯
       '/⢥'      楫 ࠡ稪 뢠, ᫨
       ⠪    ᯮ    ᪫⥫쭮      ।
       १⭮  (ਬ,  int  2Fh).    ॠ樨    
       ⫨砥    ⮤  ᪠    ᨣࠬ,  
       ᨢ  㤮.
ਬ:
----------------
.model tiny
.code
.startup
                mov     ah,52h
                int     21h
                mov     ax,es:[bx-2]
Label_000:
                mov     es,ax
                mov     di,8
                mov     cx,di
                mov     si,offset ID_Text
                repe    cmpsb                   ; ?
                jne     Not_Mine
                cmp     word ptr es:[1],0       ;   ᢮...
                jne     Already_Installed       ;--,  ⮣ 筮
Not_Mine:
                add     ax,es:[3]
                inc     ax
                cmp     byte ptr es:[0],'Z'
                jne     Label_000
                cmp     ax,0A000h               ;  ?
                je      Really_Last_Block
                mov     ah,9
                mov     dx,offset Text_3
                int     21h
Really_Last_Block:
        push    ds ds
        pop     es
                mov     ax,ds
                dec     ax
                mov     ds,ax
                mov     bx,word ptr ds:[3]
                dec     bx                      ;㬥 뤥
                mov     ah,4Ah                  ;  1 ࠣ
                int     21h
        pop     ds
                mov     ah,48h                  ;   ࠣ
                mov     bx,1                    ; 㣮 ᢮
                int     21h
                mov     es,ax
; ਥ ᯮ, ⮡  ᪠ "ப"  .  砥, ᫨
; N ᢮ ࠣ䮢    ⠫  ᢮
;㦥,  㤠,  -  孨 . ᫨ ⮣  ᤥ, 
;᫥ 襭 ணࠬ   룫拉 :
; XXXX: NC/VC/DN/...
; YYYY: free (⠫  ணࠬ)
; ZZZZ: 襭 N ࠣ䮢
; WWWW: free
; H筮 ;)
                cld
                mov     si,offset _16_bytes     ;    
                xor     di,di
                mov     cx,16
                rep     movsb
        push    es es
        pop     ax ds
                dec     ax
                mov     es,ax
                mov     word ptr es:[1],ds
        push    cs
        pop     ds
                mov     si,offset ID_Text
                mov     di,8
                mov     cx,di                   ; program name
                rep     movsb                   ;祬- ᢮
                mov     ah,9
                mov     dx,offset Text_1
                int     21h
                int     20h                     ; ⠪
Already_Installed:
                mov     ah,9
                mov     dx,offset Text_2
                int     21h
                mov     word ptr es:[di-15],0   ;᢮ 
                int     20h
_16_bytes       db 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16
Text_1          db 'Now installing...',13,10,'$'
Text_2          db 'It was already installed. Clearing memory...',13,10,'$'
Text_3          db 'There are some hidden blocks in memory.',13,10,'$'
ID_Text         db 'BeHeMoT '
end
----------------

         㣨  ਬ MCB ⠢ 襩 䠭⠧.

                                                              15.07.97
                                         BeHeMoT, 2:450/63.215@FidoNet
