80X86-Instructions-Advanced-Microcomputer-Systems80x86指令-先进的微机系统课件_第1页
80X86-Instructions-Advanced-Microcomputer-Systems80x86指令-先进的微机系统课件_第2页
80X86-Instructions-Advanced-Microcomputer-Systems80x86指令-先进的微机系统课件_第3页
80X86-Instructions-Advanced-Microcomputer-Systems80x86指令-先进的微机系统课件_第4页
80X86-Instructions-Advanced-Microcomputer-Systems80x86指令-先进的微机系统课件_第5页
已阅读5页,还剩62页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、MC68HC11 Instruction SetMC68HC11 Instruction SetOverview68HC11 instruction setA quick look at the programming procedureThe programmers modelInstruction types and formatsAddressing modesA tour of the instruction setReadings for instruction set:Spasov, Chap. 2 and Appendix AHC11 Reference Manual, Appe

2、ndix AHC11 Programming Reference GuideOverview68HC11 instruction setSEGMENT codeLooking ahead at the programming procedure:Soon youll write programs in assembly language for the HC11Heres a super simple example program:; Super simple test program ORG $B600TLOOP:INCAINCB JMP TLOOPBefore the HC11 can

3、run this program,The assembly-language code needs to be converted to machine language, and the machine-language code needs to be transferred to the HC11s memoryCont.SEGMENT codeLooking ahead at tLooking ahead at the programming procedure:Here is the machine code that results from the assembly-lang.

4、program given aboveAddressContents $B60001001100$B601 01011100$B602 01111110$B603 10110110$B604 00000000Cont.Looking ahead at the programmiLooking ahead at the programming procedure:Looking ahead at the programmiPutting it all togetherCont.try1.asm is a source fileIt is created by you, the programme

5、r, using a text editor on your PCFormat: HC11 assembly language (ASCII text)try1.lst is a listing fileIt is created by AS11.exe, the assembler/linker that runs on your PC(Youll probably run AS11.exe from DevHC11.exe)Its purpose of the file is to help you debug the program Format: ASCII textPutting i

6、t all togetherCont.trPutting it all togethertry1.s19 is an object fileIt is created by AS11.exe, the assembler/linkerIts purpose is to specify what bytes should be downloaded to the HC11, and to what locations in HC11 memoryFormat: Motorola S-record (ASCII text)Sometimes this is called a hex fileThe

7、 object file is converted to executable machine codeThe machine code is created by DevHC11.exe, the development environment that runs on your PCCont.Putting it all togethertry1.s1Putting it all togetherIts purpose is to provide instructions and data to the HC11 Format: HC11 machine language (binary)

8、Sometimes this is called the binary codeThe machine code is transferred to the HC11 through the coordinated efforts of DevHC11.exe (running on your PC) and the Buffalo monitor program (running on the HC11)Putting it all togetherIts purProgrammers ModelWhat features of the processor are most importan

9、t to the assembly-language programmer?Register setMemory organizationInstruction setAddressing modesHere is the register set (again):Cont.Programmers ModelWhat featureProgrammers ModelCont.AccumulatorsA: 8-bit general purpose accumulatorB: 8-bit general purpose accumulatorD: Double accumulator (conc

10、atenation of A and B for 16-bit operations)Most operations can be done using either accumulator A or BIndex registersX: 16-bit index registerY: 16-bit index register X and Y are used for indexed addressingX is preferred, usually, because addressing with Y is slower and takes 1 extra byte of object c

11、ode than with XProgrammers ModelCont.AccumulProgrammers ModelOperations on index registers:Simple operations (INC, DEC, and ADD from B) can be performed More complex operations are done by exchanging the index register and the D register, doing some computation, and then exchanging the values again

12、X or Y is often loaded with the base address of the I/O register address space ($1000)Cont.Programmers ModelOperations oProgrammers ModelSP: 16-bit stack pointer Stack may be anywhere in the 64 Kbyte address space The stack grows downward in memory (i.e., a push decrements SP)Cont.Programmers ModelS

