background image

Содержание 1000 MS-DOS

Страница 1: ......

Страница 2: ...D BY RADIO SHACK INCLUDING BUT NOT LlMlTEO TO ANY INTERRUPTION OF SERVICE LOSS OF BUSINESS OR ANTICIPATORY PROFITS OR CONSEOUENTIAL DAMAGES RESULTING FROM THE USE OR OPERATION OF THE EQUIPMENT OR SOFT...

Страница 3: ......

Страница 4: ...l Rights Reserved Tandy is a registered trademark of Tandy Corporation CPiM is a trademark of Digital Research IBM is a trademark of International Business Machines Reproduction or use without express...

Страница 5: ...betic Order Function Call Reference 32 Macro Definitions for MS DOS System Call Examples 137 Interrupts 137 Extended Example of MS DOS System Calls 143 Chapter 2 MS DOSControl Blocks and Work Areas 15...

Страница 6: ...7 RequestHeader 177 Unit Code Field 177 Command Code Field 178 MEDIA CHECK and BUILD BPB 178 StatusField 179 Function Call Parameters 181 MEDIACHECK 182 BUILD BPB BIOSParameter Block 183 Media Descrip...

Страница 7: ...Keyboard Control 217 Cursor Control 218 Erasing 220 Modes of Operation 221 Keyboard Key Reassignment 223 Appendix B Keyboard ASCII and Scan Codes 225 Appendix C MS DOS Memory Map 229 ROM BIOS Data Are...

Страница 8: ......

Страница 9: ......

Страница 10: ......

Страница 11: ...to save the register contents before using a system call The system calls are also invoked from any high level language that has modules capable of linking with assembly language modules Control is re...

Страница 12: ...Chapter 2 For details on the directory entry see Disk Directory in Chapter 4 Hierarchical Directories MS DOS supports hierarchical tree structured directories sim ilar to those found in the XENIX ope...

Страница 13: ...contents are identical in character to the contents of the root directory Attributes apply to the tree structured directories in the follow ing manner Attribute Meaning Function MeaningIFunction for f...

Страница 14: ...ri ficed to conserve space Many of the examples are not usable as stand alone programs but merely show you how to get started with this command You may however find the macros a conve nient way to inc...

Страница 15: ...e following exit addresses are restored from the Program Seg ment Prefix Exit Address Offset Program Terminate Critical Error CONTROL C OAH OEH 12H Note Interrupt 20H is provided for compatibility wit...

Страница 16: ...for a description of the MS DOS system functions Entry Conditions AH function call number Other registers as specified in individual function Exit Conditions As specified in individual function Exampl...

Страница 17: ...program terminates control transfers to the ad dress at offset OAH of the Program Segment Prefix This address is copied into the Program Segment Prefix from the Interrupt 22H vector when the segment...

Страница 18: ...the interrupt occurs all registers are set to the value they had when the original call to MS DOS was made There are no restrictions on what a CONTROL C handler can do including MS DOS function calls...

Страница 19: ...ead or Inter rupt 26H Absolute Disk Write These errors are usually handled by the MS DOS error routine in COMMAND COM that retries the disk operation and then gives the user the choice of aborting ret...

Страница 20: ...re Attempt to write on write protected disk The user stack will be in effect and from top to bottom will contain the following IP MS DOS registers from cs issuing INT 24H FLAGS AX BX INT 21H request c...

Страница 21: ...ll destroy the MS DOS stack and will leave MS DOS in an unpredictable state 0 The interrupt handler must not change the contents of the device header If the interrupt handler has its own error managem...

Страница 22: ...s necessary be cause data is passed back in the current flags Be sure to pop the stack upon return to prevent uncontrolled growth Entry Conditions AL drive number 0 A 1 B etc DS BX Disk Transfer Addre...

Страница 23: ...db 64 dup 512 dup 7 64 s e c t o r s i nt 25H d i s p l a y prompt s e e F u n c t i o n 09H r e a d t b d s e e F u n c t i o n 08H copy 5 groups o f 64 s e c t o r s mov C X copy push cx save t h e...

Страница 24: ...e stack upon return This is necessary be cause data is passed back in the current flags Be sure to pop the stack upon return to prevent uncontrolled growth Entry Conditions AL drive number 0 A 1 B etc...

Страница 25: ...b Any key t o start start dw 0 buffer db 64 dup 512 dup 7 64 sectors 1nt 26H display prompt s e e Function 09H read kbd see Function 08H verify on s e e Function 2EH mov C X copy 5 groups of 64 sect o...

Страница 26: ...d as an extension of MS DOS It remains res ident and is not overlaid by other programs when it terminates This interrupt provides compatibility with earlier versions of MS DOS New programs should use...

Страница 27: ...egories 00H 12H 13H 24H 25H 26H 27H 29H 2AH 2EH 2FH 38H 39H 3BH 3CH 46H 47H 4CH 4FH 48H 4BH 54H 57H calls can be divided into the following Old character device I O Old file management Old non device...

Страница 28: ...File Handles Some of the new calls use a file handle to identify a file or device A handle is a 16 bit binary value that is returned in register AX when you create or open a file or device using the...

Страница 29: ...CL register and other regis ters are set according to the function specification Then an intrasegment call is made to location 5 in the current code segment That location contains a long call to the M...

Страница 30: ...05H 06H 07H 08H 09H OAH 0BH OCH ODH OEH 0FH 10H 11H 12H 13H 14H 15H 16H 17H 19H 1AH 21H 22H 23H 24H Function Name Terminate Program Read Keyboard and Echo Display Character Auxiliary Input Auxiliary O...

Страница 31: ...endent Information Create Subdirectory Remove a Directory Entry Change the Current Directory Create a File Open a File Close a File Handle Read From a File or Device Write to a File or Device Delete a...

Страница 32: ...play Character Display String Duplicate a File Handle File Size Find Matching File Flush Buffer Read Keyboard Force a Duplicate c f a File Handle Free Allocated Memory Get Date Get Disk Free Space Get...

Страница 33: ...ting of Verify Return Country Dependent Information Return Text of Current Directory Search for First Entry Search for Next Entry Select Disk Sequential Read Sequential Write Set Date Set Disk Transfe...

