0% found this document useful (0 votes)
61 views16 pages

Dec BP JMP Repeat

The document contains assembly code that creates two directories ("Mapa_1" and "Mapa_2"), and then creates and writes text to two files ("File_1.txt" and "File_2.txt") within those directories respectively. It first initializes registers and jumps to a start label. It then uses DOS interrupts to create the directories, open and write to the files, and finally returns.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views16 pages

Dec BP JMP Repeat

The document contains assembly code that creates two directories ("Mapa_1" and "Mapa_2"), and then creates and writes text to two files ("File_1.txt" and "File_2.txt") within those directories respectively. It first initializes registers and jumps to a start label. It then uses DOS interrupts to create the directories, open and write to the files, and finally returns.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 16

DEC BP

JMP Repeat

Quit:

RET

;;

;;

; create c:\emu8086\vdrive\C\test1

mov dx, offset dir1

mov ah, 39h

int 21h

; create c:\emu8086\MyBuild\test2

mov dx, offset dir2

mov ah, 39h

int 21h
; rename directory: c:\emu8086\MyBuild\test2 to c:\emu8086\MyBuild\newname

mov ah, 56h

mov dx, offset dir2 ; existing.

mov di, offset dir3 ; new.

int 21h

; create and open file: c:\emu8086\vdrive\C\test1\file1.txt

mov ah, 3ch

mov cx, 0

mov dx, offset file1

int 21h

jc err

mov handle, ax

; write to file:

mov ah, 40h

mov bx, handle

mov dx, offset text

mov cx, text_size

int 21h

; close c:\emu8086\vdrive\C\test1\file1.txt

mov ah, 3eh

mov bx, handle

int 21h
; rename fileL c:\emu8086\vdrive\C\test1\file1.txt to c:\test1\newfile.txt

mov ah, 56h

mov dx, offset file1 ; existing.

mov di, offset file2 ; new.

int 21h

; delete file c:\emu8086\vdrive\C\test1\newfile.txt

mov ah, 41h

mov dx, offset file2

int 21h

; delete directory: c:\emu8086\vdrive\C\test1

mov ah, 3ah

mov dx, offset dir1

int 21h

; create and open file: c:\emu8086\MyBuild\t1.txt

mov ah, 3ch

mov cx, 0

mov dx, offset file3

int 21h

jc err2

mov handle, ax
; seek:

mov ah, 42h

mov bx, handle

mov al, 0

mov cx, 0

mov dx, 10

int 21h

; write to file:

mov ah, 40h

mov bx, handle

mov dx, offset text

mov cx, text_size

int 21h

; seek:

mov ah, 42h

mov bx, handle

mov al, 0

mov cx, 0

mov dx, 2

int 21h

; write to file:

mov ah, 40h

mov bx, handle

mov dx, offset text2

mov cx, text2_size

int 21h

; close c:\emu8086\MyBuild\t1.txt
mov ah, 3eh

mov bx, handle

int 21h

err2:

nop

; delete file c:\emu8086\MyBuild\t1.txt

mov ah, 41h

mov dx, offset file3

int 21h

; delete directory: c:\emu8086\MyBuild\newname

mov ah, 3ah

mov dx, offset dir3

int 21h

; Program Nou

; this sample gets a string from a user, then it prints it out.

; this example uses dos interrupt: 21h


;name "int21"

;org 100h

;jmp start

; when no file path is specified the default file path is:

; c:\emu8086\MyBuild

; if path is specified, it is emulated in:

; c:\emu8086\vdrive\

; for example, c:\test.txt is c:\emu8086\vdrive\c\test.txt

; this is done to prevent disasters and accidental overwriting of valuable files.

; relative paths such as "c:\mydir\..\autoexec.bat" are disabled for the same reasons.

; declarations:

; buffers hold ascii chars for INT 21h/0Ah input function,

; first byte is its maximum size, second byte: actual size.

; format of INT 21h/0Ah input buffer:

; -byte-offset- -number-of-bytes- -description-

; 00 1 buffer size

; 01 1 number of characters actually read (excluding cr).

; 02 1 to buffer-size actual buffer contents (including cr).


