Você está na página 1de 11

8/15/2016

BIOSandDOSInterrupts

BIOSandDOSInterrupts
Dr.TimMcGuire
CS272
SamHoustonStateUniversity
Thesenotesroughlycorrespondtotextchapter10,althoughtheapproachisconsiderablydifferent
Overview
Previously,weusedtheINT(interrupt)instructiontocallsystemroutines
Inthismodule,wediscussdifferentkindsofinterruptsandtakeacloserlookattheoperationofthe
INTinstruction
WewilldiscusstheservicesprovidedbyvariousBIOS(basicinput/outputsystem)andDOS
interruptroutines
Todemonstratetheuseofinterrupts,wewillwriteaprogramthatdisplaysthecurrenttimeonthe
screen
HardwareInterrupt
Wheneverakeyispressed,theCPUmustbenotifiedtoreadakeycodeintothekeyboardbuffer
Thegeneralhardwareinterruptgoeslikethis:
adevicethatneedsservicesendsaninterruptrequestsignaltotheprocessor
theCPUsuspendsthecurrenttaskandtransferscontroltoaninterruptroutine
theinterruptroutineservicesthehardwaredevicebyperformingsomeI/Ooperation
controlistransferredbacktotheoriginalexecutingtaskatthepointwhereitwassuspended
QuestionstobeAnswered
HowdoestheCPUfindoutadeviceissignaling?
Howdoesitknowwhichinterruptroutinetoexecute?
Howdoesitresumetheprevioustask?
AcknowledginganInterrupt
Becauseaninterruptsignalmaycomeatanytime,theCPUchecksforthesignalafterexecutingeach
instruction
Ondetectingtheinterruptsignal,theCPUacknowledgesitbysendinganinterruptacknowledge
signal
Theinterruptingdevicerespondsbysendinganeightbitnumberonthedatabus,calledaninterrupt
number
Eachdeviceusesadifferentinterruptnumbertoidentifyitsownserviceroutine
Thisprocessiscalledhandshaking
TransferringtoanInterruptRoutine
Theprocessissimilartoaprocedurecall
Beforetransferringcontroltotheinterruptroutine,theCPUfirstsavestheaddressofthenext
instructiononthestackthisisthereturnaddress
TheCPUalsosavestheFLAGSregisteronthestackthisensuresthatthestatusofthesuspendedtask
willberestored
Itistheresponsibilityoftheinterruptroutinetorestoreanyregistersituses
SoftwareInterrupt
Softwareinterruptsareusedbyprogramstorequestsystemservices
AsoftwareinterruptoccurswhenaprogramcallsaninterruptroutineusingtheINTinstruction
TheformatoftheINTinstructionis
http://www.shsu.edu/csc_tjm/spring2001/cs272/interrupt.html

1/11

8/15/2016

BIOSandDOSInterrupts

