0% found this document useful (0 votes)
291 views

DOS INT 21h DOS Function Codes: Ah 01H Read Character From Standard Input, With Echo

This document provides a summary of various DOS interrupt functions. It lists the AH values and a brief description for functions like reading/writing characters, getting the system date/time, managing files and directories, and more. For example, AH=01 reads a character from standard input with echo, AH=02 writes a character to standard output, and AH=35 gets the address of an interrupt vector. The document serves as a reference for the different low-level DOS functions that are accessible through software interrupts.

Uploaded by

walternampimadom
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
291 views

DOS INT 21h DOS Function Codes: Ah 01H Read Character From Standard Input, With Echo

This document provides a summary of various DOS interrupt functions. It lists the AH values and a brief description for functions like reading/writing characters, getting the system date/time, managing files and directories, and more. For example, AH=01 reads a character from standard input with echo, AH=02 writes a character to standard output, and AH=35 gets the address of an interrupt vector. The document serves as a reference for the different low-level DOS functions that are accessible through software interrupts.

Uploaded by

walternampimadom
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

DOSINT21hDOSFunctionCodes

ThefollowabridgedlistofDOSinterruptshasbeenextractedfromalargelistcompiledbyRalf
Brown.TheseareavailableonanySimtelmirror(e.g.sunsite.anu.edu.au)underthedirectoryms
dos/info/interNNp.zip
AH
01
05
07

Description
ReadcharacterfromSTDIN
Writecharactertoprinter
Directcharread(STDIN),noecho

AH
02
06
08

Description
WritecharactertoSTDOUT
ConsoleInput/Output
CharreadfromSTDIN,noecho

09
0B
0D
19
2A
2C
2E
35
36
3A
3C
3E
40
42
47
4D
56

WritestringtoSTDOUT
GetSTDINstatus
Diskreset
Getcurrentdefaultdrive
Getsystemdate
Getsystemtime
Setverifyflag
GetInterruptvector
Getfreediskspace
Removesubdirectory
Createfile
Closefile
Writefile
Seekfile
Getcurrentdirectory
Getreturncode
Renamefile

0A
0C
0E
25
2B
2D
30

Bufferedinput
FlushbufferforSTDIN
Selectdefaultdrive
Setinterruptvector
Setsystemdate
Setsystemtime
GetDOSversion

39
3B
3D
3F
41
43
4C
54
57

Createsubdirectory
Setworkingdirectory
Openfile
Readfile
Deletefile
Get/Setfileattributes
Exitprogram
Getverifyflag
Get/Setfiledate

AH=01hREADCHARACTERFROMSTANDARDINPUT,WITHECHO
Return:AL=characterread
Notes:
^C/^Breakarechecked
^PtogglestheDOSinternalechotoprinterflag
^Zisnotinterpreted,thusnotcausinganEOFifinputisredirectedcharacterisechoedto
standardoutput
SeeAlso:AH=06h,AH=07h,AH=08h,AH=0Ah

AH=02hWRITECHARACTERTOSTANDARDOUTPUT
Entry:DL=charactertowrite

Return:AL=lastcharacteroutput
Notes:
^C/^Breakarechecked
thelastcharacteroutputwillbethecharacterinDLunlessDL=09honentry,inwhichcase
AL=20hastabsareexpandedtoblanks
ifstandardoutputisredirectedtoafile,noerrorchecks(writeprotected,fullmedia,etc.)are
performed
SeeAlso:AH=06h,AH=09h

AH=05hWRITECHARACTERTOPRINTER
Entry:DL=charactertoprint
Notes:
keyboardcheckedfor^C/^Break
STDPRNisusuallythefirstparallelport,butmayberedirectedunderDOS2+
iftheprinterisbusy,thisfunctionwillwait
SeeAlso:INT17/AH=00h

AH=06hDIRECTCONSOLEOUTPUT
Entry:DL=character(exceptFFh)
Return:AL=characteroutput
Notes:doesnotcheck^C/^Break
SeeAlso:AH=02h,AH=09h

