"Fossies" - the Fresh Open Source Software Archive

Member "fasm/source/DOS/dpmi.inc" (9 Feb 2020, 1995 Bytes) of package /linux/misc/fasm-1.73.22.tgz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) fasm source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "dpmi.inc": 1.73.21_vs_1.73.22.

    1 
    2 ; flat assembler interface for DOS
    3 ; Copyright (c) 1999-2020, Tomasz Grysztar.
    4 ; All rights reserved.
    5 
    6 init_dpmi_memory:
    7     mov ax,500h         ; get free memory information
    8     mov edi,[buffer_address]
    9     int 31h
   10     mov ebx,[edi]
   11     allocate_dpmi_memory:
   12     mov edx,[memory_setting]
   13     shl edx,10
   14     jz  dpmi_memory_size_ok
   15     cmp ebx,edx
   16     jbe dpmi_memory_size_ok
   17     mov ebx,edx
   18     dpmi_memory_size_ok:
   19     mov [memory_end],ebx
   20     mov ecx,ebx
   21     shr ebx,16
   22     mov ax,501h
   23     int 31h
   24     jnc dpmi_memory_ok
   25     mov ebx,[memory_end]
   26     shr ebx,1
   27     cmp ebx,4000h
   28     jb  out_of_memory
   29     jmp allocate_dpmi_memory
   30     dpmi_memory_ok:
   31     shl ebx,16
   32     mov bx,cx
   33     sub ebx,[program_base]
   34     jc  out_of_memory
   35     mov [memory_start],ebx
   36     add [memory_end],ebx
   37     mov ax,100h         ; get free conventional memory size
   38     mov bx,-1
   39     int 31h
   40     movzx   ecx,bx
   41     shl ecx,4
   42     jecxz   no_conventional_memory
   43     mov ax,100h         ; allocate all conventional memory
   44     int 31h
   45     movzx   edi,ax
   46     shl edi,4
   47     sub edi,[program_base]
   48     jc  no_conventional_memory
   49     mov [additional_memory],edi
   50     mov [additional_memory_end],edi
   51     add [additional_memory_end],ecx
   52     mov eax,[memory_end]
   53     sub eax,[memory_start]
   54     shr eax,2
   55     cmp eax,ecx
   56     ja  no_conventional_memory
   57     ret
   58     no_conventional_memory:
   59     mov eax,[memory_end]
   60     mov ebx,[memory_start]
   61     sub eax,ebx
   62     shr eax,2
   63     mov [additional_memory],ebx
   64     add ebx,eax
   65     mov [additional_memory_end],ebx
   66     mov [memory_start],ebx
   67     ret
   68 
   69 dpmi_dos_int:
   70     mov [real_mode_segment],main
   71     simulate_real_mode:
   72     push    0           ; SS:SP (DPMI will allocate stack)
   73     push    0           ; CS:IP (ignored)
   74     push    0
   75     push    [real_mode_segment] ; DS
   76     push    [real_mode_segment] ; ES
   77     stc
   78     pushfw
   79     push    eax
   80     push    ecx
   81     push    edx
   82     push    ebx
   83     push    0
   84     push    ebp
   85     push    esi
   86     push    edi
   87     mov ax,300h
   88     mov bx,21h
   89     xor cx,cx
   90     mov edi,esp
   91     push    es ss
   92     pop es
   93     int 31h
   94     pop es
   95     mov edi,[esp]
   96     mov esi,[esp+4]
   97     mov ebp,[esp+8]
   98     mov ebx,[esp+10h]
   99     mov edx,[esp+14h]
  100     mov ecx,[esp+18h]
  101     mov ah,[esp+20h]
  102     add esp,32h
  103     sahf
  104     mov eax,[esp-32h+1Ch]
  105     ret
  106 dpmi_dos_int_with_buffer:
  107     mov [real_mode_segment],buffer
  108     jmp simulate_real_mode