DOC PREVIEW
NMT EE 308 - More on Assembly Language Programming

This preview shows page 1-2-23-24 out of 24 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 24 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 24 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 24 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 24 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 24 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

EE 308 Spring 2012Lecture 6January 30, 2012More on Assembly Language Programming• Review of Addressing Modes• Hand Assembling a Program• MC9S12 Cycles – How Long Does a Program Take to Run?• Assembler Directives• MC9S12 Instructions• Disassembly of MC9S12 Op Codes1EE 308 Spring 2012Summary of MC9S12 addressing modes0x2035LBRA $1F00 18 20 0E CFPC + 2 + OffsetPC + 4 + OffsetX−3 (X−3 −> X)X + 30X + 300ExtendedEXT LDAA $2035 B6 20 35INH InherentIMM ImmediateDIR DirectNameIndexedABALDAA $35 0x0035PC + 1NoneLDAA #$35Example Op CodeEffectiveAddressLDAA 3,X X + 3ADDRESSING MODESIDXIDX1IDX2IDX IndexedIDX IndexedIDX IndexedIDX IndexedPostincrementPreincrementLDAA 3,X+ X (X+3 −> X)LDAA 3,+X X+3 (X+3 −> X)PostdecrementPredecrementLDAA 3,X−LDAA 3,−XX (X−3 −> X)LDAA 30,XLDAA 300,X A6 E2 01 2CA6 03A6 E0 1396 3586 3518 06A6 32A6 22A6 3DA6 2DREL Relative BRA $1050 20 23A few instructions have two effective addresses:• MOVB #$AA,$1C00 Move byte 0xAA (IMM) to address $1C00 (EXT)• MOVW 0,X,0,Y Move word from address pointed to by X (IDX) to address pointedto by Y (IDX)A few instructions have thr ee effective addresses:• BRSET FOO,#$03,LABEL Branch to LABEL (REL) if bits #$03 (IMM) of variableFOO (EXT) are set.2EE 308 Spring 2012Hand Assembling a ProgramTo hand-assemble a program, do the following:1. Start with the org statement, which shows where the first byte of the program will gointo memory.(E.g., org $2000 will put the first instruction at address $2000.)2. Look at the first instruction. Determine the addressing mode used.(E.g., ldab #10 uses IMM mode.)3. Look up the instruction in the MC9S12 S12CPUV2 Reference Manual, find theappropriate Addressing Mode, and the Object Code for that addressing mode.(E.g., ldab IMM has object code C6 ii.)• Table A-1 of the S12CPUV2 Reference Manual has a concise summary of theinstructions,addressing modes, op-codes, and cycles.4. Put in the object code for the instruction, and put in the appropriate operand. Becareful to convert decimal operands to hex operands if necessary.(E.g., ldab #10 becomes C6 0A.)5. Add the number of bytes of this instruction to the address of the instruction to deter-mine the address of the next instruction.(E.g., $2000 + 2 = $2002 will be the starting addrss of the next instruction.)org $2000ldab #10loop: clradbne b,loopswi3EE 308 Spring 2012S12CPUV2 Reference Manual, Rev. 4.0Freescale Semiconductor 387LBGT rel16 Long Branch if Greater Than(if Z + (N ⊕ V) = 0) (signed)REL 18 2E qq rrOPPP/OPO1OPPP/OPO1– – – – – – – –LBHI rel16 Long Branch if Higher(if C + Z = 0) (unsigned)REL 18 22 qq rrOPPP/OPO1OPPP/OPO1– – – – – – – –LBHS rel16 Long Branch if Higher or Same(if C = 0) (unsigned)same function as LBCCREL 18 24 qq rrOPPP/OPO1OPPP/OPO1– – – – – – – –LBLErel16 Long Branch if Less Than or Equal(if Z + (N ⊕ V) = 1) (signed)REL 18 2F qq rrOPPP/OPO1OPPP/OPO1– – – – – – – –LBLO rel16 Long Branch if Lower(if C = 1) (unsigned)same function as LBCSREL 18 25 qq rrOPPP/OPO1OPPP/OPO1– – – – – – – –LBLSrel16 Long Branch if Lower or Same(if C + Z = 1) (unsigned)REL 18 23 qq rrOPPP/OPO1OPPP/OPO1– – – – – – – –LBLT rel16 Long Branch if Less Than(if N ⊕ V = 1) (signed)REL 18 2D qq rrOPPP/OPO1OPPP/OPO1– – – – – – – –LBMI rel16 Long Branch if Minus (if N = 1) REL 18 2B qq rrOPPP/OPO1OPPP/OPO1– – – – – – – –LBNErel16 Long Branch if Not Equal (if Z = 0) REL 18 26 qq rrOPPP/OPO1OPPP/OPO1– – – – – – – –LBPLrel16 Long Branch if Plus (if N = 0) REL 18 2A qq rrOPPP/OPO1OPPP/OPO1– – – – – – – –LBRArel16 Long Branch Always (if 1=1) REL 18 20 qq rrOPPP OPPP– – – – – – – –LBRNrel16 Long Branch Never (if 1 = 0) REL 18 21 qq rrOPO OPO– – – – – – – –LBVCrel16 Long Branch if Overflow Bit Clear (if V=0) REL 18 28 qq rrOPPP/OPO1OPPP/OPO1– – – – – – – –LBVSrel16 Long Branch if Overflow Bit Set (if V = 1) REL 18 29 qq rrOPPP/OPO1OPPP/OPO1– – – – – – – –LDAA #opr8iLDAA opr8aLDAA opr16aLDAA oprx0_xyspLDAA oprx9,xyspLDAA oprx16,xyspLDAA [D,xysp]LDAA [oprx16,xysp](M) ⇒ ALoad Accumulator AIMMDIREXTIDXIDX1IDX2[D,IDX][IDX2]86 ii96 ddB6 hh llA6 xbA6 xb ffA6 xb ee ffA6 xbA6 xb ee ffPrPfrPOrPfrPOfrPPfIfrPffIPrPfPrfPrOPrfPrPOfrPPfIfrfPfIPrfP– – – – ∆ ∆ 0 –LDAB #opr8iLDAB opr8aLDAB opr16aLDAB oprx0_xyspLDAB oprx9,xyspLDAB oprx16,xyspLDAB [D,xysp]LDAB [oprx16,xysp](M) ⇒ BLoad Accumulator BIMMDIREXTIDXIDX1IDX2[D,IDX][IDX2]C6 iiD6 ddF6 hh llE6 xbE6 xb ffE6 xb ee ffE6 xbE6 xb ee ffPrPfrPOrPfrPOfrPPfIfrPffIPrPfPrfPrOPrfPrPOfrPPfIfrfPfIPrfP– – – – ∆ ∆ 0 –LDD #opr16iLDD opr8aLDD opr16aLDD oprx0_xyspLDD oprx9,xyspLDD oprx16,xyspLDD [D,xysp]LDD [oprx16,xysp](M:M+1) ⇒ A:BLoad Double Accumulator D (A:B)IMMDIREXTIDXIDX1IDX2[D,IDX][IDX2]CC jj kkDC ddFC hh llEC xbEC xb ffEC xb ee ffEC xbEC xb ee ffPORPfRPORPfRPOfRPPfIfRPffIPRPfOPRfPROPRfPRPOfRPPfIfRfPfIPRfP– – – – ∆ ∆ 0 –Note 1. OPPP/OPO indicates this instruction takes four cycles to refill the instruction queue if the branch is taken and three cycles if the branch is not taken.LDS #opr16iLDS opr8aLDS opr16aLDS oprx0_xyspLDS oprx9,xyspLDS oprx16,xyspLDS [D,xysp]LDS [oprx16,xysp](M:M+1) ⇒ SPLoad Stack PointerIMMDIREXTIDXIDX1IDX2[D,IDX][IDX2]CF jj kkDF ddFF hh llEF xbEF xb ffEF xb ee ffEF xbEF xb ee ffPORPfRPORPfRPOfRPPfIfRPffIPRPfOPRfPROPRfPRPOfRPPfIfRfPfIPRfP– – – – ∆ ∆ 0 –LDX #opr16iLDX opr8aLDX opr16aLDX oprx0_xyspLDX oprx9,xyspLDX oprx16,xyspLDX [D,xysp]LDX [oprx16,xysp](M:M+1) ⇒ XLoad Index Register XIMMDIREXTIDXIDX1IDX2[D,IDX][IDX2]CE jj kkDE ddFE hh llEE xbEE xb ffEE xb ee ffEE xbEE xb ee ffPORPfRPORPfRPOfRPPfIfRPffIPRPfOPRfPROPRfPRPOfRPPfIfRfPfIPRfP– – – – ∆ ∆ 0 –Table A-1. Instruction Set Summary (Sheet 7 of 14)Source Form OperationAddr.ModeMachineCoding (hex)Access DetailS X H I N Z V CHCS12 M68HC124EE 308 Spring 2012S12CPUV2 Reference Manual, Rev. 4.0Freescale Semiconductor 383BLS rel8 Branch if Lower or Same(if C + Z = 1) (unsigned)REL 23 rrPPP/P1PPP/P1– – – – – – – –BLT rel8 Branch if Less Than(if N ⊕ V = 1) (signed)REL 2D rrPPP/P1PPP/P1– – – – – – – –BMI rel8 Branch if Minus (if N = 1) REL 2B rrPPP/P1PPP/P1– – – – – – – –BNErel8 Branch if Not Equal (if Z = 0) REL 26 rrPPP/P1PPP/P1– – – – – – – –BPLrel8 Branch if Plus (if


View Full Document

NMT EE 308 - More on Assembly Language Programming

Documents in this Course
Load more
Download More on Assembly Language Programming
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view More on Assembly Language Programming and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view More on Assembly Language Programming 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?