书签 分享 收藏 举报 版权申诉 / 57
上传文档赚钱

类型《单片机原理及应用》讲义课件.ppt

  • 上传人(卖家):晟晟文业
  • 文档编号:4290920
  • 上传时间:2022-11-26
  • 格式:PPT
  • 页数:57
  • 大小:471.88KB
  • 【下载声明】
    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

    23、C R0 ;(R0)(R0)+1INC DPTR ;DPTR DPTR+1 4.Increment Instructions NOT Affect PSW,except“P”flag bit.273.2.3 Arithmetic InstructionsDEC A ;A A 1 DEC Rn DEC R6DEC direct DEC 50H ;(50H)(50H)1DEC Ri DEC R1 ;(R1)(R1)1 NOT Affect PSW,except“P”flag bit.5.Decrement Instructions283.2.3 Arithmetic Instructions (1

    24、)MUL AB;A low byte of product ;B high byte of product Affect PSW:P,OV,CY=0 If the product is greater than 255(0FFH),then OV=1,else OV=0.6.Multiplication/Division Instructions(2)DIV AB ;A dividend B divisor (Before);A quotient B remainder (After)Affect PSW:If CY=0 If divisor B is 00H,then OV=1,else O

    25、V=0.293.2.3 Arithmetic Instructions DA A Affect PSW:P,AC,CY ONLY apply to decimal addition,not decimal subtraction.7.Decimal-Adjust InstructionsFor example:Assumed that:A=56H,R5=67HExecute:ADD A,R5 DA APlease fill results in the blanks:A=23H,CY=1Return303.2 Instruction Introduction Including the fol

    26、lowing 5 types:1.ANL operation Instructions2.ORL operation Instructions3.XRL operation Instructions4.CLR/CPL operation Instructions5.Rotation bits Instructions3.2.4 Logical instructions(24 items)313.2.4 Logical instructions1.ANL operation InstructionsANL A,Rn;A A Rn ANL A,direct;A A(direct)ANL A,Ri

    27、;A A(Ri)ANL A,#data;A A data ANL direct,A;direct direct AANL direct,#data;direct direct data323.2.4 Logical instructionsORL A,Rn;A A Rn ORL A,direct;A A(direct)ORL A,Ri ;A A(Ri)ORL A,#data;A A data ORL direct,A;direct direct AORL direct,#data;direct direct data2.ORL operation Instructions333.2.4 Log

    28、ical instructionsXRL A,Rn;A A Rn XRL A,direct;A A (direct)XRL A,Ri ;A A (Ri)XRL A,#data;A A data XRL direct,A;direct direct AXRL direct,#data;direct direct data3.XRL operation Instructions 0101 1100=1001(rule:different=1,same=0)343.2.4 Logical instructionsCLR A;A 0 CPL A;A A 4.CLR/CPL operation Inst

    29、ructionsRL A;An+1 An,A0 A7 RR A;An An1,A7 A0 RLC A;An+1 An,CY A7,A0 CY RRC A ;An An1,CY A0,A7 CY 5.Rotation bits Instructions Return353.2 Instruction Introduction Including the following 4 types:1.Unconditional Jump Instructions(4 items)3.2.5 Jump instructions(17 items)2.Conditional Jump Instruction

    30、s(8 items)3.Call/Return Instructions(4 items)4.No operation Instructions(1 item)Return363.2.5 Jump instructions1.Unconditional Jump Instructions Including the following 4 types:1-1 Long Jump Instructions1-2 Absolute Jump Instructions1-3 Short Jump Instructions1-4 Indexed Addressing Jump Instructions

    31、 Jump location:in the program memory.373.2.5 Jump instructions Jump Address Range:64KB (216)1-1 Long Jump InstructionsLJMP address16;PC address16 383.2.5 Jump instructions Jump Address Range:2KB (211)AJMP address11;PC PC+2 ;PC10-0 address11 1-2 Absolute Jump InstructionsFor example:2070H AJMP 16AH;P

    32、C =2070H+2=2072H;PC:2072 0010 0000 0111 0010 ;address11:16A 0000 0001 0110 1010 ;new PC=0010 0001 0110 1010=216AH393.2.5 Jump instructions rel=8-bit signed relative offset byte Jump Address Range:-128B+127B(256Byte,28)SJMP rel;PC PC+2 ;PC PC+rel1-3 Short Jump InstructionsFor example:835AH SJMP 35H;P

    33、C =835AH+2+35H=8391H 835AH SJMP 0E7H ;PC =835AH+2-19H=8343HSTOP:SJMP STOPSTOP:SJMP$403.2.5 Jump instructionsJMP A+DPTR;PC =A+DPTR1-4 Indexed Addressing Jump InstructionsReturn413.2.5 Jump instructions Including the following 3 types:2-1 Judgement A Jump Instructions2-2 Comparison Jump Instructions2-

    34、3 Decrement Jump Instructions2.Conditional Jump Instructions NOT affect PSW423.2.5 Jump instructionsJZ rel;if A 0,then PC PC+2+rel ;if A 0,then PC PC+22-1 Judgement A Jump InstructionsJNZ rel;if A 0,then PC PC+2+rel ;if A 0,then PC PC+2433.2.5 Jump instructionsCJNE A,#data,rel;if A data,then PC PC+3

    35、+rel if A data,then CY 1 if A data,then CY 02-2 Comparison Jump InstructionsCJNE A,direct,rel;if A (direct),then PC PC+3+rel if A (direct),then CY 1 if A (direct),then CY 0CJNE Rn,#data,rel ;if Rn data,then PC PC+3+rel if Rn data,then CY 1 if Rn data,then CY 0CJNE Ri,#data,rel;if(Ri)data,then PC PC+

    36、3+rel if(Ri)data,then CY 1 if(Ri)data,then CY 0443.2.5 Jump instructionsDJNZ Rn,rel ;Rn Rn-1 if Rn 0,then PC PC+2+rel if Rn 0,then PC PC+2 2-3 Decrement Jump InstructionsDJNZ direct,rel ;(direct)(direct)-1if(direct)0,then PC PC+3+relif(direct)0,then PC PC+3 Return453.2.5 Jump instructions Including

    37、the following 3 types:3-1 Absolute Call Instructions3-2 Long Call Instructions3-3 Return Instructions3.Call/Return Instructions463.2.5 Jump instructionsACALL ;PC PC+2 SP SP+1 SP PC7-0 (low 8-bit breakpoint address)SP SP+1 SP PC15-8 (high 8-bit breakpoint address)PC10-0 address11 3-1 Absolute Call In

    38、structions Subroutine Call Range:2KB (211)For example:ACALL SUBRTN_NAME1473.2.5 Jump instructionsLCALL ;PC PC+3 SP SP+1 SP PC7-0 (low 8-bit breakpoint address)SP SP+1 SP PC15-8 (high 8-bit breakpoint address)PC address16 Subroutine Call Range:64KB (216)3-2 Long Call InstructionsFor example:LCALL SUB

    39、RTN_NAME2483.2.5 Jump instructionsRET ;PC15-8 SP (Fetch high 8-bit breakpoint address)SP SP-1 PC7-0 SP (Fetch low 8-bit breakpoint address)SP SP-1 Return from Subroutine 3-3 Return InstructionsRETI ;PC15-8 SP (Fetch high 8-bit breakpoint address)SP SP-1 PC7-0 SP (Fetch low 8-bit breakpoint address)S

    40、P SP-1 Return from Interrupt Return494.No operation InstructionsNOP;PC PC+1,one machine cycle instruction3.2.5 Jump instructionsReturn503.2 Instruction Introduction Including the following 4 types instructions:1.Bit Transfer Instructions2.Bit SETB/CLR Instructions3.Bit logical operation Instructions

    41、4.Bit Jump Instructions Hardware resources of bit processor:4 items.3.2.6 Boolean instructions513.2.6 Boolean instructions1.Bit Transfer InstructionsMOV C,bit ;CY (bit)MOV bit,C ;(bit)CY For example:MOV C,20H ;CY (20H)MOV 5AH,C ;(5AH)CY 523.2.6 Boolean instructionsSETB C ;CY 1SETB bit ;(bit)1CLR C ;

    42、CY 0CLR bit ;(bit)02.Bit SETB/CLR Instructions533.2.6 Boolean instructionsANL C,bit;CY CY (bit)ANL C,/bit;CY CY (bit)ORL C,bit;CY CY (bit)ORL C,/bit;CY CY (bit)CPL C ;CY CYCPL bit ;(bit)(bit)3.Bit logical operation Instructions543.2.6 Boolean instructions4.Bit Jump InstructionsJC rel;if CY 1,then PC

    43、 PC+2+rel if CY 1,then PC PC+2JNC rel;if CY 0,then PC PC+2+rel if CY 0,then PC PC+2 JB bit,rel;if (bit)1,then PC PC+3+rel if (bit)1,then PC PC+3JNB bit,rel;if(bit)0,then PC PC+3+rel if(bit)0,then PC PC+3 JBC bit,rel;if(bit)1,then(bit)0,PC PC+3+rel if(bit)1,then PC PC+3 Return553.2 Instruction Introd

    44、uction3.2.7 Port Access instructionsOutput Instructions:MOV Pm,AMOV Pm,#dataMOV Pm,directMOV Pm.n,CInput Instructions:MOV A,PmMOV direct,PmMOV C,Pm.nOther Instructions:SETB Pm.nCLR Pm.nANL C,Pm.nORL C,Pm.nJB Pm.n,rel JBC Pm.n,rel Read-Modify-Write Instructions:Logical Instructions:ANL,ORL,XRL,etcBoolean Instructions:JBC,CPL,SETB,CLR,etcReturn56Home Work of Chapter 3 P74(一)填空题:(一)填空题:1,2,4,5,6(二)选择题:(二)选择题:1-6 (三)其他类型题:(三)其他类型题:1.全部(共全部(共23条指令)。条指令)。57

    展开阅读全文
    提示  163文库所有资源均是用户自行上传分享,仅供网友学习交流,未经上传用户书面授权,请勿作他用。
    关于本文
    本文标题:《单片机原理及应用》讲义课件.ppt
    链接地址:https://www.163wenku.com/p-4290920.html

    Copyright@ 2017-2037 Www.163WenKu.Com  网站版权所有  |  资源地图   
    IPC备案号:蜀ICP备2021032737号  | 川公网安备 51099002000191号


    侵权投诉QQ:3464097650  资料上传QQ:3464097650
       


    【声明】本站为“文档C2C交易模式”,即用户上传的文档直接卖给(下载)用户,本站只是网络空间服务平台,本站所有原创文档下载所得归上传人所有,如您发现上传作品侵犯了您的版权,请立刻联系我们并提供证据,我们将在3个工作日内予以改正。

    163文库