Presentation is loading. Please wait.

Presentation is loading. Please wait.

© 2010 Kettering University, All rights reserved..

Similar presentations


Presentation on theme: "© 2010 Kettering University, All rights reserved.."— Presentation transcript:

1 © 2010 Kettering University, All rights reserved.

2

3 Microcomputers I – CE 320 Electrical and Computer Engineering Kettering University jkwon@kettering.edu http://www.kettering.edu/~jkwon Jaerock Kwon, Ph.D.

4 Announcements The PDF version of lecture slides will have a slide per a page. Upload Exercise 2. To post the lecture slides to the course web page a day earlier.

5 Lecture 5: Unconditional Branches

6 Today’s Goals Learn hexadecimal addition and subtraction. Use unconditional branches and jump instructions.

7 Hexadecimal Addition and Subtraction For the most part, adding and subtracting in hexadecimal is performed like decimal. Only difference is carries or borrows 16 instead of 10. Examples $2367 + $5FD6$AC22 - $1EE8 = $833D = $8D3A

8 Extending Hexadecimal Numbers When a shorter number is added to or subtracted from a longer number, the shorter number must be extended to the same number of digits as the longer number Unsigned: Signed: $2357 + $D6 $2357 + $6D Always extend by adding 0’s Repeating the sign bits. = Adding ‘F’s or ‘0’s

9 Truncating Hexadecimal Numbers In microcomputers, it is common practice to represent values using a fewer number of bits to save both time and space. Shortly, we will see the need to represent the value of a two- byte hexadecimal numbers as a one-byte value if possible. UnsignedSigned: $00F5$0045 $10EC$00F5 $FFD1 $FF66 $F280 Remove only leading 0s. The remaining number is always valid. Remove leading 0s and have a positive value or Remove leading Fs and have a negative value.

10 Relative Addressing (REL) Effective Address: – Add the operand as a signed number to the value in the PC. The effective address is loaded into the PC, and the program executes form the new address Examples – BRA$30 Branch always to the instruction 30h bytes forward. – BRA-10 Branch always to the instruction 10 bytes backwards REL Op Code Relative offset Effective Address Program Counter 20 30 2000 2001 20 F6 2000 2001

11 Calculating Branch Destinations ‘Branch’ means changing a value of the program counter in the point of view of the microprocessor. The destination address can be calculated by adding the operand (either + or -0) to the value of the current PC. Valid range: -$80 ~ $7F 20 5E 2000 2001 20 EE 2000 2001 20 XX 2000 2001 20 XX 2000 2001 Destination: $2060Destination: $1FF0 Destination: $2085Destination: $1F80 pc Valid destination: $1F82 ~ $2081 if PC is $2002

12 Branch and Jump BRA – Branch always – Only uses relative addressing (REL) with one-byte operands LBRA – Long Branch always – Only uses relative addressing (REL) with two-byte operands JMP – Jump – Uses extended(EXT) or index addressing (IDX) Instructions

13 Questions?

14 Wrap-up Hexadecimal addition and subtraction Unconditional branch instructions What we’ve learned

15 What to Come Instructions for conditional branches HCS12 Assembly language


Download ppt "© 2010 Kettering University, All rights reserved.."

Similar presentations


Ads by Google