;====================================================== ;Code that determines whether a command line ;was present or not. Have a look and see how it works ;The program segment prefix (PSP) contains information ;about the program including the number or characters ;in the command tail at 80h and the command tail ;which begins at 81h and is 127 bytes long. ;This shows how to read the command trail and remove ;spaces you may not need. ;====================================================== .MODEL SMALL ;Set small memory model .8086 ; Use crusty 8086 code .STACK .DATA FILENAME DB 13 DUP (?) NOCLINE DB "Enter a command line paramater.",0ah,0dh,"e.g: TEST7 Hello!",0ah,0dh,24h YOUTYPED DB "The command line you entered was : ",24H .CODE MAIN PROC NEAR MOV AX,@DATA MOV DS,AX PUSH DS ;Make ES point to data segment PUSH ES ;and DS to PSP. ES is set to PSP POP DS ;on program entry. POP ES ;The need to be swapped for the commands we are going to use ;ES:[DI] Points to filename variable ;and DS:[SI] points to PSP, need to be like this for STOSB and LODSB ;command LEA DI,FILENAME CLD XOR CH,CH MOV SI,80H MOV CL,[SI] TEST CL,CL JNZ XD1 PUSH DS PUSH ES POP DS POP ES ;Put ES and DS back to normal; MOV DX,OFFSET NOCLINE MOV AH,09H INT 21H MOV AX,4C01H INT 21H XD1: INC SI X1: LODSB CMP AL,' ' ;Was it a space? JE X4 ;Yes, so skip it STOSB ;Store a byte X4: LOOP X1 ;Keep going to the end MOV AL,24H STOSB ;Make sure '$' at end of path PUSH DS PUSH ES POP DS POP ES ;Put ES and DS back to normal; MOV DX,OFFSET YOUTYPED MOV AH,09H INT 21H MOV DX,OFFSET FILENAME INT 21H MOV AX,4C00H ; Send exit code to dos INT 21H ; Send command to DOS MAIN ENDP ; Set end of program END MAIN ; Set starting address! ; Hard to explain. Read the book.