EE 308 Spring Binary, Hex and Decimal Numbers (4-bit representation) Binary. Hex. Decimal A B C D E F

Similar documents
Oct: 50 8 = 6 (r = 2) 6 8 = 0 (r = 6) Writing the remainders in reverse order we get: (50) 10 = (62) 8

Computer Science 281 Binary and Hexadecimal Review

Lecture 2. Binary and Hexadecimal Numbers

Binary Representation. Number Systems. Base 10, Base 2, Base 16. Positional Notation. Conversion of Any Base to Decimal.

Solution for Homework 2

CSI 333 Lecture 1 Number Systems

Useful Number Systems

Binary Representation

HOMEWORK # 2 SOLUTIO

CDA 3200 Digital Systems. Instructor: Dr. Janusz Zalewski Developed by: Dr. Dahai Guo Spring 2012

Binary Numbers. Binary Octal Hexadecimal

The string of digits in the binary number system represents the quantity

plc numbers Encoded values; BCD and ASCII Error detection; parity, gray code and checksums

Today. Binary addition Representing negative numbers. Andrew H. Fagg: Embedded Real- Time Systems: Binary Arithmetic

Systems I: Computer Organization and Architecture

Decimal to Binary Conversion

The Answer to the 14 Most Frequently Asked Modbus Questions

2010/9/19. Binary number system. Binary numbers. Outline. Binary to decimal

This 3-digit ASCII string could also be calculated as n = (Data[2]-0x30) +10*((Data[1]-0x30)+10*(Data[0]-0x30));

2011, The McGraw-Hill Companies, Inc. Chapter 3

Base Conversion written by Cathy Saxton

Goals. Unary Numbers. Decimal Numbers. 3,148 is s 100 s 10 s 1 s. Number Bases 1/12/2009. COMP370 Intro to Computer Architecture 1

LSN 2 Number Systems. ECT 224 Digital Computer Fundamentals. Department of Engineering Technology

CPEN Digital Logic Design Binary Systems

Number of bits needed to address hosts 8

Chapter 4: Computer Codes

EE 261 Introduction to Logic Circuits. Module #2 Number Systems

1. Give the 16 bit signed (twos complement) representation of the following decimal numbers, and convert to hexadecimal:

Number and codes in digital systems

Number Representation

Numeral Systems. The number twenty-five can be represented in many ways: Decimal system (base 10): 25 Roman numerals:

Counting in base 10, 2 and 16

CS101 Lecture 11: Number Systems and Binary Numbers. Aaron Stevens 14 February 2011

Subnetting Examples. There are three types of subnetting examples I will show in this document:

COMPSCI 210. Binary Fractions. Agenda & Reading

Lecture 8: Binary Multiplication & Division

Section 1.4 Place Value Systems of Numeration in Other Bases

Microcontroller Basics A microcontroller is a small, low-cost computer-on-a-chip which usually includes:

Lecture 11: Number Systems

Digital Design. Assoc. Prof. Dr. Berna Örs Yalçın

Today s topics. Digital Computers. More on binary. Binary Digits (Bits)

DNA Data and Program Representation. Alexandre David

THE BINARY NUMBER SYSTEM

To convert an arbitrary power of 2 into its English equivalent, remember the rules of exponential arithmetic:

M6800. Assembly Language Programming

NUMBER SYSTEMS. 1.1 Introduction

Chapter Binary, Octal, Decimal, and Hexadecimal Calculations

Everything you wanted to know about using Hexadecimal and Octal Numbers in Visual Basic 6

Technical Support Bulletin Nr.18 Modbus Tips

Intel Hexadecimal Object File Format Specification Revision A, 1/6/88

IP Subnetting and Related Topics A Tutorial by Chris Uriarte <chrisjur@cju.com> Updated April 2001

Unsigned Conversions from Decimal or to Decimal and other Number Systems

Memory is implemented as an array of electronic switches

Data Storage 3.1. Foundations of Computer Science Cengage Learning

The programming language C. sws1 1

NUMBER SYSTEMS. William Stallings

CS201: Architecture and Assembly Language

Positional Numbering System

Cyber Security Workshop Encryption Reference Manual

Chapter 2. Binary Values and Number Systems

APPENDIX B. Routers route based on the network number. The router that delivers the data packet to the correct destination host uses the host ID.

Programmer s Model = model of µc useful to view hardware during execution of software instructions

Number Systems. Introduction / Number Systems

2 Number Systems. Source: Foundations of Computer Science Cengage Learning. Objectives After studying this chapter, the student should be able to:

Hexadecimal Object File Format Specification

3. Convert a number from one number system to another

Lecture 3 Addressing Modes, Instruction Samples, Machine Code, Instruction Execution Cycle

First Bytes Programming Lab 2

Verilog - Representation of Number Literals

Data Storage. Chapter 3. Objectives. 3-1 Data Types. Data Inside the Computer. After studying this chapter, students should be able to:

Number Systems and Radix Conversion

Digital System Design Prof. D Roychoudhry Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Binary Numbering Systems

Numbering Systems. InThisAppendix...

Classless Subnetting Explained

Autumn 1 Maths Overview. Year groups Week 1 Week 2 Week 3 Week 4 Week 5 Week 6 Week 7 1 Number and place value. Counting. 2 Sequences and place value.

1. Convert the following base 10 numbers into 8-bit 2 s complement notation 0, -1, -12

Machine Architecture and Number Systems. Major Computer Components. Schematic Diagram of a Computer. The CPU. The Bus. Main Memory.

