"Fossies" - the Fresh Open Source Software Archive

Member "fasm/tools/dos/system.inc" (9 Feb 2020, 3189 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.

    1 
    2 display_string:
    3     lods    byte [esi]
    4     or  al,al
    5     jz  string_end
    6     mov dl,al
    7     mov ah,2
    8     int 21h
    9     jmp display_string
   10       string_end:
   11     ret
   12 alloc:
   13     push    ebx esi edi
   14     mov cx,ax
   15     shr eax,16
   16     mov bx,ax
   17     mov ax,501h
   18     int 31h
   19     jc  dpmi_allocation_failed
   20     mov ax,bx
   21     shl eax,16
   22     mov ax,cx
   23     mov edx,main
   24     shl edx,4
   25     sub eax,edx
   26     mov bx,si
   27     shl ebx,16
   28     mov bx,di
   29     mov ecx,[memory_handles_count]
   30     inc [memory_handles_count]
   31     shl ecx,3
   32     add ecx,memory_handles
   33     mov [ecx],eax
   34     mov [ecx+4],ebx
   35     pop edi esi ebx
   36     clc
   37     ret
   38     dpmi_allocation_failed:
   39     pop edi esi ebx
   40     stc
   41     ret
   42 free:
   43     push    ebx esi edi
   44     mov esi,memory_handles
   45     mov ecx,[memory_handles_count]
   46     find_memory_handle:
   47     cmp eax,[esi]
   48     je  memory_handle_found
   49     add esi,8
   50     loop    find_memory_handle
   51     pop edi esi
   52     ret
   53     memory_handle_found:
   54     mov ebx,[esi+4]
   55     dec [memory_handles_count]
   56     dec ecx
   57     jz  free_memory
   58     remove_memory_handle:
   59     mov edx,[esi+8]
   60     mov edi,[esi+8+4]
   61     mov [esi],edx
   62     mov [esi+4],edi
   63     add esi,8
   64     loop    remove_memory_handle
   65     free_memory:
   66     mov esi,ebx
   67     shr esi,16
   68     mov di,bx
   69     mov ax,502h
   70     int 31h
   71     pop edi esi ebx
   72     ret
   73 open:
   74     push    esi edi ebp
   75     call    adapt_path
   76     mov ax,716Ch
   77     mov bx,100000b
   78     mov dx,1
   79     xor cx,cx
   80     xor si,si
   81     call    dos_int
   82     jnc open_done
   83     cmp ax,7100h
   84     je  old_open
   85     stc
   86     jmp open_done
   87       old_open:
   88     mov ax,3D00h
   89     xor dx,dx
   90     call    dos_int
   91       open_done:
   92     mov bx,ax
   93     pop ebp edi esi
   94     ret
   95     adapt_path:
   96     mov esi,edx
   97     mov edi,buffer
   98       copy_path:
   99     lodsb
  100     cmp al,'/'
  101     jne path_char_ok
  102     mov al,'\'
  103       path_char_ok:
  104     stosb
  105     or  al,al
  106     jnz copy_path
  107     ret
  108     dos_int:
  109     push    0 0 0
  110     pushw   buffer_segment buffer_segment
  111     stc
  112     pushfw
  113     push    eax
  114     push    ecx
  115     push    edx
  116     push    ebx
  117     push    0
  118     push    ebp
  119     push    esi
  120     push    edi
  121     mov ax,300h
  122     mov bx,21h
  123     xor cx,cx
  124     mov edi,esp
  125     push    es ss
  126     pop es
  127     int 31h
  128     pop es
  129     mov edi,[esp]
  130     mov esi,[esp+4]
  131     mov ebp,[esp+8]
  132     mov ebx,[esp+10h]
  133     mov edx,[esp+14h]
  134     mov ecx,[esp+18h]
  135     mov ah,[esp+20h]
  136     add esp,32h
  137     sahf
  138     mov eax,[esp-32h+1Ch]
  139     ret
  140 create:
  141     push    esi edi ebp
  142     call    adapt_path
  143     mov ax,716Ch
  144     mov bx,100001b
  145     mov dx,10010b
  146     xor cx,cx
  147     xor si,si
  148     xor di,di
  149     call    dos_int
  150     jnc create_done
  151     cmp ax,7100h
  152     je  old_create
  153     stc
  154     jmp create_done
  155     old_create:
  156     mov ah,3Ch
  157     xor cx,cx
  158     xor dx,dx
  159     call    dos_int
  160     create_done:
  161     mov bx,ax
  162     pop ebp edi esi
  163     ret
  164 write:
  165     push    edx esi edi ebp
  166     mov ebp,ecx
  167     mov esi,edx
  168       write_loop:
  169     mov ecx,1000h
  170     sub ebp,1000h
  171     jnc do_write
  172     add ebp,1000h
  173     mov ecx,ebp
  174     xor ebp,ebp
  175       do_write:
  176     push    ecx
  177     mov edi,buffer
  178     shr ecx,2
  179     rep movsd
  180     mov ecx,[esp]
  181     and ecx,11b
  182     rep movsb
  183     pop ecx
  184     mov ah,40h
  185     xor dx,dx
  186     call    dos_int
  187     or  ebp,ebp
  188     jnz write_loop
  189     pop ebp edi esi edx
  190     ret
  191 read:
  192     push    edx esi edi ebp
  193     mov ebp,ecx
  194     mov edi,edx
  195       read_loop:
  196     mov ecx,1000h
  197     sub ebp,1000h
  198     jnc do_read
  199     add ebp,1000h
  200     mov ecx,ebp
  201     xor ebp,ebp
  202       do_read:
  203     push    ecx
  204     mov ah,3Fh
  205     xor dx,dx
  206     call    dos_int
  207     cmp ax,cx
  208     jne eof
  209     mov esi,buffer
  210     mov ecx,[esp]
  211     shr ecx,2
  212     rep movsd
  213     pop ecx
  214     and ecx,11b
  215     rep movsb
  216     or  ebp,ebp
  217     jnz read_loop
  218       read_done:
  219     pop ebp edi esi edx
  220     ret
  221       eof:
  222     pop ecx
  223     stc
  224     jmp read_done
  225 close:
  226     mov ah,3Eh
  227     int 21h
  228     ret
  229 lseek:
  230     mov ah,42h
  231     mov ecx,edx
  232     shr ecx,16
  233     int 21h
  234     pushf
  235     shl edx,16
  236     popf
  237     mov dx,ax
  238     mov eax,edx
  239     ret