Lec15 - ECE 212 Digital Circuits II Wednesday 26 March 2008...

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

View Full Document Right Arrow Icon
1 ECE 212 Digital Circuits II Wednesday, 26 March 2008 HW Set 15 : Problem 1 Mark K. Problem 2 Aaron L. Problem 3 Connor McG. Problem 4 Chris N. Problem 5 Peter P. Problem 6 Me Lecture 15 Goals To write assembly language programs that contain: Decisions [ if ( ), else ] Loops [ for, do-while ] To introduce 6812 instructions and features, as needed. Program Structures . . . Top-down approach. . . . NOT available in assembly language.
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 A Programming Problem Problem: do forever { if Port A data = 0x25, then send 0xFF to Port B; else, send 00 to Port B; } How do we determine if A = 25? Subtract 25 from A. If the result is 0, then A = 25. while ( 1 ) { if ( PortA == 0x25 ) PortB = 0xFF; else PortB = 00; } In C (sort of): 'Compare' Instruction cmpa (8-bit data) Source of the data: Immediate data. From memory: Using any addressing mode. Execution: Compute the difference: A – (data) If the answer is zero, make a note. NOT the only 6812 'compare' instruction. Where? In a flag . Does NOT affect the A, B register contents.
Background image of page 2
3 68HC12 Flags An 8-bit Special Purpose Register. Contains condition codes (flags). Z = The Zero flag Indicates that the result was zero. ( Z = 1 iff the result was zero.) ( Z is set iff the result was zero.) C V Z N I H X S The result of the previous instruction . Condition Code Register (CCR) Instructions Activate Flags Different instructions activate different flags. Example: cmpa affects the N, Z, V, C flags. 68HC12(Alphabetic).pdf
Background image of page 3

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

View Full DocumentRight Arrow Icon
4 Conditional Program Branch Branch if Zero Flag is set. If the result is 0, then send FF to Port B. If the result is 0, then do something. If the Zero flag is set, then do something.
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/17/2008 for the course ECE 212 taught by Professor Greco during the Spring '08 term at Lafayette.

Page1 / 13

Lec15 - ECE 212 Digital Circuits II Wednesday 26 March 2008...

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

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