Binary Adders: Half Adders and Full Adders

Decimal Number (base 10) Binary Number (base 2)

Data Representation. What is a number? Decimal Representation. Interpreting bits to give them meaning. Part 1: Numbers. six seis

EE360: Digital Design I Course Syllabus

Divide: Paper & Pencil. Computer Architecture ALU Design : Division and Floating Point. Divide algorithm. DIVIDE HARDWARE Version 1

Chapter 7 Lab - Decimal, Binary, Octal, Hexadecimal Numbering Systems

=

UNDERSTANDING SMS: Practitioner s Basics

The Hexadecimal Number System and Memory Addressing

Japannext PTS ITCH Market Data Specification. Version 1.4 Updated 3 October 2014

MEP Y9 Practice Book A

Gates, Plexers, Decoders, Registers, Addition and Comparison

HC12 Assembly Language Programming

Scilab Textbook Companion for Digital Electronics: An Introduction To Theory And Practice by W. H. Gothmann 1

Chapter 1: Digital Systems and Binary Numbers

Levent EREN A-306 Office Phone: INTRODUCTION TO DIGITAL LOGIC

BINARY CODED DECIMAL: B.C.D.

Binary Number System. 16. Binary Numbers. Base 10 digits: Base 2 digits: 0 1

Arithmetic in MIPS. Objectives. Instruction. Integer arithmetic. After completing this lab you will:

A single register, called the accumulator, stores the. operand before the operation, and stores the result. Add y # add y from memory to the acc

Transcription:

EE 8 Spring Binary, Hex and Decimal Numbers (-bit representation) Binary Hex 8 9 A B C D E F Decimal 8 9

EE 8 Spring What does a number represent? Binary numbers are a code, and represent what the programmer intends for the code. x Some possible codes: r (ASCII) INC (HC instruction).v (Input from A/D converter) (Unsigned number) (Signed number) Set temperature in room to 9 F Set cruise control speed to mph

EE 8 Spring Convert Binary to Unsigned Decimal Binary to Unsigned Decimal: x + x + x + x + x + x + x x + x + x + x 8 + x + x + x Hex to Unsigned Decimal Convert Hex to Unsigned Decimal 8D 8 x + x + x + x 8 x 9 + x + x + x 9

EE 8 Spring Unsigned Decimal to Hex Convert Unsigned Decimal to Hex Division Q R Decimal Hex / / D / = D

EE 8 Spring Unsigned Number Line: Numbers go from to 8 9 Unsigned Number Line Unsigned Number Wheel: Numbers go from to

EE 8 Spring Signed Number Line: Numbers go from to Number Wheel: Numbers go from to

EE 8 Spring Number Wheel: Carry and Overflow Carry applies to unsigned numbers when adding or subtracting, result is incorrect. Overflow applies to signed numbers when adding or subtracting, result is incorrect. Carry Overflow Blue: Unsigned Numbers Red: Signed Numbers

EE 8 Spring Binary, Hex and Decimal (Signed & Unsigned) Numbers (-bit representation) Binary Hex US Decimal S 8 9 A B C D E F 8 9 8 8

EE 8 Spring Signed Number Representation in s Complement Form: If most significant bit is (most significant hex digit ), number is positive. Get decimal equivalent by converting number to decimal, and using + sign. Example for 8 bit number: A > + ( x + x ) + ( x + x ) + 8 If most significant bit is (most significant hex digit 8 F), number is negative. Get decimal equivalent by taking s complement of number, converting to decimal, and using sign. Example for 8 bit number: A > ( D ) ( x + x ) ( x + x ) 9 9

EE 8 Spring One s Complement Table Makes It Simple To Find s Complements One s Complement Table F E D C B A 9 8 To take two s complement, add one to one s complement. Take two s complement of DC : FC + = FD

EE 8 Spring Overflow and Carry assume you have a fixed word size A carry is generated when you add two unsigned numbers together, and the result is too large to fit in the fixed word size. A carry is generated when you subtract two unsigned numbers, and the result should be negative. An overflow is generated when you add or subtract two signed numbers, and the fixed-length answer has the wrong sign. Addition and Subtraction of Binary and Hexadecimal Numbers ADDITION AND SUBTRACTION OF BINARY AND HEXADECIMAL NUMBERS ) Limit number of digits to specified word size. bit word: + Keep only bits in answer ) Does not matter if numbers are signed or unsigned mechanics the same Do the operation, then determine if carry and/or overflow bits are set. bit word: Neg + Neg Neg Carry is set, overflow is clear

EE 8 Spring Condition Code Register Gives Information On Result Of Last Operation S X H I N Z V C Condition Code Register 8 FFs N Negative : most significant bit of result Z Zero V Overflow : > last operation generated an overflow C Carry : > result zero, > result not zero : > last operation generated a carry Note: Not all HC instructions change CCR bits. A bit in the CCR is the result of the last executed instruction which affects that bit. For example, after the instruction sequence: aba ; Add B to A staa $9 ; Store A in address $9 the C bit of the CCR will reflect the result of the ABA instruction, not the result of the STAA instruction.

EE 8 Spring Overflow only occurs under certain addition and subtraction operations. S X H I N Z V C Condition Code Register 8 FFs N Negative : most significant bit of result Z Zero : > result zero, > result not zero V Overflow : > last operation generated an overflow C Carry : > last operation generated a carry If you add a positive and a negative number, on overflow never occurs. If you subtract two positive numbers, an overflow never occurs. If you subtract two negative numbers, and overflow never occurs.