Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

File handling functions

3,049 views

Published on

Published in: Technology

File handling functions

  1. 1. AGENDA: To write a menu driven ALP program for file handling.  By including options like creating a file and typing the contents of the file.  Also displaying the current system date and time.
  2. 2. FUNCTION OF INT 21H USED IN FILEHANDLING: INTERRUPT : FUNCTION PURPOSE INT21H:FUNCTION 2AH GET SYSTEM TIME INT21H:FUNCTION 2CH GET SYSTEM DATE INT21H:FUNCTION 3CH CREATE FILE INT 21H:FUNCTION 3DH OPEN FILE INT21H:FUNCTION 3EH CLOSE FILE INT21H:FUNCTION 3FH READ FILE INT21H:FUNCTION 40H WRITE FILE INT21H:FUNCTION 41H DELETE FILE INT21H:FUNCTION 09H PRINT ON THE STRING
  3. 3. FUNCTION 2AH-GET SYSTEM TIME: AH=2Ah Returns : CX=YEAR DH=MONTH(1 TO 12) DL=DAY OF MONTH(1 TO 31) AL=DAY NUMBER IN WEEK(0-6 SUNDAY TO SATURDAY)  AH=2Ch Returns : CH=HOUR(0 TO 59) CL=MINUTE(0 TO 59) DH=SECOND(0 TO 59) DL=CENTISECONDS(0 TO 99)
  4. 4. FUNCTION 3CH-TO CREATE FILE AH = 3Ch  DS:DX = address of filename  CL = attribute  If successful, AX = file handle IF NOT CF=1 When a file is created or opened in a program, DOS assigns it a unique number called the FILE HANDLE.  This number is used to identify the file.  AH = 3Dh ◦ AL=Access Mode
  5. 5. FUNCTION 40H-TO WRITE FILE: AH =4OH  BX =Handle  CX =No Of Bytes To Write  DS:DX =Segment:Offset Of Buffer  If successful then  AX =Bytes Transferred AH = 3Fh  BX = File Handle  CX = Number Of Bytes To Read  DS:DX = Memory Buffer Address  AX = Count Of Bytes Actually Read
  6. 6. START CREATE READ FILENAME PROGRAM WITH EXTENSION FILE MOV APPROPRIATE LENGTH OF FILE NAME TO CX MOV OFFSET OF FILENAME TO DX MOV APPROPRIATEFUNCTION CALL(3CH) TO AH CALL INT 21H PRINT ERROR CHEC MSG K CF IF NOT SET END PROC & RET TO MAIN R
  7. 7. START DELETE MOV OFFSET OF FILE FILENAME TO DX MOV APPROPRIATEFUNCTION (41H) CALL TO AH CALL INT 21H CHEC PRINT ERROR K CF MSG IF NOT SET PROGRAM END PROC & RET TO MAIN
  8. 8. START WRIT INTO READ DATA TO BE WRITTEN FILE MOV APPROPRIATE LENGTH OF FILE NAME TO CX MOV OFFSET OF FILENAME TO DX MOV APPROPRIATEFUNCTION CALL(3CH) TO AH CALL INT 21H CHECK FOR CARRY FLAG PROGRAM END PROC & RET R TO MAIN
  9. 9. START READ FROM MOV OFFSET OF FILENAME TO FILE DXOPEN THE FILE IN READ MODE READ DATA FROM FILE BYTE BY BYTEWHEN EOF IS REACHED, CLOSE THE FILE PRINT THE DATA END PROC & RET PROGRAM R TO MAIN
  10. 10. START READ SYSTEM MOV OFFSET OF STRING VAR TO TIME & BX MOV APPROPRIATE DISPLAYFUNCTION CALL(2CH) TO AH CALL INT 21HDECODE THE HEX VALUES TO DECIMAN PRINT THE TIME IN PROPER FORMAY END PROC & RET PROGRAM R TO MAIN
  11. 11. START READ SYSTEM MOV OFFSET OF STRING VAR TO DATE & BX MOV APPROPRIATE DISPLAYFUNCTION CALL(2AH) TO AH CALL INT 21HDECODE THE HEX VALUES TO DECIMAN PRINT THE TIME IN PROPER FORMAY END PROC & RET PROGRAM R TO MAIN

×