INTinterrupt_number
The8086treatsthisinterruptnumberinthesamewayastheinterruptnumbergeneratedbyahardware
device
WehavealreadyseenanumberofexamplesofthisusingINT21handINT10h
ProcessorException
Thereisathirdkindofinterrupt,calledaprocessorexception
Aprocessorexceptionoccurswhenaconditionarisesinsidetheprocessor,suchasdivideoverflow,
thatrequiresspecialhandling
Eachconditioncorrespondstoauniqueinterrupttype
Forexample,divideoverflowistype0,sowhenoverflowoccursinadivideinstructiontheCPU
automaticallyexecutesinterrupt0tohandletheoverflowcondition
InterruptNumbers
Theinterruptnumbersforthe8086areunsignedbytevaluestherefore256typesofinterruptsare
possible
Notallinterruptnumbersareused
BIOSinterruptserviceroutinesarestoredinROM
DOSinterruptroutines(int21h)areloadedintomemorywhenthemachineisstarted
Someadditionalinterruptnumbersarereservedbythemanufacturerforfurtherusetheremaining
numbersareavailablefortheuser
InterruptTypes
InterruptTypesDescription
0h1FhBIOSInterrupts
20h3FhDOSInterrupts
40h7Fhreserved
80hF0hROMBASIC
F1hFFhnotused
InterruptVector
TheCPUdoesnotgeneratetheinterruptroutine'saddressdirectlyfromtheinterruptnumber
Doingsowouldmeanthataparticularinterruptroutinemustbeplacedinexactlythesame
locationineverycomputer
Instead,theCPUusestheinterruptnumbertocalculatetheaddressofamemorylocationthat
containstheactualaddressoftheinterruptroutine
Thismeansthattheroutinemayappearanywhere,solongasitsaddress,calledaninterruptvector,is
storedinapredefinedmemorylocation
InterruptVectorTable
Allinterruptvectorsareplacedinaninterruptvectortable,whichoccupiesthefirst1KBofmemory
Eachinterruptvectorisgivenassegment:offsetandoccupiesfourbytes
Thefirstfourbytesofmemorycontaininterruptvector0
AccessingtheVector
Tofindthevectorforaninterruptroutine,multiplytheinterruptnumberby4
Thisgivesthememorylocationcontainingtheoffsetoftheroutine
Thesegmentnumberoftheroutineisinthenextword
Example
http://www.shsu.edu/csc_tjm/spring2001/cs272/interrupt.html

2/11

8/15/2016

BIOSandDOSInterrupts

Thekeyboardinterruptroutineisinterrupt9
Theoffsetaddressisstoredinlocation9x4=36=00024h
Thesegmentaddressisfoundinlocation24h+2=00026h
BIOSinitializesitsinterruptvectorswhenthecomputeristurnedon,andtheDOSinterruptvectorsare
initializedwhenDOSisloaded
InterruptRoutines
WhentheCPUexecutesanINTinstruction,itfirstsavestheflagsbypushingthecontentsofthe
FLAGSregisterontothestack
ThenitclearsthecontrolflagsIF(interruptflag)andTF(trapflag)
Thereasonforthisactionisexplainedlater
Finally,itusestheinterruptnumbertogettheinterruptvectorfrommemoryandtransferscontrolto
theinterruptroutinebyloadingCS:IPwiththeinterruptvector
The8086transferstoahardwareinterruptroutineorprocessorexceptioninasimilarfashion
Oncompletion,aninterruptroutineexecutesanIRET(interruptreturn)instructionthatrestorestheIP,
CS,andFLAGSregisters
TheControlFlagTF
WhenTFisset,the8086generatesaprocessorexception(interrupt1)
Thisinterruptisusedbydebuggersto"singlestep"throughaprogram
Totraceaninstruction,thedebuggerfirstsetsTF,andthentransferscontroltotheinstructionto
betraced
Aftertheinstructionisexecuted,theprocessorsgeneratesaninterrupttype1becauseTFisset
Thedebuggerusesitsowninterrupt1routinetogaincontroloftheprocessor
TheControlFlagIF
IFisusedtocontrolhardwareinterrupts
WhenIFisset,hardwaredevicesmayinterrupttheCPU
Externalinterruptsmaybedisabled(maskedout)byclearingIF
Actually,thereisahardwareinterrupt,calledNMI(nonmaskableinterrupt)thatcannotbe
maskedout
BothTFandIFareclearedbytheprocessorbeforetransferringtoaninterruptroutinesothatthe
routinewillnotbeinterrupted.
Ofcourse,aninterruptroutinecanchangetheflagstoenableinterruptsduringitsexecution
BIOSInterrupts
Interrupttypes01FhareBIOSinterruptswhoseserviceroutinesresideinROMsegmentF000h
Interrupt0DivideOverflow:generatedwhenaDIVorIDIVoperationproducesanoverflow
Theinterrupt0routinedisplaysthemessage"DIVIDEOVERFLOW"andreturnscontrolto
DOS
Interrupt1SingleStep:generatedwhentheTFisset
Interrupt2NonmaskableInterrupt:cannotbemaskedoutbyclearingtheIF
TheIBMPCusesthisinterrupttosignalmemoryandI/Oparityerrorsthatindicatebadchips
Interrupt3Breakpoint:usedbydebuggerstosetupbreakpoints
Interrupt4Overflow:generatedbytheinstructionINTO(interruptifoverflow)whenOFisset
Programmersmaywritetheirowninterruptroutinetohandleunexpectedoverflows
Interrupt5PrintScreen:TheBIOSinterrupt5routinesendsthevideoscreeninformationtothe
printer
AnINT5instructionisgeneratedbythekeyboardinterruptroutine(INT9)whenthePrtScrkey
ispressed
Interrupts6&7arereservedbyIntel
Interrupt8Timer:Atimercircuitgeneratesaninterruptonceevery54.92milliseconds
TheBIOSinterrupt8routineservicesthetimercircuit
http://www.shsu.edu/csc_tjm/spring2001/cs272/interrupt.html