13、P: 16-bit sProgrammers Model ContPC: 16-bit Program CounterCCR: -bit Condition Code RegisterH, N, Z, V, C: rithmetic status bitsN: Negative resultZ: Zero resultV: Overflow resultC: Carry out from operationH: Carry from low nibble (4 bits) of accumulatorS: Stop bit disabled =1 disables STOP instructi

14、on=1 after processor resetProgrammers Model ContPC: 16Programmers ModelI: Interrupt mask=1 masks all maskable interrupts (not XIRQ) =1 after processor reset X: XIRQ interrupt mask=1 masks XIRQ=1 after processor reset (must be cleared just after reset)Programmers ModelI: InterruptOverview of the 68HC

15、11 instruction setThe instruction set specifies the kinds of data transfers and transformations that can occur in the machineInstructions can be grouped into 5 broad categoriesData transfers: instructions that move data to and between registersLogical: instructions that perform logic operations on d

16、ata -AND, OR, etc.Arithmetic: addition, subtraction, increment, etc.Flow control: instructions that change the sequence of execution of a program -conditional and unconditional branches, stack operations, etc.Input / Output operationsCont.Overview of the 68HC11 instrucOverview of the 68HC11 instruct

17、ion setAn instruction generally consists of an opcode and some operand(s)HC11 instructions are of different lengths (1 to 5 bytes)The instruction set is summarized in Table A.1 of the text, Appendix A of the HC11 Reference Manual, and M68HC11 E Series Programming Reference Guide Lists instruction mn

18、emonic, brief description of the operation, addressing modes available, machine code format of the instruction, timing information, and effect on condition code registersCont.Overview of the 68HC11 instrucOverview of the 68HC11 instruction setCont.Overview of the 68HC11 instrucOverview of the 68HC11

19、 instruction setOpcode constructionIn general, an n-bit opcode is capable of specifying any one of 2n instructions With 8-bit opcodes, 256 distinct instructions are possible68HC11 has more than 300 actual instructions145 basic instructions plus “addressing variations”1 or 2 bytes of storage specify

20、the opcode!1-byte opcodesMost opcodes use just 1 byteDownward compatible with 6801Cont.Overview of the 68HC11 instrucOverview of the 68HC11 instruction set2-byte opcodesMost 2-byte instructions deal with register Y, which was not present in the 6801 processor It takes longer to fetch and execute 2-b

21、yte opcodesNew instructions use a pre-byte, which signals that another opcode byte follows:$18, $1A, or $CDEx.INX $08 INY $18 $08Cont.Overview of the 68HC11 instrucOverview of the 68HC11 instruction setInstruction formatAn instruction is made up of an opcode and a set of operandsOpcode may be one or

22、 two bytesInstructions may use 0, 1, 2, or 3 operandsOperands may be 1 or 2 bytesInstruction lengths range from 1 to 5 bytes Example (assume this is stored at address $E000): LDAA #$FF; load ACCA with the ; Value $FFMachine code: $E000 $86$E001 $FFCont.Overview of the 68HC11 instrucOverview of the 6

23、8HC11 instruction setFetch/Execute operation:LDAA #$FFFirst clock cycleCont.Overview of the 68HC11 instrucOverview of the 68HC11 instruction setFetch/Execute operation:LDAA #$FFSecond clock cycleOverview of the 68HC11 instrucAddressing modesHow does the instruction specify the location of data?The H

24、C11 supports 5 different addressing modesInherent AddressingOperands are specified implicitly in the opcode itselfOperands are contained in the registers instead of memoryInstruction length: or 2 bytesExamples:Register increment, clearsCLRARegister shift operationsASLARegister additionsABACont.Addre

25、ssing modesHow does the iAddressing modesHow does the instruction specify the location of data?The HC11 supports 5 different addressing modesInherent AddressingOperands are specified implicitly in the opcode itselfOperands are contained in the registers instead of memoryInstruction length: or 2 byte

