TASM Code To Create A File and Write To It
TASM Code To Create A File and Write To It
TASM Code To Create A File and Write To It
model small
.stack 100h
.data
msg1 db 'ENTER FILE NAME:$'
msg2 db 'FILE CREATED!$'
msg3 db 'ENTER NUMBER:$'
msg4 db 'ENTER EMAIL:$'
msg5 db 'ENTER GENDER:$'
buffer1 db 80,0,80 dup(0)
fwrite db ?
.code
start:
mov ax,@data
mov ds,ax
mov ah,9
lea dx,msg1
int 21h
inputname:
mov [buffer1],80
lea dx, buffer1
mov ah, 0ah
int 21h
mov bl, buffer1[1]
mov bh, 0
add bx, 2
mov buffer1[bx],0
createfile:
lea dx, buffer1[2]
mov cx,0
mov ah,3ch
int 21h
push ax
mov ah,9
lea dx,msg3
int 21h
pop bx
mov buffer1[1],0
mov fwrite,1
getchar:
mov ah,1
int 21h
cmp al,08h
jne write
mov ah,2
mov dl,20h
int 21h
mov dl,08h
int 21h
jmp getchar
write:
mov buffer1[0],al
cmp buffer1[0],0dh
je nextline
cmp buffer1[0],27
je donewrite
call writetofile
jmp getchar
nextline:
cmp fwrite,1
je numberend
cmp fwrite,2
je emailend
jmp getchar
numberend:
mov buffer1[0],'*'
call writetofile
mov ah,9
lea dx,msg4
int 21h
add fwrite,1
jmp getchar
emailend:
mov buffer1[0],'@'
call writetofile
mov ah,9
lea dx,msg5
int 21h
add fwrite,1
jmp getchar
donewrite:
mov ah,9
lea dx,msg2
int 21h
mov ax,4c00h
int 21h
writetofile proc
mov cx, 1
lea dx,buffer1[0]
mov ah,40h
int 21h
ret
writetofile endp
end start