Survey. Motivation 29.5 / 40 class is required

Similar documents
Representation of Information

M1 Computers and Data

Decimal & Binary Representation Systems. Decimal & Binary Representation Systems

Bits, Bytes and Integers

Data Storage. August 9, Indiana University. Geoffrey Brown, Bryce Himebaugh 2015 August 9, / 19

CPS 104 Computer Organization and Programming

COMP2611: Computer Organization. Data Representation

CS 265. Computer Architecture. Wei Lu, Ph.D., P.Eng.

CSE351: Memory, Data, & Addressing I

Number System. Introduction. Decimal Numbers

Beginning C Programming for Engineers

CSE 351: The Hardware/Software Interface. Section 2 Integer representations, two s complement, and bitwise operators

But first, encode deck of cards. Integer Representation. Two possible representations. Two better representations WELLESLEY CS 240 9/8/15

Computer Architecture and System Software Lecture 02: Overview of Computer Systems & Start of Chapter 2

World Inside a Computer is Binary

data within a computer system are stored in one of 2 physical states (hence the use of binary digits)

Computer (Literacy) Skills. Number representations and memory. Lubomír Bulej KDSS MFF UK

UNIT 7A Data Representation: Numbers and Text. Digital Data

COMP Overview of Tutorial #2

Groups of two-state devices are used to represent data in a computer. In general, we say the states are either: high/low, on/off, 1/0,...

CSCI 2212: Intermediate Programming / C Chapter 15

Hardware: Logical View

Announcements HW1 is due on this Friday (Sept 12th) Appendix A is very helpful to HW1. Check out system calls

Number Systems. Decimal numbers. Binary numbers. Chapter 1 <1> 8's column. 1000's column. 2's column. 4's column

ECE 250 / CS 250 Computer Architecture. C to Binary: Memory & Data Representations. Benjamin Lee

Number Systems for Computers. Outline of Introduction. Binary, Octal and Hexadecimal numbers. Issues for Binary Representation of Numbers

Final Labs and Tutors

Final Exam. 11 May 2018, 120 minutes, 26 questions, 100 points

Number Systems. Binary Numbers. Appendix. Decimal notation represents numbers as powers of 10, for example

SIGNED AND UNSIGNED SYSTEMS

Data Representation 1

CS 261 Fall Binary Information (convert to hex) Mike Lam, Professor

CTT MODBUS-RTU COMMUNICATION PROTOCOL TEMPERATURE MONITOR DEVICE

Technical Specification. Third Party Control Protocol. AV Revolution

Computer Organization & Systems Exam I Example Questions

DRAM uses a single capacitor to store and a transistor to select. SRAM typically uses 6 transistors.

imetos LoRa Data payload structure

Harry H. Porter, 2006

Computer Organization MIPS ISA

Computer Systems Organization

MCW Application Notes 24 th February 2017

IEEE-754 floating-point

l l l l l l l Base 2; each digit is 0 or 1 l Each bit in place i has value 2 i l Binary representation is used in computers

Memory, Data, & Addressing I

GNetPlus Communication Protocol

Binary Representations and Arithmetic

Math 230 Assembly Programming (AKA Computer Organization) Spring 2008

Data Representation. DRAM uses a single capacitor to store and a transistor to select. SRAM typically uses 6 transistors.

Chapter 2 Number System

ECE232: Hardware Organization and Design

LAB A Translating Data to Binary

Final Exam. 12 December 2018, 120 minutes, 26 questions, 100 points

Recap from Last Time. CSE 2021: Computer Organization. It s All about Numbers! 5/12/2011. Text Pictures Video clips Audio

Signed/Unsigned Integer Arithmetic in C. Vineel Kovvuri

Learning the Binary System

Binary Arithmetic CS 64: Computer Organization and Design Logic Lecture #2 Fall 2018

The MARIE Architecture

Solutions - Homework 2 (Due date: October 4 5:30 pm) Presentation and clarity are very important! Show your procedure!

Signed Binary Numbers

Numbers and Computers. Debdeep Mukhopadhyay Assistant Professor Dept of Computer Sc and Engg IIT Madras