AH=06hDIRECTCONSOLEINPUT
Entry:AH=06hDL=FFh
Return:
ZFsetifnocharacteravailableandAL=00h
ZFclearifcharacteravailableAL=characterread
Notes:
^C/^BreakareNOTchecked
ifthereturnedcharacteris00h,theuserpressedakeywithanextendedkeycode,whichwillbe
returnedbythenextcallofthisfunction
althoughthereturnofAL=00hwhennocharactersareavailableisnotdocumented,some
programsrelyonthisbehavior
SeeAlso:AH=0Bh

AH=07hDIRECTCHARACTERINPUT,WITHOUTECHO

Return:AL=characterreadfromstandardinput
Notes:doesnotcheck^C/^Break
SeeAlso:AH=01h,AH=06h,AH=08h,AH=0Ah

AH=08hCHARACTERINPUTWITHOUTECHO
Return:AL=characterreadfromstandardinput
Notes:^C/^Breakarechecked
SeeAlso:AH=01h,AH=06h,AH=07h,AH=0Ah,AH=64h

AH=09hWRITESTRINGTOSTANDARDOUTPUT
Entry:DS:DX>'$'terminatedstring
Return:AL=24h
Notes:^C/^Breakarechecked
SeeAlso:AH=02h,AH=06h"OUTPUT"

AH=0AhBUFFEREDINPUT
Entry:DS:DX>buffer(seebelow)
Return:bufferfilledwithuserinput
Notes:
^C/^Breakarechecked
readsfromstandardinput
SeeAlso:AH=0Ch
FormatofDOSinputbuffer:
Offset Size Description
00

maximumcharactersbuffercanhold

01

numberofcharsfromlastinputwhichmayberecalledORnumberofcharacters
actuallyread,excludingCR

02

actualcharactersread,includingthefinalcarriagereturn

AH=0BhGETSTDINSTATUS
Return:
AL=00hifnocharacteravailable
AL=FFhifcharacterisavailable

Notes:^C/^Breakarechecked
SeeAlso:AH=06h"INPUT"

AH=0ChFLUSHBUFFERANDREADSTANDARDINPUT
Entry:
AL=STDINinputfunctiontoexecuteafterflushingbuffer
otherregistersasappropriatefortheinputfunction
Return:asappropriateforthespecifiedinputfunction
Note:ifALisnotoneof01h,06h,07h,08h,or0Ah,thebufferisflushedbutnoinputisattempted
SeeAlso:AH=01h,AH=06h"INPUT",AH=07h,AH=08h,AH=0Ah

AH=0DhDISKRESET
Notes:Thisfunctionwritesallmodifieddiskbufferstodisk,butdoesnotupdatethedirectory
information
SeeAlso:AX=5D01h

AH=0EhSELECTDEFAULTDRIVE
Entry:DL=newdefaultdrive(0=A:,1=B:,etc)
Return:AL=numberofpotentiallyvaliddriveletters
Notes:thereturnvalueisthehighestdrivepresent
SeeAlso:AH=19h,AH=3Bh,AH=DBh

AH=19hGETCURRENTDEFAULTDRIVE
Return:AL=drive(0=A:,1=B:,etc)
SeeAlso:AH=0Eh,AH=47h,AH=BBh

AH=25hSETINTERRUPTVECTOR
Entry:
AL=interruptnumber
DS:DX>newinterrupthandler
Notes:thisfunctionispreferredoverdirectmodificationoftheinterruptvectortable
SeeAlso:AX=2501h,AH=35h

AH=2AhGETSYSTEMDATE

Return:CX=year(19802099)DH=monthDL=dayAL=dayofweek(00h=Sunday)
SeeAlso:AH=2Bh"DOS",AH=2Ch,AH=E7h

AH=2BhSETSYSTEMDATE
Entry:CX=year(19802099)DH=monthDL=day
Return:
AL=00successful
FFhinvaliddate,systemdateunchanged
Note:DOS3.3+alsosetsCMOSclock
SeeAlso:AH=2Ah,AH=2Dh

AH=2ChGETSYSTEMTIME
Return:CH=hourCL=minuteDH=secondDL=1/100seconds
Note:onmostsystems,theresolutionofthesystemclockisabout5/100sec,soreturnedtimes
generallydonotincrementby1onsomesystems,DLmayalwaysreturn00h
SeeAlso:AH=2Ah,AH=2Dh,AH=E7h