Страница 34: ...isk Be sure to close all files that have been changed in length before calling this function If a changed file is not closed its length will not be recorded correctly in the disk directory See Func ti...

Страница 35: ...er typed Macro Definition read kbd and echo macro mov ah OIH int 2 1 H endm Example The following program displays and prints characters as they are typed If ENTER is pressed the program sends a Line...

Страница 36: ...ro mov mov i n t endm c h a r a c t e r d1 character ah 02H 21 H Example The following program converts lowercase characters to up percase before displaying them func 02H read k bd see F u n c t i o n...

Страница 37: ...H 03H Exit Conditions AL character returned Macro Definition aux input m a c r o mov a h 8 3 H int 21H endm Example The following program prints characters as they are re ceived from the auxiliary dev...

Страница 38: ...4H i n t 21 H endm Example The following program gets a maximum of 80 bytes from the keyboard sending each to the auxiliary device It stops when a null string CR only is typed string db 81 dup 7 s e e...

Страница 39: ...sed line num db 0 func 05H mov start line mov add push mov inc CmP print i t print char bl 11 mov no reset l o o p i nc P O P loop cx 60 bl 33 b1 line num cx 80 cx bl b1 126 no re5et bl 33 pr i n t i...

Страница 40: ...racter Entry Conditions AH 06H DL FFH return character typed at the keyboard if avai1able DL FFH display character in DL Exit Conditions If DL FFH on entry Zero flag set and AL O O H if no key was pre...

Страница 41: ...t time E E E E read clock get time convert ch ten time convert cl ten time 31 convert dh ten time 61 display t i m e dir console io EFFH J mP read clock n e 5 t O P read kbd I m p f unc 06H when any c...

Страница 42: ...put macro mov ah 07H int 21 H endm Example The following program prompts for a password 8 charac ters maximum and places the characters into a string without echoing them pa 5 5 word prompt db Passwor...

Страница 43: ...ard Macro Iiefinition read k bd macro mov ah 08H int 21 H endm Example The following program prompts for a password 8 charac ters maximum and places the characters into a string without echoing them p...

Страница 44: ...displayed terminated by Macro Definition a 24H display macro string mov dx offset string mov ah 09H i n t 21H endm Example The following program displays the hexadecimal code of the key that is typed...

Страница 45: ...red If CON TROL C is typed Interrupt 23H is executed The input buffer pointed to by DS DX must be in this form byte 1 Maximum number of characters in buffer including the carriage return 1 255 you set...

Страница 46: ...stringl6 buffer xor bx bx mov b1 chars entered mov buffe rL bx 21 S mov al 50H cbw div chars entered xor ah ah mov strings per line ax mov cx 24 mov cx strings per line loop display line display crlf...

Страница 47: ...efinition check kbd 5tatu5 macro mov ah 0BH int 21H endm Example The following program continuously displays the time until any key is pressed time db 00 00 00 EO 13 l 0 I ten db 10 f unc 0BH get time...

Страница 48: ...sing was performed Macro Definition call is executed No further processing is done flujh and read kbd macro witch mov a 1 w i t c h m0v ah ECH int 21H endm Example The following program both displays...

Страница 49: ...dated you must close files that have changed in order to update their directory entries see Function Call 10H Close File This function need not be called before a disk change if all files that were wr...

Страница 50: ...ber of logical drives Macro Definition select disk m a c r o disk m a v dl dlsk 641 m o v a h 0 E H int 21 H endm Example The following program selects the drive not currently se lected in a 2 drive s...

Страница 51: ...the system de 0 The file size offset 10H date of last write offset 14H and time of last write offset 16H are set from the directory entry Before performing a sequential disk operation on the file you...

Страница 52: ...a d 5 e q f c b C m P le C m P 19 a l 0 2 H a l l d o n e ai 00H c h e c k m o r e mov xor p r i n t i nc loop JmP C m P J n e mov xor C m P c l o s e c x 1 2 8 c h a r b u f f e r 51 1 5 1 5 1 51 pri...

Страница 53: ...the open FCB of the file to close Exit Conditions If AL 00H the directory entry was found If AL FFH no directory entry was found Macro Definition clo5e macro fcb mov dx offset fcb mov ah l0H int 21H e...

Страница 54: ...1 is zero only normal file entries are found Entries for the volume label subdirectories hidden files and system files will not be returned If the attribute field is set for hidden or system files or...

Страница 55: ...r l f func 1 1 H n o t t h e r e c o n t i n u e db FILE EXISTS 0 db FILEDOESNOTEX1ST O db 2 REPORT ASM db 25 dup 7 db 128 dup 7 db 13 I0 S s e t d t a b u f f e r s e a r c h f i r s t f c b cmp al...

Страница 56: ...g name To search for hidden or system files DS DX must point to the first byte of the extended FCB prefix If a directory entry for the filename in the FCB is found an un opened FCB of the same type no...

Страница 57: ...rst fcb CmP a1 BFFH le a l l d o n e i nc f i l e s search next f c b CmP a1 EFFH le done i n c f i l e 5 Imp s e a r c h d i r c o n v e r t f i l e s t e n m e 5 5 a g e d i s p l a y message see F...

Страница 58: ...ed unopened FCB The filename can contain the wildcard character to match any character Entry Conditions AH 13H DS DX pointer to an unopened FCB Exit Conditions If A1 00H a directory entry was found If...

Страница 59: ...0 H le compare CmP f I le5 B l e a l l d o n e c o n v e r t f i l e s t e n m e 5 5 a g e d i s p l a y message 13 l 0 0 s e e F u n c t i o n 0 9 H f o r e x p l a n a t i o n o f 5 e e F u n c t i...

Страница 60: ...e at offset OEH in the FCB Entry Conditions AH 14H DS DX pointer to the opened FCB of the file to read Exit Conditions If AL 00H the read was completed successfully If AL 01H end of file was encounter...

Страница 61: ...mP a l 0 Z H Je a l l d o n e CmP a l 0 2 H 19 check more d i s p l a y b u f f e r J m P read I i ne CmP al 03H 1ne a l l d o n e C m P b u f f e r L s i l 2 6 l e a1 1 done d i s p l a y c h a r b u...

Страница 62: ...sector the data at the Disk Trans fer Address is written to a buffer The buffer is written to disk when it contains a full sector of data when the file is closed or when Function Call ODH Reset Disk...

