Lecture07_handout-F09

Lecture07_handout-F09 - CE-320 Microcomputers I Fall B 2009...

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

View Full Document Right Arrow Icon
CE-320 Microcomputers I Fall B 2009 Lecture 7 Page 1 Lecture 7 Comparison Branches Purpose: Use the Unsigned and Signed Comparison Branches to control the flow of programs Use the Transfer and Move set of instructions
Background image of page 1

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

View Full DocumentRight Arrow Icon
CE-320 Microcomputers I Fall B 2009 Lecture 7 Page 2 Comparison Branches This set of branches is based on comparing one number to another. These examine several CCR bits, and for them to function correctly, the CCR must be set by a subtraction instruction. The format for a subtraction instruction when used to prepare for a branch is as follows: Number of Interest – Reference Value = Result This format makes it a little easier for a human to determine whether or not the branch will be taken by mentally comparing the numbers instead of performing the subtraction as the microcomputer. For example, a “branch if higher” instruction would affect the PC if the Number of Interest was higher than the Reference Value. Subtraction instructions fall into three general categories: 1. Actual subtraction – perform operation and keep the result 2. Comparison – perform the subtraction and discard the answer 3. Test – perform subtraction using 00 as the inherent reference
Background image of page 2
CE-320 Microcomputers I Fall B 2009 Lecture 7 Page 3 Comparison Branches Continued One of the largest problems with comparison branches is that the result of subtraction does not depend on the number being signed or unsigned. The result is always the same. However, branches must be either signed or unsigned. Therefore, there are two sets of comparison branches: one that interprets the CCR as if unsigned numbers are being used and one for interpreting the CCR as if signed numbers are being used. To help a human remember which branches fall into each category, certain terminology is used: Unsigned: Higher, Lower, Same Signed: Greater Than, Less Than, Equal The table below summarizes the comparison branches for the Star12 Comparison Unsigned Signed > < =
Background image of page 3

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

View Full DocumentRight Arrow Icon
CE-320 Microcomputers I Fall B 2009 Lecture 7 Page 4 Example Program Trace the program below. Assume that memory locations $2000, $2001, and $2002 are already set to $40, $F0, and $55 respectively. 1: 1500 CE 2000 LDX #$2000 2: 1503 180B FF 1000 MOVB #$FF,$1000 3: 1508 C6 02 LDAB #2 4: 150A 27 0E BEQ 14 5: 150C A6 00 LDAA 0,X 6: 150E B1 1000 CMPA $1000 7: 1511 24 03 BHS 3 8: 1513 7A 1000 STAA $1000 9: 1516 08 INX 10: 1517 53 DECB 11: 1518 20 F0 BRA -16 12: 151A 3F SWI
Background image of page 4
CE-320 Microcomputers I Fall B 2009 Lecture 7 Page 5 Trace Line PC A B X N Z V C 1 1 1503 2 2 1508 3 3 150A 4 4 150C 5 5 150E 6 6 1511 7 7 1513 8 8 1516 9 9 1517 10 10 1518 11 11 150A 12 4 150C 13 5 150E 14 6 1511 15 7 1516 16 9 1517 17 10 1518 18 11 150A 19 4 151A 20 12 - - - - - - - -
Background image of page 5

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

View Full DocumentRight Arrow Icon
CE-320 Microcomputers I Fall B 2009 Lecture 7 Page 6 What does this program do? What changes are needed to process 200 bytes?
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

This document was uploaded on 11/12/2009.

Page1 / 144

Lecture07_handout-F09 - CE-320 Microcomputers I Fall B 2009...

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

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