3/11

8/15/2016

BIOSandDOSInterrupts

Itusersthetimersignalstokeeptrackofthetimeofday
Interrupt9Keyboard:generatedbythekeyboardwheneverakeyispressedorreleased
Theserviceroutinereadsascancodeandstoresitinthekeyboardbuffer
InterruptEDisketteError:TheBIOSinterruptroutineEhhandlesdisketteerrors
InterruptTypes10h1Fh
Theinterruptroutines10h1Fharesoftwareinterruptswhichcanbecalledbyapplicationprogramsto
performvariousI/Ooperationsandstatuschecking
Interrupt10hVideo:TheBIOSinterrupt10hroutineisthevideodriver
Detailshavebeencoveredinaotherunits
Interrupt11hEquipmentCheck:returnstheequipmentconfigurationoftheparticularPC
ThereturncodeisplacedinAX
ThetableonthenextslideshowshowtointerpretAX
EquipmentCheck
1514Numberofprintersinstalled
13=1ifinternalmodeminstalled
12=1ifgameadapterinstalled
119Numberofserialportsinstalled
8notused
76Numberoffloppydrives(ifbit0=1)
00=1,01=2KB,10=3,11=4
54Initialvideomode
00=notused,01=40x25color,
10=80x25color,11=80x25monochrome
32SystemboardRAMsize(originalPC)
00=16KB,01=32KB,10=48KB,11=64KB
1=1ifmathcoprocessorinstalled
0=1iffloppydriveinstalled
InterruptTypes10h1Fh
Interrupt12hMemorySize:returnsinAXtheamountofconventionalmemory
Conventionalmemoryreferstomemorycircuitswithaddressbelow640Ktheunitforthe
returnvalueisinkilobytes
Example:
Supposeacomputerhas512KBofconventionalmemory.WhatwillbereturnedinAXif
theinstructionINT12hisexecuted?
512=200h,henceAX=200h
Interrupt13hDiskI/O:TheBIOSinterrupt13hroutineisthediskdriveritallowsapplication
programstododiskI/O
MostfileoperationsaredonethroughDOSINT21h,functions39h42h,howevertheseutilize
theBIOSINT13hroutine
Interrupt14hCommunications:Thecommunicationsdriverthatinteractswiththeserialports
Interrupt15hCassette:UsedbytheoriginalPCforthecassetteinterface
Interrupt16hKeyboard:thekeyboarddriver,discussedinapreviousunit
Interrupt17hPrinterI/O:theprinterdriver
supports3functions,givenbyAH=0,1,or2
Function0:writescharactertotheprinter
Function1:initializesaprinterport
Function2:getsprinterstatus
Interrupt18hBASIC:transferscontroltoROMBASIC
Interrupt19hBootstrap:rebootsthesystem
http://www.shsu.edu/csc_tjm/spring2001/cs272/interrupt.html

4/11

8/15/2016

BIOSandDOSInterrupts