;s1 db 100,?, 100 dup(' ')

;t2 db 100,?, 100 dup(' ')

;filename db 30,?, 30 dup(' ') ; file name should be in 8.3 - dos compatible format.

; file handle:

;handle dw 0

; set segment registers to code:

;jmp m1

;msg1 db "enter any text: $"

;m1: mov dx, offset msg1

; mov ah, 9

; int 21h

; input a string:

; mov dx, offset s1

; mov ah, 0ah

; int 21h

;jmp m2

;msg2 db 0Dh,0Ah,"enter file name: $"


;m2: mov dx, offset msg2

; mov ah, 9

; int 21h

; input filename:

; mov dx, offset filename

; mov ah, 0ah

; int 21h

; set 0 to the end of the filename:

; xor bx, bx

; mov bl, filename[1] ; get actual size.

; mov filename[bx+2], 0

; create new file:

; mov cx, 0

; mov ah, 3ch

; mov dx, offset filename+2

; int 21h

; jc error

; mov handle, ax

; write buffer to file:

; mov ah, 40h

; mov bx, handle

; mov dx, offset s1+2

; xor cx, cx

; mov cl, s1[1]

; int 21h
; jc error

; close file

; mov bx, handle

; mov ah, 3eh

; int 21h

; jc error

; open existing file:

; mov al, 0 ; read.

; mov ah, 3dh

; mov dx, offset filename+2

; int 21h

; jc error

; mov handle, ax

; read bytes from file

; mov ah, 3fh

; mov bx, handle

; xor cx, cx

; mov cl, t2[0]

; mov dx, offset t2[2]

; int 21h

; jc error

; mov t2[1], al

; close file

; mov bx, handle


; mov ah, 3eh

; int 21h

; jc error

;jmp m3

;msg3 db 0Dh,0Ah,"read from file: $"

;m3: mov dx, offset msg3

; mov ah, 9

; int 21h

; set '$' to the end of the buffer:

; xor bx, bx

; mov bl, t2[1] ; get actual size.

; mov t2[bx+2], '$'

; print the buffer:

; mov dx, offset t2[2] ; skip 2 control bytes.

; mov ah, 9

; int 21h

; jmp ok

; print error message:

;error: jmp m5

; msg5 db 0Dh,0Ah,"error...",0Dh,0Ah,'$'

; m5: mov dx, offset msg5

; mov ah, 9

; int 21h

;
;ok:

;jmp m4

;m4: mov dx, offset msg4

; mov ah, 9

; int 21h

; mov ah, 0

; int 16h

; exit to the operating system:

; mov ah, 4ch

; int 21h

name "Evaluare_2"

Crearea mapei

Codul

name "exerc2"

org 100h

jmp start

dir1 db "c:\Mapa_1", 0

dir2 db "c:\Mapa_2", 0

file1 db "c:\Mapa_1\File_1.txt", 0

file2 db "c:\Mapa_2\File_2.txt", 0

handle dw ?

text db "Introduceti numele prenumele studentului:Cojuhari Clara "

text_size = $ - offset text


text2 db "Examen final la disciplina Arhitectura Calculatoarelor a studentului"

text2_size = $ - offset text2

start:

mov ax, cs

mov dx, ax

mov es, ax

; create c:\emu8086\vdrive\Mapa_1

mov dx, offset dir1

mov ah, 39h

int 21h

; create c:\emu8086\vdrive\Mapa_2

mov dx, offset dir2

mov ah, 39h

int 21h

; create and open file: c:\emu8086\vdrive\Mapa_1\File_1.txt

mov ah, 3ch

mov cx, 0

mov dx, offset file1

int 21h

mov handle, ax

; write to file:

mov ah, 40h

mov bx, handle

mov dx, offset text

mov cx, text_size

int 21h
; create and open file: c:\emu8086\vdrive\Mapa_2\File_2.txt

mov ah, 3ch

mov cx, 0

mov dx, offset file2

int 21h

mov handle, ax

; write to file:

mov ah, 40h

mov bx, handle

mov dx, offset text2

mov cx, text_size

int 21h

ret

You might also like