home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / dos_ency / 9 / fig9_8.asm < prev   
Encoding:
Assembly Source File  |  1988-08-11  |  2.3 KB  |  65 lines

  1.         .
  2.         .
  3.         .
  4.         mov     ah,40h          ; test EMM status
  5.         int     67h
  6.         or      ah,ah
  7.         jnz     error           ; jump if bad status from EMM
  8.  
  9.         mov     ah,46h          ; check EMM version
  10.         int     67h
  11.         or      ah,ah
  12.         jnz     error           ; jump if couldn't get version
  13.         cmp     al,30h          ; make sure at least ver. 3.0
  14.         jb      error           ; jump if wrong EMM version
  15.  
  16.         mov     ah,41h          ; get page frame segment
  17.         int     67h
  18.         or      ah,ah
  19.         jnz     error           ; jump if failed to get frame
  20.         mov     page_frame,bx   ; save segment of page frame
  21.  
  22.         mov     ah,42h          ; get no. of available pages
  23.         int     67h
  24.         or      ah,ah
  25.         jnz     error           ; jump if get pages error
  26.         mov     total_pages,dx  ; save total EMM pages
  27.         mov     avail_pages,bx  ; save available EMM pages
  28.         or      bx,bx
  29.         jz      error           ; abort if no pages available
  30.  
  31.         mov     ah,43h          ; try to allocate EMM pages
  32.         mov     bx,needed_pages
  33.         int     67h             ; if allocation is successful
  34.         or      ah,ah
  35.         jnz     error           ; jump if allocation failed
  36.  
  37.         mov     emm_handle,dx   ; save handle for allocated pages
  38.  
  39.         .
  40.         .                       ; now we are ready for other
  41.         .                       ; processing using EMM pages
  42.         .
  43.                                 ; map in EMM memory page...
  44.         mov     bx,log_page     ; BX <- EMM logical page number
  45.         mov     al,phys_page    ; AL <- EMM physical page (0-3)
  46.         mov     dx,emm_handle   ; EMM handle for our pages
  47.         mov     ah,44h          ; Fxn 44H = map EMM page
  48.         int     67h
  49.         or      ah,ah
  50.         jnz     error           ; jump if mapping error
  51.  
  52.         .
  53.         .
  54.         .
  55.                                 ; program ready to terminate,
  56.                                 ; give up allocated EMM pages...
  57.         mov     dx,emm_handle   ; handle for our pages
  58.         mov     ah,45h          ; EMM Fxn 45H = release pages
  59.         int     67h
  60.         or      ah,ah
  61.         jnz     error           ; jump if release failed
  62.         .
  63.         .
  64.         .
  65.