Interrupt1AhTimeofDay:allowsaprogramtogetandsetthetimertickcount
Interrupt1BhCtrlBreak:calledbytheINT9routinewhenCtrlBreakispressed
TheBIOSroutineisastubitcontainsonlyanIRETinstruction
UsersmaywritetheirownroutinestohandletheCtrlBreakkey
Interrupt1ChTimerTick:calledbyINT8eachtimethetimercircuitinterruptsasinINT1Bh,the
routineisastub
Interrupts1Dh1Fh:Theseinterruptvectorspointtodatainsteadofinstructions(videoparameters,
disketteparameters,andvideographicscharacters,respectively)
DOSInterrupts
Theinterrupttypes20h3FhareservicedbyDOSroutinesthatprovidehighlevelservicetohardware
aswellassystemresourcessuchasfilesanddirectories
ThemostusefulisINT21h,whichprovidesmanyfunctionsfordoingkeyboard,video,andfile
operations
DOSInterrupts20h27h
Interrupt20hProgramTerminate:Terminatesprogram,butitisbettertouseINT21h,function4Ch
Interrupt21hFunctionRequest:Functions0h5Fh
ThesefunctionsmaybeclassifiedascharacterI/O,fileaccess,memorymanagement,disk
access,networking,etc.
Interrupt22h26h:Thesehandlecriticalerrorsanddirectdiskaccess
Interrupt27hTerminateandStayResident:allowsprogramstostayinmemoryaftertermination
ATimeDisplayProgram
Asanexampleofusinginterruptroutines,wenowwriteaprogramthatdisplaysthecurrenttime
Wewillwritethreeversions,eachmorecomplex
Thefirstversionsimplydisplaysthecurrenttimeinhours,minutes,andseconds
Thesecondversionwillshowthetimeupdatedeverysecond
Thethirdversionwillbeamemoryresidentprogramthatcandisplaythetimewhileotherprograms
arerunning
ClockatPowerup
Whenthecomputerispoweredup,thecurrenttimeisusuallysuppliedbyarealtimeclockcircuitthat
isbatterypowered
Ifthereisnorealtimeclock,DOSpromptstheusertoenteratime
Thistimevalueiskeptinmemoryandupdatedbyatimercircuitusinginterrupt8
AprogramcancallDOSinterrupt21h,function2Ch,toaccessthetime
INT21h,Function2Ch
TimeOfDay
Input:
AH=2Ch
Output:
CH=hours(023)
CL=minutes(059)
DH=seconds(059)
DL=1/100seconds(099)
Returnsthetime:hours,minutes,seconds,andhundredthsofseconds
HowtheProgramWorks
Threesteps
obtainsthecurrenttime(procedureGET_TIME)
http://www.shsu.edu/csc_tjm/spring2001/cs272/interrupt.html

5/11

8/15/2016

BIOSandDOSInterrupts

convertsthehours,minutes,andsecondsintoASCIIdigits(ignorethefractionsofseconds)
(procedureCONVERT)
displaytheASCIIdigits
Atimebuffer,TIME_BUF,isinitializedwiththemessageof00:00:00
ThemainprocedurecallsGET_TIMEtostorethecurrenttimeinthetimebuffer
ThemainprocedurethencallsINT21h,function9toprintoutthestringinthetimebuffer
GET_TIMEcallsINT21h,function2Chtogetthetime,thencallsCONVERTtoconvertthetimeto
ASCIIcharacters
CONVERTdividestheinputnumberinALby10thiswillputtheten'sdigitinALandtheone'sdigit
inAH
ThesecondstepistoconvertthedigitsintoASCII
Theprogramdisplaysthetimeandterminates
ProgramListing(timedsp1.asm)
%TITLE"TIME_DISPLAY_VER_1"
;programthatdisplaysthecurrenttime
IDEAL
MODELsmall
STACK100h
DATASEG
TIME_BUFDB'00:00:00$';timebufferhr:min:sec
CODESEG
Start:
movAX,@data
movDS,AX;initializeDS
;getanddisplaytime
leaBX,[TIME_BUF];BXpointstoTIME_BUF
callGET_TIME;putcurrenttimeinTIME_BUF
leaDX,[TIME_BUF];DXpointstoTIME_BUF
movAH,09h;displaytime
int21h
;exit
movAH,4Ch;return
int21h;toDOS