CS 241 Data Organization Binary

Chapter 10 Binary Arithmetics

Arithmetic and Bitwise Operations on Binary Data

ECE 2020B Fundamentals of Digital Design Spring problems, 6 pages Exam Two Solutions 26 February 2014

Number Representations

//

IT 1204 Section 2.0. Data Representation and Arithmetic. 2009, University of Colombo School of Computing 1

DMTME Multimeters. Communication protocol. Technical specification V1.2 ABB

1 Digital tools. 1.1 Introduction

SISTEMI EMBEDDED. Basic Concepts about Computers. Federico Baronti Last version:

Integer Representation

COMP2121: Microprocessors and Interfacing. Number Systems

Bits, Bytes, and Integers Part 2

Binary Arithmetic CS 64: Computer Organization and Design Logic Lecture #2

Content. Information Coding. Where are we? Where are we? Bit vectors (aka Words )

ICS Instructor: Aleksandar Kuzmanovic TA: Ionut Trestian Recitation 2

Goals for this Week. CSC 2400: Computer Systems. Bits, Bytes and Data Types. Binary number system. Finite representations of binary integers

Keywords: CRC, CRC-7, cyclic redundancy check, industrial output, PLC, programmable logic controller, C code, CRC generation, microprocessor, switch

Data Representation COE 301. Computer Organization Prof. Muhamed Mudawar

A complement number system is used to represent positive and negative integers. A complement number system is based on a fixed length representation

Chapter 2A Instructions: Language of the Computer

C-string format with scanf/printf

Byte Ordering. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

2.1. Unit 2. Integer Operations (Arithmetic, Overflow, Bitwise Logic, Shifting)

CENG3420 Lecture 03 Review

Instructions: Language of the Computer

Number Systems CHAPTER Positional Number Systems

CS 107 Lecture 2: Bits and Bytes (continued)

CS 61C: Great Ideas in Computer Architecture. (Brief) Review Lecture

CHAPTER 1 Numerical Representation

Inf2C - Computer Systems Lecture 2 Data Representation

Introduction to Computer Science-103. Midterm

Number representations

9/3/2015. Data Representation II. 2.4 Signed Integer Representation. 2.4 Signed Integer Representation

CS61, Fall 2012 Midterm Review Section

Memory, Data, & Addressing II CSE 351 Spring

Jin-Soo Kim Systems Software & Architecture Lab. Seoul National University. Integers. Spring 2019

The Design of C: A Rational Reconstruction

RS-232 Control of the Advantage EQ281/8, EQ282/8 and Advantage SMS200

Arithmetic and Bitwise Operations on Binary Data

Transcription:

Survey Motivation 29.5 / 40 class is required Concerns 6 / 40 not good at examination That s why we have 3 examinations 6 / 40 this class sounds difficult 8 / 40 understand the instructor Want class to be 27 / 40 challenging 8 / 40 easy

overview bit, byte and int float point [C] basics, bitwise operator, control flow [C] scopes rules, pointers, arrays [C] structs, mallocs [C] large program (linked list) Machine Prog: ISA, Compile, movq Machine Prog: Control Code (condition, jump instruction) Machine Prog: Array allocation and access Machine Prog: Procedure calls Machine Prog: Structure, Memory Layout Machine Prog: Buffer Overflow Code optimizations Virtual memory: Address Spaces/ Translation, Goal Virtual memory: Page table/physcial to virtual Process Dynamic Memory Allocation I: malloc, free Dynamic Memory Allocation II: design allocator Dynamic Memory Allocation III: futher optimization Concurrent Programming I: thread, race Concurrent Programming II: lock Concurrent Programming III: conditional variable Concurrent Programming IV: Other primitives Basic (Easy) Advanced (Hard)

Bits, Bytes, Ints, Word Zhaoguo Wang

Bit 0 /

The world has moved away from analog signal to Analog signals: smooth and continuous Problems. Difficult to design 2. Susceptible to noise Analog components: resistors, capacitors, inductors, diodes, e.t.c

