Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1057 lines
24 KiB

  1. PAGE 60,132
  2. TITLE DEBCOM1.ASM - PART1 DEBUGGER COMMANDS PC DOS
  3. ;/*
  4. ; * Microsoft Confidential
  5. ; * Copyright (C) Microsoft Corporation 1991
  6. ; * All Rights Reserved.
  7. ; */
  8. ;======================= START OF SPECIFICATIONS =========================
  9. ;
  10. ; MODULE NAME: DECOM1.asm
  11. ;
  12. ; DESCRIPTIVE NAME: DEBUGGING TOOL
  13. ;
  14. ; FUNCTION: PROVIDES USERS WITH A TOOL FOR DEBUGGING PROGRAMS.
  15. ;
  16. ; ENTRY POINT: ANY CALLED ROUTINE
  17. ;
  18. ; INPUT: NA
  19. ;
  20. ; EXIT NORMAL: NA
  21. ;
  22. ; EXIT ERROR: NA
  23. ;
  24. ; INTERNAL REFERENCES:
  25. ;
  26. ; EXTERNAL REFERENCES:
  27. ;
  28. ; ROUTINE: DEBCOM2 - CONTAINS ROUTINES CALLED BY DEBUG
  29. ; DEBCOM3 - CONTAINS ROUTINES CALLED BY DEBUG
  30. ; DEBASM - CONTAINS ROUTINES CALLED BY DEBUG
  31. ; DEBUASM - CONTAINS ROUTINES CALLED BY DEBUG
  32. ; DEBMES - CONTAINS ROUTINES CALLED BY DEBUG
  33. ;
  34. ; NOTES: THIS MODULE IS TO BE PREPPED BY SALUT WITH THE "PR" OPTIONS.
  35. ; LINK DEBUG+DEBCOM1+DEBCOM2+DEBCOM3+DEBASM+DEBUASM+DEBERR+
  36. ; DEBCONST+DEBDATA+DEBMES
  37. ;
  38. ; REVISION HISTORY:
  39. ;
  40. ; AN000 VERSION 4.00 - REVISIONS MADE RELATE TO THE FOLLOWING:
  41. ;
  42. ; - IMPLEMENT DBCS HANDLING DMS:6/17/87
  43. ; - IMPLEMENT MESSAGE RETRIEVER DMS:6/17/87
  44. ; - IMPLEMENT > 32MB SUPPORT DMS:6/17/87
  45. ;
  46. ; COPYRIGHT: "MS DOS DEBUG UTILITY"
  47. ; "VERSION 4.00 (C) COPYRIGHT 1988 Microsoft"
  48. ; "LICENSED MATERIAL - PROPERTY OF Microsoft "
  49. ;
  50. ;======================= END OF SPECIFICATIONS ===========================
  51. ; Routines to perform debugger commands except ASSEMble and UASSEMble
  52. IF1
  53. ;%out COMPONENT=DEBUG, MODULE=DEBCOM1
  54. ENDIF
  55. .XLIST
  56. .XCREF
  57. include syscall.inc ; cas -- missing equates
  58. include version.inc ; cas -- missing equates
  59. INCLUDE DOSSYM.INC
  60. INCLUDE debug.inc
  61. .CREF
  62. .LIST
  63. CODE SEGMENT PUBLIC BYTE
  64. CODE ENDS
  65. CONST SEGMENT PUBLIC BYTE
  66. EXTRN SYNERR_PTR:BYTE
  67. EXTRN DISPB:WORD,DSIZ:BYTE,DSSAVE:WORD
  68. IF SYSVER
  69. EXTRN CIN:DWORD,PFLAG:BYTE
  70. ENDIF
  71. CONST ENDS
  72. CSTACK SEGMENT STACK
  73. CSTACK ENDS
  74. DATA SEGMENT PUBLIC BYTE
  75. EXTRN DEFLEN:WORD,BYTEBUF:BYTE,DEFDUMP:BYTE
  76. EXTRN ARG_BUF:BYTE,ARG_BUF_PTR:BYTE
  77. EXTRN ONE_CHAR_BUF:BYTE,ONE_CHAR_BUF_PTR:WORD
  78. DATA ENDS
  79. DG GROUP CODE,CONST,CSTACK,DATA
  80. CODE SEGMENT PUBLIC BYTE
  81. ASSUME CS:DG,DS:DG,ES:DG,SS:DG
  82. PUBLIC HEXCHK,GETHEX1,PRINT,DSRANGE,ADDRESS,HEXIN,PERROR
  83. PUBLIC GETHEX,GET_ADDRESS,GETEOL,GETHX,PERR
  84. PUBLIC PERR,MOVE,DUMP,ENTERDATA,FILL,SEARCH,DEFAULT
  85. ifdef JAPAN
  86. public SETDUMPMODE
  87. extrn test_lead:near
  88. endif
  89. IF SYSVER
  90. PUBLIC IN
  91. EXTRN DISPREG:NEAR,DEVIOCALL:NEAR
  92. ENDIF
  93. EXTRN CRLF:NEAR,OUTDI:NEAR,OUTSI:NEAR,SCANP:NEAR
  94. EXTRN SCANB:NEAR,BLANK:NEAR,TAB:NEAR,COMMAND:NEAR
  95. EXTRN HEX:NEAR,BACKUP:NEAR
  96. EXTRN PRINTF_CRLF:NEAR,HEX_ADDRESS_ONLY:NEAR,HEX_ADDRESS_STR:NEAR
  97. EXTRN STD_PRINTF:NEAR
  98. DEBCOM1:
  99. ; RANGE - Looks for parameters defining an address range.
  100. ; The first parameter is the starting address. The second parameter
  101. ; may specify the ending address, or it may be preceded by
  102. ; "L" and specify a length (4 digits max), or it may be
  103. ; omitted and a length of 128 bytes is assumed. Returns with
  104. ; segment in AX, displacement in DX, and length in CX.
  105. DSRANGE:
  106. MOV BP,[DSSAVE] ; Set default segment to DS
  107. MOV [DEFLEN],128 ; And default length to 128 bytes
  108. RANGE:
  109. CALL ADDRESS
  110. PUSH AX ; Save segment
  111. PUSH DX ; Save offset
  112. CALL SCANP ; Get to next parameter
  113. MOV AL,[SI]
  114. CMP AL,UPPER_L ; Length indicator?
  115. JE GETLEN
  116. MOV DX,[DEFLEN] ; Default length
  117. CALL HEXIN ; Second parameter present?
  118. JC GETDEF ; If not, use default
  119. MOV CX,4
  120. CALL GETHEX ; Get ending address (same segment)
  121. MOV CX,DX ; Low 16 bits of ending addr.
  122. POP DX ; Low 16 bits of starting addr.
  123. SUB CX,DX ; Compute range
  124. JAE DSRNG2
  125. DSRNG1:
  126. JMP PERROR ; Negative range
  127. DSRNG2:
  128. INC CX ; Include last location
  129. ; JCXZ DSRNG1 ; Wrap around error
  130. ; Removing this instruction allows 0 FFFF to valid range
  131. POP AX ; Restore segment
  132. RET
  133. GETDEF:
  134. POP CX ; get original offset
  135. PUSH CX ; save it
  136. NEG CX ; rest of segment
  137. JZ RNGRET ; use default
  138. CMP CX,DX ; more room in segment?
  139. JAE RNGRET ; yes, use default
  140. JMP short RNGRET1 ; no, length is in CX
  141. GETLEN:
  142. INC SI ; Skip over "L" to length
  143. MOV CX,4 ; Length may have 4 digits
  144. CALL GETHEX ; Get the range
  145. RNGRET:
  146. MOV CX,DX ; Length
  147. RNGRET1:
  148. POP DX ; Offset
  149. MOV AX,CX
  150. ADD AX,DX
  151. JNC OKRET
  152. CMP AX,1
  153. JAE DSRNG1 ; Look for wrap error
  154. OKRET:
  155. POP AX ; Segment
  156. RET
  157. DEFAULT:
  158. ; DI points to default address and CX has default length
  159. CALL SCANP
  160. JZ USEDEF ; Use default if no parameters
  161. MOV [DEFLEN],CX
  162. CALL RANGE
  163. JMP GETEOL
  164. USEDEF:
  165. MOV SI,DI
  166. LODSW ; Get default displacement
  167. MOV DX,AX
  168. LODSW ; Get default segment
  169. RET
  170. ifdef JAPAN
  171. ;
  172. ; Set Dump mode to Kanji or Ascii
  173. ;
  174. dump_mode db 0
  175. dbcs_flag db 0
  176. dbcs_adj db 0
  177. SETDUMPMODE:
  178. call scanp ; get parameter
  179. jz dm_err ; if none
  180. lodsb
  181. cmp al,'K' ; is it for Kanji mode
  182. jnz @f ; no
  183. call geteol
  184. mov cs:dump_mode,1 ; set Kanji mode
  185. jmp short dm_ret
  186. @@:
  187. cmp al,'A' ; is it for Ascii mode
  188. jnz @f ; no
  189. call geteol
  190. mov cs:dump_mode,0 ; set Ascii mode
  191. jmp short dm_ret
  192. @@:
  193. dm_err:
  194. jmp PERR
  195. dm_ret:
  196. ret
  197. endif
  198. ; Dump an area of memory in both hex and ASCII
  199. DUMP:
  200. ifdef JAPAN
  201. mov cs:dbcs_flag,0
  202. mov cs:dbcs_adj,0
  203. endif
  204. MOV BP,[DSSAVE]
  205. MOV CX,DISPB
  206. MOV DI,OFFSET DG:DEFDUMP
  207. CALL DEFAULT ; Get range if specified
  208. MOV DS,AX ; Set segment
  209. ASSUME DS:NOTHING
  210. MOV SI,DX ; SI has displacement in segment
  211. PUSH SI ; save SI away
  212. MOV AL,DSIZ
  213. XOR AH,AH
  214. XOR AX,-1
  215. AND SI,AX ; convert to para number
  216. MOV DI,OFFSET DG:ARG_BUF ; Build the output str in arg_buf
  217. CALL OUTSI ; display location
  218. POP SI ; get SI back
  219. ; Determine where the registers display should begin.
  220. MOV AX,SI ; move offset
  221. MOV AH,3 ; spaces per byte
  222. AND AL,DSIZ ; convert to real offset
  223. MUL AH ; 3 char positions per byte of output
  224. OR AL,AL ; at beginning?
  225. JZ INROW ; if so, then no movement.
  226. PUSH CX
  227. MOV CX,AX
  228. CALL TAB
  229. POP CX
  230. INROW:
  231. PUSH SI ; Save address for ASCII dump
  232. BYTE0:
  233. CALL BLANK ; Space between bytes
  234. BYTE1:
  235. LODSB ; Get byte to dump
  236. CALL HEX ; and display it
  237. POP DX ; DX has start addr. for ASCII dump
  238. DEC CX ; Drop loop count
  239. JZ ASCII ; If through do ASCII dump
  240. MOV AX,SI
  241. TEST AL,DSIZ ; On row boundary?
  242. JZ ENDROW
  243. PUSH DX ; Didn't need ASCII addr. yet
  244. TEST AL,7 ; On 8-byte boundary?
  245. JNZ BYTE0
  246. MOV AL,CHAR_MINUS ; Mark every 8 bytes with "-"
  247. STOSB
  248. JMP SHORT BYTE1
  249. ENDROW:
  250. CALL ASCII ; Show it in ASCII
  251. MOV DI,OFFSET DG:ARG_BUF ; Build the output str in arg_buf
  252. CALL OUTSI ; Get the address at start of line
  253. JMP INROW ; Loop until count is zero
  254. ; Produce a dump of the ascii text characters. We take the current SI which
  255. ; contains the byte after the last one dumped. From this we determine how
  256. ; many spaces we need to output to get to the ascii column. Then we look at
  257. ; the beginning address of the dump to tsee how many spaces we need to indent.
  258. ASCII:
  259. PUSH CX ; Save count of remaining bytes
  260. ; Determine how many spaces to go until the ASCII column.
  261. MOV AX,SI ; get offset of next byte
  262. DEC AL
  263. AND AL,DSIZ
  264. INC AL
  265. ; AX now has the number of bytes that we have displayed: 1 to Dsiz+1.
  266. ; Compute characters remaining to be displayed. We *always* put the ASCII
  267. ; dump in column 51 (or whereever)
  268. SUB AL,10H ; get negative of number
  269. DEC AL ;
  270. NEG AL ; convert to positive
  271. CBW ; convert to word
  272. ; 3 character positions for each byte displayed.
  273. MOV CX,AX
  274. SHL AX,1
  275. ADD CX,AX
  276. ; Compute indent for ascii dump
  277. MOV AX,DX
  278. AND AL,DSIZ
  279. XOR AH,AH
  280. ADD CX,AX
  281. ; Tab over
  282. CALL TAB
  283. ; Set up for true dump
  284. MOV CX,SI
  285. MOV SI,DX
  286. SUB CX,SI
  287. ASCDMP:
  288. LODSB ; Get ASCII byte to dump
  289. ifdef JAPAN
  290. cmp cs:dbcs_flag,1
  291. jz set_dbcs ; if it was lead byte
  292. cmp cs:dbcs_flag,2
  293. jnz @f ; if it was not tail byte
  294. mov cs:dbcs_flag,0 ; reset
  295. @@:
  296. call test_lead
  297. jnc @f ; if this is not lead byte
  298. cmp byte ptr [si],CHAR_BLANK
  299. jae set_dbcs ; if tail byte is not control corde
  300. mov al,CHAR_PERIOD
  301. jmp short @f
  302. set_dbcs:
  303. inc cs:dbcs_flag
  304. @@:
  305. cmp cs:dump_mode,1
  306. jnz @f ; if not Kanji mode
  307. cmp cs:dbcs_adj,1
  308. jnz kanjiprt ; if no need to adjust
  309. mov al,' ' ; tail byte is displayed already
  310. mov cs:dbcs_adj,0
  311. jmp short kanjiprt
  312. @@:
  313. endif
  314. CMP AL,CHAR_RUBOUT
  315. JAE NOPRT ; Don't print RUBOUT or above
  316. ifdef JAPAN
  317. kanjiprt:
  318. endif
  319. CMP AL,CHAR_BLANK
  320. JAE PRIN ; print space through RUBOUT-1
  321. NOPRT:
  322. MOV AL,CHAR_PERIOD ; If unprintable character
  323. PRIN:
  324. STOSB
  325. LOOP ASCDMP ; CX times
  326. ifdef JAPAN
  327. cmp cs:dump_mode,1
  328. jnz @f ; if not Kanji mode
  329. cmp cs:dbcs_flag,1
  330. jnz @f ; if not ended with lead byte
  331. mov al,[si] ; get tail byte
  332. stosb
  333. mov cs:dbcs_adj,1
  334. @@:
  335. endif
  336. MOV AL,0
  337. STOSB
  338. PUSH DS
  339. PUSH CS
  340. POP DS
  341. ASSUME DS:DG
  342. CALL HEX_ADDRESS_STR
  343. CALL CRLF
  344. POP DS
  345. ASSUME DS:NOTHING
  346. POP CX ; Restore overall dump len
  347. MOV WORD PTR [DEFDUMP],SI
  348. MOV WORD PTR [DEFDUMP+WORD],DS ; Save last address as def
  349. RET
  350. ASSUME DS:DG
  351. ; Block move one area of memory to another Overlapping moves are performed
  352. ; correctly, i.e., so that a source byte is not overwritten until after it has
  353. ; been moved.
  354. MOVE:
  355. CALL DSRANGE ; Get range of source area
  356. PUSH CX ; Save length
  357. PUSH AX ; Save segment
  358. PUSH DX ; Save source displacement
  359. CALL ADDRESS ; Get destination address (sam
  360. CALL GETEOL ; Check for errors
  361. POP SI
  362. MOV DI,DX ; Set dest. displacement
  363. POP BX ; Source segment
  364. MOV DS,BX
  365. MOV ES,AX ; Destination segment
  366. POP CX ; Length
  367. CMP DI,SI ; Check direction of move
  368. SBB AX,BX ; Extend the CMP to 32 bits
  369. JB COPYLIST ; Move forward into lower mem.
  370. ; Otherwise, move backward. Figure end of source and destination
  371. ; areas and flip direction flag.
  372. DEC CX
  373. ADD SI,CX ; End of source area
  374. ADD DI,CX ; End of destination area
  375. STD ; Reverse direction
  376. INC CX
  377. COPYLIST:
  378. MOVSB ; Do at least 1 - Range is 1-1
  379. DEC CX
  380. REP MOVSB ; Block move
  381. RET1:
  382. RET
  383. ; Fill an area of memory with a list values. If the list
  384. ; is bigger than the area, don't use the whole list. If the
  385. ; list is smaller, repeat it as many times as necessary.
  386. FILL:
  387. CALL DSRANGE ; Get range to fill
  388. PUSH CX ; Save length
  389. PUSH AX ; Save segment number
  390. PUSH DX ; Save displacement
  391. CALL LIST ; Get list of values to fill w
  392. POP DI ; Displacement in segment
  393. POP ES ; Segment
  394. POP CX ; Length
  395. CMP BX,CX ; BX is length of fill list
  396. MOV SI,OFFSET DG:BYTEBUF ; List is in byte buffer
  397. JCXZ BIGRNG
  398. JAE COPYLIST ; If list is big, copy part of
  399. BIGRNG:
  400. SUB CX,BX ; How much bigger is area than
  401. XCHG CX,BX ; CX=length of list
  402. PUSH DI ; Save starting addr. of area
  403. REP MOVSB ; Move list into area
  404. POP SI
  405. ; The list has been copied into the beginning of the
  406. ; specified area of memory. SI is the first address
  407. ; of that area, DI is the end of the copy of the list
  408. ; plus one, which is where the list will begin to repeat.
  409. ; All we need to do now is copy [SI] to [DI] until the
  410. ; end of the memory area is reached. This will cause the
  411. ; list to repeat as many times as necessary.
  412. MOV CX,BX ; Length of area minus list
  413. PUSH ES ; Different index register
  414. POP DS ; requires different segment r
  415. JMP SHORT COPYLIST ; Do the block move
  416. ; Search a specified area of memory for given list of bytes.
  417. ; Print address of first byte of each match.
  418. SEARCH:
  419. CALL DSRANGE ; Get area to be searched
  420. PUSH CX ; Save count
  421. PUSH AX ; Save segment number
  422. PUSH DX ; Save displacement
  423. CALL LIST ; Get search list
  424. DEC BX ; No. of bytes in list-1
  425. POP DI ; Displacement within segment
  426. POP ES ; Segment
  427. POP CX ; Length to be searched
  428. SUB CX,BX ; minus length of list
  429. SCAN:
  430. MOV SI,OFFSET DG:BYTEBUF ; List kept in byte buffer
  431. LODSB ; Bring first byte into AL
  432. DOSCAN:
  433. SCASB ; Search for first byte
  434. LOOPNE DOSCAN ; Do at least once by using LO
  435. JNZ RET1 ; Exit if not found
  436. PUSH BX ; Length of list minus 1
  437. XCHG BX,CX
  438. PUSH DI ; Will resume search here
  439. REPE CMPSB ; Compare rest of string
  440. MOV CX,BX ; Area length back in CX
  441. POP DI ; Next search location
  442. POP BX ; Restore list length
  443. JNZ TTEST ; Continue search if no match
  444. DEC DI ; Match address
  445. CALL OUTDI ; Print it
  446. INC DI ; Restore search address
  447. CALL HEX_ADDRESS_ONLY ; Print the addresss
  448. CALL CRLF
  449. TTEST:
  450. JCXZ RET1
  451. JMP SHORT SCAN ; Look for next occurrence
  452. ; Get the next parameter, which must be a hex number.
  453. ; CX is maximum number of digits the number may have.
  454. ;=========================================================================
  455. ; GETHX: This routine calculates the binary representation of an address
  456. ; entered in ASCII by a user. GETHX has been modified to provide
  457. ; support for sector addresses > 32mb. To do this the bx register
  458. ; has been added to provide a 32 bit address. BX is the high word
  459. ; and DX is the low word. For routines that rely on DX for a 16
  460. ; bit address, the use of BX will have no effect.
  461. ;
  462. ; Date : 6/16/87
  463. ;=========================================================================
  464. GETHX:
  465. CALL SCANP
  466. GETHX1:
  467. XOR DX,DX ; Initialize the number
  468. xor bx,bx ;an000;initialize high word for
  469. ; sector address
  470. CALL HEXIN ; Get a hex digit
  471. JC HXERR ; Must be one valid digit
  472. MOV DL,AL ; First 4 bits in position
  473. GETLP:
  474. INC SI ; Next char in buffer
  475. DEC CX ; Digit count
  476. CALL HEXIN ; Get another hex digit?
  477. JC RETHX ; All done if no more digits
  478. STC
  479. JCXZ HXERR ; Too many digits?
  480. call ADDRESS_32_BIT ;an000;multiply by 32
  481. JMP SHORT GETLP ; Get more digits
  482. GETHEX:
  483. CALL GETHX ; Scan to next parameter
  484. JMP SHORT GETHX2
  485. GETHEX1:
  486. CALL GETHX1
  487. GETHX2:
  488. JC PERROR
  489. RETHX:
  490. CLC
  491. HXERR:
  492. RET
  493. ; Check if next character in the input buffer is a hex digit
  494. ; and convert it to binary if it is. Carry set if not.
  495. HEXIN:
  496. MOV AL,[SI]
  497. ; Check if AL is a hex digit and convert it to binary if it
  498. ; is. Carry set if not.
  499. HEXCHK:
  500. SUB AL,CHAR_ZERO ; Kill ASCII numeric bias
  501. JC RET2
  502. CMP AL,10
  503. CMC
  504. JNC RET2 ; OK if 0-9
  505. AND AL,5FH
  506. SUB AL,7 ; Kill A-F bias
  507. CMP AL,10
  508. JC RET2
  509. CMP AL,16
  510. CMC
  511. RET2:
  512. RET
  513. ; Process one parameter when a list of bytes is
  514. ; required. Carry set if parameter bad. Called by LIST.
  515. LISTITEM:
  516. CALL SCANP ; Scan to parameter
  517. CALL HEXIN ; Is it in hex?
  518. JC STRINGCHK ; If not, could be a string
  519. MOV CX,2 ; Only 2 hex digits for bytes
  520. push bx ;an000;save it - we stomp it
  521. CALL GETHEX ; Get the byte value
  522. pop bx ;an000;restore it
  523. MOV [BX],DL ; Add to list
  524. INC BX
  525. GRET:
  526. CLC ; Parameter was OK
  527. RET
  528. STRINGCHK:
  529. MOV AL,[SI] ; Get first character of param
  530. CMP AL,SINGLE_QUOTE ; String?
  531. JZ STRING
  532. CMP AL,DOUBLE_QUOTE ; Either quote is all right
  533. JZ STRING
  534. STC ; Not string, not hex - bad
  535. RET
  536. STRING:
  537. MOV AH,AL ; Save for closing quote
  538. INC SI
  539. STRNGLP:
  540. LODSB ; Next char of string
  541. CMP AL,CR ; Check for end of line
  542. JZ PERR ; Must find a close quote
  543. CMP AL,AH ; Check for close quote
  544. JNZ STOSTRG ; Add new character to list
  545. CMP AH,[SI] ; Two quotes in a row?
  546. JNZ GRET ; If not, we're done
  547. INC SI ; Yes - skip second one
  548. STOSTRG:
  549. MOV [BX],AL ; Put new char in list
  550. INC BX
  551. JMP SHORT STRNGLP ; Get more characters
  552. ; Get a byte list for ENTER, FILL or SEARCH. Accepts any number
  553. ; of 2-digit hex values or character strings in either single
  554. ; (') or double (") quotes.
  555. LIST:
  556. MOV BX,OFFSET DG:BYTEBUF ; Put byte list in the byte buffer
  557. LISTLP:
  558. CALL LISTITEM ; Process a parameter
  559. JNC LISTLP ; If OK, try for more
  560. SUB BX,OFFSET DG:BYTEBUF ; BX now has no. of bytes in list
  561. JZ PERROR ; List must not be empty
  562. ; Make sure there is nothing more on the line except for
  563. ; blanks and carriage return. If there is, it is an
  564. ; unrecognized parameter and an error.
  565. GETEOL:
  566. CALL SCANB ; Skip blanks
  567. JNZ PERROR ; Better be a RETURN
  568. RET3:
  569. RET
  570. ; Command error. SI has been incremented beyond the command letter so it must
  571. ; decremented for the error pointer to work.
  572. PERR:
  573. DEC SI
  574. ; Syntax error. SI points to character in the input buffer which caused
  575. ; error. By subtracting from start of buffer, we will know how far to tab
  576. ; over to appear directly below it on the terminal. Then print "^ Error".
  577. PERROR:
  578. SUB SI,OFFSET DG:(BYTEBUF-1) ; How many char processed so far?
  579. MOV CX,SI ; Parameter for TAB in CX
  580. MOV DI,OFFSET DG:ARG_BUF ;
  581. CALL TAB ; Directly below bad char
  582. MOV BYTE PTR [DI],0 ; nul terminate the tab
  583. MOV DX,OFFSET DG:SYNERR_PTR ; Error message
  584. ; Print error message and abort to command level
  585. PRINT:
  586. CALL PRINTF_CRLF
  587. JMP COMMAND
  588. ; Gets an address in Segment:Displacement format. Segment may be omitted
  589. ; and a default (kept in BP) will be used, or it may be a segment
  590. ; register (DS, ES, SS, CS). Returns with segment in AX, OFFSET in DX.
  591. ADDRESS:
  592. CALL GET_ADDRESS
  593. JC PERROR
  594. ADRERR:
  595. STC
  596. RET
  597. GET_ADDRESS:
  598. CALL SCANP
  599. MOV AL,[SI+1]
  600. CMP AL,UPPER_S
  601. JZ SEGREG
  602. MOV CX,4
  603. CALL GETHX
  604. JC ADRERR
  605. MOV AX,BP ; Get default segment
  606. CMP BYTE PTR [SI],CHAR_COLON
  607. JNZ GETRET
  608. PUSH DX
  609. GETDISP:
  610. INC SI ; Skip over ":"
  611. MOV CX,4
  612. CALL GETHX
  613. POP AX
  614. JC ADRERR
  615. GETRET:
  616. CLC
  617. RET
  618. SEGREG:
  619. MOV AL,[SI]
  620. MOV DI,OFFSET DG:SEGLET ; SEGLET DB "CSED"
  621. MOV CX,4
  622. REPNE SCASB
  623. JNZ ADRERR
  624. INC SI
  625. INC SI
  626. SHL CX,1
  627. MOV BX,CX
  628. CMP BYTE PTR [SI],CHAR_COLON
  629. JNZ ADRERR
  630. PUSH [BX+DSSAVE]
  631. JMP SHORT GETDISP
  632. SEGLET DB "CSED" ; First letter of each of the segregs: CS,SS,ES,DS
  633. ; Short form of ENTER command. A list of values from the
  634. ; command line are put into memory without using normal
  635. ; ENTER mode.
  636. GETLIST:
  637. CALL LIST ; Get the bytes to enter
  638. POP DI ; Displacement within segment
  639. POP ES ; Segment to enter into
  640. MOV SI,OFFSET DG:BYTEBUF ; List of bytes is in byte buffer
  641. MOV CX,BX ; Count of bytes
  642. REP MOVSB ; Enter that byte list
  643. RET
  644. ; Enter values into memory at a specified address. If the line contains
  645. ; nothing but the address we go into "enter mode", where the address and its
  646. ; current value are printed and the user may change it if desired. To change,
  647. ; type in new value in hex. Backspace works to correct errors. If an illegal
  648. ; hex digit or too many digits are typed, the bell is sounded but it is
  649. ; otherwise ignored. To go to the next byte (with or without change), hit
  650. ; space bar. To back CLDto a previous address, type "-". On every 8-byte
  651. ; boundary a new line is started and the address is printed. To terminate
  652. ; command, type carriage return.
  653. ; Alternatively, the list of bytes to be entered may be included on the
  654. ; original command line immediately following the address. This is in regular
  655. ; LIST format so any number of hex values or strings in quotes may be entered.
  656. ENTERDATA:
  657. MOV BP,[DSSAVE] ; Set default segment to DS
  658. CALL ADDRESS
  659. PUSH AX ; Save for later
  660. PUSH DX
  661. CALL SCANB ; Any more parameters?
  662. JNZ GETLIST ; If not end-of-line get list
  663. POP DI ; Displacement of ENTER
  664. POP ES ; Segment
  665. GETROW:
  666. CALL OUTDI ; Print address of entry
  667. PUSH DI
  668. PUSH ES
  669. PUSH DS
  670. POP ES
  671. MOV DI,OFFSET DG:ARG_BUF
  672. CALL BLANK
  673. XOR AL,AL
  674. STOSB
  675. CALL HEX_ADDRESS_STR
  676. POP ES
  677. POP DI
  678. GETBYTE:
  679. MOV AL,ES:[DI] ; Get current value
  680. PUSH DI
  681. PUSH ES
  682. PUSH DS
  683. POP ES
  684. MOV DI,OFFSET DG:ARG_BUF
  685. CALL HEX ; And display it
  686. MOV AL,CHAR_PERIOD
  687. STOSB
  688. XOR AL,AL
  689. STOSB
  690. MOV DX,OFFSET DG:ARG_BUF_PTR
  691. CALL STD_PRINTF
  692. POP ES
  693. POP DI
  694. LOOK_AGAIN:
  695. MOV CX,2 ; Max of 2 digits in new value
  696. MOV DX,0 ; Intial new value
  697. GETDIG:
  698. CALL INPT ; Get digit from user
  699. MOV AH,AL ; Save
  700. CALL HEXCHK ; Hex digit?
  701. XCHG AH,AL ; Need original for echo
  702. JC NOHEX ; If not, try special command
  703. MOV DH,DL ; Rotate new value
  704. MOV DL,AH ; And include new digit
  705. LOOP GETDIG ; At most 2 digits
  706. ; We have two digits, so all we will accept now is a command.
  707. DWAIT:
  708. CALL INPT ; Get command character
  709. NOHEX:
  710. CMP AL,CHAR_BACKSPACE ; Backspace
  711. JZ BS
  712. CMP AL,CHAR_RUBOUT ; RUBOUT
  713. JZ RUB
  714. CMP AL,CHAR_MINUS ; Back up to previous address
  715. JZ PREV
  716. CMP AL,CR ; All done with command?
  717. JZ EOL
  718. CMP AL,CHAR_BLANK ; Go to next address
  719. JZ NEXT
  720. MOV AL,CHAR_BACKSPACE
  721. CALL OUT_CHAR ; Back up over illegal character
  722. CALL BACKUP
  723. JCXZ DWAIT
  724. JMP SHORT GETDIG
  725. RUB:
  726. MOV AL,CHAR_BACKSPACE
  727. CALL OUT_char
  728. BS:
  729. CMP CL,2 ; CX=2 means nothing typed yet
  730. JZ PUTDOT ; Put back the dot we backed up over
  731. INC CL ; Accept one more character
  732. MOV DL,DH ; Rotate out last digit
  733. MOV DH,CH ; Zero this digit
  734. CALL BACKUP ; Physical backspace
  735. JMP SHORT GETDIG ; Get more digits
  736. PUTDOT:
  737. MOV AL,CHAR_PERIOD
  738. CALL OUT_CHAR
  739. JMP LOOK_AGAIN
  740. ; If new value has been entered, convert it to binary and
  741. ; put into memory. Always bump pointer to next location
  742. STORE:
  743. CMP CL,2 ; CX=2 means nothing typed yet
  744. JZ NOSTO ; So no new value to store
  745. ; Rotate DH left 4 bits to combine with DL and make a byte value
  746. PUSH CX
  747. MOV CL,4
  748. SHL DH,CL
  749. POP CX
  750. OR DL,DH ; Hex is now converted to binary
  751. MOV ES:[DI],DL ; Store new value
  752. NOSTO:
  753. INC DI ; Prepare for next location
  754. RET
  755. NEXT:
  756. CALL STORE ; Enter new value
  757. INC CX ; Leave a space plus two for
  758. INC CX ; each digit not entered
  759. PUSH DI
  760. MOV DI,OFFSET DG:ARG_BUF
  761. PUSH ES
  762. PUSH DS
  763. POP ES
  764. CALL TAB
  765. XOR AL,AL
  766. STOSB
  767. MOV DX,OFFSET DG:ARG_BUF_PTR
  768. CALL STD_PRINTF
  769. POP ES
  770. POP DI
  771. MOV AX,DI ; Next memory address
  772. AND AL,7 ; Check for 8-byte boundary
  773. JZ NEWROW ; Take 8 per line
  774. JMP GETBYTE
  775. NEWROW:
  776. CALL CRLF ; Terminate line
  777. JMP GETROW ; Print address on new line
  778. PREV:
  779. CALL STORE ; Enter the new value
  780. ; DI has been bumped to next byte. Drop it 2 to go to previous addr
  781. DEC DI
  782. DEC DI
  783. JMP SHORT NEWROW ; Terminate line after backing CLD
  784. EOL:
  785. CALL STORE ; Enter the new value
  786. JMP CRLF ; CR/LF and terminate
  787. ; Console input of single character
  788. IF SYSVER
  789. INPT: ;*** change for build - label to inpt
  790. PUSH DS
  791. PUSH SI
  792. LDS SI,CS:[CIN]
  793. MOV AH,4
  794. CALL DEVIOCALL
  795. POP SI
  796. POP DS
  797. CMP AL,3
  798. JNZ NOTCNTC
  799. INT VEC_CTRL_BREAK ;23H
  800. NOTCNTC:
  801. CMP AL,UPPER_P - CHAR_AT_SIGN
  802. JZ PRINTON
  803. CMP AL,UPPER_N - CHAR_AT_SIGN
  804. JZ PRINTOFF
  805. CALL OUT_CHAR
  806. RET
  807. PRINTOFF:
  808. PRINTON:
  809. NOT [PFLAG]
  810. JMP SHORT IN
  811. ELSE
  812. INPT: ; Change label for build
  813. MOV AH,Std_Con_Input ;OPTION=1, STANDARD CONSOLE INPUT
  814. INT 21H
  815. RET
  816. ENDIF
  817. OUT_CHAR:
  818. PUSH DI
  819. PUSH DX
  820. PUSH ES
  821. PUSH DS
  822. POP ES
  823. MOV DI,OFFSET DG:ONE_CHAR_BUF
  824. STOSB
  825. MOV AL,0
  826. STOSB
  827. MOV DX,OFFSET DG:ONE_CHAR_BUF_PTR
  828. CALL STD_PRINTF
  829. POP ES
  830. POP DX
  831. POP DI
  832. RET
  833. ;=========================================================================
  834. ; ADDRESS_32_BIT: This routine will build an address for 32bit sector
  835. ; addressibility. BX will be the high word, with DX being
  836. ; the low word.
  837. ;
  838. ; Inputs : DX/BX - registers to contain 32bit sector address
  839. ; DX & BX are both initialized to 0 on first call to routine.
  840. ;
  841. ; Outputs: DX/BX - registers to contain 32bit sector address
  842. ;
  843. ; Date : 6/16/87
  844. ;=========================================================================
  845. ADDRESS_32_BIT proc near ;an000;perform 32 bit address
  846. ; creation
  847. push cx ;an000;save affected regs.
  848. mov cx,04h ;an000;initialize to
  849. ; nibble shift
  850. ; $do ;an000;while cx not= 0
  851. $$DO1:
  852. cmp cx,00h ;an000;are we done?
  853. ; $leave e ;an000;yes, quit loop
  854. JE $$EN1
  855. shl bx,1 ;an000;shift bx 1 bit
  856. shl dx,1 ;an000;shift dx 1 bit
  857. ; $if c ;an000;did low word carry
  858. JNC $$IF3
  859. or bx,01h ;an000;set bit 0 of high word
  860. ; $endif ;an000;
  861. $$IF3:
  862. dec cx ;an000;decrease counter
  863. ; $enddo ;an000;end while loop
  864. JMP SHORT $$DO1
  865. $$EN1:
  866. or dl, al ;an000;overlay low word
  867. ; bits 0-3 with next
  868. ; portion of the address
  869. pop cx ;an000;restore affected regs.
  870. ret ;an000;return to caller
  871. ADDRESS_32_BIT endp ;an000;end proc
  872. CODE ENDS
  873. END DEBCOM1
  874.