Introduction to Windows as a Platform.docx

上传人:b****6 文档编号:8835240 上传时间:2023-02-02 格式:DOCX 页数:14 大小:225.21KB
下载 相关 举报
Introduction to Windows as a Platform.docx_第1页
第1页 / 共14页
Introduction to Windows as a Platform.docx_第2页
第2页 / 共14页
Introduction to Windows as a Platform.docx_第3页
第3页 / 共14页
Introduction to Windows as a Platform.docx_第4页
第4页 / 共14页
Introduction to Windows as a Platform.docx_第5页
第5页 / 共14页
点击查看更多>>
下载资源
资源描述

Introduction to Windows as a Platform.docx

《Introduction to Windows as a Platform.docx》由会员分享,可在线阅读,更多相关《Introduction to Windows as a Platform.docx(14页珍藏版)》请在冰豆网上搜索。

Introduction to Windows as a Platform.docx

IntroductiontoWindowsasaPlatform

VisualStudioExpress:

IntroductiontoWindowsasaPlatform

Author:

RichTebb

Company:

ContentMasterLtd

Introduction

TheVisualStudioExpressEditionsfamilyprovidesafree,lightweight,andeasy-to-learnsuiteofprogrammingtoolsthatareaimedatthehobbyist,novice,andstudentdeveloper.Manypeopleinthiscategorywillnothavehadanyformaltrainingincomputerscience,andindeedtheymaynothaveanyprogrammingexperienceatall.Ifyoufallintothiscategory,don’tworry–thisguideisforyou!

Thisbeginner’sguideisdesignedforpeoplewithlittleornopriorknowledgeofcomputerprogramming,whowanttocreatecomputerprogramswiththeVisualStudioExpresstools.Ifyoualreadyhavesignificantprogrammingexperience,thenyouwillprobablynothavemuchtolearnfromthisarticle.

So,whatwillyoulearnbyreadingthroughthisguide?

Well,ifyouwanttowriteaprogramthatyoucanrunonyourMicrosoftWindowscomputer,thisguidewillintroduceyoutothefundamentalconceptsthatwillhelpyouunderstandhowtodojustthat.Youwilllearntheanswertoquestionssuchas:

∙Howdoesacomputerwork?

∙What’sthedifferencebetweenhardwareandsoftware?

∙What’sanOperatingSystem?

∙Howdoesacomputerrunmyprogram?

∙Whatarethecomponentpartsofaprogram?

ThepurposeofthisguideistohelpyouunderstandtheenvironmentinwhichaMicrosoftWindowsprogramruns.Thewaythataprogramworksisaffectedbymanyfactorsincludingthecomputerthatitrunson,theoperatingsystem,andthewaythatpeoplewillusetheprogram.Theenvironmentofacomputerprogramiscalleditsplatform.Whenyouunderstandtheprogrammingenvironment,youwillbeabletoappreciatehowthecomputerinterpretsyourprograms,andasaresult,learningtoprogramwillbecomeeasierandultimatelyyou’llwritebetterprograms.

ThisguidedescribestheMicrosoftWindowsplatformasaprogrammingenvironment.ItappliestoprogramsthatrunonWindowsandareusedbypeoplethatrunMicrosoftWindows–thesearecalledWindowsapplications.Ifyouwanttowriteanapplicationthatpeoplewillaccessbyusingthroughtheirbrowser,thenyouneedtocreateaWebapplication,notaWindowsapplication.Inthatcase,youshouldreadthecompanionguide“IntroductiontoWebasaplatform”,whichprovidesinformationabouttheWorldWideWebasanapplicationplatform.

HowComputersWork

Althoughcomputersconsistofadvancedtechnologicalcomponents,thebasicwayacomputeroperatesisverysimple,andhaschangedverylittlesincetheinventionofelectroniccomputersinthemiddleofthetwentiethcentury.Acomputercontainsthreemainfunctionalareas:

∙Input/Output.Thisreferstoanydeviceattachedtothecomputerthatprovidesameansofinteractionorcommunicationbetweenthecomputerandthe‘outsideworld’(fromthecomputer’sperspective).Examplesofinputdevicesincludethekeyboard,mouse,andjoystick.Examplesofoutputdevicesincludethemonitor,printerandsoundcard.

∙Memory.Thisisthepartofthecomputerthatprovidesinformationstorage.Acomputer’smemoryisdividedintomanythousandsofsmallunitscalledbytes.Allthedatathatacomputermanagesisstoredasoneormorebytes.Youcanimaginethesebytesasslotsorpigeonholes,eachwithitsownmemorylocationoraddressthatthecomputerusestofetchandstoredata,similartoaroomfullofPostOfficeboxes.Each‘box’orbytecontainsanumberthatthecomputercanprocess.

∙CentralProcessingUnit.TheCentralProcessingUnit(CPU)isthe‘brain’ofthecomputer,whichperformsallcalculationsandco-ordinatestheoperationofthememoryandinput/outputdevices.

TheInstructionCycle

AcomputeroperatesbycopyingbytesfromthememoryoraninputdeviceontotheCPU,performingsomecalculationsonthosebytes,andthencopyingtheresultofthecalculationstothememoryoranoutputdevice.Thisprocesscontinuesinacycleasshownbelow:

Forthiscycleofdataprocessingtobeuseful,thecomputerneedstohaveinstructionsthattellitwhattoreadandwrite,andwhichcalculationstoperform.TheseinstructionstelltheCPUwhatmemorylocationtoreadfrom(fetchingdatafrommemory)orwriteto(storingdatatomemory),andwhichinputoroutputdevicestoaccess.(Lateroninthisarticleyouwillseehowcomputermemorycanholdinformationthatrepresentsexternalentitiessuchasimagesorsound.)

