版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
IntroductoryMicrocontrollerTheoryandApplicationsChapter1IntroducingMicrocontrollersMicrocontrollers微控制器,单片机TypesofComputersSupercomputers超级电脑Mainframecomputers主机电脑Minicomputers小型计算机Microcomputers微型计算机Microprocessors微处理机CraySupercomputerMicrocontrollers微控制器,单片机TypesofComputersSupercomputers超级电脑Mainframecomputers主机电脑Minicomputers小型计算机Microcomputers微型计算机Microprocessors微处理机IBMMainframecomputerMicrocontrollers微控制器,单片机TypesofComputersSupercomputers超级电脑Mainframecomputers主机电脑Minicomputers小型计算机Microcomputers微型计算机Microprocessors微信息处理机PDP8minicomputerMicrocontrollers微控制器,单片机TypesofComputersSupercomputers超级电脑Mainframecomputers主机电脑Minicomputers小型计算机Microcomputers微型计算机Microprocessors微信息处理机PCmicrocomputerTypesofComputersSupercomputers超级电脑Mainframecomputers主机电脑Minicomputers小型计算机Microcomputers微型计算机Microprocessors微信息处理机IntelmicroprocessorMicrocontrollers微控制器,单片机TypesofComputersSupercomputers超级电脑Mainframecomputers主机电脑Minicomputers小型计算机Microcomputers微型计算机Microprocessors微信息处理机IntelmicrocontrollerMicrocontrollers微控制器,单片机TypesofComputersSupercomputers超级电脑Mainframecomputers主机电脑Minicomputers小型计算机Microcomputers微型计算机Microprocessors微处理机Microcontrollers微控制器,单片机Microcomputers微型计算机Microprocessors微处理机Howaremicroprocessorsused?MicroprocessorEmbeddedSystemComputer嵌入式系统COMPUTEROperatingSystem操作系统MicroprocessorMemory存储器HarddriveUSBKeyboardMousePrinterportActuator传动装置ROMSoftwareROM里的软件Display显示器MicroprocessorSensor传感器MemoryEMBEDDEDSYSTEMEmbeddedSystemsAutomation自动化FluidControl流体控制ProcessControl过程控制AirborneSystems机载系统SubmarineCommunications潜水艇通信系统Vehiclecontrol汽车控制MedicalInstrumentation
医疗器械医用呼吸机HistoryoftheMicroprocessorCombinationalLogic组合逻辑SequentialLogic时序逻辑Bidirectionalbus双向总线Memories存储器MicroprocessorInputs输入Output输出11100HistoryoftheMicroprocessorLogiccircuits逻辑电路11100HistoryoftheMicroprocessorLogiccircuits逻辑电路CombinationalLogic组合逻辑Inputs输入Output输出CKCKCKCKQQQQInputOutputsQ3Q2Q1Q0SequentialLogic顺序逻辑I/OlinesRead/Write10Bidirectionalbus双向总线Writeto…Readfrom…Memories存储器WilliamsTube(1947)CoreMemory(1950)Memories存储器Memories存储器65963795451381798424ADDRESSBUS地址总线DATABUS数据总线Read/Write110010111111Decoder译码器Memoryarrangement11100100MSBLSBDATABUSADDRESSBUSMEMORYLOCATIONS内存单元Decoder译码器11100100MSBLSBDATABUSADDRESSBUS011111100001000Decoder译码器MEMORYLOCATIONS内存单元11100100MSBLSBDATABUSADDRESSBUS011111100001000R/W1100Decoder译码器11100100MSBLSBDATABUSADDRESSBUS011111100001000R/W1011100Decoder译码器11100100MSBLSBDATABUSADDRESSBUS011111100001000R/W1011101Decoder译码器IfAddressBushasNlinesandDataBushasDlines…NumberofMemoryLocations=2NHighestaddress=2N-1ForN=2NumberofMemoryLocations=22=4Highestaddress=22–1=3IfAddressBushasNlinesandDataBushasDlines…Highestdatavalue=2D-1ForD=3Highestdatavalue=23–1=7Unsignednumbers00000000 = 001011111111 = 25510 = 27+26+25 +24+23+22 +21+20无符号数ValueFor+usedigitsdirectlyFor-useTwo’sComplementSignbit0=+1=-10110011Signednumbers带符号数Two’sComplementNumbers补码 10011011 01100100(One’scomplement) 反码 01100101(Two’scomplement) 补码Signednumbers+0000001 = 00000001-0000001 = 11111111+0000010 = 00000010-0000100 = 11111100-2552550127-128000000000111111111111111Unsigned000000000111111110000000Signed无符号数带符号数IfAddressBushasNlinesandDataBushasDlines…ForSignedNumbersHighestdatavalue =2D-1–1Lowestdatavalue =-2D-1ForD=8Highestdatavalue =27–1 =127Lowestdatavalue =-27 =-128Pleasetrythefollowing..(Pages13-14)Question1.11.7Question1.11.8Question1.11.9Question1.11.10Question1.11.7Intel8088(1979)Intel8080(1974)Question1.11.7Question1.11.8Intel8086(1976)Intel80386(1989)Intel8080(1974)Question1.11.9Question1.11.10MICROPROCESSORMemoryAddressbusDatabusR/WStorageofprograminstructionsMICROPROCESSORAddressbusDatabusR/WStorageofprograminstructions1MemoryMICROPROCESSOR微处理器DataBus数据总线AddressBus地址总线MICROPROCESSOR微处理器RAM随机存储器ROM只读存储器INTERFACES接口WhatisthedifferencebetweenaMicroprocessorandaMicrocontroller?RAM随机存储器ROM只读存储器INTERFACES接口MICROPROCESSOR微处理器MICROCONTROLLER
单片机Interrupts中断CPU中央处理器RAMTimers定时器
UART通用异步收发机ROMClockPIA外围界面Microcontroller单片机MicroprocessorsandMicrocontrollersMicroprocessorNeedsexternalcomponentsManyinstructionsDatamovementinandoutLargenumbersMicrocontrollerFewexternalcomponentsFewinstructionsInternalmovementofbitsSmallnumbers:bitsorbytes指令位字节CompanyTypeCompatibilityINTELMCS-51series系列(8051)Compatiblewith8051与8051兼容ATMELAT89X51serieswithFlashPhilips8XC552&89C66XseriesTexasMSP430LGGMS90/97seriesCygnalC8051Fhi-speedSOCMotorola68HC11seriesNot8051compatible与8051不兼容ARMARM10&ARM11seriesMicrochipPICseriesRISCdevicesPopularMicrocontrollersIntel8051MicrochipPICIntelMCS-51series8051- ContainsROM8751- ContainsEPROM8031- ContainsnomemoryFormakingverylargenumbersFormakingsmallnumbersVerycheap,needsEPROM8951- ContainsFLASHmemory
快闪存储器WhatactionscantheMicrocontrollerdo?Takeanumberfrommemory(READ)Putanumberintomemory(WRITE)36h37h35h34h33h6565READ65WRITEMemoryCPUWhatactionscantheMicrocontrollerdo?Takeanumberfrommemory(READ)Putanumberintomemory(WRITE)Arithmeticoperations(8bit)WhatactionscantheMicrocontrollerdo?Takeanumberfrommemory(READ)Putanumberintomemory(WRITE)ArithmeticoperationsLogicaloperationsWhatactionscantheMicrocontrollerdo?Takeanumberfrommemory(READ)Putanumberintomemory(WRITE)ArithmeticoperationsLogicaloperationsDecisionsaboutprogramroute36h37h35h34h33h65Memory32h31h30h2FhPrograminstructionsinmemory5109437726930227WhatactionscantheMicrocontrollerdo?Takeanumberfrommemory(READ)Putanumberintomemory(WRITE)ArithmeticoperationsLogicaloperationsDecisionsaboutprogramrouteIntroductoryMicrocontrollerTheoryandApplicationsEndofChapter1IntroductoryMicrocontrollerTheoryandApplicationsChapter2TheHardwareoftheMCS-51MicrocontrollerOscillatorInterruptCPUROMRAMTimer1Timer0I/OportsSerialExternalinterruptsCounterinputsP0P1P2P3TXDRXD8051MicrocontrollerOscillatorInterruptCPUROMRAMTimer1Timer0I/OportsSerialExternalinterruptsCounterinputsP0P1P2P3TXDRXDToholdprogram程序16-bitaddressbus8-bitdatabus数据总线8-bitaddressbus地址总线OscillatorInterruptCPUROMRAMTimer1Timer0I/OportsSerialExternalinterruptsCounterinputsP0P1P2P3TXDRXD中央处理器中断振荡器定时器串口OscillatorInterruptCPUROMRAMTimer1Timer0I/OportsSerialExternalinterruptsCounterinputsP0P1P2P3TXDRXDMOVP3,23hOscillatorInterruptCPUROMRAMTimer1Timer0I/OportsSerialExternalinterruptsCounterinputsP0P1P2P3TXDRXDMOVP3,23hMOVP3,23hOscillatorInterruptCPUROMRAMTimer1Timer0I/OportsSerialExternalinterruptsCounterinputsP0P1P2P3TXDRXDMOVP3,23hOscillatorInterruptCPUROMRAMTimer1Timer0I/OportsSerialExternalinterruptsCounterinputsP0P1P2P3TXDRXDMOVP3,23h40239133843753663573483393210311130122913281427152616251724182319222021P1.0P1.1P1.2P1.3P1.4P1.5P1.6P1.7P2.7P2.6P2.5P2.4P2.3P2.2P2.1P2.0Vcc+5vP0.0P0.1P0.2P0.3P0.4P0.5P0.6VssGNDXTAL2P3.0RXDRSTP3.1TXDP3.2INT0P3.3INT1P3.4T0P3.5T1P3.6WRP3.7RDXTAL1P0.7Vpp/EAPROG/ALEPSEN805140239133843753663573483393210311130122913281427152616251724182319222021P1.0P1.1P1.2P1.3P1.4P1.5P1.6P1.7P2.7P2.6P2.5P2.4P2.3P2.2P2.1P2.0Vcc+5vP0.0P0.1P0.2P0.3P0.4P0.5P0.6VssGNDXTAL2P3.0RXDRSTP3.1TXDP3.2INT0P3.3INT1P3.4T0P3.5T1P3.6WRP3.7RDXTAL1P0.7Vpp/EAPROG/ALEPSEN8051P1P0P2P3PinAlternateDescriptionP3.0RXDSerialportreceivepinP3.1TXDSerialporttransmitpinP3.2/INT0Interrupt0inputP3.3/INT1Interrupt1inputP3.4T0Timer/Counter0inputP3.5T1Timer/Counter1inputP3.6/WRWriteEnable(externalchips)P3.7/RDReadEnable(externalchips)Port3AlternateFunctions16-bitaddressbus8-bitaddressbusOscillatorInterruptCPUROMRAMTimer1Timer0I/OportsSerialExternalinterruptsCounterinputsP0P1P2P3TXDRXD8051MicrocontrollerOscillatorInterruptCPUROMRAMTimer1Timer0I/OportsSerialExternalinterruptsCounterinputsP0P1P2P3TXDRXD8051MicrocontrollerCPU算术逻辑运算单元ArithmeticandLogicalUnitTYPESOFMEMORYARRANGEMENTVonNeumannarrangement00010C0B0A0908070605040302TYPESOFMEMORYARRANGEMENT冯·诺依曼JohnVonNeumannVonNeumannarrangement00010C0B0A0908070605040302TYPESOFMEMORYARRANGEMENT4B44016F2326A3554745DataProgramVonNeumannarrangementHarvardarrangement00010C0B0A09080706050403A02CBDTYPESOFMEMORYARRANGEMENT哈佛大学12345VonNeumannarchitectureOneaddress=onehouseBulawayo,Zimbabwe12345123451234512345HarvardarchitectureOneaddress=manyhousesFivetypesofmemoryExternalRAMExternalROM8051InternalROMSpecialFunctionRegistersInternalRAM特殊功能寄存器00hFFh80h7FhFFFF0000Datamemory8051MemoryMap内存分配数据存储器UpperdatamemoryLowerdatamemory00hFFh80h7FhFFFF0000Datamemory8051MemoryMap内存分配SpecialFunctionRegisters特殊功能寄存器00hFFh80h7FhFFFF0000DatamemorySpecialFunctionRegistersDatamemory8051MemoryMap内存分配数据存储器00hFFh80h7FhFFFF0000DatamemorySpecialFunctionRegistersDatamemoryProgramCodememory8051MemoryMap内存分配程序存储器00hFFh80h7FhFFFF0000DatamemorySpecialFunctionRegistersDatamemoryProgramCodememory8051MemoryMap内存分配InternalExternalFivetypesofmemoryExternalRAMExternalROM8051InternalROMSpecialFunctionRegistersInternalRAMDataMemoryDataMemCodeMemoryCodeMemorySFRs0080FFFFFFFFFF0000InternalRAMInternalROMExternalROMExternalRAMHowdoesthe8051knowwhichtypeofmemory?DataMemoryDataMemCodeMemoryCodeMemorySFRs0080FFFFFFFFFF0000MOVInternalRAMInternalROMExternalROMExternalRAMDataMemoryDataMemCodeMemoryCodeMemorySFRs0080FFFFFFFFFF0000MOVInternalRAMInternalROMExternalROMExternalRAMDataMemoryDataMemCodeMemoryCodeMemorySFRs0080FFFFFFFFFF0000MOV(indirect)InternalRAMInternalROMExternalROMExternalRAMDataMemoryDataMemCodeMemoryCodeMemorySFRs0080FFFFFFFFFF0000MOVX(indirect)InternalRAMInternalROMExternalROMExternalRAMDataMemoryDataMemCodeMemoryCodeMemorySFRs0080FFFFFFFFFF0000MOVC(indirect)InternalRAMInternalROMExternalROMExternalRAMDataMemoryDataMemCodeMemoryCodeMemorySFRs0080FFFFFFFFFF0000MOVC(indirect)InternalRAMInternalROMExternalROMExternalRAMDataMemoryDataMemCodeMemoryCodeMemorySFRs0080FFFFFFFFFF0000HowdoesitknowwhichCodeMemorytouse?InternalRAMInternalROMExternalROMExternalRAM40239133843753663573483393210311130122913281427152616251724182319222021P1.0P1.1P1.2P1.3P1.4P1.5P1.6P1.7P2.7P2.6P2.5P2.4P2.3P2.2P2.1P2.0Vcc+5vP0.0P0.1P0.2P0.3P0.4P0.5P0.6VssGNDXTAL2P3.0RXDRSTP3.1TXDP3.2INT0P3.3INT1P3.4T0P3.5T1P3.6WRP3.7RDXTAL1P0.7Vpp/EAPROG/ALEPSEN8051EA=ExternalAccessIfLowthenExternalMemoryIfHighthenInternalMemory+5VDataMemoryDataMemCodeMemoryCodeMemorySFRs0080FFFFFFFFFF0000InternalRAMInternalROMExternalROMExternalRAMEA=lowEA=highPleasetrythefollowing.. Question2.10.9 Question2.10.10 Question2.10.11 Question2.10.12 Question2.10.13Question2.10.9 Whichmemoryarrangementis foundinthe8051?HarvardarrangementACBD00hFFh80h7FhDatamemorySpecialFunctionRegisters83hQuestion2.10.10Address83h-directaddressingDirectaddressingaccessestheSFRsQuestion2.10.11EA=ExternalAccessIfLowthenExternalMemoryIfHighthenInternalMemoryIfEApinisHigh(+5V)thenInternalROMisaccessed00hFFh80h7FhDatamemorySpecialFunctionRegisters83hQuestion2.10.12Address83h-indirectaddressingIndirectaddressingaccessestheupperdatamemory00hFFh80h7FhQuestion2.10.13HighestaddressinInternalDatamemory?Highestaddress=FFh =255RegisterBanksAwaytomakeprogrammingeasierGivenamestomemorylocationsinInternalRAM00RegisterBanks07080F1017181FRegisterBank0RegisterBank1RegisterBank2RegisterBank3R0R7R0R7R0R7R0R7寄存器组RegisterBank3AddressofR6?RegisterBank0AddressofR4?WhatisaStack?TheStack堆栈inthe8051RatherlikeastackofplatesLIFOLastInFirstOutCoreMemoryStack19501.Datastorage数据存储2.Temporarystorageinaprogram暂存3.Returnaddressesforsubroutines 子程序返回地址4.Savingstatusinformation状态信息5.Interruptreturnaddresses 中断返回地址What’stheStackusedfor?BaseEndGrowingupwards基地址AddnewitemsontopBaseEndGrowingupwardsTheStackisinInternalRAM易失性存储器WhereistheStack?00hFFh80h7FhFFFF0000DatamemorySpecialFunctionRegistersDatamemoryProgramCodememory8051MemoryMap内存分配TheStackisinInternalRAM易失性存储器StackPointer栈指针StackPointer(8-bit)containstheaddressofthelastitemonthestackSTACKStackPointerStackPointerWhenthe8051isRESET–SPissetto07h07h1110000008h09h0Ah06h05h04h03hBaseDatamemorySpecialFunctionRegistersDatamemoryProgramCodememoryTheStackPointerisaSpecialFunctionRegister
WhereistheStackPointer?PUSH36hStackPointer36h37h35hXXXXPOP37hStackPointer36h37h35hXXXXBit 位Byte 字节 Bit-addressableRAM 位可寻址存储器Byte-addressableRAM 字节可寻址存储器
1101001110F00101F202F30RegisterBanksBit-addressableareaInternalDataRAMBit-addressableRAMByteBitaddressesaddBit7Bit6Bit5Bit4Bit3Bit2Bit1Bit02F2F.72F.62F.52F.42F.32F.22F.12F.02E2E.72E.62E.52E.42E.32E.22E.12E.02222.722.622.522.422.322.222.122.02121.721.621.521.421.321.221.121.02020.720.620.520.420.320.220.120.0ByteBitaddressesaddBit7Bit6Bit5Bit4Bit3Bit2Bit1Bit02F7F7E7D7C7B7A79782E7776757473727170221716151413121110210F0E0D0COB0A09082007060504030201002F.7h=7Fh20.0h=00hHowdoweknowifthenumberisabitorbyteaddress?…bythetypeofinstructionINC7Fh {Increment}SETB7Fh {Setbit}ByteBitPleasetrythefollowing..(Page28)Question2.10.14Question2.10.15Question2.10.16Question2.10.17Question2.10.18Question2.10.19Question2.10.14ForRegisterBank3whatisaddressofR4?Question2.10.15WhatishighestaddressinBank1?ForBank3,R0isat18h.ThereforeR4isat1Ch.07080F1017181F0123R0R7R0R7ForBank1,R0isat08h.ThereforeR7isat0Fh.Question2.10.16Whichbytehasbit-address7Ah?Question2.10.17Whatisbit-addressof27h.6?Question2.10.18Bit-addressofbit2inbyte21h?Question2.10.19StackpointerafteraPOPoperation?Bit-address=3EhByteis2FhBit-address=0AhDecrementedClockOscillator晶振VssGNDXTAL2XTAL1805130pF30pFExternalCrystal11.0592MHzVssGNDXTAL2XTAL18051ExternalClockSignalExternalclockClockOscillator晶振40239133843753663573483393210311130122913281427152616251724182319222021P1.0P1.1P1.2P1.3P1.4P1.5P1.6P1.7P2.7P2.6P2.5P2.4P2.3P2.2P2.1P2.0Vcc+5vP0.0P0.1P0.2P0.3P0.4P0.5P0.6VssGNDXTAL2P3.0RXDRSTP3.1TXDP3.2INT0P3.3INT1P3.4T0P3.5T1P3.6WRP3.7RDXTAL1P0.7Vpp/EAPROG/ALEPSEN80518051RESETOperationThemeaningof“Cycles”ClockcycleMachinecycleClockfrequency=Oscillatorfrequency=Crystalfrequency时钟周期机器周期ForExample:WhentheCrystalFrequency=12MHZthen….8051RESETOperationVssGND+5VRESET8051Resetswitch5VToResetthe8051:-MakeRESETpinHigh(>2.5V)formorethan 2machinecycles2.MakeRESETpinLow(<2.5V)Whenbelow2.5V,microcontrollerwillresetVssGND+5VRESET0123451234567cyclesVReset8051resetsSwitchclosed8051RESETOperationVssGND+5VRESET8051Resetswitch5VPowerswitchVssGND+5VRESET0123451234567cyclesVReset8051resetsWhatdoesRESETdo?
Startstheprogramrunningat address0000h00hFFFF0000ProgramCodememory8051MemoryMap内存分配InternalExternal8051runsprogramfrom0000hWhatdoesRESETdo?
Startstheprogramrunningat address0000hPutsinitial初始值valuesin theSpecialFunctionRegisters (SFRs)WhatdoesRESETdo?SFRnameValueSFRnameValueA(ACC)00PSW00B00SBUF00DPTR00SCON00IE00SP07hIP00TCON00P0FFhTH000P1FFhTL000P2FFhTH100P3FFhTL100PCON00TMOD00ParallelInput/OutputPortsI/OportsP0P1P2P340239133843753663573483393210311130122913281427152616251724182319222021P1.0P1.1P1.2P1.3P1.4P1.5P1.6P1.7P2.7P2.6P2.5P2.4P2.3P2.2P2.1P2.0Vcc+5vP0.0P0.1P0.2P0.3P0.4P0.5P0.6VssGNDXTAL2P3.0RXDRSTP3.1TXDP3.2INT0P3.3INT1P3.4T0P3.5T1P3.6WRP3.7RDXTAL1P0.7Vpp/EAPROG/ALEPSEN8051P1P0P2P3ReferenceasBITSReferenceasBYTESAlternate切换功能functionpinsSimplifiedPortCircuit接口电路P1.0+5VDataWriteenableDQReadenableToCPUSimplifiedPortCircuit(Write)P1.0+5VDQCK0TurnonCLRP1.0DataWriteenableReadenable010SimplifiedPortCircuit(Write)P1.0+5VDQCK1TurnoffSETBP1.0DataWriteenableReadenable011SimplifiedPortCircuitP1.0+5VDataWriteenableDQReadenableSink2mA0SimplifiedPortCircuitP1.0+5VDataWriteenableDQReadenableSource60mA1SimplifiedPortCircuitP1.0+5VDataWriteenableDQReadenableSink2mASource60mA灌电流拉电流LowZHighZPortCurrentCapability8051P1.48051P1.4LEDLEDGND+5V60mA2mASETBP1.4CLRP1.410SimplifiedPortCircuit(Read)P1.0+5VDQCKTurnoffDataWriteenableReadenable10SETBP1.0MOVC,P1.011READINGPORTSPutportinhi-Zstate(byoutputting1s)2.Copydatafromport40239133843753663573483393210311130122913281427152616251724182319222021P1.0P1.1P1.2P1.3P1.4P1.5P1.6P1.7P2.7P2.6P2.5P2.4P2.3P2.2P2.1P2.0Vcc+5vP0.0P0.1P0.2P0.3P0.4P0.5P0.6VssGNDXTAL2P3.0RXDRSTP3.1TXDP3.2INT0P3.3INT1P3.4T0P3.5T1P3.6WRP3.7RDXTAL1P0.7Vpp/EAPROG/ALEPSEN8051P1P0P2P3Alternate切换功能functionpinsPowerConsiderationsNMOStransistor晶体管CMOStransistorPowerConsiderationsHighcurrentLowcurrentPowerModesDeviceconditionFrequencyPowersupplycurrentOperatingmode12MHz16MHz10.2mA12.6mAIdlemode12MHz16MHz3.9mA5.1mAPower-downmode50mAPowerModesDeviceconditionFrequencyPowersupplycurrentOperatingmode12MHz16MHz10.2mA12.6mAIdlemode空闲方式12MHz16MHz3.9mA5.1mAPower-downmode50mACPUturnedoffPowerModesDeviceconditionFrequencyPowersupplycurrentOperatingmode12MHz16MHz10.2mA12.6mAIdlemode空闲方式12MHz16MHz3.9mA5.1mAPower-downmode掉电方式50mAOnlymemoryonMinimalMicrocontrollerSystemMinimalMicrocontrollerSystem12LEDs发光二及管4Photocells光电阻16Resistors电阻Pleasetrythefollowing..(Page28)Question2.10.20Question2.10.22Question2.10.24Question2.10.27Question2.10.20Capacitorvaluesforexternalcrystal?Question2.10.22RSTvoltagetocausereset?Question2.10.24DatainAafterreset?Question2.10.27InactivecomponentsinIdlemode?Two30pFcapacitorsAcontains00hCPUHighfor2machinecycles,then<2.5VIntroductoryMicrocontrollerTheoryandApplicationsEndofChapter2IntroductoryMicrocontrollerTheoryandApplicationsChapter3TheMCS-51InstructionSetandSpecialFunctionRegistersLANGUAGESFORTHE8051HighLevellanguages:- C51,SDCC,SmallC,PL/M-51Assemblylanguage:- ASM51高级语言编译语言Edit(Write)AssembleRun汇编SourceCodeObjectCode源码目标码Edit(Write)AssembleRunSourceCodeObjectCodeReadablebypeopleReadableby8051MOVA,25hPOPAINCAADDA,45h100101011001100111001011SourceCodeObjectCodeMOVA,25hE525MOV4Bh,26h854B26INCA04SETB20h.3D203AssemblyLanguageProgramFormatLABEL OPCODE
OPERANDCOMMENTBEGIN: MOV A,#34h;loadaccumulator
MOV 0C6h,A标号操作码操作数注释
SJMP BEGIN
Base SymbolDecimal noneBinary bHexadecimal hNumberFormats十进制二进制十六进制00000011b = 310 = 03h00100000b = 3210 = 20h1610 = 10h =00010000b30h = 4810 =00110000b11111111b = FFh = 2551043h=01000011bInaprogram,ahexnumbercannotbeginwithaletter F0h 0F0h E4h 0E4h C7h 0C7h
FFh 0FFhADDRESSINGMODES寻址方式
00010C0B0A0908070605040302ImmediateAddressingMOV07h,#3Fh3F3F
立即Numberneedsa#(hash井)00010C0B0A0908070605040302DirectAddressingMOV09h,02h直接
FFFFNo#meansanaddressR0R70F1017181FRegisterBank0RegisterAddressingMOVA,R6AccumulatorA寄存器5A5AHouseNo12DirectIndirect间接007HouseNo15HouseNo12R0R10C0B0A0908R7R6R5R4R3R2IndirectAddressingMOV@R1,#6Eh0A6E6EIndirectaddressingcanuseR0,R1orDPTRasindirectionregister.@=at16-bitAddressingModesImmediateDirectRegisterIndirect34hR5R0AAAAR0R10C0B0A0908R7R6R5R4R3R2InherentAddressingCLR AINC ADEC AInstructionswhichdonotmakeuseofmemoryornumbersAccumulatorAddressingRegisterARegisterAcanhavetwodifferentaddressingmodesAccumulatorAddressing8-bitbusesAccumulatoraddressingADirectaddressingACCPUSHACC {Directaddressing}POPACC {Directaddressing}INCA {Accumulatoraddressing}INCACC {Directaddressing}MOV23h,ACC {Directaddressing}MOV23h,A {Accumulatoraddress}AddressingAArethesethesame?MOV23h,ACCRAMAddressingADirectaddressingMOV23h,ACCAddressingARAMDirectaddressingRAMMOV23h,ACCAddressingADirectaddressingRAMMOV23h,ACCAddressingADirectaddressingRAMMOV23h,AAddressingAAccumulatoraddressingRAMMOV23h,AAddressingAAccumulatoraddressingMOV23h,ACC 24clockcycles
MOV23h,A 12clockcycles
时钟周期BitAddressingSomeinstructionsrefertobitsSETB28.5h {Set28.5h}SETB45h {Set28.5h}CLRP0.3 {ClearP0pin3}CPL5Eh {Complementbit5Eh}Whichlocationscanbebit-addressed?BitAddressingSomeinstructionsrefertobitsInternalRAM20h-2FhAccumulatorACCRegisterBI/OPortsMostSFRs
Whichlocationscanbebit-addressed? CLRACC.40AccumulatorABitAddressing CLR P0.30AccumulatorAClearPin3ofPort0 CLRACC.4BitAddressingBitAddressing20212C2B2A29282726252423222D2E2F CLR 24.6h00 CLR P0.3AccumulatorAClearPin3ofPort0 CLRACC.4THEMCS-51INSTRUCTIONSETFulldetailsinAppendixA(Page236)AppendixAInstruction DescriptionBytesClock cyclesADD A,direct A+(direct)->A 2 12ADD A,@Ri
A+(Ri)->A 1 12INC A A+1->A 1 12INC DPTR DPTR+1->DPTR 1 24addr11 =11-bitaddressaddr16 =16-bitaddressdirect =8-bitaddressofinternalRAMorSFRRn =DataintheregistersR0toR7@Ri =IndirectaddressusingR0orR1[]: =IFconditionin[]isTRUEthenaction() =Dataattheaddressin()rel =OffsettobeaddedtocreatetheaddressTHEMCS-51INSTRUCTIONSETDataMovementInstructionsDataMovementInstructionsMOVA,#34hMOVA,47hMOVA,R3MOVA,@R034hFFhFFh34h5Fh5FhC6hC6h47hR0R3ACCA累加器Direct直接寻址@Ri间接寻址Rn寄存器#data立即数PossibleDataTransferInstructionsMOV,AACCA累加器Direct直接寻址@Ri间接寻址Rn寄存器#data立即数PossibleDataTransferInstructionsMOV,DPTR16-bit16-bitNowtrythefollowing..Question3.5.1Question3.5.5Question3.5.7Question3.5.8Question3.5.9Page47-!!!!Question3.5.1Number5toR5,8toR7MOV R5,#05hMOV R7,#08hQuestion3.5.5Write55htoPort1MOV P1,#55hQuestion3.5.7CopyfromA9hto36hAddressingmodes:36h=Direct,A9h=IndirectUseR0asindirectregisterPage20Table2.2DataMemoryDataMemCodeMemoryCodeMemorySFRs0080FFFFFFFFFF0000IndirectInternalRAMInternalROMExternalROMExternalRAMDirectMOV R0,#0A9hMOV 36h,@R0Question3.5.1Number5toR5,8toR7MOV R5,#05hMOV R7,#08hQuestion3.5.5Write55htoPort1MOV P1,#55hQuestion3.5.7CopyfromA9hto36hAddressingmodes:36h=Direct,A9h=IndirectUseR0asindirectregisterPage20Table2.2Question3.5.8
MovefromaddressinR0to48hMOV 48h,@R0MOV R6,@R1Question3.5.9
MovefromaddressinR1toR6ACCA累加器Direct直接寻址@Ri间接寻址Rn寄存器#data立即数PossibleDataTransferInstructionsQuestion3.5.8
MovefromaddressinR0to48hMOV 48h,@R0MOV R6,@R1Question3.5.9
MovefromaddressinR1toR6MOV A,@R1MOVR6,ADataMovementInstructionsMOVCA,@A+DPTRProgramCodememoryAC656h00hDPTR=C656h56h56hDataMovementInstructionsMOVXA,@DPTRDatamemoryAMOVX@DPTR,AC656h56h56hDPTR=C656hPOP37hStackPointer36h37h35hXXXXDataMovementInstructionsPUSH36hStackPointer36h37h35hXXXXDataMovementInstructionsDataMovementInstructionsXCHA,67h(Exchange)67h66h65h68h10011100A11110000MOVR7,AMOVA,67hMOV67h,R748cyclesDataMovementInstructionsXCHDA,@R
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2027年湖北省道德与法治中考考前冲刺卷(含答案)
- 超越自我 2026年秋季七年级生物人教版第六单元单元测试卷(含答案)
- 2027年中考四川省语文九年级人教版基础过关卷(含答案)
- 2027年吉林省语文初三考前最后一卷(含答案)
- 查漏补缺 2026年秋季初三语文部编版上学期期中测试卷(含答案)
- 2027年安徽省历史中考押题预测卷(含答案)
- 决胜中考 2027年中考天津市英语中考人教版高分冲刺模拟卷(含答案)
- 2027年上海市道德与法治初三预测模拟卷(含答案)
- 四川事业编社会工作岗 面试专项练习试卷 含答案解析
- 湖南事业编财会岗 2026 面试专项练习试卷
- 2026年部编版新教材道德与法治八年级上册全套单元、期中、期末检测题及答案(共6套)
- GB 20815-2026视频安防监控数字录像设备
- 食品检验检测机构授权签字人考核通关指南
- 安徽省县中联盟大联考2025-2026学年高二年级上册10月月考物理试题(原卷版)
- 2026年养老管理师考试试题及答案详解
- 2026年上海市浦东新区高三二模英语试题(含答案)
- 产程中产妇情绪管理及心理护理要点
- 幼儿园家长数字素养对家园共育质量影响研究-基于2023年素养测评与共育质量评估
- 楼盘招商活动策划方案
- 20S515 钢筋混凝土及砖砌排水检查井
- 《老人与海》:硬汉精神与生命哲思
评论
0/150
提交评论