ProcedureGET_TIME
PROCGET_TIMENEAR
;gettimeofdayandstoreASCIIdigitsintimebuffer
;input:BX=addressoftimebuffer
movAH,2Ch;gettime
int21h;CH=hr,CL=min,DH=sec
;converthoursintoASCIIandstore
movAL,CH;hour
callCONVERT;converttoASCII
mov[BX],AX;store
;convertminutesintoASCIIandstore
movAL,CL;minute
callCONVERT;converttoASCII
mov[BX+3],AX;store
;convertsecondsintoASCIIandstore
movAL,DH;second
callCONVERT;converttoASCII
http://www.shsu.edu/csc_tjm/spring2001/cs272/interrupt.html

6/11

8/15/2016

BIOSandDOSInterrupts

mov[BX+6],AX;store
ret
ENDPGET_TIME

ProcedureCONVERT
PROCCONVERT
;convertsbytenumber(059)intoASCIIdigits
;input:AL=number
;output:AX=ASCIIdigits,AL=highdigit,AH=lowdigit
movAH,0;clearAH
movDL,10;divideAXby10
divDL;AHhasremainder,ALhasquotient
orAX,3030h;converttoASCII,AHhaslowdigit
ret;ALhashighdigit
ENDPCONVERT
;
ENDStart
UserInterruptProcedures
Tomakethetimedisplayprogrammoreinteresting,let'swriteasecondversionthatdisplaysthetime
andupdatesiteverysecond
Onewaytocontinuouslyupdatethetimeistoexecutealoopthatkeepsobtainingthetimevia
INT21h,function2Chanddisplayingit
Theproblemhereistofindawaytoterminatetheprogram
Insteadofpursingthisapproach,wewillwritearoutineforinterrupt1Ch
INT8andINT1Ch
Interrupt1ChisgeneratedbytheINT8routinewhichisactivatedbyatimercircuitabout18.2times
persecond
Wewillwriteanewinterrupt1Chroutinesothatwhenitiscalled,itwillgetthetimeanddisplayit
Ourprogramwillhaveamainprocedurethatsetsuptheinterruptroutineandwhenakeyispressed,it
willdeactivatetheinterruptroutineandterminate
SetInterruptVector
Tosetupaninterruptroutine,weneedto
savethecurrentinterruptvector
placethevectoroftheuserprocedureintheinterruptvectortable,and
restorethepreviousvectorbeforeterminatingtheprogram
WeuseINT21h,function35htogettheoldvectorandfunction25htosetupthenewinterruptvector
INT21h,Function25h
SetInterruptVector
Storeinterruptvectorintovectortable
Input:
AH=25h
AL=Interruptnumber
DS:DX=interruptvector
Output:
none
http://www.shsu.edu/csc_tjm/spring2001/cs272/interrupt.html

7/11

8/15/2016

BIOSandDOSInterrupts

INT21h,Function35h
GetInterruptVector
Obtaininterruptvectorfromvectortable
Input:
AH=35h
AL=Interruptnumber
Output:
ES:BX=interruptvector
ProcedureSETUP_INT
TheprocedureSETUP_INTinprogramlistingsetupint.asmsavesanoldinterruptvectorandsetsupa
newvector
ItgetstheinterruptnumberinAL,abuffertosavetheoldvectoratDS:DI,andabuffercontainingthe
newinterruptvectoratDS:SI
Byreversingthetwobuffers,SETUP_INTcanalsobeusedtorestoretheoldvector
CursorControl
EachdisplayofthecurrenttimebyINT21h,function9,willadvancethecursor
Ifanewtimeisdisplayed,itappearsatadifferentscreenposition
So,toviewthetimeupdatedatthesamescreenpositionwemustrestorethecursortoitsoriginal
positionbeforewedisplaythetime
Thisisachievedbyfirstdeterminingthecurrentcursorpositionthen,aftereachprintstring
operation,wemovethecursorback
WeuseINT10h,functions2and3,tosavetheoriginalcursorpositionandtomovethecursortoits
originalpositionaftereachprintstringoperation
INT10h,Function2
DescribedinI/Omodule,repeatedhereforconvenience
MoveCursor
Input:
AH=2
DH=newcursorrow(024)
DL=newcursorcolumn(079for80x25mode)
BH=pagenumber
Output:none
INT10h,Function3
DescribedinI/Omodule,repeatedhereforconvenience
GetCursorPositionandSize
Input:
AH=3
BH=pagenumber
Output:
DH=cursorrow
DL=cursorcolumn
CH=cursorstartingscanline
CL=cursorendingscanline
InterruptProcedure
Whenaninterruptprocedureisactivated,itcannotassumethattheDSregistercontainstheprogram's
datasegmentaddress
http://www.shsu.edu/csc_tjm/spring2001/cs272/interrupt.html

