งานนำเสนอกำลังจะดาวน์โหลด โปรดรอ

งานนำเสนอกำลังจะดาวน์โหลด โปรดรอ

CS344-321 Assembly Language Programming Period 35.

งานนำเสนอที่คล้ายกัน


งานนำเสนอเรื่อง: "CS344-321 Assembly Language Programming Period 35."— ใบสำเนางานนำเสนอ:

1 CS344-321 Assembly Language Programming Period 35

2 การใช้ทรัพยากรของ เครื่อง การใช้ทรัพยากรของ เครื่อง DOS FILE SYSTEM มี file handle 5 อันที่ automatic open และไม่ต้อง close คือ HandleUseDefault Setting (file name) 0Standard input (keyboard)CON 1Standard output (screen)CON 2Standard error (screen)CON 3Standard auxiliaryAUX 4Standard printer (LPT1: or PRN)PRN

3 FunctionParameters Results Int 21h function 3chAH = 3chIf function successful Create fileCX = file attribute CF = 0 DS:DX=address of ASCIIZ filenameAX = handle if function unsuccessful CF = 1 AX = error code Int 21h function 3dhAH = 3dhIf function successful Open fileAL = access mode CF = 0 DS:DX=address of ASCIIZ filenameAX = handle if function unsuccessful CF = 1 AX = error code

4 Int 21h function 3fhAH = 3fhIf function successful Read fileBX = handleCF = 0 CX = number of bytesAX = bytes transferred DS:DX=buffer addressif function unsuccessful CF = 1 AX = error code Int 21h function 40hAH = 40hIf function successful Write fileBX = handleCF = 0 CX = number of bytesAX = bytes transferred DS:DX=buffer addressif function unsuccessful CF = 1 AX = error code

5 Int 21h function 42hAH = 42hIf function successful Set file pointerAL = method (0=relative to start CF = 0 of file, 1=relative to current DX:AX = actual file offset of file, 1=relative to current DX:AX = actual file offset file position, 2 = relative toif function unsuccessful file position, 2 = relative toif function unsuccessful end of file)CF = 1 end of file)CF = 1 BX = handle AX = error code CX:DX=offset value Int 21h function 3ehAH = 3ehIf function successful Close fileBX = handleCF = 0 if function unsuccessful CF = 1 AX = error code

6 Int 21h function 41hAH = 3ehIf function successful Delete fileDS:DX = address of ASCIIZ filename CF = 0 if function unsuccessful CF = 1 AX = error code Int 21h function 56hAH = 56hIf function successful Rename fileDS:DX = address of ASCIIZ currentCF = 0 filenameif function unsuccessful filenameif function unsuccessful ES:DI = address of ASCIIZ newCF = 1 filename AX = error code filename AX = error code

7 - หมายเหตุ ASCIIZ คือ string ที่สิ้นสุดด้วย 0 เช่น file_name db ‘test.dat’,0 -file attribute bitvalue(hex)meaning 76543210 76543210 00000000 0normal 00000000 0normal 000000011Read-only 000000011Read-only 000000102Hidden 000001004System 000010008Volume label 00010000 10 Subdirectory 00100000 20Archive 01000000 40Unused 10000000 80Unused -access mode 20hRead (only) access 40hRead or write access

8 -file ที่มีอยู่แล้ว ต้อง open ก่อนถึงจะใช้ได้ และเมื่อเลิกใช้ ต้อง close เสมอ - ข้อควรระมัดระวัง ! กรณีที่สร้าง file ใหม่ โดยใช้ฟังก์ชัน Create file ถ้าปรากฏว่ามี file นั้นอยู่แล้ว ข้อมูลใน file นั้น จะหาย ข้อแนะนำควรทดสองตรวจสอบดูว่ามี file ชื่อ ดังกล่าวอยู่หรือไม่ ด้วยฟังก์ชัน open file ถ้าไม่มี error แสดงว่ามี file ชื่อนั้นอยู่ ควรถาม user ว่าต้องการสร้าง file ชื่อดังกล่าวหรือไม่ เพราะข้อมูลเดิมจะหาย (File exist, replace[y/n]?) ถ้า user ตอบ y จึงใช้ฟังก์ชัน Create file


ดาวน์โหลด ppt CS344-321 Assembly Language Programming Period 35.

งานนำเสนอที่คล้ายกัน


Ads by Google