my program has purpose: read symbols from command line and use them as full path-name going to another directory.
This program works if instead of inputting symbols from command line i define buffer as P:\test\
, so the problem is in the reading characters.
However, i tried to print out my buffer by using: ah 02h int 21h (single character output) and it outputted it correctly.
.model small
.stack 100h
.data
dir db 255 dup (0)
.code
start:
mov dx, @data
mov ds, dx
xor cx, cx
mov cl, es:[80h]
mov si, 0082h ;reading from command prompt 0082h because first one is space
xor bx, bx
l1:
mov al, es:[si+bx] ;filling buffer
mov ds:[dir+bx], al
inc bx
loop l1
mov dx, offset dir ;going to directory
mov ah, 3Bh
int 21h
mov ah, 4ch
mov al, 0
int 21h
end start
At the end of the command line resides always a 0Dh
. So the value in es:[80h]
(count of the characters in the command line) is one too big. Also, the end of the path must be nullified for Int 21h/AH=3Bh
("ASCIZ" means: ASCII characters plus zero).
This one should work:
.model small
.stack 1000h ; Don't skimp on stack.
.data
dir db 255 dup (0)
.code
start:
mov dx, @data
mov ds, dx
xor cx, cx
mov cl, es:[80h]
dec cl ; Without the last character (0Dh)
mov si, 0082h ; reading from command prompt 0082h because first one is space
xor bx, bx
l1:
mov al, es:[si+bx] ; filling buffer
mov ds:[dir+bx], al
inc bx
loop l1
mov byte ptr [dir+bx], 0 ; Terminator
mov dx, offset dir ; going to directory
mov ah, 3Bh
int 21h
mov ax, 4C00h ; Exit with 0
int 21h
end start
Do you consider, that you cannot change the drive letter with Int 21h/AH=3Bh
?