Страница 63: ...mP c l o s e 14 2 DIR TMP 25 dup 7 25 dup 7 l 2 8 d u p 7 2 7 7 7 7 7 7 7 7 7 7 7 o f f s e t o f R e c o r d s i z e f i e l d i n F C B b u f f e r see F u n c t i o n 1 A H f c b 2 see F u n c t i...

Страница 64: ...FCB 1 set to 2 If an entry is found for the specified filename all data in the file is released making a zero length file and the Open File function call 0FH is issued for the filename If you try to...

Страница 65: ...c l o s e 14 2 DIR TMP 25 dup 7 25 dup 7 1 2 8 d u p 7 2 7 7 7 7 7 7 7 7 7 7 7 o f f s e t o f R e c o r d s i z e f i e l d o f FCB b u f f e r s e e F u n c t i o n l A H f c b 2 s e e F u n c t i...

Страница 66: ...a matching directory entry is found the filename in the direc tory entry is changed to match the second filename in the modi fied FCB If the wildcard character is used in the second filename the corre...

Страница 67: ...prompt1 g e t s t r i n g 1 5 r e p l y d i s p l a y c r l f p a r s e r e p l y 2 1 f c b d i s p l a y prompt2 g e t s t r i n g 1 5 r e p l y d i s p l a y c r l f p a r s e r e p l y 2 l f c b l...

Страница 68: ...rently selected default drive in a 2 drive system message db c r l f db C u r r e n t d i s k 1 5 0 see F u n c t i o n 09H 13 l 0 0 f o r e x p l a n a t i o n o f func 19H d i s p l a y message see...

Страница 69: ...the end of the segment to the beginning nor can they overflow into the next segment If you do not set the Disk Transfer Address it defaults to offset 80H in the Program Segment Prefix Entry Condition...

Страница 70: ...p 7 Enter l e t t e r t 13 10 func 1 AH s e t d t a b u f f e r T H I S F U N C T I O N open f c b s e e F u n c t i o n 0FH mov fcb record sizel 28 setrecord5ize ge t c h a r d i s p l a y prompt 5 e...

Страница 71: ...ddress Entry Conditions AH 21H DS DX pointer to the opened FCB of the file to read Exit Conditions If AL IfAL If AL If AL Macro Definition read ran macro f c b 00H the read was completed successfully...

Страница 72: ...r L e t t e r 13 10 func 21H s e t d t a b u f f e r s e e F u n c t i o n 1 A H open f c b s e e F u n c t i o n B F H mov f c b r e c o r d _ s i z e 1 2 8 s e t r e c o r d s i z e g e t c h a r d...

Страница 73: ...f AL 00H the write was completed successfully If AL 01H the disk is full If AL 02H there was not enough room at the Disk Transfer Macro Definition Address to write 1record the write was canceled wr I...

Страница 74: ...o n v e r t A S C I I mov f c b r e l a t i v e r e c o r d 1 a l d i s p l a y c r l f s e e F u n c t i o n 09H r e a d r a n f c b THIS FUNCTION d i s p l a y b u f f e r s e e F u n c t i o n 09H...

Страница 75: ...0EH of the FCB If the value of the record size field of the FCB does not match the actual number of characters in a record this function does not return the correct file size If the default record si...

Страница 76: ...5 1 d i s p l a y prompt s e e F u n c t i o n 09H g e t s t r i n g 1 7 r e p l y s e e F u n c t i o n 0FIH CmP r e p l y l 1 O J u s t aCR7 1ne g e t l e n g t h no keepgoing 1 P a 1I done yes goh...

Страница 77: ...f f s e t f c b mov ah 24H i n t 21 H endm Example The following program copies a file using the Random Block Read and Random Block Write function calls It speeds the copy by setting the record lengt...

Страница 78: ...c t i o n B F H mov f c b c u r r e n t r e c o r d l B 5et C u r r e n t Record s e t r e l a t i v e r e c o r d f c b THISFUNCTION mov a x w o r d p t r f c b I f i l e s i z e 1 g e t f i l e 5 i...

Страница 79: ...t programs should never set interrupt vectors by writing them directly in the low memory vector table Entry Conditions AH 25H AL number of the interrupt to set DS DX address of the interrupt handling...

Страница 80: ...s AH 27H CX number of records to read DS DX pointer to the opened FCB of the file to read Exit Conditions CX actual number of records read If AL 00H all records were read successfully IfAL 01H end of...

Страница 81: ...a y prompt2 g e t 5 t r i n g 1 5 f i l e n a m e d i s p l a y c r l f parse f 1lename 211 c r e a t e f c b mov f c b c u r r e n t _ s e t r e l a t i v e r e c o r d f c b o f f s e t o f C u r r...

Страница 82: ...ten but the file size field of the directory entry offset 1CH is set to the number of records specified by the relative record field of the FCB offset 21H Allocation units are allocated or re leased a...

Страница 83: ...f db 1 3 l 0 num recs dw 7 buffer db 32767 dup 7 func 28H set dta buffer 5ee Function 1AH display prompt1 s e e Function E9H get string 15 filename 5 e e Function ERH display crlf see Function E9H par...

Страница 84: ...the string does not contain a drive number 1 The drive number in the FCB is not changed if the string does not contain a drive number 2 0 The filename in the FCB is set to 8 blanks if the string does...

Страница 85: ...of memory to fill in with an unopened FCB AL controls parsing see above Exit Conditions IfAL 00H then no wildcard characters appeared in the IfAL 01H then wildcard characters appeared in the file DS...

Страница 86: ...o db func 29H display get string parse search first 1 CmP Je display J mP not there display continue 37 dup 7 Filename 0 17 dup 7 F ILE EX ISTS 13 l E 0 F ILE DOES NOT EX IST 13 l B 0 prompt see Funct...

Страница 87: ...s the date increments the day increments the month or year if necessary and sets the new date month db 31 28 31 38 31 38 31 31 30 31 30 31 func 2AH get date inc xor mov dec CmP 1 e mov inc CmP mov inc...

Страница 88: ...Conditions AH 2BH CX year 1980 2099 DH month 1 January 2 February etc DL day of the month 1 31 Exit Conditions If AL 00H the date was valid If AL FFH the date was not valid and the function was cance...