26、sExamples:Register increment, clearsCLRARegister shift operationsASLARegister additionsABACont.Addressing modesHow does the iAddressing modesImmediate addressing One operand is included as part of the instruction wordOther operand (if needed) comes from an implied registerInstruction length: 2 -4 by

27、tesSpecified operand is a constant and cannot be altered at run timeMode is denoted by a # before the operand valueExample:LDAA #$05 $86 $05Cont.Addressing modesImmediate addrAddressing modeDirect addressingThe operand included in the instruction word is a memory address, specifying where the data i

28、s locatedSecond operand is an implied registerInstruction length: 2 -4 bytesSince an address is specified, the data value itself can be changed during program executionAddress is a constantAddress included in the instruction word is only 1 byteDirect addressing can only be used to reference location

29、s$0000 -$00FF -256 locationsExample: LDAA 05 $96 $05Cont.Addressing modeDirect addressiAddressing modeExtended addressingSame as direct addressing, but with 2 bytes of address -the full range of addresses can be specified ($0000 to $FFFF)Instruction length: 3 or 4 bytesExample: LDAA $0005 $B6 $00 $0

30、5Why have both modes?Cont.Addressing modeExtended addresAddressing modeIndexed addressingThe effective address of the data in memory is computed as the sum of the value contained in an index register (X or Y) and an offset (contained in the instruction word)The offset is a 1-byte unsigned quantity U

31、seful for table and array accessEg.DAA $56,X $A6 56Cont.Addressing modeIndexed addressAddressing modeRelative addressingSimilar to indexed addressing uses PC value instead of the value in X or YInstructions offset value is added to the value in the program counter to give the address of the next ins

32、tructionUsed to specify branch addresses resulting from jump commandsOffset is an 8-bit 2s complement number -ranges from -128 to +127 decimalAddressing modeRelative addresBasic tour of the instruction setLoad InstructionsTransfer data from memory to registerLDAA, LDAB, LDD, LDX, LDY, LDSDifferent a

33、ddressing modes supportedAssume the following memory contents:0050 40 41 42 43 44 45 46 47 -48 49 4a 4b 4c 4d 4e 4f2000 50 51 52 53 54 55 56 57 -58 59 5a 5b 5c 5d 5e 5fLDAA #$56; ACCA$56 (immediate) LDAB $56; ACCB = $46 (direct) LDAA $2000 ; ACCA = $50 (extended) LDD $2002 ; ACCD = $5253 (extended)C

34、ont.Basic tour of the instruction Basic tour of the instruction set; CCA = $52, ACCB = $53 LDX #$2000; IX = $2000 (immediate) LDAA $C, X ; ACCA = $5C (indexed) LDY #$56 ; IY = $56 (immediate) LDAB 0, Y ; ACCB = $46 (indexed) LDX $5, X ; IX = ? (indexed)Store InstructionsTransfer data from register t

35、o memory STAA, STAB, STD, STX, STY, STSDirect, extended, or indexed addressing No immediate addressingCont.Basic tour of the instruction Basic tour of the instruction setTransfer InstructionsTransfer data from register to register TAB ; ACCA ACCBTBA ; ACCB ACCATAP ; ACCA CCRTPA ; CCR ACCATXS ; IX SP

36、TSX ; SP IXTYS ; IY SPTSY ; SP IYXGDX ; IX ACCDXDGY ; IY ACCDCont.Basic tour of the instruction Basic tour of the instruction setIncrement Instructions INC oprINCA INCB INX INY INSDecrement InstructionsDEC oprDECA DECB Cont.Basic tour of the instruction Basic tour of the instruction setDEX DEY DESCl

37、ear InstructionsCLR oprCLRARotate InstructionsShifts all 8 bits plus the Carry bit circularly one position.ROL oprROLAROLBCont.Basic tour of the instruction Basic tour of the instruction setROR oprRORARORBNote: 9 rotates puts data back in original position (not 8 as stated in text)Rotate Instruction

