1/1/ / faculty of Electrical Engineering eindhoven university of technology Introduction Part 2: Data types and addressing modes dr.ir. A.C. Verschueren.

Slides:



Advertisements
Similar presentations
1/1/ / faculty of Electrical Engineering eindhoven university of technology Memory Management and Protection Part 3:Virtual memory, mode switching,
Advertisements

INSTRUCTION SET ARCHITECTURES
Fixed Point Numbers The binary integer arithmetic you are used to is known by the more general term of Fixed Point arithmetic. Fixed Point means that we.
Chapter Three.
Computer Engineering FloatingPoint page 1 Floating Point Number system corresponding to the decimal notation 1,837 * 10 significand exponent A great number.
CENG536 Computer Engineering department Çankaya University.
1/1/ / faculty of Electrical Engineering eindhoven university of technology Introduction Part 3: Input/output and co-processors dr.ir. A.C. Verschueren.
Topics covered: Floating point arithmetic CSE243: Introduction to Computer Architecture and Hardware/Software Interface.
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3:
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3: IT Students.
1/1/ / faculty of Electrical Engineering eindhoven university of technology Introduction Part 1: Bits, bytes and a simple processor dr.ir. A.C. Verschueren.
Assembly Language and Computer Architecture Using C++ and Java
Number Systems Standard positional representation of numbers:
Chapter 3 Data Representation.
Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation.
8 November Forms and JavaScript. Types of Inputs Radio Buttons (select one of a list) Checkbox (select as many as wanted) Text inputs (user types text)
PZ04A Programming Language design and Implementation -4th Edition Copyright©Prentice Hall, PZ04A - Scalar and composite data Programming Language.
CSE 378 Floating-point1 How to represent real numbers In decimal scientific notation –sign –fraction –base (i.e., 10) to some power Most of the time, usual.
2 Systems Architecture, Fifth Edition Chapter Goals Describe numbering systems and their use in data representation Compare and contrast various data.
Simple Data Type Representation and conversion of numbers
Information Representation (Level ISA3) Floating point numbers.
Computer Organization and Architecture Computer Arithmetic Chapter 9.
Computer Arithmetic Nizamettin AYDIN
Computer Arithmetic. Instruction Formats Layout of bits in an instruction Includes opcode Includes (implicit or explicit) operand(s) Usually more than.
1 Lecture 5 Floating Point Numbers ITEC 1000 “Introduction to Information Technology”
Machine Instruction Characteristics
IT253: Computer Organization
Computing Systems Basic arithmetic for computers.
Data Representation and Computer Arithmetic
CSC 221 Computer Organization and Assembly Language
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3:
Computer Arithmetic Floating Point. We need a way to represent –numbers with fractions, e.g., –very small numbers, e.g., –very large.
Computer Architecture Lecture 22 Fasih ur Rehman.
CDA 3101 Fall 2013 Introduction to Computer Organization
Computer Engineering FloatingPoint page 1 Floating Point Number system corresponding to the decimal notation 1,837 * 10 significand exponent A great number.
What is a program? A sequence of steps
Instruction Sets. Instruction set It is a list of all instructions that a processor can execute. It is a list of all instructions that a processor can.
1 Scalar and composite data Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
Scalar and composite data Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
1 CE 454 Computer Architecture Lecture 4 Ahmed Ezzat The Digital Logic, Ch-3.1.
William Stallings Computer Organization and Architecture 8th Edition
Floating Point Representations
Programming and Data Structure
Binary Numbers The arithmetic used by computers differs in some ways from that used by people. Computers perform operations on numbers with finite and.
Number Representation
Computer Architecture & Operations I
Data Representation Binary Numbers Binary Addition
Integer Division.
Floating Point Number system corresponding to the decimal notation
William Stallings Computer Organization and Architecture 7th Edition
Chapter 6 Floating Point
Data Structures Mohammed Thajeel To the second year students
Chapter 2 Bits, Data Types & Operations Integer Representation
CSCE 350 Computer Architecture
Data Representation Data Types Complements Fixed Point Representation
How to represent real numbers
ECEG-3202 Computer Architecture and Organization
Computer Organization and Assembly Language
Chapter 10 Instruction Sets: Characteristics and Functions
Presentation transcript:

1/1/ / faculty of Electrical Engineering eindhoven university of technology Introduction Part 2: Data types and addressing modes dr.ir. A.C. Verschueren Eindhoven University of Technology Section of Digital Information Systems

1/1/ / faculty of Electrical Engineering eindhoven university of technology Data type basics High level data types must be mapped onto bit patterns which can be manipulated by the CPU The representation must be such that hardware is kept as simple as possible –Basic data types are stored in one word or fixed number of words (2, 4, 8: powers of two!) –Complex data types are not handled as a unit, the parts are addressed and manipulated separately

1/1/ / faculty of Electrical Engineering eindhoven university of technology Data type determination Generally the instruction determines the data type, not the stored bit patterns themselves –Data type enforcing is done by high level compiler ! ‘Tagging’ data with data type is possible –Requires extra memory bits for each data word –Data read must be type checked and/or converted This requires complex hardware and execution time!

1/1/ / faculty of Electrical Engineering eindhoven university of technology 'Ordinals’: non-negative whole- numbers Encoded by giving 'weights' to the bits in a word and adding the weights of the '1' bits together N-1N-2012Bit number 2 N N-2 Weight For N=8 –Value range is 0..(2 N -1) for N bit values, possibility of overflow and underflow ! –Standard operations: Add, Subtract, Multiply, Divide, Shift (= mul/div by 2 N )

1/1/ / faculty of Electrical Engineering eindhoven university of technology ’Integers’: generic whole-numbers Encoding generally done using 'two's complement' N-1N-2012Bit number –2 N N-2 Weight – For N=8 –Value range is –(2 N–1 )..(2 N–1 – 1) for N bit values, possibility of overflow and underflow ! –Other encodings can be used for integers: ‘one’s complement’ or ‘sign and magnitude’ –Standard operations as ordinals (different shift right) Different check for overflow/underflow

1/1/ / faculty of Electrical Engineering eindhoven university of technology Boolean logic values: one bit ‘true’/’false’ AND, OR and XOR mostly done on whole words –Some processors can perform boolean operations on single bits in a word (using special instructions) Compilers may use whole words for a boolean –Use specific bit patterns to denote true/false OR –Use only one bit in the word and disregard the rest OR –Use rules like 'all 0 = false, anything else = true' Conditional jumps normally based on bit flags which indicate the last instruction’s result Zero, Positive/Negative, Carry/Borrow, Overflow....

1/1/ / faculty of Electrical Engineering eindhoven university of technology ‘Characters’: encoded readable text Uses arbitrary bit pattern encoding: international standards like ‘ASCII’ needed –Truly international character sets require a large amount of separate characters (Japanese, Chinese !) Only few operations make sense on characters –Comparing for equality is always possible –Comparing for higher/lower only if order is defined (an alphabet!) and encoded in the bit patterns –’Block move' instructions handle character sequences

1/1/ / faculty of Electrical Engineering eindhoven university of technology Binary fixed point values: fractions Change the bit weights of ordinals or integers –Example with range – in steps of –The binary point can be placed arbitrarily –The minimum step size is fixed by this choice –Program must manage the position of the binary point, there is no hardware support ! Bit number 345 – Weight 124 True ‘real’ values are impossible

1/1/ / faculty of Electrical Engineering eindhoven university of technology ‘Floating point’: more precise For a fixed number of bits, relative precision can be kept constant by moving the binary point value = base exponent mantissa Base is a fixed number, normally taken as 2 Mantissa is the basic value represented by a binary fixed point notation For base 2, mantissa range is normally [0..1) or [0..2) Mantissa also encodes the sign of the complete value Exponent indicates by how much the mantissa is scaled to smaller (exp. 0) values

1/1/ / faculty of Electrical Engineering eindhoven university of technology The IEEE floating point standard Lots of choices, a standard was needed ! Base is taken 2 here Mantissa is given as sign-and-magnitude value Separate sign bit Magnitude as fixed point binary with range [0..2) Exponent is given as ordinal with fixed negative offset –Minimum and maximum exponent values are special cases for encoding zero, overflow etc.

1/1/ / faculty of Electrical Engineering eindhoven university of technology ExponentMantissaValue 'IEEE floating point' exponent values –Mantissa [0..1) only for minimum exponent –Mantissa [1..2) only for non-minimum exponent Leftmost bit of mantissa can be determined from exponent! [1..2)normal value minimum normal maximum +/– 0(two different zero notations !) 0 +/– 'infinity’(may be result of overflow) 1 (0..1)'denormalised’(close to zero, reduced precision) [1..2)illegal, not allowed [0..1)illegal, not allowed [0..1)illegal, not allowed (1..2)'Not a Number’(NaN- to report/propagate errors)

1/1/ / faculty of Electrical Engineering eindhoven university of technology E M minimum exponent maximum exponent exponent offset MSB mantissa total width IEEE format name: ‘IEEE floating point’ standard formats sign bit exponent mantissa (magnitude) single extended  11 bits  32 bits  –1022  unspecified stored  44 bits double extended  15 bits  64 bits  –16382  unspecified stored  80 bits single 8 bits 23 bits – –127 not stored 32 bits double 11 bits 52 bits – –1023 not stored 64 bits

