lecture_note3

lecture_note3 - CpE 390: Microprocessor Systems Lecture...

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon
Stevens Institute of Technology 1 CpE 390: Microprocessor Systems Lecture Note 3 68HC12 Assembly Programming (2)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Stevens Institute of Technology 2 Program Loops Types of program loops: finite and infinite loops Looping mechanisms: 1. do statement S forever 2. For i = n1 to n2 do statement S or For i = n2 downto n1 do statement S 3. While C do statement S 4. Repeat statement S until C Program loops are implemented by using the conditional branch instructions and the execution of these instructions depends on the contents of the CCR register.
Background image of page 2
Stevens Institute of Technology 3 Figure 2.4 An infinite loop S CS true false Figure 2.6 The While . .. Do looping construct Figure 2.5 For looping construct I i 1 i 2 ? S yes I + 1 (a) For I = i 1 to i 2 DO S no i 2 i 1 ? S yes I - 1 (b) For I = i 2 downto i 1 no Figure 2.7 The Repeat . .. Until looping construct initialize C S C true false
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Condition Code Register SX I 76543210 Figure 2.8 Condition code register H N Z V C S – Stop disable X – Interrupt mask I – Interrupt mask Example: N Z V C CLRA 0 1 0 0 ADDA #$20 0 0 0 0 SUBA #$30 1 0 0 1 TSTA 1 0 0 0 CMPA #$F0 0 1 0 0 Stevens Institute of Technology 4
Background image of page 4
Stevens Institute of Technology 5 Branch Instructions Four types of branch instructions: Unary (unconditional) branch: always execute Simple branches: branch is taken when a specific bit of CCR is in a specific status Unsigned branches: branches are taken when a comparison or test of unsigned numbers results in a specific combination of CCR bits Signed branches: branches are taken when a comparison or test of signed quantities results in a specific combination of CCR bits Two categories of Branches Short Branches: in the range of -128 ~ +127 bytes Long Branches: in the range of 64KB
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Stevens Institute of Technology 6 Table 2.2 Summary of short branch instructions Mnemonic Function Unary Branches BRA BRN Branch always Branch never Equation or Operation Simple Branches BCC BCS BEQ BMI BNE BPL BVC BVS Branch if carry clear Branch if carry set Branch if equal Branch if minus Branch if not equal Branch if plus Branch if overflow clear Branch if overflow set 1 = 1 1 = 0 Unsigned Branches BHI BHS BLO BLS Branch if higher Branch if higher or same Branch if lower Branch if lower or same C = 0 C = 1 Z = 1 N = 1 Z = 0 N = 0 V = 0 V = 1 C + Z = 0 C + Z = 1 Signed Branches BGE BGT BLE BLT Branch if greater than or equal Branch if greater than Branch if less than or equal Branch if less than N Z + (N V) = 0 V) = 1
Background image of page 6
Stevens Institute of Technology 7 Table 2.3 Summary of long branch instructions Mnemonic Function Unary Branches LBRA LBRN Long branch always Long branch never Equation or Operation Simple Branches LBCC LBCS LBEQ LBMI LBNE LBPL LBVC LBVS Long branch if carry clear Long branch if carry set Long branch if equal Long branch if minus Long branch if not equal Long branch if plus Long branch if overflow is clear Long branch if overflow set 1 = 1 1 = 0 Unsigned Branches LBHI LBHS LBLO LBLS Long branch if higher Long branch if higher or same Long branch if lower Long branch if lower or same
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 34

lecture_note3 - CpE 390: Microprocessor Systems Lecture...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online