38、sExampleAssume C = 1, ACCA = $3BCont.Basic tour of the instruction Basic tour of the instruction setShift InstructionsLogical ShiftsLSL oprLSLALSLBLSLDLSR oprLSRALSRBLSRDCont.Basic tour of the instruction Basic tour of the instruction setShift InstructionsArithmatic ShiftsASL oprASLAASLBASLDASR oprA

39、SRAASRBASRDCont.ASR preserves sign bitASL/ASR can be used to multiply/divide by 2What is the difference between ASL and LSL?Basic tour of the instruction Basic tour of the instruction setLogical InstructionsBit-wise ANDANDA oprANDB oprBit-wise ORORA oprORB oprBit-wise Exclusive-OREORA oprEORB oprCon

40、t.Basic tour of the instruction Basic tour of the instruction set1s ComplementCOM oprCOMACOMBArithmetic InstructionsAdd instructions ABA ; ACCA + ACCB ACCAADDA opr ; ACCA + M ACCAADDB opr ; ACCB + M ACCBADDD opr ; ACCD + M ACCDADCA opr ; ACCA+ M+ C ACCACont.Basic tour of the instruction Basic tour o

41、f the instruction setABX ; IX + ACCB IX ABY ; IY + ACCB IYSubtract InstructionsSBA ; ACCA -ACCB ACCASUBA opr ; ACCA -M ACCASUBB opr ; ACCB -M ACCBSUBD opr ; ACCD -M ACCDSBCA opr ; ACCA -M -C ACCASBCB opr ; ACCB -M -C ACCBCont.Basic tour of the instruction Basic tour of the instruction setArithmetic

42、InstructionsUnsigned arithmeticNumbers range from $00 to $FF (0 to 255)The carry bit (C) is set if result is outside rangeSigned arithmeticNumbers range from $80 to $7f (-128 to +127)The overflow bit (V) is set if result is outside rangeThe negative bit (N) is set if result is negative (same as MSB

43、of result)Cont.Basic tour of the instruction Basic tour of the instruction setArithmetic instructionsThe same instructions are used for both signed and unsigned arithmetic The CPU does not care whether the values are signed or unsigned The arithmetic result is the same for both cases C, V, and N bit

44、s are set based on Boolean combinations of the operands Programmer must keep track of whether values are signed or unsigned Whether to use the C or V bit to check for overflowCont.Basic tour of the instruction Basic tour of the instruction setArithmetic InstructionsExample:Add $56 + $B0Unsigned: $56

45、 + $B0 = $106 (86 + 176 = 262)Signed: $56 + $B0 = $06 (86 + (-80) = 6) LDAA #$56 LDAB #$B0ABA ;ACCA = $06, C = 1, V = 0Example:Add $56 to $60 Unsigned: $56 + $60 = $B6 (86 + 96 = 182)Signed: $56 + $60 = $B6 (86 + 96 = -74!)Cont.Basic tour of the instruction Basic tour of the instruction setLDAA #$56

46、LDAB #$60ABA ;ACCA = $B6, C = 0, V = 1MultiplicationMUL instruction Multiplies 8-bit unsigned values in ACCA and ACCB, then puts the 16-bit result in ACCD Note that this overwrites ACCA and ACCB! If youre multiplying by a power of 2, you may want to use ASL instructions instead Why?Cont.Basic tour o

47、f the instruction Basic tour of the instruction setBinary FractionsMultiplying two 8-bit numbers gives 16-bit result. What if you only want 8 bits?Different ways to interpret 8-bit numbersUnsigned integers 0 255Signed integers -128 -+127Binary fractions 0 -1 $00 = 0/256 = 0 $80 = 128/256 = 0.5 $FF =

48、 255/256 = 0.9961You can use the ADCA instruction after a MUL to convert 16-bit result to 8-bit binary fractionMUL sets C to 1 if bit 7 of ACCB is 1Cont.Basic tour of the instruction Basic tour of the instruction setBinary Fractions Example: Multiply $20 x $35 (32 x 53 in decimal) Unsigned integers:

49、 $20 x $35 = 32 x 53 = 1696 = $6A0 LDAA #$20 LDAB #$35 MUL ; ACCD = $06A0, C = 1 ; ACCA=$06, ACCB=$A0Binary fractions:(32 / 256) x (53 / 256) = 1696 / 65,536Cont.Basic tour of the instruction Basic tour of the instruction set= 6.625 / 256 = 7 / 256 LDAA #$20LDAB #$35 MUL ; ACCD = $06A0, C = 1 ADCA #

50、$00 ; now ACCA = $07Integer DivisionIDIV Divides 16-bit unsigned integer in ACCD by 16-bit unsigned integer in IXPuts quotient in IX, remainder in ACCDExample: 6 / 4 Cont.Basic tour of the instruction Basic tour of the instruction setLDD #$6 ; ACCD = $6 LDX #$4 ; IX = $4 IDIV ; IX = $1, ACCD = $2Not

51、e: IDIV takes 41 cycles to executeYou can use ASR instructions to divide by powers of 2Only gives you the quotient, not the remainderDivide by zero IX set to $FFFF, C set to 1Fractional DivisionFDIV Divides 16-bit binary fraction in ACCD by 16-bit fraction in IX16-bit values between 0 and 1Cont.Basi

52、c tour of the instruction Basic tour of the instruction set16-bit values between 0 and 1Puts quotient in IX, remainder in ACCDOften used to convert remainder from IDIV into a fraction Example: 6/4 LDD #$6 LDX #$4 IDIV ; IX = $1, ACCD = $2 STX Somewhere ; store quotient LDX #$4 ; reload denominator F

53、DIV ; IX = $8000, ACCD = $0 ; (Note $8000 = 0.5)Cont.Basic tour of the instruction Basic tour of the instruction setFloating point numbersUsed to increase the range of number representation past that of integer formatsDue to 8-bit CPU, IEEE floating point standard is not supported on the HC11 Motoro

54、la has a non-standard formatFloating point routines can be downloaded from the Motorola web site if you need these for projects (you will not need them for the labs)CCR OperationsCLC ; clear the C bitCLV ; clear the V bitSEC ; set the C bitSEV ; set the V bitCont.Basic tour of the instruction Basic

55、tour of the instruction setCan use SEC and CLC to set up the C bit prior to rotate instructions, for example“No Operation” Instruction NOPDoes nothing but increment the PCWhy would you need this?Compare InstructionsCompares two registers, or a register and a memory location/immediate value Subtracts

56、 the two valuesSets N, Z, V, C condition codes Does not change operandsCont.Basic tour of the instruction Basic tour of the instruction setCBA ; ACCA -ACCB CMPA opr ; ACCA -M CMPB opr ; ACCB MCPD opr ; ACCD -M CPX opr ; IX -M CPY opr ; IY -MCan be used to check if two values are equal, greater than/

57、less than, etc. Often used before conditional branch instructionCompare Instructions Example: Assume the 16-bit value $5100 is stored at memory location $2000: LDAA #$50Cont.Basic tour of the instruction Basic tour of the instruction setBit Set/Clear InstructionsUsed to set or clear multiple bits in

58、 a memory locationBSET opr mask BCLR opr mask 1s in mask specify which bits are set or cleared. Other bits are unaffected.Example: Assume IX = $20, memory location $34 contains the value $1A BSET $14,X $31 ; now location $34 = $3BBCLR $34 $1C ; now location $34 = $23Bit Test InstructionsCont.Basic t

59、our of the instruction Basic tour of the instruction setBit Test InstructionsPerforms logical AND and modifies condition codes N and Z (V is always cleared, C is unaffected) Does not modify the operands BITA oprBITB oprExample: Assume location $2000 contains the value $1A LDAA #$3F LDAB #$05 BITA #$

60、03 ; N=0, Z=0 BITB $2000 ; N=0, Z=1Cont.Basic tour of the instruction Basic tour of the instruction setFlow control with looping and branchingFlow control is the process ofMaking decisionsPerforming operations in sequence Repeating identical operationsFig 2.21 Flow control mechanismsCont.Basic tour

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论