Страница 89: ...i nc month ok s e t d a t e d l bx bx b l dh bx d l m o n t h b x l month ok d l 1 dh d h l 2 mont h o k d h l cx c x d h d l see F u n c t i o n 2AH increment day s o EL can be used as i n d e x move...

Страница 90: ...endm Example The following program continuously displays the time until any key is pressed time db ten db 10 00 00 00 OB 1 3 l 0 func 2CH get time convert ch ten time convert cl ten time 31 convert d...

Страница 91: ...23 CL minutes 0 59 DH seconds 0 59 DL hundredths of a second 0 99 Exit Conditions If AL 00H the time specified on entry is valid If AL FFH the time was not valid the function was canceled Macro Defin...

Страница 92: ...0 f unc 2DH 5et time 0 0 0 0 read clock get time convert ch ten time convert cl ten time 31 convert dh ten time 61 convert dl ten time 91 display time TH15 FUNCTION 5ee Function 2CH 5 e e end o f cha...

Страница 93: ...each disk write is to be verified or not MS DOS checks this flag each time it writes to a disk The verify flag is normally off Entry Conditions AH 2EH AL verify Flag O O H do not verify 01H verify Ma...

Страница 94: ...k w r i t e 1 bu add s t a r POP cx l o o p C O P Y v e r i f y o f f d i s k r e a d 0 bu a b s d i s k w r i t e add s t a r POP cx l o o p COPY v e r i f y o f f f e r 6 4 s t a r t f e r 6 4 s t...

Страница 95: ...et Disk Transfer Address Function Call 2FH Returns the Disk Transfer Address Entry Conditions AH 2FH Exit Conditions ES BX pointer to current Disk Transfer Address Error Returns None Example Get DTA e...

Страница 96: ...gnation on return For example for MS DOS 2 0 AL would contain 2 and AH would contain 0 Entry Conditions AH 30H Exit Conditions AL major version number AH minor version number BH OEM original equipment...

Страница 97: ...belonging to that process are freed The exit code passed in AX is retrievable by the parent via function call 4DH This method is preferred over Interrupt 27H and has the advantage of allowing more th...

Страница 98: ...CONTROL C trapping on the CON TROL C interrupt is given at the system call that initi ates the disk operation Note that programs using Function Calls 06H or 07H to read CONTROL Cs as data must ensure...

Страница 99: ...th a specified interrupt Note that programs should never get an inter rupt vector by reading the low memory vector table directly Entry Conditions AH 35H AL interrupt number Exit Conditions ES BX poin...

Страница 100: ...onditions AH 36H DL drive 0 default 1 A etc Exit Conditions BX number of free allocation units on drive DX total number of allocation units on drive CX bytes per sector AX sectors per allocation unit...

Страница 101: ...ated in AL The value passed in AL is either 0 for current country or a country code Country codes are typically the international telephone pre fix code for the country If DX 1 this call sets the curr...

Страница 102: ...ng Thousands separator 2 BYTE ASCIIZ string Decimal separator 2 BYTE ASCIIZ string Date separator 2 BYTE ASCIIZ string Time separator 1 BYTE Bit field I I Currency l BYTE places 1 BYTE I Time format D...

Страница 103: ...ld indicates the number of places which appear after the decimal point on currency amounts The time format has the following values 0 12 hour time 1 24 hour time The Case Mapping call is a FAR procedu...

Страница 104: ...or returns AX 2 AX error code DS DX country datu File not found The country passed in AL was not found no table exists for the specified country Example I d 5 d x b l k mov ah 38H mov a l country code...

Страница 105: ...SCIIZ pathname Exit Conditions Carry set AX error code Carry not set No error Error Returns AX 3 Path not found The path specified was invalid or not found Access denied The directory could not be cre...

Страница 106: ...arry set AX error code Carry not set No error Error Returns AX 3 Path not found The path specified was invalid or not found Access denied The path specified was not empty was not a directory was the r...

Страница 107: ...cified pathname does not exist then the current directory is unchanged Entry Conditions AH 3BH DS DX pointer to ASCZIZ pathname Exit Conditions Carry set AX error code Carry not set No error Error Ret...

Страница 108: ...Entry Conditions AH 3CH DS DX pointer to ASCZZZ pathnume CX file attribute s Exit Conditions Carry set Carry not set Error Returns AX error code AX file handle number AX AX AX 5 Access denied 1 the at...

Страница 109: ...Chawter 1 I System Calls Example Creat equ 3CH Id5 dx pathname mov cx attribute mov ah Creat int 21 H 107...

Страница 110: ...O to the file Entry Conditions AH 3DH DS DX pointer to ASCIIZ pathname for file to open AL access code 0 read 1 write 2 read and Exit Conditions Carry set Carry not set Error Returns AX 12 write AX er...

Страница 111: ...Chapter 1 I System Calls Example Open e q u 3DH I d s dx pathname mov a1 access mov ah Open int 21 H 109...

Страница 112: ...file handle Internal buffers are flushed Entry Conditions AH 3EH BX file handle for file to close Exit Conditions Carry set AX error code Carry not set No error Error Return AX 6 Invalid handle The h...

Страница 113: ...pointers no segment wrap around will occur MS DOS takes the pointer you specify in DS DX and modifies it so that DX is OOOFH or smaller Entry Conditions AH 3FH DS DX pointer to buffer CX number of byt...

Страница 114: ...ed pointers no segment wrap around will occur MS DOS takes the pointer you specify in DS DX and modifies it so that DX is OOOFH or smaller Entry Conditions AH 40H DS DX pointer to buffer CX number of...

Страница 115: ...fied filename Entry Conditions AH 41H DS DX pointer to pathnam Exit Conditions Carry set AX error code Carry not set No error Error Returns AX 2 File not found The path was invalid or not found AX 5 A...

Страница 116: ...ffset Entry Conditions AH 42H CX DX distance to move the pointer offset in bytes CX contains the most significant part AL method of moving 0 1 or 2 see above BX file handle Exit Conditions Carry set C...

Страница 117: ...butes to those in CX O O H return file s attributes in CX CX attribute s to be set Exit Conditions Carry set Carry not set Error Returns AX 3 AX 5 AX error code CX current attribute s if AL OOH on ent...

