資源描述:
《雙語(yǔ)教學(xué)雙語(yǔ)教學(xué)4.doc》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫(kù)。
1、Ch4???The?Program?Design?of?Assembly?LanguagelKeywords:機(jī)器語(yǔ)言(MachineLanguage)匯編語(yǔ)言(AssemblyLanguage)高級(jí)語(yǔ)言(High-Level?Language)?簡(jiǎn)單程序(simpleprogram)分支程序(branchprogram)循環(huán)程序(circleorloopprogram)子程序(Subprogram)lIntroduction:The8031supportsMachineLanguage,AssemblyLanguageandHigh-Level?Language
2、programming.Inthe8031assemblyprogramming,theprogramhasoftenthreekindsofforms:Simpleprogram,BranchprogramandCircleprogram.Thenwe’lltellyouhowtodesignaprogram.Togainthefulldepthcontainedineachlinesexplanation,wehighlyrecommendyourefertoeachlineanditsdescription.Line1:stackThisdefinesthe
3、stackentrypoint,allwin32programscontainaSTACK.Line2:dataAlldatadefinitionsaredefinedhereLine3:codeAllProgramcodetobeexecutedgoesbelowthisstatementLine4:START:ThislinetellsthecompilerwheretoexecutetheMAINcode.AllcodewithintheSTARTandENDSTARTlabelsisexecuted.TheprogramwillLOOPthroughthe
4、contentsuntilENDSTARTisfound.Anythingwithaproceeding:isalabel.Line5:movAX,segmsgWecallupontheasm'mov'instructiontomovthecontentsofsegmentofmsgintotheAXRegister.Movisasfollows:movdestination,sourceEg:movAX,10wouldplacethevalue10intotheAXregister.Line6:movds,AXBecausewecannotmoveimmedia
5、tedatadirectlyintotheDSandESregisters,wemustmoveourdataintothegeneralpurposeregisters,andthenfromthere,intotheDataSegmentandExtraSegments.Line7:ENDSTARTWhatIhaveleftoutabovearethelinesthatcontain;'sAlinethatcontainsa;carriesacomment.Anythingafterthe;isconsideredtobeacomment,andisignor
6、edbythecompiler.Acommenthelpsimproveprogramreadability.Hopefullythissmallexampleprogramwillhelpyouonyourwaytolearningthebasicstoassemblerprogramming.Tohelpyouonyourjourney,Iwillnowgiveyousomefuninterruptstoplaywith,thatmayhelpyoudiscovernewandexcitingthings=)InterruptsOneinterruptinwh
7、ichisfoundratherhandyis16H,whichwaitsforasinglekeypressfromthekeyboard,thefollowingcodewillpausetheprogramuntilakeyhasbeenpressed:Nearlyallinterruptswillcallupontheregistersasvariableswhentheyexecutetheirinstructions.Forinterrupt16h,wemustcleartheaxregister.Interrupt16histhestandardke
8、yboar