8/11

8/15/2016

BIOSandDOSInterrupts

Thus,ifitusesanyvariablesitmustfirstresettheDSregister
TheDSregistershouldberestoredbeforeendingtheinterruptroutinewithIRET
DISPTIME2.ASM
Programlistingdsptime2.asmcontainsamainprocedureandtheinterruptprocedureTIME_INT
thestepsinthemainprocedureare
savethecurrentcursorposition
setuptheinterruptvectorforTIME_INT
waitforakeyinput,and
restoretheoldinterruptvectorandterminate
SettingandRestoringtheInterruptVector
Tosetuptheinterruptvector,weusethepseudoopsOFFSETandSEGtoobtaintheoffsetand
segmentoftheTIME_INTroutine
ThevectoristhenstoredinthebufferNEW_VEC
SETUP_INTiscalledtosetupthevectorforinterrupttype1Ch(timertick)
INT16h,fcn0isusedforkeyinput
SETUP_INTisagainusedfortorestoretheoldinterruptvector
thistimeSIpointstotheoldvectorandDIpointstothevectorforTIME_INT
TheTIME_INTRoutine
ThestepsinTIME_INTare
setDS
getnewtime
displaytime
restorecursorposition,and
restoreDS
OutlineoftheProgram
Theprogramoperateslikethis:
Aftersettingupthecursorandinterruptvectors,themainprocedurejustwaitsforakeystroke
Inthemeantime,theinterruptroutine(TIME_INT)keepsupdatingthetimewheneverthetimer
circuitticks
Afterakeyishit,theoldinterruptvectorisrestoredandtheprogramterminates
AssemblingandLinking
Themodulesmustbeseparatelyassembledandthenlinkedwith:
tlinktimedsp2setupintgettime
MemoryResidentProgram
WewillwritethethirdversionofDISPLAY_TIMEasaTSR(terminateandstayresident)program
Normally,whenaprogramterminates,thememoryoccupiedbytheprogramisusedbyDOStoload
otherprograms
However,whenaTSRprogramterminates,thememoryoccupiedisnotreleased
Thus,aTSRprogramisalsocalledamemoryresidentprogram
TerminatingaTSR
ToreturntoDOS,aTSRprogramisterminatedbyusingeitherINT27horINT21h,function31h
OurprogramusesINT27h
Wewriteourprogramasa.COMprogrambecausetouseinterrupt27h,weneedtodeterminehow
manybytesaretoremainmemoryresident
http://www.shsu.edu/csc_tjm/spring2001/cs272/interrupt.html

9/11

8/15/2016

BIOSandDOSInterrupts