Страница 118: ...he number of bytes indicated in CX from the device control channel into buffer pointed to by DS DX BX file handle 3 Write the number of bytes indicated in CX to the device control channel from the buf...

Страница 119: ...t process control strings via calls AL 2 and AL 3 CTRL 1 if this device can process control strings via calls AL 2 and AL 3 Note that the CTRL bit cannot be set by the Ioctl system call If ISDEV 0 EOF...

Страница 120: ...inter function call 42H Output Always ready even if disk is full Note The status is defined at the time the system is called In future versions of MS DOS by the time control is returned to the user fr...

Страница 121: ...ction The function passed in AL was not in the range 0 7 Invalid data Access denied for calls AL 4 5 6 7 AX 1 AX 13 AX 5 Example loct I equ mov or mav m o v or Ids m o v mov m o v I n t 44H bx handle...

Страница 122: ...nditions AH 45H BX file handle to duplicate Exit Conditions Carry set Carry not set Error Returns AX 6 AX error code AX new file handle Invalid Handle The handle passed in BX is not cur rently open To...

Страница 123: ...specified in CX it is closed first Entry Conditions AH 46H BX existing file handle CX new file handle Exit Conditions Carry set AX error code Carry not set No error Error Returns AX 6 Invalid handle T...

Страница 124: ...ing path separator Entry Conditions AH 47H DS SI pointer to 64 byte memory area to receive directory DL drive 0 default 1 A 2 B etc Exit Conditions Carry set Carry not set Error Returns AX 15 AX error...

Страница 125: ...ould be allocated in paragraphs if the requested size was not available AX10 pointer to the allocated memory Carry not set Error Returns AX 8 Not enough memory The largest available free block is smal...

Страница 126: ...y area to be freed Exit Conditions Carry set AX error code Carry not set No error Error Returns AX 9 Invalid block The block passed in ES is not one allo cated via the Allocate Memory function call 48...

Страница 127: ...quested size was not available on a grow request Carry not set No error Error Returns AX 9 Invalid block The block specified in ES is not one allocated via this call Arena trashed The internal consist...

Страница 128: ...l in loading program overlays For each value of AL the parameter block pointed to by ES BX has the following format AL 0 Load and execute program WORD segment address of environment string DWORD point...

Страница 129: ...the parent is an environ ment This is a block of text strings less than 32K bytes total that convey various configuration parameters The format of the environment is as follows paragraph boundary BYT...

Страница 130: ...larger than 32K bytes Bad format The file pointed to by DS DX was an EXE format file and contained information that was internally inconsistent Not enough memory There was not enough memory for the p...

Страница 131: ...transfers control to the in voking process In addition a return code may be sent All files open at the time are closed This method is preferred over all others Interrupt 20H JMP 0 Entry Conditions AH...

Страница 132: ...The low byte of this code is sent by the Keep Process function call 31H The high byte indicates the circumstances that caused the child to terminate and is one of the following 0 Terminate abort 2 Ha...

Страница 133: ...ytes Time of file 2 bytes Date of file 2 bytes Least significant word of file size 2 bytes Most significant word of file size 13 bytes To obtain the subsequent matches of the pathname see the descript...

Страница 134: ...Chapter 1 I System Calls Example F i n d F i r s t eq 4EH Ids d x pathname mov C Y a t t r i b u t e mov ah F i n d F i r 5 t i n t 21H 132...

Страница 135: ...Address must contain the block returned by the Find First function call 4EH Entry Conditions AH 4FH Exit Conditions Carry set AX error code Carry not set No error Error Returns AX 18 No more files Th...

Страница 136: ...t Setting of Verify Function Call 54H Returns the current setting of the verify flag Entry Conditions AH 54H Exit Conditions AL current verify flag value O O H off OIH on Error Returns None Example Ge...

Страница 137: ...r to new ASCIIZ pathname Exit Conditions Carry set AX error code Carry not set No error Error Returns AX 2 File not found The filename specified by DS DX was not found AX 17 Not same device The source...

Страница 138: ...ime to be set if AL 01H DX date to be set if AL 01H Exit Conditions Carry set Carry not set AX error code If AL 00 H on entry CX time of last write DX date of last write Error Returns AX 1 AX 6 Invali...

Страница 139: ...macro disk buffer num sectors first sector mov a 1 d i s k mov cx num_sector5 mov d x f i r s t s e c t o r i n t 26H endm POPf stay resident macro l a s t i n s t r u c mov d x o f f 5 e t l a s t i...

Страница 140: ...H endm displaymacro string mov dx offiet string mov ah 9 int 21 H endm get string macro limit string mov dx offsetstring mov 5tring limit mov ah 0AH int 21H endm check kbd statusmacro mov ah 0BH int...

Страница 141: ...21 H endm s e a r c h n e x t m a c r o f c b mow d x o f f s e t f c b mov ah l2H i n t 21 H endm d e l e t e m a c r o f c b mov d x o f f s e t f c b mov a h l 3 H i n t 21 H endm read seq macro f...

Страница 142: ...f f s e t f c b mov a h 2 l H i n t 21 H endm w r i t e r a n m a c r o f c b mov d x o f f s e t f c b mov ah 22H i n t 21 H endm f i l e s i z e m a c r o f c b mov d x o f f s e t f c b mov ah 23H...

Страница 143: ...mov d x o f f s e t f c b moc cx count mov w o r d p t r f c b E E H I r e c 5 i z e mov ah 28H i n t 21 H endm p a r s e m a c r o s t r i n g f c b mov 5 i o f f s e t s t r i n g mov d i o f f s e...

Страница 144: ...l VERIFY functionPEH mov string macro source destination num_bytes push mov mov assume mov mov mov assume POP endm rep movs convert macro local imp table db start mov xor xor div mov mov mov mov mov m...

Страница 145: ...T TO BINRRY ten start calc mult no mult s t a r t 1 0 v a l u e 0 c x c x c1 number ax ax a l s t r i n g s i l a1 48 cx 2 no mult 5 1 5 1 cx cx c s t e n m u l t v a l u e ax c a l c c x 5 1 d i r e...

