home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / progmisc / hellsrc.zip / FLIB.ASM < prev    next >
Assembly Source File  |  1993-05-29  |  4KB  |  137 lines

  1.         .386p
  2.         jumps
  3. code32  segment para public use32
  4.         assume cs:code32, ds:code32
  5.  
  6. include pmode.inc
  7. include file.inc
  8.  
  9. public  _flopenlib, _flcloselib, _flopenfile, _flreadfile
  10.  
  11. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  12. ; DATA
  13. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  14. tokeninfo       dw      256 dup(?)
  15.  
  16. libnum          db      ?               ; number of files in library
  17. libhandle       dw      ?               ; file handle of library
  18. libheaderoff    dd      0               ; off of library header from end
  19.  
  20. filetogo        dd      ?               ; length of selected file to go
  21.  
  22. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  23. ; CODE
  24. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  25.  
  26. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  27. ; Open a library file
  28. ; In:
  29. ;   EDX -> lib filename
  30. ; Out:
  31. ;   V86R_BX - ?
  32. ;   CF=0 - lib opened succesfully
  33. ;   CF=1 - lib not found
  34. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  35. _flopenlib:
  36.         call _openfile
  37.         jc short flopenlibd
  38.         push eax bx ecx edx
  39.         mov ax,v86r_bx
  40.         mov libhandle,ax
  41.         mov eax,-1
  42.         mov bl,2
  43.         call _lseekfile
  44.         mov edx,offset libnum
  45.         mov ecx,1
  46.         call _readfile
  47.         movzx eax,byte ptr [edx]
  48.         shl eax,3
  49.         mov ecx,eax
  50.         inc eax
  51.         neg eax
  52.         mov libheaderoff,eax
  53.         call _lseekfile
  54.         mov edx,offset tokeninfo
  55.         call _readfile
  56.         pop edx ecx bx eax
  57. flopenlibd:
  58.         ret
  59.  
  60. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  61. ; Close a library file
  62. ; Out:
  63. ;   V86R_BX - ?
  64. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  65. _flcloselib:
  66.         push ax
  67.         mov ax,libhandle
  68.         mov v86r_bx,ax
  69.         call _closefile
  70.         pop ax
  71.         ret
  72.  
  73. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  74. ; Select a file from library
  75. ; In:
  76. ;   EAX - space padded token name (all 4 characters are used)
  77. ; Out:
  78. ;   V86R_BX - ?
  79. ;   CF=0 - file found
  80. ;   CF=1 - file not found
  81. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  82. _flopenfile:
  83.         push eax ebx ecx edx
  84.         movzx ecx,libnum
  85.         mov edx,ecx
  86.         shl edx,3
  87.         add edx,offset tokeninfo
  88.         mov ebx,libheaderoff
  89. flopenfilel0:
  90.         sub edx,8
  91.         sub ebx,[edx+4]
  92.         cmp eax,[edx]
  93.         loopne flopenfilel0
  94.         stc
  95.         jne short flopenfiled
  96.         mov ax,libhandle
  97.         mov v86r_bx,ax
  98.         mov eax,ebx
  99.         mov bl,2
  100.         call _lseekfile
  101.         mov eax,[edx+4]
  102.         mov filetogo,eax
  103. flopenfiled:
  104.         pop edx ecx ebx eax
  105.         ret
  106.  
  107. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  108. ; Read from a selected file
  109. ; In:
  110. ;   ECX - bytes to read
  111. ;   EDX -> buffer to read to
  112. ; Out:
  113. ;   EAX - bytes read
  114. ;   V86R_BX - ?
  115. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  116. _flreadfile:
  117.         push ecx
  118.         mov ax,libhandle
  119.         mov v86r_bx,ax
  120.         mov eax,filetogo
  121.         cmp eax,ecx
  122.         ja short flreadfilef0
  123.         mov ecx,eax
  124. flreadfilef0:
  125.         xor eax,eax
  126.         jecxz flreadfiled
  127.         sub filetogo,ecx
  128.         call _readfile
  129. flreadfiled:
  130.         pop ecx
  131.         ret
  132.  
  133.  
  134. code32  ends
  135.         end
  136.  
  137.