0% found this document useful (0 votes)
17 views3 pages

Assembly Language File Handling Guide

The document discusses conditional directives and file handling in assembly language. It provides examples of using conditional directives like IF-ELSE and WHILE to control program flow. It also describes the interrupt syntax for file handling operations like loading, closing, reading, and writing files. Interrupts like 3DH, 3FH, and 40H are used along with registers like AH, DX to access and manipulate files from within assembly programs.

Uploaded by

aleena
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)
17 views3 pages

Assembly Language File Handling Guide

The document discusses conditional directives and file handling in assembly language. It provides examples of using conditional directives like IF-ELSE and WHILE to control program flow. It also describes the interrupt syntax for file handling operations like loading, closing, reading, and writing files. Interrupts like 3DH, 3FH, and 40H are used along with registers like AH, DX to access and manipulate files from within assembly programs.

Uploaded by

aleena
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

Coal Lab 11 Notes:

Conditional directives:

syntax 

.data

A db ? ; take user input or whatever, just a variable

.code

1-(if—else)

.If (condition eg. A<=5) note: red color are the keywords

--prog

.elseif (condition)

--prog

.else

--prog

.endif

2-(while)

.while (condition)

--prog

.endw

Eg:

Mov dl,65
.while a<10 ;code to print first 10 alphabets
inc a
mov ah,02h
int 21h
inc dl

.endw

2- (do..while)

.repeat

--prog

.until(condition)
________________________________________________________
File Handling:

Interrupt syntax for filing

To load file: mov ah,3dh


int 21h

To close file: mov ah,3eh


int 21h

To read file: mov ah,3fh


int 21h

to write file: mov ah,40h


int 21h

to append: mov ah,42h

int 21h

different regs are used along with the interrupts to access the file, eg when we use ah,02h for printing
we use dl, from which value is printed.

A file of type .txt is created withing the same bin folder, we then create an object of file in .asm file

Eg: to read from text file  [Link] in bin


.data
File db “[Link]”,0 ; File is now my object with 0 value in it
buffer db 500 DUP(?) ; a variable to save contents of file as we cannot directly
print on console
. code
mov ax,@data
mov ds,ax

mov dx, offset File ; Giving the path of our text file using the object we made
mov al,0 ; read only mode of opening file
mov ah,3dh
int 21h
mov dx,offset buffer ; using our variable (as string) to read the contents into it
mov ah,3fh ; interrupt to then read
int 21h
mov dx,offset buffer ;printing the contents
Mov ah,09h
int 21h

Eg: To write into text file  [Link]


. code
(prev similar code)
mov dx, offset File
mov al,2 ;write mode of opening file
mov ah,3dh ; sending interrupt of file load
int 21h
mov dx, offset msg ; variable which has the string we need to store in file
mov cx, 10 ;length of our string variable
mov ah,40h ;interrupt to write into file
mov 21h

To close file:

Mov ah,3eh
int 21h

You might also like