Lab-6 Solution
Lab-6 Solution
model tiny
.data
fname db 'test.txt',0
handle dw ?
.code
.startup
.exit
end
Output:
Code:
.model tiny
.data
fname db 'second.txt',0
handle dw ?
msg db 'MUP La=B'
.code
.startup
Code
.model tiny
.data
fname db 'second.txt',0
handle dw ?
msg db 'MUP MSP'
.code
.startup
; open a file
mov ah,3dh
mov al,1h
lea dx,fname
int 21h
mov handle,ax
; write msg to file
mov ah,40h
mov bx,handle
mov cx,10
lea dx,msg
int 21h
;closing a file
mov ah,3eh
int 21h
.exit
end
.model tiny
.data
str1 db 'Enter your name: $'
max1 db 32
act1 db ?
inp1 db 32 dup('$')
fname db 'testing.txt',0
handle dw ?
.code
.startup
; write to console
mov ah, 09h
lea dx, str1
int 21h
; create file
mov ah, 3ch
lea dx, fname
mov cl, 0
int 21h
mov handle, ax
; write to file
mov ah, 40h
mov cx, 00h
mov cl, act1
mov bx, handle
lea dx, inp1
int 21h
; close file
mov ah, 3eh
mov bx, handle
int 21h
.exit
end
; *** Part A ***
.model tiny
.data
fname1 db 'name.txt',0
fname2 db 'id.txt',0
handle1 dw ?
handle2 dw ?
msg1 db 'Mritunjay'
len1 db 06h
msg2 db 'Shall'
len2 db 0dh
.code
.startup
; create name.txt
mov ah, 3ch
lea dx, fname1
mov cl, 1
int 21h
; create id.txt
mov ah, 3ch
lea dx, fname2
mov cl, 1
int 21h
; open name.txt
mov ah, 3dh
mov al, 1h
lea dx, fname1
int 21h
mov handle1, ax
; open id.txt
mov ah, 3dh
mov al, 1h
lea dx, fname2
int 21h
mov handle2, ax
; write to name.txt
mov ah, 40h
mov bx, handle1
mov cx, 00h
mov cl, len1
lea dx, msg1
int 21h
; write to id.txt
mov ah, 40h
mov bx, handle2
mov cx, 00h
mov cl, len2
lea dx, msg2
int 21h
part1 db 8 dup('$')
part2 db 6 dup('$')
.code
.startup
; create splice.txt
mov ah, 3ch
lea dx, fname3
mov cl, 01h
int 21h
; write to splice.txt
mov ah, 40h
mov bx, handle3
mov cx, 0eh
lea dx, part1
int 21h
; close splice.txt
mov ax, 3eh
mov bx, handle1
int 21h