I'm writing an encoding/decoding .COM program using Huffman algorithm for dos 8086 (16-bit tasm or masm without using libraries), and need to store 2 command-line arguments (inputfilename and outputfilename) in arrays so that I can read the input file, apply my huffman encoding, and write to the output file.
I've read that they are stored at address 80h, where 80h contains the length of the arguments, and 81h onward the arguments themselves. So the idea is to store the first argument in inarg (and the second one in outarg, which I haven't started working on yet) The purpose of the interrupt 21h call with subroutine 9 was to check I had it right. (which is not the case)
Here is what I have so far:
getCLargs proc near
mov cx, [080h] ; store memory address of command-line argument length
mov bx, 082h ; store command-line arguments first byte
sub si,si
sub di,di
next:
mov dx, [bx] ; store first byte of argument into dx
mov inarg[si],dx ; put it into the first byte of the array inarg
cmp cx, di ; compare di to the length of the args
je print ; if equal, done, jump to print
inc di ; else: inc di
; inc si
jmp next ; do it again until cx=di
print:
mov ah, 09h ; print content of inarg array to check it's right
mov dx, inarg
mov inarg[si+1], '$' ; not sure whether I must terminate my string array with '$'
int 21h
done:
ret
getCLargs endp
With the following relevant data:
inarg dw ?
outarg dw ?
I've started with the basics without considering delimiters, and trying to get only the first argument (inarg, which is the input file name).
And it doesn't work, so I'm definitely doing something wrong. This look may like a total mess to any experienced programmer, but that's because I tried to follow resources I found on the internet without success, and therefore switch to implement it using only the concepts I understand so far. Any help would be greatly appreciated, Thank you.