Thestructureofa.COMprogrammakesthiseasy,becausethereisonlyoneprogramsegment
.COMprogramsalsoaresmaller,sotheysavespaceforTSRs
INT27h
TerminateandStayResident
Input:
DS:DX=addressofbytebeyondthepartthatistoremainresident
Output:
none
Onceterminated,aTSRprogramisnotactive
Itmustbeactivatedbysomeexternalactivity,suchasacertainkeycombinationorbythetimer
TheadvantageofaTRSprogramisthatitmaybeactivatedwhilesomeotherprogramisrunning
OurprogramwillbecomeactivewhentheCtrlandrightshiftkeysarepressed
Tokeeptheprogramsmall,itwillnotupdatethetime
Theprogramhastwoparts:
aninitializationpartthatsetsuptheinterruptvector,and
theinterruptroutineitself
TheprocedureINITIALIZEinitializestheinterruptvector9(keyboardinterrupt)withtheaddressof
theinterruptprocedureMAINandthencallsINT27htoterminate
TheaddressispassedtoINT27histhebeginningaddressoftheINITIALIZEprocedure
thisispossiblebecausetheinstructionsarenolongerneeded
TheprocedureINITIALIZEisshownintheprogramlistingINITLZE.ASM
Thereareanumberofwaysfortheinterruptroutinetodetectaparticularkeycombination
Thesimplestwayistodetectthecontrolandshiftkeysbycheckingthekeyboardflags
Whenactivatedbyakeystroke,theinterruptroutinecallstheoldkeyboardinterruptroutineto
handlethekeyinput
Todetectthecontrolandshiftkeys,aprogramcanexaminethekeyboardflagsattheBIOSdata
area0000:0417horuseINT16h,function2
INT16h,Function2
GetKeyboardFlags
Input:
AH=2
Output:
AL=keyflags
bitmeaning
7=1Inserton
6=1CapsLockon
5=1NumLockon
4=1ScrollLockon
3=1Altkeydown
2=1Ctrlkeydown
1=1Leftshiftkeydown
0=1Rightshiftkeydown

WewillusetheCtrlandrightshiftkeycombinationtoactivateanddeactivatetheclockdisplay
Whenactivated,thecurrenttimewillbedisplayedontheupperrighthandcorner
Wemustfirstsavethescreendatasothatwhentheclockdisplayisdeactivatedthescreencanbe
restored
TheprocedureSET_CURSORsetsthecursoratrow0andthecolumngiveninDL
http://www.shsu.edu/csc_tjm/spring2001/cs272/interrupt.html

10/11

8/15/2016

BIOSandDOSInterrupts

TheprocedureSAVE_SCREENcopiesthescreendataintoabuffercalledSS_BUF,andtheprocedure
RESTORE_SCREENmovesthedatabacktothescreenbuffer
AllthreeproceduresarecontainedinSAVESCRN.ASM
Wearenowreadytowritetheinterruptroutine
Todeterminewhethertoactivateordeactivaethetimedisplay,weusethevariableON_FLAG,which
issetto1whenthetimeisbeingdisplayed
ProcedureMAINistheinterruptroutine
ThestepsinprocedureMAINare:
saveallregistersusedandsetuptheDSandESregisters
calltheoldkeyboardinterruptroutinetohandlethekeyinput
checktoseeifbothCtrlandrightshiftkeysaredown(ifnot,thenexit)
testON_FLAGtodeterminestatus,andifON_FLAGis1thenrestorescreenandexit
savecurrentcursorpositionandalsothedisplayscreeninfo,and
gettime,displaytime,thenexit
Instep1,tosetuptheregistersDSandES,weuseCS
segmentvaluescannotbeusedina.COMprogram
Instep2,weneedtopushtheFLAGSregistersothattheprocedurecallsimulatesaninterruptcall
Instep6,weusetheBIOSinterrupt10hinsteadofDOSinterrupt21h,function9todisplaythetime
because(fromexperience)INT21h,function9tendstobeunreliableinaTSRprogram
Becausetheprogramhasbeenwrittenasa.COMprogram,weneedtorewritethefilecontainingthe
GET_TIMEprocedurewithfullsegmentdirectives.ThefileGETTIME2.ASMcontainsGET_TIME,
CONVERT,andSETUP_INT
TheTLINKcommandshouldbe
tlink/ttimedsp3savescrngettime2initlze
Noticethatinitlze.objislinkedlastsothattheprocedureINITIALIZEisplacedattheendofthe
program
WritingTSRprogramsistrickyifthereareotherTSRprogramsonyoursystem,yourprogrammay
notfunctionproperly

http://www.shsu.edu/csc_tjm/spring2001/cs272/interrupt.html

11/11

Você também pode gostar