Decimal, Hexadecimal and Binary Numbers

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

Solution for Homework 2

Computer Science 281 Binary and Hexadecimal Review

Lecture 2. Binary and Hexadecimal Numbers

Binary Numbers. Binary Octal Hexadecimal

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

CSI 333 Lecture 1 Number Systems

Number of bits needed to address hosts 8

Useful Number Systems

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

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

Binary Representation

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

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

HOMEWORK # 2 SOLUTIO

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

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

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

Base Conversion written by Cathy Saxton

CPEN Digital Logic Design Binary Systems

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

Systems I: Computer Organization and Architecture

Number and codes in digital systems

Decimal to Binary Conversion

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

The Answer to the 14 Most Frequently Asked Modbus Questions

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

Number Representation

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

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

Lecture 11: Number Systems

M6800. Assembly Language Programming

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

Chapter 4: Computer Codes

NUMBER SYSTEMS. 1.1 Introduction

Technical Support Bulletin Nr.18 Modbus Tips

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.

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

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

Number Systems. Introduction / Number Systems

Counting in base 10, 2 and 16

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

3. Convert a number from one number system to another

DNA Data and Program Representation. Alexandre David

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

COMPSCI 210. Binary Fractions. Agenda & Reading

Chapter 2. Binary Values and Number Systems

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

Section 1.4 Place Value Systems of Numeration in Other Bases

Lecture 8: Binary Multiplication & Division

Classless Subnetting Explained

Verilog - Representation of Number Literals

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

CS201: Architecture and Assembly Language

THE BINARY NUMBER SYSTEM

Chapter Binary, Octal, Decimal, and Hexadecimal Calculations

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

Number Systems and Radix Conversion

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

Numbering Systems. InThisAppendix...

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

Unsigned Conversions from Decimal or to Decimal and other Number Systems

Memory is implemented as an array of electronic switches

The programming language C. sws1 1

NUMBER SYSTEMS. William Stallings

Positional Numbering System

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

Cyber Security Workshop Encryption Reference Manual

Microprocessor/Microcontroller. Introduction

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

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

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

Number Conversions Dr. Sarita Agarwal (Acharya Narendra Dev College,University of Delhi)

Binary Numbering Systems

Classful Subnetting Explained

Hexadecimal Object File Format Specification

Chapter 4 IP Addresses: Classful Addressing

IT:101 Cisco Networking Academy I Subnetting

2.3 IPv4 Address Subnetting Part 2

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

BINARY CODED DECIMAL: B.C.D.

Digital codes. Resources and methods for learning about these subjects (list a few here, in preparation for your research):

1. Start Log Monitor. 2. Stop Log Monitor, check. Alarm State and turn on. alarm LED if alarm was. triggered. 3. Reset LED control state,

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

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

COMP 250 Fall 2012 lecture 2 binary representations Sept. 11, 2012

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

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

Modbus Protocol. PDF format version of the MODBUS Protocol. The original was found at:

Nemo 96HD/HD+ MODBUS

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

Binary Adders: Half Adders and Full Adders

ND48-RS ASCII A2.04 Communication Protocol

Chapter 4. IP Addresses: Classful Addressing

Binary Division. Decimal Division. Hardware for Binary Division. Simple 16-bit Divider Circuit

Experiment # 9. Clock generator circuits & Counters. Eng. Waleed Y. Mousa

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

20 Saving Device Data Backup

Binary, Hexadecimal, Octal, and BCD Numbers

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

Transcription:

Decimal, Hexadecimal and Binary Numbers o Binary numbers are a code, and represent what the programmer intends for the code o Convert binary and hex numbers to unsigned decimal o Convert unsigned decimal to hex o Unsigned number line and wheel o Signed number line and wheel o Binary, Hex, Signed and Unsigned Decimal o Signed number representation --- 's Complement form o Using the 's complement table to find 's complements of hex numbers o Overflow and Carry o Addition and subtraction of binary and hexadecimal numbers o The Condition Code Register (CCR): N, Z, V and C bits Binary Hex Decimal 0000 000 000 00 000 00 00 0 000 00 00 0 00 0 0 0 3 4 5 6 7 8 9 A B C D E F 0 3 4 5 6 7 8 9 0 3 4 5 What does a number represent? Binary numbers are a code, and represent what the programmer intends for the code. 0x7 Some possible meanings: r (ASCII) INC MEM (hh ll) (HC instruction).6v (Input from A/D converter) 4 0 (Unsigned number) 4 0 (Signed number) Set temperature in room to 69 F

Set cruise control speed to 0 mph Binary to Unsigned Decimal: Convert Binary to Unsigned Decimal 0 x 6 + x 5 + x 4 + x 3 + 0 x + x + x 0 x 64 + x 3 + x 6 + x 8 + 0 x 4 + x + x 3 0 Hex to Unsigned Decimal Convert Hex to Unsigned Decimal 8D6 6 8 x 6 3 + x 6 + 3 x 6 + 6 x 6 0 8 x 4096 + x 56 + 3 x 6 + 6 x 33494 0 Unsigned Decimal to Hex Convert Unsigned Decimal to Hex Division Q R Decimal 7/6 45 45/6 3 /6 0 Hex D 7 0 = D 6 Unsigned Number Line: Numbers go from 0 to Unsigned Number Wheel: Numbers go from 0 to N

Signed Number Line: Numbers go from to Number Wheel: What to do about 00 Number Wheel: Numbers go from (N ) to (N ) 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.

Binary, Hex and Decimal (Signed & Unsigned) Numbers (4-bit representation) Binary Hex Decimal Unsigned Signed 0000 0 0 0 000 000 00 3 3 3 000 4 4 4 00 5 5 5 00 6 6 6 0 7 7 7 000 8 8-8 00 9 9-7 00 A 0-6 0 B -5 00 C -4 0 D 3-3 0 E 4 - F 5 -

Signed Number Representation in s Complement Form: If the most significant bit (MSB) is 0 (most significant hex digit 0 7), then the number is positive. Get decimal equivalent by converting number to decimal, and use the + sign. Example for 8 bit number: 3A 6 > + ( 3 x 6 + 0 x 6 0 ) 0 + ( 3 x 6 + 0 x ) 0 + 58 0 If the most significant bit is (most significant hex digit 8 F), then the number is negative. Get decimal equivalent by taking s complement of number, converting to decimal, and using sign. Example for 8 bit number: A3 6 > - (5D) 6 - ( 5 x 6 + 3 x 6 0 ) 0 - ( 5 x 6 + 3 x ) 0-93 0 One s complement table makes it simple to finding s complements To take two s complement, add one to one s complement. Take two s complement of D0C3: F3C + = F3D

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 ) Limit number of digits to specified word size. 4 bit word: 0 + 0 000 Keep only 4 bits in answer, carry is set ) It does not matter if numbers are signed or unsigned the mechanics are the same Do the operation, then determine if carry and/or overflow bits are set. 4 bit word: 0 Neg + 00 Neg 00 Pos Keep only 4 bits in answer, overflow is clear Condition Code Register (CCR) gives information on the result of last operation Condition Code Register 8 FFs C Carry : > last operation generated a carry V Overflow : > last operation generated an overflow Z Zero : > result zero, 0 > result not zero N Negative : most significant bit of result I Interrupt mask H Half carry X Interrupt mask S Stop disable

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, consider the following instruction sequence: aba ; Add B to A staa $0900 ; Store A in address $0900 The ABA instruction will change the H, N, Z, V and C bits of the CCR. The STAA instruction will change the N and Z bit, and clear the V bit. After the two instructions, the H and C bits will reflect the result of the ABA instruction; the N and Z bits will reflect the result of the STAA instruction (was the number stored negative or zero?), and the V bit will be 0. Overflow occurs only under certain addition and subtraction operations 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.