Theinstructionsthatacomputerrunsaresimplynumberslikeanyotherdata,andtheyarestoredinthecomputer’smemory.TheCPUalwayskeepsaninternalrecordofwhichmemorylocation(address)containsthenextinstructionthatitwillexecute.Whenitcompletesoneinstruction,itreadsthenextinstructionfrommemory,andupdatesitsrecordtopointtotheinstructionafterthat.Afterithasupdateditsrecord,itcanprocesstheinstructionthatithasjustreadfrommemory.

SoacomputerprogramisjustaseriesofbytesthatcontaininstructionsfortheCPU.Whenthecomputerrunstheprogram,itmovessequentiallythroughthesetofinstructionbytes,loadingeachinstructionontotheCPU,performingthatinstruction,andthengoingbacktofetchthenextinstructionontotheCPU.TheprogramitselfdoesnotalwaysneedtotelltheCPUtomovetothenextinstruction–thishappensautomatically.

However,instructionscanalsotelltheCPUtomodifyitsinternalrecordsothatitwillreadthenextinstructionfromadifferentaddress.Theseinstructions,called‘jump’instructions,enablethecomputertoperformdifferentactionsdependingonthecircumstances.Let’shavealookathowinstructionsworkinsideacomputer,bytakingsomeexampleinstructionsandseeinghowthecomputerusesthem.

ThediagramdepictsseveralbytesofcomputermemorythatcontainCPUinstructions(inthelowersection)anddata(intheuppersection).

Inthelowersectionofmemorydepicted,thenumericalvaluesoftheCPUinstructionsaredisplayedinbluetext.AlongsidethenumericalvalueisamnemonicrepresentationoftheCPUinstructionsinsemi-readabletext.

Startingwiththelowestmemorylocation(atthebottomofthediagram)andreadingupwards,theCPUinstructionstelltheCPUtoperformthefollowingactions:

read[8000]

Readthevaluefromaddress8000intotheCPU.

sub100

Subtract100fromthevalueintheCPU(theresultofthesubtractionreplacesthevaluejustreadintotheCPU).

cmp121

ComparethecurrentvalueintheCPUto121.

jne+8

IftheCPUvalueisnotequal(jnestandsforJumpNotEqual),jumpforwardby8bytesfromthecurrentinstruction(toaddress2020)andcontinuebyexecutingtheinstructioncontainedatthatmemorylocation.

IftheCPUvalueisequalto121,thentheCPUwouldnotjump,anditwouldcontinuetoreaditsinstructionsfromthenextsequentialmemorylocation,whichis2016inthisexample.

jmp[2038]

Jumptoaddress2038andcontinuebyexecutingtheinstructioncontainedatthatmemorylocation.

write[8842]

WritethevalueintheCPUtomemorylocation8842.

Phew!

Ittakesquitealeapofimaginationtoseehowallthisnumberprocessingcouldenableacomputertoperformalltheactionsthatweusefromdaytoday,likewordprocessingorbrowsingtheInternet.Hangon–you’rethroughthemostcomplicatedpart,butyoustillneedabitmoreinformationtohelpyoumaketheleap.

Challenge:

Asaquickchallenge,seeifyoucanworkoutwhatwillhappenintheexampleabove.Assumingthatthevalueatmemorylocation8000containsthevalue221,workthroughtheCPUinstructionsandanswerthefollowingquestions:

∙Whatvaluegetswrittentomemorylocation8842?

∙Whatvaluegetswrittentomemorylocation8878?

Youcanfindtheanswersattheendofthisarticle.

InputandOutputDevices

Ifacomputersimplyprocessedinstructionsinmemory,itwouldnotserveanyusefulpurpose.Inordertobeuseful,thecomputerneedstoprovideawaytoenabletheusertoindicatewhatcalculationstoperform,andtodisplaytheresultsofitscalculations–tointeractwiththecomputer.

Interactionwithacomputertakesplacethroughcomponentscalledinput/outputdevices.Forexample,akeyboardisaninputdevice,becausethecomputercanreadfromthekeyboardtoseewhenakeyispressed.Fromthecomputer’sperspective,thekeypressisinformationthatiscomingin.Conversely,amonitorisanoutputdevice,becausethecomputersendsinformationouttothedisplayasaresultofitscalculations.

Youmaywonderhowthecomputercaninteractwiththesedevices,whenallitdoesiscopybytesfromoneplacetoanotherplace.Theansweristhatalltheinputandoutputinformationcanberepresentedasbytes.Forexample,eachkeyonthekeyboardhasitsownnumericvaluesothecomputercanidentifythekeyandstorethenumberinamemorylocation.

Lessobviously,theinformationdisplayedonyourmonitorrightnowisjustaseriesofbytestothecomputer.Eachdot(pixel)onthescreenisrepresentedbysomebytesthatindicatewhatcolortodisplayonthemonitoratthatpixel.

Infact,everythingthatacomputerdisplaysorstoresisasetofbytes,calledadigitalrepresentation–whetheritisaphoto,avideo,asong,orevenawordprocessingdocument.Ifyou’veeverseenthemovieTheMatrix,you’llrecognizetheimageofgreen0’sand1’scascadingdownablackscreen.Thisimageactuallyhassometruthtoit,sinceacomputerseesalldataasrepresentedbynumbers.Thetranslationbetweenwhatacomputerseesandwhatweseeonourmonitorsorasaprintoutisdonebytheinput/outputdevices.

Thejobofthecomputer’sinput/outputdevicesistoperformtheseconversionsbetweenth

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 求职职场 > 社交礼仪

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1