to digital 0 0 0 0 0 0 Digital signals: discrete (encode sequence of 0s and s) Advantages Digital components: transistors, logic gates. Easier to design Simple Integrate millions on a single chip 2. Reliable Robust to noise

Using bits to represent everything A bit is too small to be much used In English, there are 26 characters and plenty words in the vocabulary Using bits instead of bit Group bits together Apply some interpretation to the different possible bit patterns Represent elements of any limit set

Represent nonnegative integer bits: b n- b n-2 b 2 b b 0 b i : bit b in i-th position (from right to left) 0 <= i < n b * 2 i (b is 0 or ) Bits 000 Value 0*2 4 +*2 3 +0*2 2 +*2 +0*2 0 = 0 Bits 000 Value?

Represent nonnegative integer bits: b n- b n-2 b 2 b b 0 b i : bit b in i-th position (from right to left) 0 <= i < n b * 2 i (b is 0 or ) Bits 000 Value 0*2 4 +*2 3 +0*2 2 +*2 +0*2 0 = 0 Bits 000 Value 28

Most significant bit (MSB) The bit position has the greatest value Bits 000 MSB? Bits 000 MSB?

Most significant bit (MSB) The bit position has the greatest value The leftmost bit Bits 000 MSB 0 Bits 000 MSB

Least significant bit (LSB) The bit position has the least value The rightmost bit Bits 000 MSB 0 Bits 000 MSB 0

Your Mental Model 0 0 0 CPU Arithmetic Logic Unit Memory Memory is a continuous array. Each unit of the array has one bit.

Your Mental Model 0 0 0 * 2 7 CPU Arithmetic Logic Unit Memory

Your Mental Model 0 0 0 * 2 7 + * 2 6 CPU Arithmetic Logic Unit Memory

Your Mental Model 0 0 0 CPU Arithmetic Logic Unit * 2 7 + * 2 6 + 0 * 2 5 Memory

Your Mental Model 0 0 0 CPU Arithmetic Logic Unit * 2 7 + * 2 6 + 0 * 2 5 + * 2 4 Memory

Your Mental Model 0 0 0 CPU Arithmetic Logic Unit * 2 7 + * 2 6 + 0 * 2 5 + * 2 4 + * 2 3 Memory

Your Mental Model 0 0 0 CPU Arithmetic Logic Unit * 2 7 + * 2 6 + 0 * 2 5 + * 2 4 + * 2 3 + * 2 2 Memory

Your Mental Model 0 0 0 CPU Arithmetic Logic Unit * 2 7 + * 2 6 + 0 * 2 5 + * 2 4 + * 2 3 + * 2 2 + * 2 Memory

Your Mental Model 0 0 0 CPU Arithmetic Logic Unit * 2 7 + * 2 6 + 0 * 2 5 + * 2 4 + * 2 3 + * 2 2 + * 2 + 0 Memory

Your Mental Model 0 0 0 Memory CPU Arithmetic Logic Unit * 2 7 + * 2 6 + 0 * 2 5 + * 2 4 + * 2 3 + * 2 2 + * 2 + 0 Low efficiency

Byte Each memory unit has multiple bits Dr. Werner Buchholz in July 956 Byte sizes from bit to 48 bits have been used in the history

Byte Each memory unit has multiple bits Dr. Werner Buchholz in July 956 Byte sizes from bit to 48 bits have been used in the history 00 0 00 00 000 0000 000 00 CPU Arithmetic Logic Unit Memory is a continuous array. Each unit is a byte. Memory

Byte 8 bits chunk IBM System/360, 964 Introduce Intel 8080, 974 Modern processors Widely adopted Standard

Your current mental model Bits 000 0000 00000 00000 addresses addr addr 2 addr 3 addr 4 000 0000 00000 00000... Memory addr 000 Each byte has 8 bits CPU Arithmetic Logic Unit

Your current mental model Bits 000 0000 00000 00000 addresses addresses addr 4 addr 3 addr 2 addr 00000 00000 0000 000... Memory addr 000 Each byte has 8 bits CPU Arithmetic Logic Unit

Range of Single Byte Maximum Minimum