Страница 146: ...l db l b db ends s u b t t l STACKSEGMENT s t a c k segment s t a c k t op l a b e l s t a c k ends s u b t t l MACROS page page dw INCLUDE 8 CALLS MAC BLANK LINE b l a n k l i n e macro l o c a l pus...

Страница 147: ...t endp p r o c push mov x o r mov i nc POP r e t endp loop p r o c mov i n c r e t c s c o d e d s d a t a s s s t a c k ax d a t a ds ax a x 5 tack 55 ax sp of f s e t s t a c k t o p main procedure...

Страница 148: ...sectors prompt get string 4 buffer convert to binary digits current length sectors to dump 4 buffer ret endp proc push mov mov convert inc add call sub mov add mov CmP CmP 19 mov mov inc inc POP ret...

Страница 149: ...ine 3 display continue prompt get char no echo display crlf POP cx r e t mov header mov al header dil output buffertdil output buffer dil dump it call clear line display screen endp ENDPROCEDURES subt...

Страница 150: ......

Страница 151: ......

Страница 152: ......

Страница 153: ...O H Drive number 1 means Drive A 2 means Drive B etc If the FCB is to be used to create or open a file this field can be set to 0 to specify the de fault drive the Open File function call Function 0F...

Страница 154: ...Offset 15H Offset 14H M M D D D D D Time of last write The time the file was created or last updated The hour minutes and seconds are mapped into two bytes as follows lFr7p 15 14 13 1 H 12 I H 11 I 10...

Страница 155: ...t starts at offset 80H the default Disk Transfer Address Extended File Control Block The Extended File Control Block is used to create or search for files in the disk directory that have special attri...

Страница 156: ...our methods result in transferring control to the program that issued the EXEC During this returning process interrupt vectors 22H 23H and 24H Terminate Address CONTROL C Exit Address and Fatal Error...

Страница 157: ...AH a program can issue a far call to offset 50H to invoke an MS DOS function rather than issuing an Interrupt 21H Since this is a call and not an interrupt MS DOS may place any code appropriate to ma...

Страница 158: ...and SP are set to the values passed by For executable COM programs 0 All four segment registers contain the segment address of the initial allocation block that starts with the Program Segment Prefix...

Страница 159: ...l pointer Used by MS DOS Formatted Parameter Area 1 formatted as standard unopened FCB Formatted Parameter Area 2 formatted as standard unopened FCB overlaid if FCB at 5CH is opened Unformatted Parame...

Страница 160: ......

Страница 161: ......

Страница 162: ......

Страница 163: ...within this portion of COMMAND COM including the display of error messages and processing the Abort Retry or Ignore message replies An initialization portion follows the resident portion During start...

Страница 164: ......

Страница 165: ......

Страница 166: ......

Страница 167: ...nsistency If the disk should develop a bad sector in the first FAT the second can be used This prevents loss of data due to an unusable disk The clusters are arranged on disk to minimize head movement...

Страница 168: ...ormance reasons The directory entry has been used but the file has been erased The entry is for a directory If the second byte is also 2EH then the cluster field con tains the cluster number of this d...

Страница 169: ...to 1whenever the file has been written to and closed Note The system files I0 SYS and MSDOS SYS are marked as read only hidden and system files Files can be marked hidden when they are created Also th...

Страница 170: ...Refer to the section How to Use the File Al location Table for details about converting cluster numbers to logical sector numbers File size in bytes The first word is the low order part of the size 1A...

Страница 171: ...allocated for new files Each FAT entry contains three hexadecimal characters Any of the following combinations is possible 000 FF7 The cluster is unused and available The cluster has a bad sector in i...

Страница 172: ...ated FAT offset into a register If the last cluster used was an even number keep the low order 12 bits of the register by ANDing it with FFF other wise keep the high order 12 bits by shifting the regi...

Страница 173: ......

Страница 174: ......

Страница 175: ...disk drives They perform random 110 in pieces called blocks usually the physical sector size These devices are not named as the character devices are and therefore cannot be opened directly They are...

Страница 176: ...t a device name For block devices the first byte is the number of units Vote that the device entry points are words They must be offsets from the same segment number used to point to this table For ex...

Страница 177: ...d The NON IBM FORMAT bit applies only to block devices and af fects the operation of the BUILD BPB Bios Parameter Block de vice call Refer to MEDIA CHECK and BUILD BPB later in this chapter for furthe...

Страница 178: ...ote that for device drivers the code should not be originated at 100H but rather at 0 The link field pointer to the next Device Header should be 1 unless there is more than one device driver in the fi...

Страница 179: ...d length header followed by data pertinent to the opera tion being performed Note that it is the device driver s responsi bility t o preserve the machine state for example save all registers on entry...

Страница 180: ...BUILD BPB are used with block devices only MS DOS calls MEDIA CHECK first for a drive unit MS DOS passes its current media descriptor byte refer to the section Media Descriptor Byte later in this chap...

Страница 181: ...y the NON IBM FOR MAT bit in the attribute field If the bit is zero device is IBM format compatible then the buffer contains the first sector of the first FAT The FAT ID byte is the first byte of this...

Страница 182: ...MS DOS will not continuously wait for something to get into a buffer that does not exist One of the functions defined for each device is INIT This routine is called only once when the device is insta...

Страница 183: ...ans nothing to MS DOS but is passed to devices so that they know what parameters MS DOS is currently using for a particular drive unit Block devices may take several approaches they may be dumb or sma...

Страница 184: ...ce drivers in a single COM file the ending address returned by the last INIT called will be used by MS DOS It is recommended that all device drivsrs in a single COM file return the same ending address...

Страница 185: ...it is 0 then this buffer contains the first sector of the first FAT and the driver must not alter this buffer If IBM compatible format is used NON IBM FORMAT BIT 0 the first sector of the first FAT mu...

Страница 186: ...help the BIOS un derstand the media Sectors per track may be redundant could be calculated from total size of the disk Number of heads is useful for supporting different multi head drives which have t...

Страница 187: ...ivers Under certain circumstances the BIOS may be asked to perform a write operation of 64K bytes that seems to be a wrap around of the transfer address in the BIOS I O packet This request arises beca...

Страница 188: ...r is not removed from the input buffer hence the term non destructive read This call allows MS DOS to look ahead one input character STATUS Command codes 6 and 10 ES BX 13 BYTE Request Header All the...

