directry.asm
上传用户:xiaoan1112
上传日期:2013-04-11
资源大小:19621k
文件大小:4k
源码类别:

操作系统开发

开发平台:

Visual C++

  1. TITLE DIRECTRY - GW BASIC 2.0 DIRECTORY HANDLING ROUTINES
  2. ;***
  3. ; DIRECTRY - GW BASIC 2.0 Directory handling routines
  4. ;
  5. ; Copyright <C> 1986, Microsoft Corporation
  6. ;
  7. ;Purpose:
  8. ;
  9. ; BASIC Syntax mapping to included runtime entry points:
  10. ;
  11. ;
  12. ; - CHDIR Statement:
  13. ;
  14. ;      CHDIR pathname
  15. ;  |
  16. ;      B$CDIR
  17. ;
  18. ;
  19. ; - MKDIR Statement:
  20. ;
  21. ;      MKDIR pathname
  22. ;  |
  23. ;      B$MDIR
  24. ;
  25. ;
  26. ; - RMDIR Statement:
  27. ;
  28. ;      RMDIR pathname
  29. ;  |
  30. ;      B$RDIR
  31. ;
  32. ;******************************************************************************
  33. INCLUDE switch.inc
  34. INCLUDE rmacros.inc
  35. ;
  36. ; Code Segments
  37. ;
  38. USESEG <DK_TEXT> ;Disk I/O component
  39. USESEG <NH_TEXT> ; For string deallocation
  40. ;
  41. ; Data Segments
  42. ;
  43. USESEG <_DATA>  ;Pre-initialized data
  44. INCLUDE seg.inc  ;segment definitions
  45. INCLUDE files.inc ;get callos macro, fn defs.
  46. INCLUDE baslibma.inc
  47. INCLUDE string.inc
  48. sBegin NH_TEXT
  49. externNP B$STDALCTMP ; Deallocate temp string
  50. externNP B$STPUTZ ; Null-terminate string
  51. sEnd NH_TEXT
  52. assumes CS,DK_TEXT
  53. sBegin DK_TEXT
  54. externNP B$ERR_PNF
  55. externNP B$ERR_ACD
  56. PAGE
  57. ;***
  58. ; B$MDIR - make a new directory entry (via DOS call)
  59. ; pascal far B$MDIR(psdDirectory)
  60. ;
  61. ; Input:
  62. ; psdDirectory == a pointer to an sd containing the input string
  63. ; Output:
  64. ; NONE
  65. ; Modifies:
  66. ; per convention
  67. ; Exceptions:
  68. ; May call B$ERR_PNF or B$ERR_ACD
  69. ;****
  70. cProc B$MDIR,<PUBLIC,FAR>
  71. cBegin <nogen>
  72. MOV AH,C_MKDIR ; DOS function code for make-directory
  73. SKIP 2 ; Proceed with processing
  74. cEnd <nogen> ; End of B$MDIR
  75. PAGE
  76. ;***
  77. ; B$RDIR - remove a directory entry (via DOS call)
  78. ; pascal far B$RDIR(psdDirectory)
  79. ;
  80. ; Input:
  81. ; psdDirectory == a pointer to an sd containing the input string
  82. ;
  83. ; Output:
  84. ; NONE
  85. ; Modifies:
  86. ; per convention
  87. ; Exceptions:
  88. ; May call B$ERR_PNF or B$ERR_ACD
  89. ;****
  90. cProc B$RDIR,<PUBLIC,FAR>
  91. cBegin <nogen>
  92. MOV AH,C_RMDIR ; DOS function code for remove-directory
  93. SKIP 2 ; Proceed with processing
  94. cEnd <nogen> ; End of B$RDIR
  95. PAGE
  96. ;***
  97. ; B$CDIR - change current working directory (via a DOS call)
  98. ; pascal far B$CDIR(psdDirectory)
  99. ;
  100. ; Input:
  101. ; psdDirectory == a pointer to an sd containing the input string
  102. ; Output:
  103. ; NONE
  104. ; Modifies:
  105. ; per convention
  106. ; Exceptions:
  107. ; May call B$ERR_PNF or B$ERR_ACD
  108. ;****
  109. cProc B$CDIR,<PUBLIC,FAR>
  110. cBegin <nogen>
  111. MOV AH,C_CHDIR ; AH = DOS function code for change-dir
  112. cEnd <nogen> ; End of B$CDIR & fall through
  113. PAGE
  114. ;***
  115. ;DIRECTORY - Common routine for all the three routines
  116. ;Pascal far DIRECTORY(psdDIRECTORY)   /* AH or AX is also input */
  117. ;
  118. ;ENTRY:
  119. ; psdDIRECTORY = pointer to an sd containing the input string
  120. ; AH = DOS function code for the directory function (DOS 2)
  121. ; AL = Entry index into the dispatch-table for directory function (DOS 5)
  122. ;
  123. ;EXIT:
  124. ; NONE
  125. ;
  126. ;Modifies:
  127. ; per convention
  128. ;
  129. ;Exceptions:
  130. ; May call B$ERR_PNF or B$ERR_ACD
  131. ;
  132. ;****
  133. cProc DIRECTORY,<FAR>,<SI,DI> 
  134. ParmSD sdDIRECTORY
  135. cBegin
  136. MOV BX,sdDIRECTORY ; Get the sd of string
  137. CALL B$STPUTZ ; null-terminate the string
  138. ; AH preserved from entry
  139. MOV DX,[BX+2] ; DS:DX = pathname string address
  140. CALLOS ; Do the requested function
  141. JC DIR_ERROR ; Brif error
  142. cCALL B$STDALCTMP ; deallocate temporary string
  143. cEnd ; End of DIRECTORY
  144. DIR_ERROR: ; DOS returned an error
  145. ; Analyze it
  146. CMP AL,ERRACD ; Is it Access-Denied?
  147. JE ACCESS_DENIED ; Brif so
  148. JMP B$ERR_PNF ; default to Path-not-found error
  149. ACCESS_DENIED:
  150. JMP B$ERR_ACD ; Access-Denied error
  151. sEnd DK_TEXT
  152. END