Range of Single Byte Maximum 2 à 255 Minimum

Range of Single Byte Maximum 2 à 255 Minimum 00000000 2 à 0

Bit pattern description intuitive way Binary notation Bits 000 0000 00000 00000 4 bytes

Bit pattern description intuitive way Binary notation Too verbose Bits 000 0000 00000 00000 4 bytes 5 cm on my laptop

Bit pattern description strawman Decimal Notation 3 decimal digits to represent one byte Bits 000 0000 00000 00000 Decimal 74 202 04 026

Bit pattern description strawman Decimal Notation 3 decimal digits to represent one byte Bits 000 0000 00000 00000 Decimal 74 202 04 026 too tedious to do the conversion

Hexadecimal Notation Write bit patterns as base-6 (hex) numbers 0-9 and a-f (0-5) Each number can represent a 4 bits chunk Each byte is represented with 2 hex numbers

Hexadecimal Notation Byte / 8 bits Binary: 00000000 2 to 2 Decimal: 0 0 to 255 0 Hex: 00 6 to FF 6 0 0 0000 000 2 2 000 3 3 00 4 4 000 5 5 00 6 6 00 7 7 0 8 8 000 9 9 00 A 0 00 B 0 C 2 00 D 3 0 E 4 0 F 5

Hexadecimal Notation Write bit patterns as base-6 (hex) numbers 0-9 and a-f (0-5) Each number can represent a 4 bits chunk Each byte is represented with 2 hex numbers (00 6 -- FF 6 ) Bits 000 0000 00000 00000 Decimal 74 202 04 026 Hex Hex(C) 00 =

Hexadecimal Notation Write bit patterns as base-6 (hex) numbers 0-9 and a-f (0-5) Each number can represent a 4 bits chunk Each byte is represented with 2 hex numbers (00 6 -- FF 6 ) Bits 000 0000 00000 00000 Decimal 74 202 04 026 Hex A Hex(C) 00 = * 2 3 + 0 * 2 2 + * 2 + 0 = 0 = A 6

Hexadecimal Notation Write bit patterns as base-6 (hex) numbers 0-9 and a-f (0-5) Each number can represent a 4 bits chunk Each byte is represented with 2 hex numbers (00 6 -- FF 6 ) Bits 000 0000 00000 00000 Decimal 74 202 04 026 Hex A Hex(C) 0 =

Hexadecimal Notation Write bit patterns as base-6 (hex) numbers 0-9 and a-f (0-5) Each number can represent a 4 bits chunk Each byte is represented with 2 hex numbers (00 6 -- FF 6 ) Bits 000 0000 00000 00000 Decimal 74 202 04 026 Hex A E Hex(C) 0 = * 2 3 + * 2 2 + * 2 + 0 = 4 = E 6

Hexadecimal Notation Write bit patterns as base-6 (hex) numbers 0-9 and a-f (0-5) Each number can represent a 4 bits chunk Each byte is represented with 2 hex numbers (00 6 -- FF 6 ) Bits 000 0000 00000 00000 Decimal 74 202 04 026 Hex A E Hex(C) 00 =

Hexadecimal Notation Write bit patterns as base-6 (hex) numbers 0-9 and a-f (0-5) Each number can represent a 4 bits chunk Each byte is represented with 2 hex numbers (00 6 -- FF 6 ) Bits 000 0000 00000 00000 Decimal 74 202 04 026 Hex A E C Hex(C) 00 = * 2 3 + * 2 2 + 0 * 2 + 0 = 2 = C 6

Hexadecimal Notation Write bit patterns as base-6 (hex) numbers 0-9 and a-f (0-5) Each number can represent a 4 bits chunk Each byte is represented with 2 hex numbers (00 6 -- FF 6 ) Bits 000 0000 00000 00000 Decimal 74 202 04 026 Hex A E C Hex(C) 00 =

Hexadecimal Notation Write bit patterns as base-6 (hex) numbers 0-9 and a-f (0-5) Each number can represent a 4 bits chunk Each byte is represented with 2 hex numbers (00 6 -- FF 6 ) Bits 000 0000 00000 00000 Decimal 74 202 04 026 Hex A E C A Hex(C) 00 = * 2 3 + 0 * 2 2 + * 2 + 0 = 0 = A 6