Страница 189: ...and performs functions like any other character device Most functions will be set done bit reset er ror bit return When a read or write to this device occurs exactly 6 bytes are transferred The first...

Страница 190: ......

Страница 191: ......

Страница 192: ......

Страница 193: ...BIOS routines are normally passed in CPU registers Similarly exit parameters are generally returned from these routines to the caller in CPU registers To insure BIOS compatibility with other machines...

Страница 194: ...l de vice IiO and system status services Service Keyboard Video Display Serial Communications Line Printer System Clock Floppy Disk Equipment Memory Size Software Interrupts 16 hex 22 dec 10 hex 16 de...

Страница 195: ...board buffer destructive read Entry Conditions AH 0 Exit Conditions AL ASCII value of character AH keyboard scan code Scan Keyboard Set up the zero flag Z flag to indicate whether a character is avail...

Страница 196: ...itions AL current shift status bit settings set true reset false bit 0 RIGHT SHIFT key depressed bit 1 LEFT SHIFT key depressed bit 2 CTRL control key depressed bit 3 ALT alternate mode key depressed...

Страница 197: ...Get Cursor Position AH 4 Read Light Pen Position AH 5 Select Active Page AH 6 Scroll Up AH 7 Scroll Down AH 8 Read AttributeKharacter AH 9 Write AttributeICharacter AH 10 Write Character Only AH 11 Se...

Страница 198: ...olor AL 4 320x200 color graphics AL 5 320x200 black and white graphics with 4 AL 6 640x200 black and white graphics with 2 AL 7 Reserved AL 8 160x200 color graphics with 16 colors AL 9 320x200 color g...

Страница 199: ...top row DL column 0 leftmost column Get Cursor Position Read get cursor position Entry Conditions AH 3 BH page number must Exit Conditions 0for gral ics modes DH row of current cursor position 0 top r...

Страница 200: ...e value for modes 2 3 AL 80H read CRTICPU page registers AL 81H set CPU page register to value in BL AL 82H set CRT page register to value in BH AL 83H set both CRT and CPU page registers in CL and BH...

Страница 201: ...H row of upper left corner of scroll window CL column of upper left corner of scroll window DH row of lower right corner of scroll window DL column of lower right corner of scroll window BH attribute...

Страница 202: ...rite BL attribute of character for alpha modes or color of character for graphics modes if bit 7 of BL is set the color of the character is XOR ed with the color value See Scroll Up AH 6 for attribute...

Страница 203: ...0 1 green I 2 red I 3 yellow BL 1 1 cyan 12 magenta 1 3 white In 16 color graphics modes 1 blue I 2 green I 3 cyan I 4 red I 5 magenta I 6 yellow I 7 light gray I 8 dark gray I 9 light blue I 10 ligh...

Страница 204: ...shion Control characters are in terpreted in the normal manner Entry Conditions AH 14 AL character to write BL foreground color graphics mode Get CRT Mode Get the current video mode Entry Conditions A...

Страница 205: ...0 15 to set BH color value to store AL 1Set border color register AL 2 Set palette color value to store and border registers BH color value to store ES DX points to a 17 byte list bytes 0 15 values f...

Страница 206: ...Word Length I 000 110 baud x0 none 0 1sb 10 7 bits 001 150 baud 01 odd 1 2 sb 11 8 bits 010 300 baud 11 even 011 600 baud 100 1200 baud 101 2400 baud 110 4800 baud 111 9600 baud Exit Conditions AX RS...

Страница 207: ...Character Receive input a character in AL wait for a character if neces sary On exit AH will contain the RS 232 status except that only the error bits 1 2 3 4 7 may be set the timeout bit 7 if set in...

Страница 208: ...tect bit 5 transmitter holding register empty bit 6 transmitter shift register empty bit 7 timeout occurred bit 0 delta clear to send bit 1 delta data set ready bit 2 trailing edge ring detector bit 3...

Страница 209: ...Current Printer Status Function Descriptions Print Character Print a character Entry Conditions AH 0 AL character to print DX printer to be used 0 2 Exit Conditions OAH printer status see Get Current...

Страница 210: ...edge bit 7 not busy System Clock These routines provide methods of reading and setting the clock maintained by the system This device is labeled CLOCK in the device list of the operating system An int...

Страница 211: ...in Set Time Of Day Set write the time of day using binary format Entry Conditions AH 1 CX high most significant portion of clock count DX l o w least significant portion of clock count Sound Multiplex...

Страница 212: ...Format Track on Floppy Disk Function Descriptions Reset Floppy Disk Reset the diskette system Resets associated hardware and re calibrates all diskette drives Entry Conditions AH 0 Exit Conditions See...

Страница 213: ...ppy Disk Write the desired sector s from RAM to disk Entry Conditions AH 3 DL drive number 0 1 DH head number 0 1 CH track number 0 39 CL sector number 1 to 9 AL sector count 1 to 9 ES BX pointer to d...

Страница 214: ...head number R sector number N the number of bytes per sector 00 128 01 There is one entry for every sector on a given track 256 02 512 03 1024 Exit Conditions See Exits From All Calls below Exits Fro...

Страница 215: ...cated equipment is in the system bit 0 diskette installed bit 1 not used bit 2 3 always 11 bit 4 5 initial video mode 01 40 25BW 10 80x25BW number of diskette drives only if bit 0 1 00 1 01 2 0 dma pr...

Страница 216: ......

Страница 217: ......

Страница 218: ......

Страница 219: ...be installed To do this place the following command in your CONFIG SYS file see Ap pendix C in the MS DOS Commands Reference Manual for infor mation on the configuration file DEVICE ANSI SYS In the co...

Страница 220: ...C A Moves the cursor up one or more lines without changing col umns The value of determines the number of lines moved The default value for is 1 This sequence is ignored if the cursor is already on th...

Страница 221: ...Cursor Position Report CPR se quence on receipt of DSR see below Cursor Position Report CPR ESC R Reports current cursor position through the standard input de vice The first parameter specifies the c...

Страница 222: ...home position up per left corner Erase Line EL ESC K Erases from the cursor to the end of the line including the cur sor position Erase To End Of Screen ESC 0J Erases the screen from the cursor posit...

