Hello All,
I'm trying to get the input filename and output filename from a user using the command line.
The only problem is, this doesn't seem to open the input filename. I am assuming that 81h is always going to be a space, therefore I started with 82h.
ex. thisprogram input.txt output.txt
I am storing "input.txt "
Should I be decreasing the variable by 1 position and then adding a 0 to the end like I'm doing in this program and am I doing it right?
Am I saving my handles correct as well?
Thank you very much.
MOV SI, 82h
XOR DI, DI
MOV AL, BYTE PTR ES:[SI]
CMP AL, 0dh
JE MISSING
INC SI
CMP AL, 0dh
JE MISSING
INPUT1:
CMP AL, 20h ; Test for Space
JE PREINPUT2
MOV NAME1[DI], AL
INC DI
INC SI
JMP INPUT1
PREINPUT2:
MOV NAME1[DI], 30h
INC SI
MOV DX, offset CHECK1 ; Display Check1
INT 21h
XOR DI, DI
INPUT2:
MOV AL, BYTE PTR ES:[SI]
CMP AL, 0Dh
JE MISSING1
CMP AL, 20h
JE OPENIN
MOV NAME2[DI], AL
INC DI
INC SI
JMP INPUT2
OPENIN:
MOV NAME2[DI], 0
MOV AH, 9
MOV DX, offset ANSCHECK
INT 21h
MOV DX, offset CHECK2 ; Display Check2
INT 21h
CLC
MOV DX, offset NAME1
MOV AH, 3Dh ; Open file code
MOV AL, 0
INT 21h
JC ERROR1
MOV HANDLE1, AX ; Save Open Input Handle
JMP OUTPUT
ERROR1:
JMP MISSMESSAGE1
MISSING1:
CALL MISSMESSAGE1
JMP THEEND
MISSMESSAGE1 proc
MOV AH, 9
MOV DX, offset INERROR
INT 21h
ret
MISSMESSAGE1 endp
CHECK1 DB 'Checking for Valid Input Filename...',0dh,0ah,'$'
CHECK2 DB 'Checking for Valid Output Filename...',0dh,0ah,'$'
ANSCHECK DB 'Check Done ... OK',0dh,0ah,'$'
INERROR DB '*ERROR with Input File*', 0dh, 0ah, '$'
NAME1 DB 32 DUP (?)
I'm trying to get the input filename and output filename from a user using the command line.
The only problem is, this doesn't seem to open the input filename. I am assuming that 81h is always going to be a space, therefore I started with 82h.
ex. thisprogram input.txt output.txt
I am storing "input.txt "
Should I be decreasing the variable by 1 position and then adding a 0 to the end like I'm doing in this program and am I doing it right?
Am I saving my handles correct as well?
Thank you very much.
MOV SI, 82h
XOR DI, DI
MOV AL, BYTE PTR ES:[SI]
CMP AL, 0dh
JE MISSING
INC SI
CMP AL, 0dh
JE MISSING
INPUT1:
CMP AL, 20h ; Test for Space
JE PREINPUT2
MOV NAME1[DI], AL
INC DI
INC SI
JMP INPUT1
PREINPUT2:
MOV NAME1[DI], 30h
INC SI
MOV DX, offset CHECK1 ; Display Check1
INT 21h
XOR DI, DI
INPUT2:
MOV AL, BYTE PTR ES:[SI]
CMP AL, 0Dh
JE MISSING1
CMP AL, 20h
JE OPENIN
MOV NAME2[DI], AL
INC DI
INC SI
JMP INPUT2
OPENIN:
MOV NAME2[DI], 0
MOV AH, 9
MOV DX, offset ANSCHECK
INT 21h
MOV DX, offset CHECK2 ; Display Check2
INT 21h
CLC
MOV DX, offset NAME1
MOV AH, 3Dh ; Open file code
MOV AL, 0
INT 21h
JC ERROR1
MOV HANDLE1, AX ; Save Open Input Handle
JMP OUTPUT
ERROR1:
JMP MISSMESSAGE1
MISSING1:
CALL MISSMESSAGE1
JMP THEEND
MISSMESSAGE1 proc
MOV AH, 9
MOV DX, offset INERROR
INT 21h
ret
MISSMESSAGE1 endp
CHECK1 DB 'Checking for Valid Input Filename...',0dh,0ah,'$'
CHECK2 DB 'Checking for Valid Output Filename...',0dh,0ah,'$'
ANSCHECK DB 'Check Done ... OK',0dh,0ah,'$'
INERROR DB '*ERROR with Input File*', 0dh, 0ah, '$'
NAME1 DB 32 DUP (?)