Hexadecimal Notation Write bit patterns as base-6 (hex) numbers 0-9 and a-f (0-5) Each number can represent a 4 bits chunk Each byte is represented with 2 hex numbers (00 6 -- FF 6 ) Bits 000 0000 00000 00000 Decimal 74 202 04 026 Hex A E C A 0 Hex(C) 0000 = 0 * 2 3 + 0 * 2 2 + 0 * 2 + 0 = 0 = 0 6

Hexadecimal Notation Write bit patterns as base-6 (hex) numbers 0-9 and a-f (0-5) Each number can represent a 4 bits chunk Each byte is represented with 2 hex numbers (00 6 -- FF 6 ) Bits 000 0000 00000 00000 Decimal 74 202 04 026 Hex A E C A 0 E Hex(C) 0 = * 2 3 + * 2 2 + * 2 + 0 = 4 = E 6

Hexadecimal Notation Write bit patterns as base-6 (hex) numbers 0-9 and a-f (0-5) Each number can represent a 4 bits chunk Each byte is represented with 2 hex numbers (00 6 -- FF 6 ) Bits 000 0000 00000 00000 Decimal 74 202 04 026 Hex A E C A 0 E Hex(C) 000 = 0 * 2 3 + 0 * 2 2 + 0 * 2 + = = 6

Hexadecimal Notation Write bit patterns as base-6 (hex) numbers 0-9 and a-f (0-5) Each number can represent a 4 bits chunk Each byte is represented with 2 hex numbers (00 6 -- FF 6 ) Bits 000 0000 00000 00000 Decimal 74 202 04 026 Hex A E C A 0 E A Hex(C) 00 = * 2 3 + 0 * 2 2 + * 2 + 0 = 0 = A 6

Hexadecimal Notation Write bit patterns as base-6 (hex) numbers 0-9 and a-f (0-5) Each number can represent a 4 bits chunk Each byte is represented with 2 hex numbers (00 6 -- FF 6 ) Bits 000 0000 00000 00000 Decimal 74 202 04 026 Hex A E C A 0 E A Hex(C) 0xAECA0EA

Exercises Time Hexadecimal Decimal Binary 0xBC 0xF3 55 00 0 00 0

Answers Hexadecimal Decimal Binary 0xA7 0*6 + 7 = 67 00 0 0x3E 3*6 + 4 = 62 00 0 0xBC *6 + 2 = 88 0 00 0x37 3*6+7=55 00 0 0xF3 5*6+3=243 00

Unsigned addition + 0 0xB + 0xA 00000 2 + 000000 2

Unsigned addition + 0 0xB + 0xA 00000 2 + 000000 2 0 0 0 0 0 + 0 0 0 0 0 0

Unsigned addition + 0 0xB + 0xA 00000 2 + 000000 2 0 0 0 0 0 + 0 0 0 0 0 0

Unsigned addition + 0 0xB + 0xA 00000 2 + 000000 2 0 0 0 0 0 + 0 0 0 0 0 0 2

Unsigned addition + 0 0xB + 0xA 00000 2 + 000000 2 0 0 0 0 0 + 0 0 0 0 0 0 0

Unsigned addition + 0 0xB + 0xA 00000 2 + 000000 2 0 0 0 0 0 + 0 0 0 0 0 0 0

Unsigned addition + 0 0xB + 0xA 00000 2 + 000000 2 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0

Unsigned subtraction - 0 0xB - 0xA 00000 2-000000 2 0 0 0 0 0-0 0 0 0 0 0 0 0 0 0 0 0 0

Unsigned subtraction - 0 0xB - 0xA 00000 2-000000 2 0 0 0 0 0-0 0 0 0 0 0 0 0 0 0 0 0 0

Unsigned subtraction 0-0xA 0xB 000000 2-00000 2 0 0 0 0 0 0-0 0 0 0 0???

Question N: How to represent negative numbers?

Strawman Most significant bit (MSB) represent the sign 0 0 0 0 0 0 0 2 0 0 0 0 0 0 2-0 0 0 0 0 0 0 + 0 0 0 0 0 0

Strawman Most significant bit (MSB) represent the sign 0 0 0 0 0 0 0 2 0 0 0 0 0 0 2-0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0

Strawman Most significant bit (MSB) represent the sign 0 0 0 0 0 0 0 2 0 0 0 0 0 0 2-0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0-2???

Two s complement Byte 0000 Unsigned number * 2 7 + 0 * 2 6 + 0 * 2 5 + * 2 4 + 0 * 2 3 + * 2 2 + * 2 + 0 * 2 0

Two s complement Byte 0000 Unsigned number * 2 7 + 0 * 2 6 + 0 * 2 5 + * 2 4 + 0 * 2 3 + * 2 2 + * 2 + 0 * 2 0 Signed number - * 2 7 + 0 * 2 6 + 0 * 2 5 + * 2 4 + 0 * 2 3 + * 2 2 + * 2 + 0 * 2 0

Two s complement b! = [ b w, b w,..., b ] 0 val! b w i=0 ( ) = b w 2 w + b i 2 i MSB: val( b w ) = -b w * 2w Other: val ( b i ) = b i * 2i, 0 <= i < w

Two s complement b! = [ b w, b w,..., b ] 0 val! b w i=0 ( ) = b w 2 w + b i 2 i Binary 000 000 00 00 00 00 Value

Two s complement b! = [ b w, b w,..., b ] 0 val! b w i=0 ( ) = b w 2 w + b i 2 i Binary Value 000 000 - * 2 7 + -27 00 00 00 00

Two s complement b! = [ b w, b w,..., b ] 0 val! b w i=0 ( ) = b w 2 w + b i 2 i Binary Value 000 000 - * 2 7 + -27 00 00 - * 2 7 + 2 5 + 2 2 + 2 0-9 00 00

Two s complement b! = [ b w, b w,..., b ] 0 val! b w i=0 ( ) = b w 2 w + b i 2 i Binary Value 000 000 - * 2 7 + -27 00 00 - * 2 7 + 2 5 + 2 2 + 2 0-9 00 00 2 6 + 2 4 + 2 2 + 2 85

Two s complement b! = [ b w, b w,..., b ] 0 val! b w i=0 ( ) = b w 2 w + b i 2 i 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0

Two s complement b! = [ b w, b w,..., b ] 0 val! b w i=0 ( ) = b w 2 w + b i 2 i 0 0 0 0 0 0 0 2 0 + 0 0 0 0 0 0 - * 2 7 + 2 0-27 0 0 0 0 0 0 - * 2 7 + 2-26

Find 2 s complement quickly With a negative number, how to give its binary representation? e.g. -40

Find 2 s complement quickly With a negative number, how to give its binary representation? e.g. -40 Step. represent 40 in binary 000 000

Find 2 s complement quickly With a negative number, how to give its binary representation? e.g. -40 Step 2. flip all bits 000 000 0 0

Find 2 s complement quickly With a negative number, how to give its binary representation? e.g. -40 Step 3. add 000 000 0 0 0 000

Find 2 s complement quickly With a negative number, how to give its binary representation? e.g. -40 Step 3. add 000 000 0 0 0 000 + 000 000 0 0

Find 2 s complement quickly With a negative number, how to give its binary representation? e.g. -40 Step 3. add 000 000 0 0 0 000 000 000 0 0 + 0000 0000

Exercise Time II Hexadecimal Decimal Binary 0xce 27-28 -90 00 00

Answers Hexadecimal Decimal Binary 0xce -50 00 0 0x9c -00 00 00 0x7f 27 0 0x80-28 000 0000 0xa6-90 00 00

Ranges Range Min Max byte unsigned [0, 2 8 ] 0 255 byte signed

Ranges Range Min Max byte unsigned [0, 2 8 ] 0 255 byte signed [-2 7, 2 7 ] -28 27 Min: 000 0000 Max: 0