Страница 223: ...rameter 0 1 5 7 8 30 31 32 33 34 35 36 37 40 41 42 43 44 45 46 47 Meaning All attributes off normal white on black Highlight on high intensity Blink on Reverse video on Concealed on invisible Black fo...

Страница 224: ...80 x 25 black and white 80 x 25 color 320 x 200 color 320 x 200 black and white 640 x 200 black and white Wrap around at end of line new line starts when old line filled 160 x 200 16 color 320 x 200 1...

Страница 225: ...erated when this key is intercepted However if the first code in the sequence is zero NUL then the first and second codes make up an extended ASCII redefinition See Appendix B for a list of ASCII and...

Страница 226: ......

Страница 227: ...normal ASCII value returned when only the indicated key is depressed SHIFT The shifted ASCII value returned when SHIFT is also depressed CTRL the control ASCII value returned when CTRL is also depress...

Страница 228: ...4 35 36 37 38 39 30 2D 3D 08 09 71 77 65 72 74 79 75 69 6F 70 5B 5D O D 61 73 64 66 67 68 6A 6B 6C 3B 27 x48 x4B 7A 78 63 76 1B 21 40 23 24 25 5E 26 2A 28 29 5F 2B 08 x0F 51 57 45 52 54 59 55 49 4F 50...

Страница 229: ...0 20 x3B x3c x3D x3E x3F x40 x41 x42 x43 x44 37 38 39 x50 34 35 36 x4D 31 32 33 30 2D xOO 2B 2E 0D x47 x98 x99 42 4E 4D 3c 3E 3F 20 x54 x55 x56 x57 x58 x59 x5A x5B x5c x5D 5 c 7E x49 x86 7 c xF3 xF4 x...

Страница 230: ...ceded by an ASCII NUL The ALT key provides a way to generate the ASCII codes of decimal numbers between 1 and 255 Hold down the ALT key while you type on the numeric keypad any decimal number between...

Страница 231: ...rs ROM BIOS Data Area MSDOS and BASIC Data Area I O SYS Drivers Available to user Video RAM in 32K video modes Video RAM in 16K video modes Video RAM Window 32K Reserved for system ROM System BIOS ROM...

Страница 232: ...counter 0078 4 1byte per printer Comm Timeout counter 007C 4 1byte per card KBD extra data area 0080 4 2 words The structure and usage of the Video driver RAM data area is as follows HEX Offset From...

Страница 233: ...RAM data Length and Intended Use drive recalibration status bit 3 0 if 0 then drive 3 0 needs recal before next seek bit 7 indicates interrupt occurrence motor status bit 3 0 drive 3 0 motor is ordof...

Страница 234: ...as follows HEX Offset From Length and Segment 0040 0010 Intended Use 17 1byte Keyboard shift state flag returned by function 02 6 CAPS LOCK on off 5 NUM LOCK ordoff 4 SCROLL LOCK doff 3 ALT key depre...

Страница 235: ...ord pointer to beginning of the 1word pointer to end of the 15 typeahead entries The structure and usage of the clock service routine is as follows HEX Offset From Length and Segment 00400000 Intended...

Страница 236: ......

Страница 237: ......

Страница 238: ......

Страница 239: ...ngs 26 attribute retrieving 115 field 175 in FCB 167 of a file 11 setting 115 device 35 36 input 35 output 36 auxinput 35 auxoutput 36 background color 199 basic input output system 191 baud rate com...

Страница 240: ...ng 34 inputting 33 receive 205 transmit 205 printing 37 attribute 195 chdir 105 check keyboard status 45 child process 127 130 chmod 115 clock device 187 clock system 208 209 close 110 close a file ha...

Страница 241: ...lock FCB 151 current com status 205 206 current disk 66 current printer status 208 current record number FCB 152 current shift status keyboard 193 currentdir 122 cursor 197 cursor control esc 218 219...

Страница 242: ...current 105 directory entry moving 134 removing 104 search for first 52 search for next 54 dirsearchfirst 52 53 disk allocation 165 BIOS format 212 directory 166 168 free space on 98 disk I O support...

Страница 243: ...ock 153 extended screen and keyboard control 17 23 fatal error abort address 17 19 file FAT 168 170 FCB 151 153 attribute 11 closing 51 110 creating 62 106 deleting 56 moving 134 opening 49 108 renami...

Страница 244: ...IOS 212 free allocated memory 124 function call parameters 181 function calls 25 147 alphabetical list of 30 31 calling 27 categories 25 CPM M compatible 27 descriptions of 32 136 error codes 25 26 nu...

Страница 245: ...99 102 interrupt list of 12 vector retrieving 97 vector setting 77 interrupts 12 24 ioctl 116 118 keep process 95 keyboard ASCII and scan codes 225 228 BIOS services 193 194 I O 192 input 33 read 41...

Страница 246: ...disk allocation 165 disk directory 166 168 memory map 229 initialization 161 work areas 151 157 multiplexer sound 209 name field 176 nondestructive read no wait 186 open 108 109 open a file 108 109 o...

Страница 247: ...ck read 78 79 random read 69 70 random write 71 72 raster line 198 rbread 78 79 read device I O interrupts 192 attribute character 205 from file or device 111 keyboard 41 46 keyboard BIOS 193 light pe...

Страница 248: ...scan codes keyboard 225 228 scan keyboard BIOS 193 screen and keyboard control extended 217 223 screen width 195 scroll 195 198 search for first entry 52 53 search for next entry 54 searchnext 54 55...

Страница 249: ...terrupts 191 192 sound multiplexer 209 starting cluster 168 170 status 186 status printer 208 stdconinput 33 stdconoutput 34 stop bits com port 204 string displaying 42 system 192 system calk 9 147 ca...

Страница 250: ...02 flag setting and resetting 91 returning 134 sectors floppy disk 211 212 version returning 94 video display BIOS 192 195 wait 130 width screen 195 write character 200 cursor position 197 random 71 r...

Страница 251: ...Fort Worth Texas 76102 CANADA Barrie Ontario L4M 4W5 TANDY CORPORATION AUSTRALJA 91 Kurrajong Road Mount Druitt N S W 2770 BELGIUM Pare Industriel De Naninne 5140 Naninne U K Bilston Road Wednesbury...

Отзывы: