Exam review, floating point, chars

Download Report

Transcript Exam review, floating point, chars

ENGR 330: Today’s Class
•
•
•
•
•
Exam Topic Overview
Technical Topic Review
Skills Review – conversions, programming
Data: Characters
Data: Floating Point
March 2005
R. Smith - University of St Thomas - Minnesota
1
Topics for the Exam
• Data Formats: convert to/from decimal
– Sign and magnitude, 1’s complement, 2’s complement
• 2’s complement binary and hex arithmetic
– AND, OR, NOT, Add, Subtract
• Programming
– Arithmetic expressions for MIPS or LC-3
– Conditionals (IFs) in LC-3 assembly language
– Looping in LC-3 assembly language
• Instruction Set Architectures
– Properties – compare for processors we’ve studied
• Stacks and Method Calls
– Role of different MIPS registers
– “Program wide” and “per method” memory maps
March 2005
R. Smith - University of St Thomas - Minnesota
2
Suggestions
• Print out copies of lecture notes
• They should fit readably 6 to a page
• You probably don’t need to print out the lecture
with all the instruction data flows
– If you don’t “get” instruction data flows, don’t worry, we’ll be
doing a lot of that in the next few weeks
– It’s easier to use the appendix in P&P that describes how the
instructions work
• Bring BOTH books on Monday, just to be safe
– It should be enough to just bring the little MIPS card if you feel
comfortable with how MIPS instructions work
March 2005
R. Smith - University of St Thomas - Minnesota
3
Properties of ISAs
• Data sizes for operations (register sizes)
• Address range for RAM
• Common address modes for RAM
– Which types of instructions use which modes
– EX: “fetch store” design vs. allowing arithmetic to access RAM
• Instruction Sizing
– Fixed vs variable length instructions
• Things to Look For
– Shared consistencies – things both processors do
– Differences – what’s different in the ISA between them
March 2005
R. Smith - University of St Thomas - Minnesota
4
Memory Maps and Methods
• “Global” map for a running program
– Text
– Data region
• Starts with fixed “global” data
• Then comes a variable sized “heap” of
data given to the program piecemeal on
request
– Stack
March 2005
R. Smith - University of St Thomas - Minnesota
5
“Map” for individual methods
• Section 2.7 – Stacks and Methods
– Described in terms of MIPS subroutine calls
• Stack Frame
– Return address
– Local variables for the new method
• Pointed to by “Frame Pointer”
– Registers saved while used locally
• Stack Pointer – start of RAM belonging to the stack
– Stack grows downward in RAM as more space is needed
• Must ALWAYS ‘pop’ the stack back to its starting point
when done with it – like when a method is finished and
returns to its caller
March 2005
R. Smith - University of St Thomas - Minnesota
6
Skills Review
•
•
•
•
Representation/Conversion
2’s Complement add/subtract
Binary/hex add, subtract, and, or, not
Arithmetic in LC-3 or MIPS
– Short RAM example
– Longer register based example
• IF example in LC-3
– Min/max using registers
• Loop example
– Down counting
– Sentinel value
March 2005
R. Smith - University of St Thomas - Minnesota
7
“The assignment that got away”
• Write a MIPS program that adds a list of 4 or 8
integers and calculates the (truncated) average
value. Do NOT use the built-in Divide operation.
• How do you calculate the average?
• How do you do it without integer divide?
March 2005
R. Smith - University of St Thomas - Minnesota
8
Characters
• Comparison issues
– 3 vs ‘3’ vs “3”
• Character (decimal) to integer conversion
March 2005
R. Smith - University of St Thomas - Minnesota
9
What is Floating Point?
• Parts
– Mantissa – the fraction part
– Exponent – powers of 2
– Signs
• Special Values: 0, Infinity, and “Not a Number”
• Problems
– Overflow, Underflow
– Loss of precision
• Double vs Float
– Float = 32 bits, 8 bit exponent, 23 bit mantissa, sign bit
– Double = 64 bits, 11 bit exponent, 52 bit mantissa, sign bit
March 2005
R. Smith - University of St Thomas - Minnesota
10
Floating Point Format
• First bit is the sign
– Easy to compare <0 or >0
• Next is exponent
– Easier to compare magnitude of numbers based on exponent
– EXCEPT that negative exponents are “larger” than positive
– Exponent in 2’s complement notation
• Finally comes the mantissa
– Generally a ‘hidden’ 1 at the top – implicitly always there
– Unsigned magnitude value
– “Sign and magnitude” form
March 2005
R. Smith - University of St Thomas - Minnesota
11