My program asks for a filename to be read, then it should produce a clone of that file with the filename "Clone_originalfilename". This is my block of code:
.data
filename db 100
db ?
db 100 dup (0)
copyfile db "Clone_", 0
.code
mov dx, offset filename ; reads the filename entered by user
mov ah, 0Ah
int 21h
mov si, offset filename + 1 ; replaces the last character (Enter) to '$'
mov cl, [ si ]
mov ch, 0
inc cx
add si, cx
mov al, '$'
mov [ si ], al
; concatenate "Clone_" to the filename
lea si, filename
lea di, copyfile
L0:
cmp byte ptr [di], '_'
jz exL0
inc di
jmp L0
exL0:
inc di
add si, 2
xor bx, bx
L1:
cmp byte ptr [si], 0
jz exL1
mov bl, byte ptr [si]
mov byte ptr [di], bl
inc si
inc di
jmp L1
exL1:
inc di
mov bl, byte ptr [si]
mov byte ptr [di], bl
mov dx, offset filename
mov al, 2
mov ah, 3Dh
int 21h
mov handle, ax
jc erroropening
....
but whenever I execute it, the program proceeds to erroropening which displays that the file cannot be read, I think the problem's in the concatenation of the strings but I have no idea how to fix it. Sorry I'm a newbie here.