Overflow + 0 0 0 0 0 0 0 0 0 0 0 0-27 -27 Range Min Max byte unsigned [0, 2 8 ] 0 255 byte signed [-2 7, 2 7 ] -28 27

Overflow + 0 0 0 0 0 0 0 0 0 0 0 0-27 -27 2??? 0 0 0 0 0 0 0 Range Min Max byte unsigned [0, 2 8 ] 0 255 byte signed [-2 7, 2 7 ] -28 27

Intel 8080 0xb0 0xa9 0xa8 0xa7 0xa6 0xa5 0xa4 0xa3 0xa2 0xa 0x0f 0xaf 0xe 0x4c 0xea 0xcb 0xba 0x00 0xff 0x8c 0x4c CPU Arithmetic Logic Unit registers 0x4c Memory

Intel 8080 0xb0 0xa9 0xa8 0xa7 0xa6 0xa5 0xa4 0xa3 0xa2 0xa 0x0f 0xaf 0xe 0x4c 0xea 0xcb 0xba 0x00 0xff 0x8c Memory 0x4c CPU Arithmetic Logic Unit registers 0x4c 8 bits machine 8 bits length of Memory processor transfer CPU Register Memory Address Instruction

Intel 386 0x000000b0 0x000000a9 0x000000a8 0x000000a7 0x000000a6 0x000000a5 0x000000a4 0x000000a3 0x000000a2 0x000000a 0x0f 0xaf 0xe 0x4c 0xea 0xcb 0xba 0x00 0xff 0x8c Memory 0x4ceaf0f CPU Arithmetic Logic Unit registers 0x4ceaf0f 32 bits machine 32 bits length of Memory processor transfer CPU Register Memory Address Instruction

Intel Opteron à i7 0x00 00b0 0x00 00a9 0x00 00a8 0x00 00a7 0x00 00a6 0x00 00a5 0x00 00a4 0x00 00a3 0x00 00a2 0x00 00a 0x0f 0xaf 0xe 0x4c 0xea 0xcb 0xba 0x00 0xff 0x8c Memory 0x00bacbea4ceaf0f CPU Arithmetic Logic Unit registers 0x00bacbea4ceaf0f 64 bits machine 64 bits length of Memory processor transfer CPU Register Memory Address Instruction

Intel Opteron à i7 0x00 00b0 0x00 00a9 0x00 00a8 0x00 00a7 0x00 00a6 0x00 00a5 0x00 00a4 0x00 00a3 0x00 00a2 0x00 00a 0x0f 0xaf 0xe 0x4c 0xea 0xcb 0xba 0x00 0xff 0x8c Memory 0x00bacbea4ceaf0f CPU Arithmetic Logic Unit registers 0x00bacbea4ceaf0f Word Memory processor transfer CPU Register Memory Address Instruction

Word Definition Fixed size of data handled as a unit by the instruction set or processor Length 8 for 8 bits machine 32 for 32 bits machine 64 for 64 bits machine

Integral data types on 64 bits machine Length Min Max [signed] char byte -2 7 2 7 - unsigned char byte 0 2 8 - short 2 bytes unsigned short 2 bytes int 4 bytes unsigned int 4 bytes long 8 bytes unsigned long 8 bytes

Integral data types on 64 bits machine Length Min Max [signed] char byte -2 7 2 7 - unsigned char byte 0 2 8 - short 2 bytes -2 5 2 5 - unsigned short 2 bytes 0 2 6 - int 4 bytes unsigned int 4 bytes long 8 bytes unsigned long 8 bytes

Integral data types on 64 bits machine Length Min Max [signed] char byte -2 7 2 7 - unsigned char byte 0 2 8 - short 2 bytes -2 5 2 5 - unsigned short 2 bytes 0 2 6 - int 4 bytes -2 3 2 3 - unsigned int 4 bytes 0 2 32 - long 8 bytes unsigned long 8 bytes

Integral data types on 64 bits machine Length Min Max [signed] char byte -2 7 2 7 - unsigned char byte 0 2 8 - short 2 bytes -2 5 2 5 - unsigned short 2 bytes 0 2 6 - int 4 bytes -2 3 2 3 - unsigned int 4 bytes 0 2 32 - long 8 bytes -2 63 2 63 - unsigned long 8 bytes 0 2 64 -

