CS-280 Dr. Mark L. Hornick 1 ASCII table. 2 Displaying Numbers as Text Problem: display numerical values as text Consider the numerical value 0x5A held.

Slides:



Advertisements
Similar presentations
Number Systems and Codes
Advertisements

Computer Structure - Computer Arithmetic Goal: Representing Numbers in Binary  Base 10 (decimal) - Numbers are represented using 10 numerals: 0, 1, 2,
Overview Program in LC-3 machine language Use the Editor
Some thoughts: If it is too good to be true, it isn’t. Success is temporary. It is hard work to make it simple. Knowing you did it right is enough reward.
1 Representing Numbers Using Bases Numbers in base 10 are called decimal numbers, they are composed of 10 numerals ( ספרות ) = 9* * *10.
Overview Review Trap Instruction Program in LC-3 machine language Use LC-3 Simulator.

Chapter 6 Programming in Machine Language The LC-3 Simulator
Introduction to Computing Systems (1st Exam). 1. [10] What is the range of decimal integers that can be represented by the following given numbers of.
©Brooks/Cole, 2003 Chapter 2 Data Representation.
Table 1. Software Hierarchy Levels.. Essential Tools An assembler is a program that converts source-code programs into a machine language (object file).
Data Representation in Computers
Lab #2 Hints. CMPE12cCyrus Bazeghi 2 Want to produce ASCII table Needs to be in a form like: DecHexOctChar
4-Bit Binary-to-BCD Converter: case Statement
ASCII & Gray Codes.
Binary Numbers.
CODING SYSTEMS CODING SYSTEMS CODING SYSTEMS. CHARACTERS CHARACTERS digits: 0 – 9 (numeric characters) letters: alphabetic characters punctuation marks:
Hexadecimal and ASCII Lesson Objective: Understand the purpose of ASCII and how to use it. Lesson Outcome: Convert between Hexadecimal and ASCII Convert.
Writing an Assembly-language program Atmel assembly language CS-280 Dr. Mark L. Hornick 1.
Chapter 2 Data Representation. Define data types. Visualize how data are stored inside a computer. Understand the differences between text, numbers, images,
COMT 222 Tools for a Digital World. Digital? What makes information Digital? If it helps:  When is information not analog? Answer:  A finite number.
Aloha Aloha What you see: What the computer sees: binary number columns binary number columns
The Digital Codes.
EX_01.1/46 Numeric Systems. EX_01.2/46 Overview Numeric systems – general, Binary numbers, Octal numbers, Hexadecimal system, Data units, ASCII code,
Binary, Decimal and Hexadecimal Numbers Svetlin Nakov Telerik Corporation
Title NUMERIC SYSTEMS USED IN NETWORKING NUMERIC SYSTEMS USED IN NETWORKING.
CS-280 Dr. Mark L. Hornick 1 Programming for the LCD Display.
EE3A1 Computer Hardware and Digital Design Lecture 5 Testbenches and Memories in VHDL.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.
Chapter 2 Data Representation.
©Brooks/Cole, 2003 Chapter 2 Data Representation.
Number Bases and Representation. Denary Number System (Base 10) Our number system uses 10 digits (0-9) As you move from right to left each number is worth.
CIS 020 Assembly Programming Chapter 11 - Binary Operations Using RX-Format Instructions © John Urrutia 2012, All Rights Reserved.5/27/20121.
Binary01.ppt Decimal Decimal: Base 10 means 10 Unique numerical digits ,00010,000 Weight Positions 3,
Springfield Technical Community College Center for Business and Technology.
Introduction to Microprocessors Chapter 2. Decimal or Base 10 Numbers  Have ten different digits (0-9)  It is a weighted number system. Each position.
CS 111 – Sept. 1 Intro to data representation Binary numbers –Convert binary  decimal –Convert decimal  binary Text –ASCII and Unicode Commitment: –For.
Chapter 3 The Power of HEX Finding Slivers of Data.
Lecture Objectives: 1)Explain the relationship between miss rate and block size in a cache. 2)Construct a flowchart explaining how a cache miss is handled.
Agenda Character representation Numerical Conversions ASCII EBCDIC
Department of Electronic & Electrical Engineering Seven segment display Subroutines.
Department of Electronic & Electrical Engineering Lecture 2 ● Introduction to IO ● Using a subroutine ● Driving a 7seg display.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.
Introduction to Number Representation A451 GCSE Computing.
1 Bits, Bytes, Binary & Hex CIS TAG ▪ Byte Bit.
Department of Electronic & Electrical Engineering Lecture 3. ● Template program. ● Introduction to IO ● PORTA PORTB TRISA TRISB ● Using a subroutine ●
CC410: System Programming Dr. Manal Helal – Fall 2014 – Lecture 10 – Loaders.
Base 16 (hexadecimal) Uses the decimal digits and the first letters of the alphabet to encode 4 binary bits (16=2 4 ) abcdef or ABCDEF.
Writing an Assembly-language program MIPS assembly language using MARS: MIPS Assembler and Runtime Simulator CS-2710 Dr. Mark L. Hornick 1.
Programming in Machine Language
Data Transfer ASCII FILES.
SE-1021 Software Engineering II
Slide design: Dr. Mark L. Hornick
Binary, Decimal and Hexadecimal Numbers
Chapter 7 LC-2 Assembly Language.
Help! Tell me about Computer Data!
Slide design: Dr. Mark L. Hornick
Presenting information as bit patterns
COMS 161 Introduction to Computing
Chapter 2 Data Representation.
Chapter 1 Number System RGGP, Narwana.
COMS 161 Introduction to Computing
CS334: Memory _ Mars simulator Lab 4(part2-2)
Homework Homework Continue Reading K&R Chapter 2 Questions?
CS 206D Computer Organization
Learning Intention I will learn how computers store text.
ARM Bitwise Logic.
CS334: Number Systems Lab 1.
Binary Lesson 7 Review of Binary and Hexadecimal
Presentation transcript:

CS-280 Dr. Mark L. Hornick 1 ASCII table

2 Displaying Numbers as Text Problem: display numerical values as text Consider the numerical value 0x5A held in a single 8-bit register The string “0x5A” is to be displayed on the LCD

CS-280 Dr. Mark L. Hornick 3 How to do it? Each hex digit represents 4 bits Ex: Numeric value 0x5A in binary is We need to output characters ‘0’, ‘x’, ‘5’, ‘A’ ‘0’ is ASCII character code 0x30 ‘x’ is ASCII 0x78 ‘5’ is ASCII 0x35 ‘A’ is ASCII 0x41 Is there any pattern here?

CS-280 Dr. Mark L. Hornick 4 Pattern? ASCII characters ‘0’-’9’: The ASCII code for ‘0’ is 0x30 = 0x0 + 0x30 The ASCII code for ‘1’ is 0x31 = 0x1 + 0x30 The ASCII code for ‘8’ is 0x38 = 0x8 + 0x30 The ASCII code for ‘9’ is 0x39 = 0x9 + 0x30 ASCII characters ‘A’-’F’ The ASCII code for A is 0x41 = 0xA + 0x37 The ASCII code for B is 0x42 = 0xB + 0x37 The ASCII code for C is 0x43 = 0xC + 0x37 The ASCII code for D is 0x44 = 0xD + 0x37 The ASCII code for E is 0x45 = 0xE + 0x37 The ASCII code for F is 0x46 = 0xF + 0x37

CS-280 Dr. Mark L. Hornick 5 Solution For hex values 0x0 – 0x9 Add 0x30 to convert to ASCII code of corresponding character ‘0’ – ‘9’ For hex values 0xA – 0xF Add 0x37 to convert to ASCII code of corresponding character ‘A’ – ‘F’ Add 0x57 to convert to ASCII code of corresponding character ‘a’ – ‘f’

CS-280 Dr. Mark L. Hornick 6 SWAP Instruction LDIr20, 0x5A; init SWAP r20; swap nibbles After SWAP, r20 contains 0xA5

CS-280 Dr. Mark L. Hornick 7 Converting numeric to ASCII LDIr20, 0x5A; init r20 to a value MOVr21, r20; copy r20 ANDIr21, 0x0F; r21=0x0A after mask MOVr22, r20; copy r20 SWAP r22; r22=0xA5 after swap ANDIr22, 0x0F; r22=0x05 after mask LDIr20, 0x37; ASCII offset for A-F ADDr21, r20; r21 is now 0x41=‘A’ LDIr20, 0x30; ASCII offset for 0-9 ADDr22, r20; r22 is now 0x35=‘5’