AH=2DhSETSYSTEMTIME
Entry:CH=hourCL=minuteDH=secondDL=1/100seconds
Return:
AL=00hsuccessful
FFhifinvalidtime,systemtimeunchanged
Note:DOS3.3+alsosetsCMOSclock
SeeAlso:AH=2Bh"DOS",AH=2Ch

AH=2EhSETVERIFYFLAG
Entry:AL=newstateofverifyflag(00off,01ho)
Notes:
defaultstateatsystembootisOFF
whenON,alldiskwritesareverifiedprovidedthedevicedriversupportsreadafterwrite
verification
SeeAlso:AH=54h

AH=30hGETDOSVERSION
Entry:AL=whattoreturninBH(00hOEMnumber,01hversionflag)

Return:
AL=majorversionnumber(00hifDOS1.x)
AH=minorversionnumber
BL:CX=24bituserserialnumber(mostversionsdonotusethis)ifDOS<5orAL=00h
BH=MSDOSOEMnumberifDOS5+andAL=01h
BH=versionflagbit3:DOSisinROMother:reserved(0)
Notes:
DOS4.01and4.02identifythemselvesasversion4.00
MSDOS6.21reportsitsversionas6.20version6.22returnsthecorrectvalue
Windows95returnsversion7.00(theunderlyingMSDOS)
SeeAlso:AX=3000h/BX=3000h,AX=3306h,AX=4452h

AH=35hGETINTERRUPTVECTOR
Entry:AL=interruptnumber
Return:ES:BX>currentinterrupthandler
SeeAlso:AH=25h,AX=2503h

AH=36hGETFREEDISKSPACE
Entry:DL=drivenumber(0=default,1=A:,etc)
Return:
AX=FFFFhifinvaliddrive
AX=sectorsperclusterBX=numberoffreeclustersCX=bytespersectorDX=totalclusters
ondrive
Notes:
freespaceondriveinbytesisAX*BX*CX
totalspaceondriveinbytesisAX*CX*DX
"lostclusters"areconsideredtobeinuse
thisfunctiondoesnotreturnproperresultsonCDROMsuseAX=4402h"CDROM"instead
SeeAlso:AH=1Bh,AH=1Ch,AX=4402h"CDROM"

AH=39h"MKDIR"CREATESUBDIRECTORY
Entry:DS:DX>ASCIZpathname
Return:
CFclearifsuccessfulAXdestroyed
CFsetonerrorAX=errorcode(03h,05h)
Notes:
alldirectoriesinthegivenpathexceptthelastmustexist

failsiftheparentdirectoryistherootandisfull
DOS2.x3.3allowthecreationofadirectorysufficientlydeepthatitisnotpossibletomake
thatdirectorythecurrentdirectorybecausethepathwouldexceed64characters
SeeAlso:AH=3Ah,AH=3Bh,AH=6Dh

AH=3Ah"RMDIR"REMOVESUBDIRECTORY
Entry:DS:DX>ASCIZpathnameofdirectorytoberemoved
Return:
CFclearifsuccessful,AXdestroyed
CFsetonerrorAX=errorcode(03h,05h,06h,10h)
Notes:directorymustbeempty(containonly'.'and'..'entries)
SeeAlso:AH=39h,AH=3Bh

AH=3Bh"CHDIR"SETCURRENTDIRECTORY
Entry:DS:DX>ASCIZpathnametobecomecurrentdirectory(max64bytes)
Return:
CFclearifsuccessful,AXdestroyed
CFsetonerrorAX=errorcode(03h)
Notes:ifnewdirectorynameincludesadriveletter,thedefaultdriveisnotchanged,onlythecurrent
directoryonthatdrive
SeeAlso:AH=47h,AH=71h,INT2F/AX=1105h

AH=3Ch"CREAT"CREATEORTRUNCATEFILE
Entry:
CX=fileattributes
DS:DX>ASCIZfilename
Return:
CFclearifsuccessful,AX=filehandle
CFsetonerrorAX=errorcode(03h,04h,05h)
Notes:ifafilewiththegivennameexists,itistruncatedtozerolength
SeeAlso:AH=16h,AH=3Dh,AH=5Ah,AH=5Bh

