《单片机原理及应用》讲义课件.ppt
- 【下载声明】
1. 本站全部试题类文档,若标题没写含答案,则无答案;标题注明含答案的文档,主观题也可能无答案。请谨慎下单,一旦售出,不予退换。
2. 本站全部PPT文档均不含视频和音频,PPT中出现的音频或视频标识(或文字)仅表示流程,实际无音频或视频文件。请谨慎下单,一旦售出,不予退换。
3. 本页资料《《单片机原理及应用》讲义课件.ppt》由用户(晟晟文业)主动上传,其收益全归该用户。163文库仅提供信息存储空间,仅对该用户上传内容的表现方式做保护处理,对上传内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知163文库(点击联系客服),我们立即给予删除!
4. 请根据预览情况,自愿下载本文。本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
5. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007及以上版本和PDF阅读器,压缩文件请下载最新的WinRAR软件解压。
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 单片机原理及应用 单片机 原理 应用 讲义 课件
- 资源描述:
-
1、Chapter 3:Instruction systemMicrocontroller Principle and Application主讲教师:黄英主讲教师:黄英1Contents:3.1 Instruction format and Addressing Modes 3.2 Instruction Introduction Chapter 3 Instruction system2 Assemble Language:symbolic language Assembler:A computer program used to assemble Source Program Assembl
2、er Object program (Source codes)(Machine codes)Instruction Set:can not transplant directlyChapter 3 Instruction system3.1 Instruction format and Addressing Modes33.1 Instruction format and Addressing Modes3.1.1 Instruction format Instruction=opcode operand =opcode destination operand,source operand
3、Instruction types:1-byte Instruction:includes opcode and operand 2-byte Instruction:1th byte is opcode 2th byte is operand 3-byte Instruction:1th byte is opcode 2th,3th byte are operands43.1 Instruction format and Addressing Modes Addressing:how to get the location of (source)operand.Addressing Mode
4、s:7 types 1.Register Addressing 2.Direct Addressing 3.Register Indirect Addressing 4.Immediate Constants Addressing 5.Indexed Addressing 6.Boolean Addressing 3.1.2 Addressing Modes 7.Relative Addressing (get the jumping destination address of PC)53.1.2 Addressing Modes1.Register Addressing Operand:d
5、enoted by register.For example:MOV A,R0 Addressing Range:General register:4 banks 8(R0 R7)32 registers Some SFRs:A,AB,DPTR,etc.63.1.2 Addressing Modes Operand:denoted directly by 8-bit address.For example:MOV A,3AH Addressing Range:Lower 128 bytes of internal RAM SFRs2.Direct Addressing73.1.2 Addres
6、sing Modes Operand:specifies a register to contain operand address with the prefix“”.Addressing Range:Lower 128 bytes of internal RAM (8-bit address)64KB of external RAM(16-bit address)3.Register Indirect Addressing address register of 8-bit address:Ri(i=0,1)SP(PUSH,POP)address register of 16-bit ad
7、dress:DPTR For example:MOV A,R0 MOVX A,DPTR83.1.2 Addressing Modes Operand:specifies the value of a 8-bit or 16-bit constant with the prefix“#”.For example:MOV A,#3AH MOV DPTR,#0200H4.Immediate Constants Addressing93.1.2 Addressing Modes Only three instruction:MOVC A,A+DPTR MOVC A,A+PCJMP A+DPTR Add
8、ressing Range:Program Memory(ROM)5.Indexed Addressing Program Memory can only be accessed via this mode.Designed for reading look-up tables in Program Memory or executing unconditional jumps.A 16-bit base register(DPTR or PC)points to the base address of table,and A is set up with the table entry nu
9、mber.The 16-bit address in ROM is formed by adding the A data to the base pointer.103.1.2 Addressing Modes Addressing Range:1.Bit addressable area in Internal RAM cell address:20H2FH,bit address:00H7FH 2 ways to specifies the addressing bit:Cell address+bit:20H.6 Bit address:06H 6.Boolean Addressing
10、2.Addressable bit in SFRs 4 ways to specifies the addressing bit SFR symbol+bit:PSW.5 Bit address:0D5H Cell address+bit:0D0H.5 Bit name:F0113.1.2 Addressing Modes offset Range:-128(backward)+127(forward)7.Relative Addressing Used for getting the jumping destination address of PC in Jump Instruction.
11、Destination address=PC+rel PC=(address+byte number)of Jump instruction rel=8-bit relative offset byteReturn12Chapter 3 Instruction system3.2 Instruction Introduction (111 items)Data transfer instructions(29 items)Arithmetic instructions(24 items)Logical instructions(24 items)Jump instructions(17 ite
12、ms)Boolean instructions(17 items)Port Access instructions The symbol meaning of Instruction formatReturn133.2 Instruction Introduction3.2.1 The symbol meaning of Instruction formatReturn See P45143.2 Instruction Introduction General format:MOV ,Source operand:A,Rn,Direct address,Indirect address reg
13、ister,#data,#data16 Destination operand:A,Rn,Direct address,Indirect address register 3.2.2 Data transfer instructions(29 items)15 8-bit data:MOV A,#data MOV A,00H MOV direct,#dataMOV 3CH,0FFH MOV Rn,#dataMOV R5,0FH MOV Ri,#dataMOV R1,0CH 16-bit data:MOV DPTR,#data16 MOV DPTR,0200H3.2.2 Data transfe
14、r instructions1.Data Transfer of internal RAM(1)Transfer immediate Constants16 MOV direct2,direct1 MOV 50H,30H MOV direct,RnMOV 32H,R1 MOV Rn,directMOV R0,33H MOV Ri,directMOV R1,0D0H MOV direct,Ri MOV 0D0H,R1 3.2.2 Data transfer instructions(2)Transfer data among internal RAM cells17 MOV A,Rn MOV A
15、,R3 MOV Rn,AMOV R2,A MOV A,directMOV A,0E0H MOV direct,A MOV 30H,A MOV A,Ri MOV A,R0 MOV Ri,AMOV R1,A 3.2.2 Data transfer instructions(3)Transfer data by A18(1)Transfer data by DPTR MOVX A,DPTR MOVX DPTR,A(2)Transfer data by Ri MOVX A,Ri MOVX Ri,A They are Read/Write instructions of external RAM.3.2
16、.2 Data transfer instructions2.Data Transfer of external RAM19 MOVC A,A+DPTR MOVC A,A+PC Read instructions of program memory.Indexed addressing mode Designed for reading look-up tables in Program Memory3.2.2 Data transfer instructions For example:PC A 2000 HBA:INC A ;2001 01H 2001 MOVC A,A+PC;2002 3
17、0H 2002 RET;2003 2003 DB 30H 2004 DB 31H 2005 DB 32H 3.Data Transfer of Program Memory20 XCH A,Rn XCH A,direct XCH A,Ri XCHD A,Ri ;(A3A0)(Ri3Ri0)SWAP A ;(A3A0)(A7A4)3.2.2 Data transfer instructions4.Data Exchange Instruction For example:MOV R0,#20H;R0=20H MOV A,#3FH;A=3FH MOV 20H,#75H;(20H)=75H XCHD
18、 A,R0;A=35H,(20H)=7FH SWAP A ;A=53H 21 PUSH direct ;SP SP+1,(SP)(direct)POP direct;(direct)(SP),SP SP-1 3.2.2 Data transfer instructions5.Stack operation InstructionReturn223.2 Instruction Introduction For unsigned constants Including the following 7 types:3.2.3 Arithmetic Instructions(24 items)1.Ad
19、dition Instructions2.Addition Instructions with carry bit3.Subtraction Instructions with carry bit4.Increment Instructions5.Decrement Instructions6.Multiplication/Division Instructions 7.Decimal-Adjust Instructions233.2.3 Arithmetic InstructionsADD A,RnADD A,R6ADD A,directADD A,30HADD A,RiADD A,R1 ;
20、A A+(R1)ADD A,#dataADD A,#0FH1.Addition Instructions Affect PSW If bit 3 has carry bit,then AC=1,else AC=0.If bit 7 has carry bit,then CY=1,else CY=0.If bit 6 has carry bit but not bit 7,or If bit 7 has carry bit but not bit 6,then OV=1,else OV=0.243.2.3 Arithmetic InstructionsADDC A,RnADDC A,R6 ;A
21、A+R6+CY ADDC A,directADDC A,30HADDC A,RiADDC A,R1 ;A A+(R1)+CY ADDC A,#dataADDC A,#0FH2.Addition Instructions with carry bit253.2.3 Arithmetic InstructionsSUBB A,Rn SUBB A,R6 ;A A R6 CY SUBB A,direct SUBB A,30HSUBB A,Ri SUBB A,R1 ;A A (R1)CY SUBB A,#data SUBB A,#0FH3.Subtraction Instructions with ca
22、rry bit Affect PSW If bit 3 has carry bit,then AC=1,else AC=0.If bit 7 has carry bit,then CY=1,else CY=0.If bit 6 has carry bit but not bit 7,or If bit 7 has carry bit but not bit 6,then OV=1,else OV=0.263.2.3 Arithmetic InstructionsINC A ;A A+1 INC Rn INC R6INC direct INC 50H ;(50H)(50H)+1INC Ri IN
展开阅读全文