1/1/ / faculty of Electrical Engineering eindhoven university of technology ‘IEEE floating point’ requirements (1) Several rounding modes must be present –Round towards zero –Round towards negative infinity –Round towards positive infinity –Round 'towards nearest or even’ (balances errors) A number of functions must be present too –Arithmetic: standard add, subtract, multiply and divide, but also remainder, square root, round-to-integer –Floating point  integer or decimal string –Compare operations (may return ‘not comparable’) for ‘interval arithmetic’

1/1/ / faculty of Electrical Engineering eindhoven university of technology ‘IEEE floating point’ requirements (2) Precision of calculations must be very high –Results must really be rounded values of absolute precision calculations ! Must be possible to round to lower precision if more than just single precision is provided –Needed to simulate low precision format calculations Calculation errors must be logged and/or trapped –Can use ‘NaN’ to propagate error to end of calculation

1/1/ / faculty of Electrical Engineering eindhoven university of technology address address Addressing arrays and records (structs) Map them on sequence of memory words –Address the sub-parts separately ! A[3] (word 1) A[3] (word 2) A[4] (word 1) A[9] (word 1) A[4] (word 2) A[9] (word 2) A = array [3..9] of 'double-word' base address = base + (index – 3)  scale (to get to word 1 of each 'double-word') address = base + (index – 3)  scale (to get to word 1 of each 'double-word') R =record p: word; q: boolean; r: 'double- word’ end; R.p (word) R.q (boolean) R.r (word 1) R.r (word 2) base offset offset = 0 offset = 1 offset = 2 & 3 address = base + offset scale (=2)

1/1/ / faculty of Electrical Engineering eindhoven university of technology High level language stack ‘frames’ The stack plays a major role in high-level languages –A 'base' (or 'frame' ) pointer ‘BP’ references parameters and variables stored on the stack procedure p1 var p: word; p := f1(3); end; procedure p1 var p: word; p := f1(3); end; BP (for p1) function f1(x: word): word; var y: word; begin y := 1; f1 := x + y; end; function f1(x: word): word; var y: word; begin y := 1; f1 := x + y; end; SP ret. addr. p1 p (word) BP p1 caller address x (value 3) SP ret. addr. f1 SP BP for p1 SP,BP (for s1) y (word) SP BP (for s1) 1: Push parameter(s) 2: Call subroutine 3: Push base pointer BP 4: Load BP with SP 5: SP  SP + size of variable(s) run subroutine (result  register) 1: Load SP with BP BP (for s1), SP 2: pop BP from the stack SP BP (for p1) 3: return from subroutine SP 4: SP  SP – size of parameter(s) SP 5: use result value (from register) p (value 4)

1/1/ / faculty of Electrical Engineering eindhoven university of technology Basic adressing modes Immediate ADD #15 The instruction includes the (constant!) data itself Register ADD r1 A register contains the actual data Absolute (or ‘Direct’) ADD [105] A directly specified (constant) address contains the data Indirect ADD [r2] A register contains the address of the data Indexed (or ’Based') ADD [r4 + 14] A register and a fixed offset are added to address the data

1/1/ / faculty of Electrical Engineering eindhoven university of technology Some addressing mode ‘extensions’ Automatic increment/decrement ADD [r1++] –A register addresses the data and is modified Register pointed to previous data item:pre-increment Register pointed to next data item:pre-decrement Register must point to next data item:post-increment Register must point to previous item:post-decrement –The added/subtracted offset depends upon the data size Scaled index ADD [r2*4+123] –A register value multiplied by a scale factor (power of 2) and fixed offset are added to address the data –Used to access arrays with a fixed base position

1/1/ / faculty of Electrical Engineering eindhoven university of technology Some really complex addressing modes Double indirect ADD [[r3]] –A register contains the address of the address of the data –Some processors allow 'multiple indirect addressing’ (with a flag bit indicating the last address) Scaled indexed based offset ADD [r1*8+r2+14] –Can access an array local variable inside a subroutine: r1 = array index, 8 = array entry size, r2 = base pointer, 14 = offset from the base pointer to start of the array

1/1/ / faculty of Electrical Engineering eindhoven university of technology Final addressing mode remarks Stack (relative) addressing uses the SP or BP registers in one of these modes as 'base' register True RISC processors only know immediate, register and indirect addressing modes The 'set' data type is generally implemented as a bitmap, using word-wide logical operations Other high-level data structures are normally constructed in software ! Hardware implementation is difficult but may be very attractive for speed !