home *** CD-ROM | disk | FTP | other *** search
- ;=============================================================================
- ; GETHOME.ASM
- ;=============================================================================
- ;
- ; To make GETHOME.COM you have to compile this file to .OBJ file.
- ; Following syntax is for Turbo Assembler (Borland):
- ;
- ; TASM gethome
- ;
- ; Then it must be linked to .COM file.
- ; Syntax is:
- ;
- ; TLINK /t gethome
- ;
- ;------------------------------------------------------------------------------
-
- WRITE_STDOUT MACRO
-
- MOV BX,01h ; CON file handle.
- MOV AH,40h ; Write thru handle.
- INT 21h
-
- ENDM
-
- _TEXT SEGMENT PUBLIC 'CODE'
- ASSUME CS:_TEXT, DS:_TEXT, ES:_TEXT, SS:_TEXT
-
- ORG 100h
- START:
- JMP SHORT MAIN
-
- DRIVE DB "A:"
- CRLF DB 13,10
- CMD DB "CD \"
- BUFFER DB 64 DUP (?)
-
- MAIN:
- MOV AH,19h ; Get default drive.
- INT 21h
-
- ADD DRIVE,AL
-
- ; Now, print character and colon.
-
- MOV DX,OFFSET DRIVE
- MOV CX,4 ; Four chars, including CRLF.
- WRITE_STDOUT
-
- ; Get current directory
-
- XOR DL,DL ; Current drive into DL
- MOV SI,OFFSET BUFFER
- MOV AH,47h ; Get directory
- INT 21h
-
-
- ; Count path string length into CX.
-
- CLD ; Forward search.
- XOR CX,CX ; Zero length counter.
-
- COUNT_LOOP:
- LODSB ; Get a byte.
- INC CX ; Bump counter.
- OR AL,AL ; Is byte, just read, zero ?
- JNZ COUNT_LOOP ; If not, get next byte.
-
- ;
- ; Print it !
- ;
- ADD CX,4 ; Include "CD \" along
- MOV DX,OFFSET CMD
- WRITE_STDOUT
-
- ; Print CR LF pair also.
-
- MOV CX,2
- MOV DX,OFFSET CRLF
- WRITE_STDOUT
- ;
- ; That's all.
- ;
- MOV AX,4C00h
- INT 21h
-
- _TEXT ENDS
- END START