Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

лаб14

.docx
Скачиваний:
0
Добавлен:
26.03.2021
Размер:
35.12 Кб
Скачать

ЛАБОРАТОРНА РОБОТА №14

Тема: Виконання найпростіших функцій роботи з файлами та каталогами у програмах на мові Асемблер.

Мета: Оволодіти навичками написання програм на мові Асемблер для роботи з дисковими функціями.

Завдання 1:

data segment

filename db 'myfile.001',0

attrib dw ?

atr db 0dh, 0ah, "atribut(chislo):$"

pkey db 0dh, 0ah, "press any key...$"

ends

stack segment

dw 128dup(0)

ends

code segment

start:

mov ax, data

mov ds, ax

mov es, ax

mov ah, 09h

lea dx, [atr]

int 21h

mov ah, 01h

int 21h

mov ah,0

sub al,30h

mov attrib,ax

mov ah,3ch

mov dx,offset filename

mov cx,attrib

int 21h

lea dx, pkey

mov ah, 9

int 21h

mov ah, 1

int 21h

mov ax, 4c00h

int 21h

ends

end start

Завдання 2:

data segment

buff db 12,?

filename db 12 dup(?)

attrib dw ?

nam db 0dh, 0ah,"name:$"

atr db 0dh, 0ah, "atribut(chislo):$"

pkey db 0dh, 0ah, "press any key...$"

ends

stack segment

dw 128dup(0)

ends

code segment

start:

mov ax, data

mov ds, ax

mov es, ax

mov dx, offset nam

mov ah, 9

int 21h

mov ah,0ah

mov dx,offset buff

int 21h

xor bx,bx

mov bl,[buff+1]

mov [filename+bx],0

mov [attrib], 0

mov ah, 09h

lea dx, [atr]

int 21h

mov ah, 01h

int 21h

mov ah,0

sub al,30h

mov attrib,ax

mov ah,3ch

mov dx,offset filename

mov cx,attrib

int 21h

lea dx, pkey

mov ah, 9

int 21h

mov ah, 1

int 21h

mov ax, 4c00h

int 21h

ends

end start

Завдання 3:

data segment

f_name db 'test\test42.txt',0

dir db 'test',0

descr dw ?

buf db 100

str_len db ?

strg db 100 dup (?)

nam db 0dh, 0ah,"vvedi ryadok:$"

pkey db 0dh, 0ah, "press any key...$"

ends

stack segment

dw 128 dup(0)

ends

code segment

start:

mov ax, data

mov ds, ax

mov es, ax

mov ah, 39h

mov dx, offset dir

int 21h

mov dx, offset nam

mov ah, 9

int 21h

mov ah,0ah

lea dx,buf

int 21h

mov ah,3ch

xor cx,cx

lea dx,f_name

int 21h

mov descr,ax

mov ah,3dh

mov al,2

lea dx,f_name

int 21h

mov descr,ax

xor ax,ax

mov al,str_len

cbw

mov bp,ax

xor ax,ax

mov bx,descr

call write

mov ah,3eh

mov bx,descr

int 21h

mov al, 0ah

int 29h

mov bx,1

mov ax,4c00h

int 21h

write:

mov ah,40h

mov cx,bp

lea dx,strg

int 21h

lea dx, pkey

mov ah, 9

int 21h

mov ah, 1

int 21h

mov ax, 4c00h

int 21h

ends

end start

Завдання 4:

data segment

f_name db 'test\test1.txt',0

r_name db 'test\test2.txt',0

sum db 'test\sum.txt',0

dir db 'test',0

bufin db 200 dup (' ')

descr1 dw ?

descr2 dw ?

buf db 100

str_len db ?

strg db 100 dup (?)

nam db 0dh, 0ah,"vvedi ryadok:$"

pkey db 0dh, 0ah, "press any key...$"

sec dw 8/2

min dw 25*32

hour dw 19*2048

day dw 3

mon dw 8*32

year dw 21*512

ends

stack segment

dw 128dup(0)

ends

code segment

start:

mov ax, data

mov ds, ax

mov es, ax

mov ah, 39h

mov dx, offset dir

int 21h

mov dx, offset nam

mov ah, 9

int 21h

mov ah,0ah

lea dx,buf

int 21h

mov ah,3ch

xor cx,cx

lea dx,f_name

int 21h

mov descr1,ax

mov ah,3dh

mov al,2

lea dx,f_name

int 21h

mov descr1,ax

xor ax,ax

mov al,str_len

cbw

mov bp,ax

xor ax,ax

mov bx,descr1

mov ah,40h

mov cx,bp

lea dx,strg

int 21h

mov dx, offset nam

mov ah, 9

int 21h

mov ah,0ah

lea dx,buf

int 21h

mov ah,3ch

xor cx,cx

lea dx,r_name

int 21h

mov descr2,ax

mov ah,3dh

mov al,2

lea dx,r_name

int 21h

mov descr2,ax

xor ax,ax

mov al,str_len

cbw

mov bp,ax

xor ax,ax

mov bx,descr2

mov ah,40h

mov cx,bp

lea dx,strg

int 21h

mov ah, 3ch

lea dx,sum

mov cx, 0

int 21h

mov ah, 3dh

mov al,0

lea dx,sum

int 21h

mov descr1,ax

mov ah,57h

mov al,1

mov bx,descr1

mov cx,0

or cx,sec

or cx,min

or cx,hour

mov dx,0

or dx,day

or dx,mon

or dx,year

int 21h

mov ah, 3dh

mov al, 1

lea dx,f_name

int 21h

mov descr2,ax

mov ah,3fh

mov bx,descr2

mov cx,102

lea dx,bufin

int 21h

mov ah,40h

mov bx,descr1

mov cx,100

lea dx,bufin

int 21h

mov ah,3eh

mov bx,descr2

int 21h

mov ah, 3dh

mov al, 1

lea dx,r_name

int 21h

mov descr2,ax

mov ah,3fh

mov bx,descr2

mov cx,100

lea dx,bufin

int 21h

mov ah,40h

mov bx,descr2

mov cx,100

lea dx,bufin

int 21h

mov ah,3eh

mov bx,descr2

int 21h

lea dx, pkey

mov ah, 9

int 21h

mov ah, 1

int 21h

mov ax, 4c00h

int 21h

ends

end start

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]