AH=3Dh"OPEN"OPENEXISTINGFILE
Entry:
AL=accessandsharingmodes

DS:DX>ASCIZfilename
Return:
CFclearifsuccessful,AX=filehandle
CFsetonerrorAX=errorcode(01h,02h,03h,04h,05h,0Ch,56h)
Notes:
filepointerissettostartoffile
filehandleswhichareinheritedfromaparentalsoinheritsharingandaccessrestrictions
filesmaybeopenedevenifgiventhehiddenorsystemattributes
SeeAlso:AH=0Fh,AH=3Ch,AX=4301h,AX=5D00h

AH=3Eh"CLOSE"CLOSEFILE
Entry:BX=filehandle
Return:
CFclearifsuccessful,AXdestroyed
CFsetonerror,AX=errorcode(06h)
Note:ifthefilewaswrittento,anypendingdiskwritesareperformed,thetimeanddatestampsare
settothecurrenttime,andthedirectoryentryisupdated
SeeAlso:AH=10h,AH=3Ch,AH=3Dh

AH=3Fh"READ"READFROMFILEORDEVICE
Entry:
BX=filehandle
CX=numberofbytestoread
DS:DX>bufferfordata
Return:
CFclearifsuccessfulAX=numberofbytesactuallyread(0ifatEOFbeforecall)
CFsetonerrorAX=errorcode(05h,06h)
Notes:
dataisreadbeginningatcurrentfileposition,andthefilepositionisupdatedafterasuccessful
read
thereturnedAXmaybesmallerthantherequestinCXifapartialreadoccurred
ifreadingfromCON,readstopsatfirstCR
SeeAlso:AH=27h,AH=40h,AH=93h

AH=40h"WRITE"WRITETOFILEORDEVICE
Entry:

BX=filehandle
CX=numberofbytestowrite
DS:DX>datatowrite
Return:
CFclearifsuccessfulAX=numberofbytesactuallywritten
CFsetonerrorAX=errorcode(05h,06h)
Notes:
ifCXiszero,nodataiswritten,andthefileistruncatedorextendedtothecurrentposition
dataiswrittenbeginningatthecurrentfileposition,andthefilepositionisupdatedaftera
successfulwrite
theusualcauseforAX<CXonreturnisafulldisk
SeeAlso:AH=28h,AH=3Fh

AH=41H"UNLINK"DELETEFILE
Entry:
DS:DX>ASCIZfilename(nowildcards,butseenotes)
CL=attributemaskfordeletion(servercallonly,seenotes)
Return:
CFclearifsuccessful,AXdestroyed(DOS3.3)ALseemstobedriveofdeletedfile
CFsetonerrorAX=errorcode(02h,03h,05h)
Notes:
(DOS3.1+)wildcardsareallowedifinvokedviaAX=5D00h,inwhichcasethefilespecmust
becanonical(asreturnedbyAH=60h),andonlyfilesmatchingtheattributemaskinCLare
deleted
DOSdoesnoterasethefile'sdataitmerelybecomesinaccessiblebecausetheFATchainfor
thefileiscleared
deletingafilewhichiscurrentlyopenmayleadtofilesystemcorruption.
SeeAlso:AH=13h,AX=4301h,AX=4380h,AX=5D00h,AH=60h,AH=71h

AH=42h"LSEEK"SETCURRENTFILEPOSITION
Entry:
AL=originofmove00hstartoffile01hcurrentfileposition02hendoffile
BX=filehandle
CX:DX=offsetfromoriginofnewfileposition
Return:
CFclearifsuccessful,DX:AX=newfilepositioninbytesfromstartoffile
CFsetonerror,AX=errorcode(01h,06h)
Notes:

fororigins01hand02h,thepointermaybepositionedbeforethestartofthefilenoerroris
returnedinthatcase,butsubsequentattemptsatI/Owillproduceerrors
ifthenewpositionisbeyondthecurrentendoffile,thefilewillbeextendedbythenextwrite
(seeAH=40h)
SeeAlso:AH=24h

