Start New Discussion within our Software Development Community

ive been wondering why wont codes make a file

.model small
.stack 100h
.data
buffer db 10,?, 10 dup(' ')

.code
start:
mov ah,1
int 21h
cmp al,"1"
je input
jne finish

input:                                     ; will input string i.e "qw.txt"
mov ax,seg buffer
mov ds,ax
mov dx, offset buffer
		mov ah, 0ah
		int 21h
		push ax
		jmp print
		print:
		xor bx, bx
		mov bl, buffer[1]
		mov buffer[bx+2], '$'
		mov dx, offset buffer + 2
		mov ah, 9
		int 21h
		
creatfile:		;creating a file like *txt
mov ah,3ch
mov cx,0
pop bx
mov ah,3ch
int 21h
finish:			;terminate program
mov ah,4ch
int 21h
end start

the code above doesnt work,doesnt create file qwe.txt when executed btw i place cmp so that when i press 1 it goes to createfile and jne to terminate program..
but the code below works and is the opposite of jump statements above how come it works but the logic is same right?

.model small
.stack 100h
.data
buffer db 10,?, 10 dup(' ')

.code
start:
mov ah,1
int 21h
cmp al,"1"
jne input
je finish
input:
mov ax,seg buffer
mov ds,ax
mov dx, offset buffer
		mov ah, 0ah
		int 21h
		push ax
		jmp print
		print:
		xor bx, bx
		mov bl, buffer[1]
		mov buffer[bx+2], '$'
		mov dx, offset buffer + 2
		mov ah, 9
		int 21h
		
creatfile:		;creating a file like *txt
mov ah,3ch
mov cx,0
pop bx
mov ah,3ch
int 21h
finish:			;terminate program
mov ah,4ch
int 21h
end start

can someone tell me why it wont work..
thanks..

Function 3Ch takes a null-terminated ASCIZ string
pointed to by DS : DX and your passing it a '$' terminated
string. I think that's your problem.

This article has been dead for over six months. Start a new discussion instead.