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

操作系统开发

开发平台:

Visual C++

  1. TITLE OSCMD - Operating System Command line access
  2. ;***
  3. ;OSCMD.ASM - Operating System  command line access
  4. ;
  5. ; Copyright <C> 1987, Microsoft Corporation
  6. ;
  7. ;Purpose:
  8. ; This module contains routines to access and manipulate the
  9. ; command line.  This is used by statements such as OPEN "PIPE:",
  10. ; RUN/CHAIN/SHELL/COMMAND$.
  11. ;
  12. ;******************************************************************************
  13. INCLUDE switch.inc
  14. INCLUDE rmacros.inc
  15. ;
  16. ; Code Segments
  17. ;
  18. USESEG <OS_TEXT> ;Operating System
  19. USESEG <NH_TEXT> ;Near Heap
  20. USESEG <RT_TEXT> ;Runtime Core
  21. ;
  22. ; Data Segments
  23. ;
  24. USESEG <_DATA>
  25. USESEG <_BSS> ;runtime data (uninitialized)
  26. INCLUDE seg.inc
  27. INCLUDE ascii.inc
  28. INCLUDE idmac.inc
  29. SUBTTL Code Externals
  30. PAGE
  31. sBegin NH_TEXT
  32. externNP B$STALCTMPCPY
  33. sEnd NH_TEXT
  34. sBegin RT_TEXT
  35. sEnd RT_TEXT
  36. SUBTTL Runtime data definitions for BASIC Operating System
  37. PAGE
  38. sBegin _BSS
  39. externW __acmdln ;command line pointer
  40. externB b$Buf1 ;defined in GWINI.ASM
  41. sEnd _BSS
  42. SUBTTL Runtime Operating System  Initialization
  43. PAGE
  44. assumes CS,OS_TEXT
  45. sBegin OS_TEXT
  46. ;***
  47. ;B$Arg0Skip - Skip past the program name on command line.
  48. ;Purpose:
  49. ; The DOS 5 command line now has the program name as the
  50. ; first element of the command line string.  This element
  51. ; needs to be skipped for compatability in things like
  52. ; Command$, RUN and CHAIN.
  53. ;
  54. ; NOTE: this routine works for KANJI characters because all of
  55. ; the items that we are testing (" ", 0, ASCCR) are less than
  56. ; any possible second byte of a Kanji Character.
  57. ;
  58. ;Entry:
  59. ; DS:SI - points to command line
  60. ;Exit:
  61. ; DS:AX - points to command line past program name
  62. ;Modifies:
  63. ; None.
  64. ;Exceptions:
  65. ; None.
  66. ;*****************************************************************************
  67. ;***
  68. ;B$CmdCopy - copy DOS command line from DS:SI to ES:DI
  69. ;Purpose:
  70. ; Copies the MSDOS command line into a buffer.  This routine is
  71. ; called by COMMAND$, CHAIN, and RUN.
  72. ;Entry:
  73. ; DS:SI - points to command line
  74. ; ES:DI - points to place to put command line
  75. ; For DOS 3, this is limited to 128 bytes, but OS/2 could
  76. ; could have up to 256 bytes.
  77. ;Exit:
  78. ; BX - count of chars copied
  79. ; Command line is copied into ES:DI
  80. ;Modifies:
  81. ; None.
  82. ;Exceptions:
  83. ; None.
  84. ;***************************************************************************
  85. cProc B$CmdCopy,<PUBLIC,NEAR>,<SI,DI>
  86. cBegin
  87. XOR BX,BX ; initialize character count
  88. CMD_IGNORE:
  89. LODSB ; fetch next char from command line
  90. CMP AL," "
  91. JE CMD_IGNORE ; ignore leading blanks
  92. CMD_LOOP:
  93. OR AL,AL ; 0 terminates command string
  94. JZ CMD_TERM
  95. CMP AL,ASCCR
  96. JE CMD_TERM ; CR terminates command string
  97. CMP AL,"a"
  98. JB CMD_COPY ; just copy if not lower case
  99. CMP AL,"z"
  100. JA CMD_COPY ; just copy if not lower case
  101. XOR AL,20H ; convert lower case to upper case
  102. CMD_COPY:
  103. STOSB ; copy char into temporary buffer
  104. INC BX ; increment char count
  105. DbAssertRelB BH,E,0,OS_TEXT,<Buffer overflow in B$CmdCopy>
  106. LODSB ; fetch next char from command line
  107. JMP SHORT CMD_LOOP ; repeat until end of command string
  108. CMD_TERM:
  109. cEnd
  110. ;***
  111. ;B$FCMD - return command line
  112. ;Purpose:
  113. ; Implement COMMAND$ function by returning a string containimg
  114. ; the MS-DOS command line.
  115. ;
  116. ;Inputs:
  117. ; None.
  118. ;Outputs:
  119. ; AX = ptr to string desc for temp with command line.
  120. ;Modifies:
  121. ; None.
  122. ;Exceptions:
  123. ; None.
  124. ;******************************************************************************
  125. externNP B$FrameAFE
  126. cProc B$FCMD,<PUBLIC,FAR>
  127. cBegin <nogen> 
  128. jmp B$FrameAFE
  129. cEnd <nogen> 
  130. sEnd OS_TEXT
  131. END