AH=43GETFILEATTRIBUTES
Entry:
AL=00h
DS:DX>ASCIZfilename
Return:
CFclearifsuccessfulCX=fileattributes
CFsetonerror,AX=errorcode(01h,02h,03h,05h)
BUG:WindowsforWorkgroupsreturnserrorcode05h(accessdenied)insteadoferrorcode02h(file
notfound)whenattemptingtogettheattributesofanonexistentfile.
SeeAlso:AX=4301h,AX=4310h,AX=7143h,AH=B6h

AH=43"CHMOD"SETFILEATTRIBUTES
Entry:
AL=01h
CX=newfileattributes
DS:DX>ASCIZfilename
Return:
CFclearifsuccessful,AXdestroyed
CFsetonerror,AX=errorcode(01h,02h,03h,05h)
Notes:
willnotchangevolumelabelordirectoryattributebits,butwillchangetheotherattributebits
ofadirectory
MSDOS4.01reportedlyclosesthefileifitiscurrentlyopen
SeeAlso:AX=4300h,AX=4311h,AX=7143h,INT2F/AX=110Eh
Bitfieldsforfileattributes:
Bits

6 5

Description shareable archive directory vol.label system hidden readonly

AH=47h"CWD"GETCURRENTDIRECTORY
Entry:

DL=drivenumber(00h=default,01h=A:,etc)
DS:SI>64bytebufferforASCIZpathname
Return:
CFclearifsuccessful
CFsetonerror,AX=errorcode(0Fh)
Notes:
thereturnedpathdoesnotincludeadriveortheinitialbackslash
manyMicrosoftproductsforWindowsrelyonAXbeing0100honsuccess
SeeAlso:AH=19h,AH=3Bh,AH=71h

AH=4Ch"EXIT"TERMINATEWITHRETURNCODE
Entry:AL=returncode
Return:neverreturns
Notes:unlesstheprocessisitsownparent,allopenfilesareclosedandallmemorybelongingtothe
processisfreed
SeeAlso:AH=00h,AH=26h,AH=4Bh,AH=4Dh

AH=4DhGETRETURNCODE(ERRORLEVEL)
Return:
AH=terminationtype(00=normal,01hcontrolCabort,02h=criticalerrorabort,03hterminate
andstayresident)
AL=returncode
Notes:
thewordinwhichDOSstoresthereturncodeisclearedafterbeingreadbythisfunction,sothe
returncodecanonlyberetrievedonce
COMMAND.COMstoresthereturncodeofthelastexternalcommanditexecutedas
ERRORLEVEL
SeeAlso:AH=4Bh,AH=4Ch,AH=8Ah

AH=54hGETVERIFYFLAG
Return:AL=verifyflag(00h=off,01h=on,i.e.alldiskwritesverifiedafterwriting)
SeeAlso:AH=2Eh

AH=56h"RENAME"RENAMEFILE
Entry:
DS:DX>ASCIZfilenameofexistingfile(nowildcards,butseebelow)

ES:DI>ASCIZnewfilename(nowildcards)
CL=attributemask(servercallonly,seebelow)
Return:
CFclearifsuccessful
CFsetonerror,AX=errorcode(02h,03h,05h,11h)
Notes:
allowsmovebetweendirectoriesonsamelogicalvolume
thisfunctiondoesnotsetthearchiveattribute
openfilesshouldnotberenamed
(DOS3.0+)allowsrenamingofdirectories

AH=57hGETFILE'SLASTWRITTENDATEANDTIME
Entry:
AL=00h(Getattribute)
BX=filehandle
Return:
CFclearifsuccessful,CX=file'stimeDX=file'sdate
CFsetonerror,AX=errorcode(01h,06h)
SeeAlso:AX=5701h
Bitfieldsforfiletime:
Bits

1511 105

40

Description hours minutes seconds


Bitfieldsforfiledate:
Bits

159

85

40

Description year(1980) month day

AH=57hSETFILE'SLASTWRITTENDATEANDTIME
Entry:
AL=01h(Setattributes)
BX=filehandle
CX=newtime
DX=newdate
Return:
CFclearifsuccessful
CFsetonerrorAX=errorcode(01h,06h)

SeeAlso:AX=5700h
ThispageismaintainedbyBarryWilks.

You might also like