home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / pc / progrmng / xm.lzh / XMINIT.ASM < prev    next >
Assembly Source File  |  1990-10-08  |  3KB  |  193 lines

  1.         .386
  2.         include    xmhd.inc
  3.         include xmmac.mac
  4.         include    xmmsg.def
  5. ;
  6. _DATA        segment    para public USE16 'DATA'
  7.         extrn    edata:sect, ebss:sect, ecode:sect
  8. _DATA        ends
  9. ;
  10. _TEXT        segment    para public USE16 'CODE'
  11.         assume    cs:_TEXT, ds:_DATA
  12.         extrn    a20_on:near, a20_off:near
  13.         extrn    pushtoexestack:near
  14.  
  15.         public  CopyVectors, setenvp    
  16. CopyVectors    proc    near
  17.         push    ds
  18.         push    es
  19.         sub    ax, ax
  20.         mov    ds, ax
  21.         mov    es, ax
  22.         mov    si, 4*8        ;copy vectors 8..f
  23.         mov    di, 4*50h    ;to 50..57
  24.         mov    cx, 8        ;eight double words
  25.         rep    movsd
  26.         pop    es
  27.         pop    ds
  28.         ret
  29. CopyVectors    endp
  30.  
  31. SetEnvP        proc    near
  32.         sub    eax, eax
  33.         jmp    PushToExeStack
  34. SetEnvP        endp
  35.  
  36. comment %
  37.  
  38. SetParm        proc    near
  39.         push    es
  40.         push    di
  41.         push    cx
  42.         mov    ax, _DATA
  43.         mov    es, ax
  44.         lea    di, PSPwork[129]
  45.         mov    cx, 127
  46.         cld
  47. .setpr04:
  48.         mov    al, es:[di]
  49.         mov    es:byte ptr[di],' '
  50.         inc    di
  51.         dec    cx
  52.         cmp    al, ' '
  53.         jbe    .setpr04
  54. .setpr05:
  55.         mov    al, es:[di]
  56.         cmp    al, ' '
  57.         jbe    .setpr01
  58.         mov    es:byte ptr[di],' '
  59.         inc    di
  60.         loop    .setpr05
  61.         
  62. .setpr01:
  63.         mov    al, es:[di]
  64.         cmp    al, 0
  65.         jnz    .setpr02
  66.         mov    es:byte ptr[di], ' '
  67. .setpr02:
  68.         inc    di
  69.         loop    .setpr01
  70.         pop    cx
  71.         pop    di
  72.         pop    es
  73.         ret    
  74. SetParm        endp
  75. %
  76.         public    memoryconfig, memscan, memmax
  77.  
  78. ;
  79. ;
  80. ; Check memory configration by compairing lowest memory and just at 1MB area.
  81. ;    return cf=1 if 8Kbytes data is match
  82. ;    by cf=0, we assume that extended memory (above 1MByte) is valid.
  83. ;
  84. MemoryConfig    proc    near    
  85.         push    ds
  86.         push    es
  87.         push    cx
  88. IF FMR70
  89.         call    a20_on
  90. ENDIF
  91.         mov    cx, 0
  92.         mov    ds, cx
  93.         mov    si, cx
  94. ;
  95.         mov    cx, 0ffffh
  96.         mov    es, cx
  97.         mov    di, 10h
  98. ;
  99.         mov    cx, 0fffh
  100.         cld
  101.     repz    cmpsw            
  102.         cmp    cx, 0
  103.         je    .MemNormal
  104. IF FMR70
  105.         call    a20_on
  106. ENDIF
  107.         stc
  108. .MemNormal:
  109.         cmc
  110.         pop    cx
  111.         pop    es
  112.         pop    ds
  113.         ret
  114. MemoryConfig    endp
  115.  
  116. memscan        proc    near
  117. IF  FMR70
  118.         call    a20_on
  119. ENDIF
  120.         mov    ax, es:word ptr[esi]
  121. IF FMR70 and Testing
  122.         call    a20_off
  123. ENDIF
  124.         mov    bx, ax
  125.         not    ax
  126. IF FMR70 and Testing
  127.         call    a20_on
  128. ENDIF
  129.         mov    es: word ptr[esi], ax
  130.         cmp    ax, es:word ptr[esi]
  131.         mov    es:word ptr[esi], bx
  132. IF FMR70 and Testing
  133.         call    a20_off
  134. ENDIF
  135.         jne    .memscanx
  136.  
  137.         add    esi, edx
  138.         cmp    esi, edi
  139.         jae    .memscanx
  140.         loop    memscan
  141. .memscanx:
  142.         ret
  143. memscan        endp
  144.  
  145.  
  146. MemMax        proc    near
  147. ;
  148. ; judge how much memory(above 1MB) is available
  149. ;    set maxmem in EData.Hi and return in esi
  150. ;
  151.         push    es
  152.         push    ax
  153.         push    bx
  154.         push    edi
  155. ;
  156. IF PCAT
  157.         call    a20_on
  158.         mov    ax,8800h    ; extended memory in K bytes
  159.         int    15h
  160. ENDIF
  161. IF FMR70
  162.         mov    ax,3072        ; 3MByte of memory at most
  163. ENDIF
  164.         movzx    edx, ax
  165.         shl    edx, 10
  166.         mov    esi, 1024 * 1024    ; at least
  167.         lea    edi, [edx + esi]    ; at most
  168. ;
  169.         mov    ax, 0
  170.         mov    es, ax
  171.         shr    edx, 3
  172.         mov    ecx, 11        ; 
  173. .exist:        
  174.         push    cx
  175.         mov    cx, 8            ; 8M bytes at most
  176.         call    memscan
  177.         sub    esi, edx
  178.         pop    cx
  179.         shr    edx, 2
  180.         loopnz    .exist
  181.         pop    edi
  182.         pop    bx
  183.         pop    ax
  184.         pop    es
  185.         mov    EData.Hi, esi
  186.         mov    EBSS.Hi, esi
  187.         ret
  188.         endp
  189.  
  190.  
  191. _TEXT        ends
  192.         end    
  193.