Memory layout 0x00 00b0 0x00 00a9 0x00 00a8 CPU Arithmetic Logic Unit 0x00 00a7 0x00 00a6 registers 0x00 00a5 0x00 00a4 0x00 00a3 int a = 0x2345678 0x00 00a2 0x00 00a int a address: 0x00 00a2 Memory

Memory layout Intuition 0x00 00b0 0x00 00a9 0x00 00a8 CPU Arithmetic Logic Unit 0x00 00a7 0x00 00a6 registers 0x00 00a5 0x00 00a4 0x00 00a3 0x00 00a2 0x00 00a 0x78 0x56 0x34 0x2 int a int a = 0x2345678 address: 0x00 00a2 Memory

Memory layout Little Endian 0x00 00b0 0x00 00a9 0x00 00a8 CPU Arithmetic Logic Unit 0x00 00a7 0x00 00a6 registers 0x00 00a5 0x00 00a4 0x00 00a3 0x00 00a2 0x00 00a 0x2 0x34 0x56 0x78 Memory int a int a = 0x2345678 address: 0x00 00a2 Least significant byte in smallest address, e.g, laptops, and server machines

Advantages of Little Endian + 0x2345678 0x2345 Processor performs the calculation from the least significant bit Processor can simultaneously perform memory transfer and calculation.

Advantages of Little Endian 0x00 00b0 0x00 00a9 0x00 00a8 0x00 00a7 0x00 00a6 0x00 00a5 0x00 00a4 0x00 00a3 0x00 00a2 0x00 00a Memory CPU Arithmetic Logic Unit registers long a = 0x0000000090abcdef address: 0x00 00a2 long a

Advantages of Little Endian 0x00 00b0 0x00 00a9 0x00 00a8 0x00 00a7 0x00 00a6 0x00 00a5 0x00 00a4 0x00 00a3 0x00 00a2 0x00 00a 0x00 0x00 0x00 0x00 0x90 0xab 0xcd 0xef Memory CPU Arithmetic Logic Unit registers long a = 0x0000000090abcdef address: 0x00 00a2 long a

Advantages of Little Endian 0x00 00b0 0x00 00a9 0x00 00a8 0x00 00a7 0x00 00a6 0x00 00a5 0x00 00a4 0x00 00a3 0x00 00a2 0x00 00a 0x00 0x00 0x00 0x00 0x90 0xab 0xcd 0xef Memory CPU Arithmetic Logic Unit registers long a = 0x0000000090abcdef address: 0x00 00a2 long a int b = (int)a Directly get the data from 0x00 00a2

Memory layout Intuition 0x00 00b0 0x00 00a9 0x00 00a8 CPU Arithmetic Logic Unit 0x00 00a7 0x00 00a6 registers 0x00 00a5 0x00 00a4 0x00 00a3 0x00 00a2 0x00 00a 0x78 0x56 0x34 0x2 int a int a = 0x2345678 address: 0x00 00a2 Is this wrong? Memory

Memory layout Intuition 0x00 00b0 0x00 00a9 0x00 00a8 CPU Arithmetic Logic Unit 0x00 00a7 0x00 00a6 registers 0x00 00a5 0x00 00a4 0x00 00a3 0x00 00a2 0x00 00a 0x78 0x56 0x34 0x2 int a int a = 0x2345678 address: 0x00 00a2 Is this wrong? Memory

Memory layout Big Endian 0x00 00b0 0x00 00a9 0x00 00a8 0x00 00a7 0x00 00a6 0x00 00a5 0x00 00a4 0x00 00a3 0x00 00a2 0x00 00a 0x78 0x56 0x34 0x2 Memory int a CPU Arithmetic Logic Unit registers int a = 0x2345678 address: 0x00 00a2 Most significant byte in smallest address, e.g, ARM architecture >v3 (cellphones, ipads)

Advantages of Big Endian. Easy to read 2. Test whether the number is positive or negative by looking at the byte at offset zero.