Programs & Defining Data Ch.5 – pp. 95-109. Data in Computer Memory See page 69 480 481 482 Byte locations in memory - One character per byte location.

Slides:



Advertisements
Similar presentations
Number Systems and Codes
Advertisements

Assembly Language for Intel-Based Computers, 4 th Edition Chapter 1: Basic Concepts (c) Pearson Education, All rights reserved. You may modify and.
Intro to CS – Honors I Representing Numbers GEORGIOS PORTOKALIDIS
Data Representation COE 202 Digital Logic Design Dr. Aiman El-Maleh
ICS312 Set 2 Representation of Numbers and Characters.
The Binary Numbering Systems
Lecturer: Omid Jafarinezhad Sharif University of Technology Department of Computer Engineering 1 Fundamental of Programming (C) Lecture 2 Number Systems.
Advanced Topics Object-Oriented Programming Using C++ Second Edition 13.
Binary Representation
Number Systems. 2 The total number of allowable symbols in a number system is called the radix or base of the system. Decimal Numbers: radix = 10 (symbols:
Chapter Chapter Goals Know the different types of numbers Describe positional notation.
Chapter 4.2 Binary numbers: Arithmetic
Data Representation in Computers
Chapter 02 Binary Values and Number Systems Nell Dale & John Lewis.
FIGURES FOR CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION
Binary Arithmetic Math For Computers.
Data Representation in Computers. Data Representation in Computers/Session 3 / 2 of 33 Number systems  The additive approach – Number earlier consisted.
Lecture 18 Last Lecture Today’s Topic Instruction formats
Number Systems and Codes
The Binary Number System
Data Representation Number Systems.
(2.1) Fundamentals  Terms for magnitudes – logarithms and logarithmic graphs  Digital representations – Binary numbers – Text – Analog information 
Numeral Systems Subjects: Numeral System Positional systems Decimal
Computers Organization & Assembly Language
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.
How Computers Work Dr. John P. Abraham Professor UTPA.
Click to edit Master title style Click to edit Master text styles –Second level Third level –Fourth level »Fifth level 1 Today’s Topics How information.
IT253: Computer Organization
Lec 3: Data Representation Computer Organization & Assembly Language Programming.
ECEN2102 Digital Logic Design Lecture 1 Numbers Systems Abdullah Said Alkalbani University of Buraimi.
ICS312 Set 1 Representation of Numbers and Characters.
Information Representation. Digital Hardware Systems Digital Systems Digital vs. Analog Waveforms Analog: values vary over a broad range continuously.
CIS 020 Assembly Programming Chapter 07 - Decimal Arithmetic Operations © John Urrutia 2012, All Rights Reserved.5/27/20121.
Chapter 2 Binary Values and Number Systems. 2 2 Natural Numbers Zero and any number obtained by repeatedly adding one to it. Examples: 100, 0, 45645,
Cosc 2150: Computer Organization Chapter 2 Part 1 Integers addition and subtraction.
Number systems, Operations, and Codes
Binary Values and Number Systems
Positional Notation 642 in base 10 positional notation is:
1 Data Representation Characters, Integers and Real Numbers Binary Number System Octal Number System Hexadecimal Number System Powered by DeSiaMore.
EET 250 Number systems. Introduction to Number Systems While we live in a world where the decimal number is predominant in our lives, computers and digital.
EEL 3801C EEL 3801 Part I Computing Basics. EEL 3801C Data Representation Digital computers are binary in nature. They operate only on 0’s and 1’s. Everything.
Data Representation, Number Systems and Base Conversions
CIS 020 Assembly Programming Chapter 11 - Binary Operations Using RX-Format Instructions © John Urrutia 2012, All Rights Reserved.5/27/20121.
Introduction To Number Systems Binary System M. AL-Towaileb1.
CIS 020 Assembly Programming Chapter 08 - Advanced Decimal Arithmetic Instructions © John Urrutia 2012, All Rights Reserved.5/27/20121.
©2010 Cengage Learning SLIDES FOR CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION Click the mouse to move to the next page. Use the ESC key to exit.
Chapter 1 Representing Data in a Computer. 1.1 Binary and Hexadecimal Numbers.
Number Systems. Topics  The Decimal Number System  The Binary Number System  Converting from Binary to Decimal  Converting from Decimal to Binary.
CHAPTER 3 BINARY NUMBER SYSTEM. Computers are electronic machines which operate using binary logic. These devices use two different values to represent.
Number Systems. The position of each digit in a weighted number system is assigned a weight based on the base or radix of the system. The radix of decimal.
Computer Maintenance Numbering Systems Copyright © Texas Education Agency, All rights reserved.1.
Binary Values. Numbers Natural Numbers Zero and any number obtained by repeatedly adding one to it. Examples: 100, 0, 45645, 32 Negative Numbers.
DATA Unit 2 Topic 2. Different Types of Data ASCII code: ASCII - The American Standard Code for Information Interchange is a standard seven-bit code that.
Cosc 2150: Computer Organization
Lecturer: Santokh Singh
Computer Maintenance Numbering Systems Trade & Industrial Education
Number Systems and Codes
NUMBER SYSTEMS.
Lec 3: Data Representation
3.1 Denary, Binary and Hexadecimal Number Systems
Using the Windows Calculator for quick decimal to binary conversions
Number Systems.
Coding Schemes and Number Systems
Variables and Arithmetic Operations
Number Systems and Codes
Numbering System TODAY AND TOMORROW 11th Edition
Number Systems Lecture 2.
Computing in COBOL: The Arithmetic Verbs and Intrinsic Functions
Chapter 3 - Binary Numbering System
Presentation transcript:

Programs & Defining Data Ch.5 – pp

Data in Computer Memory See page Byte locations in memory - One character per byte location 483

Data in Memory G=C7= E=C5= O=D6= R=D9= G=C7= E=C5= =F3= =F4= The characters shown in memory are really made up of binary digits (bits) as depicted to the right. In a mainframe computer, the bits are configured as EBCDIC whereas in a PC, the bit configurations are different, in ASCII. Are you comfortable with ASCII and EBCDIC? Are you comfortable with binary/hexadecimal data configurations? If not, check out your textbook on pages: in Ch.4

DecimalBinaryHex A B C D E F Hexadecimal conversion chart – the same as shown in your text on page 70. Representing Data 1 Character = 1 Byte = 2 Hex Digits

Representing Character Data Left justified - padded with blanks (40) - truncated to the right Example: GEORGE=C7 C5 D6 D9 C7 C5

Define Storage / Constant

Defining Storage Reserve Storage with no initialization See Data Definitions topic beginning p.103 Used to allow a symbolic name for an area of memory symbolicname DS definition 1-8 alphanumeric characters 1 st must be alphabetic 1. Duplication factor 2. Type code 3. Length

Defining Storage Example Output buffer area that will be printed – allows each sub-field to be identified and accessed symbolically and the entire area can also be accessed as OWKAREA. Example: MOVEOWKPRICE,INVCOST*MOVE COST TO PRICE MOVEOWKONHND,INVHAND*MOVE ONHAND TO ONHAND PUTOUTFILE,OWKAREA*PRINT ENTIRE O/P RECORD p. 103

The numbers within the orange boxes represent the field lengths in bytes. The labels represent the subfield name (statement label). The entire field (made up of 7 subfields) constitutes the output buffer. Each subfield can be manipulated, then accessed together and in the same order as parts of OWKAREA

And the Memory Reserved? UNPK OWKPRICE(5),PPRICE Print from OWKAREA

Another Example?

Initializing Storage Areas Define Constants – DC, rather than DS ABCDCC’ABC’C1 C2 C3 DSIGNDCC’$’5B NO3DCC’3’F3 NAMEDCC’JOE’D1 D6 C5 TAXRTDCC’28’F2 F8

Example (w/instructions) CALCPACKRATE(4),TAXRT PACKTAXAMT(6),TOTINC MPTAXAMT(6),RATE UNPKINCTAX(8),TAXAMT(6) ….. RATEDSF TAXRTDCCL2’20’*F2 F0 TAXAMTDSPL6 TOTINCDCCL’40000’*F4 F0 F0 F0 F0 INCTAXDSCL8

Other Data Types [label]DS/DCCcharacter Xhex Ppacked dec. Bbinary Ffullword (bin) Hhalfword (bin) Ddoubleword

Representing Zoned Decimal Numbers are left justified, also padded to the right with blanks (same as character data) 1234=F1 F2 F3 F4 F1 F2 F3 C4 Feb. 8, 2007

Representing Packed Decimal Right justified, padded with leading zeroes +1234= C -1234= D The top value is positive and the sign character is the right-most part of the value in memory. The lower value is negative. Notice the difference in the sign character.

Representing Binary Data 1 byte = 8 binary digits (bits) (B6) Halfword = 2 bytes Fullword = 4 bytes The top value, defined as binary digits with length of 2 bytes in memory appears just as the value appears in the DC operand (but with 8 bits of leading 0’s as padding). On the other hand, when defined as a fullword (also binary), in memory, the 1-bits are no different, but there would be 4 bytes instead of 2 bytes – ‘ ’

Convert Binary to Decimal = 809 Assign positional values to each binary digit beginning on the right – right-most bit is 2º, next bit to the left is 2 1, then 2 2, and so forth. Then simply add up the equivalent decimal values where there are 1-bits in the binary field above.

Use the Scientific Calculator Calculators are found under the Accessories menu when you ‘click’ on the START button in the lower left corner of your screen. For the Scientific Calculator, click on the VIEW menu in the Calculator Window and choose ‘Scientific’ … Enter your DEC number, then ‘Click’ the BIN button to convert Dec  Bin

Convert Decimal to Binary Use the table on the top of page 75 that shows converting hex to decimal, but use it in reverse. Example: convert to hex Using entire table, find smallest number less than the number you are attempting to convert which is 12,228 which is hex 3000 (in Byte 3 in left-hand column). Record the Hex value on your piece of paper…3000. Subtract 12,228 from the original number – which is 2890 Find next smallest number again in the next column to the right (2816). Record the Hex value … B00 And so on until you are at the far right column (64 and 10). Record the Hex values … 40 and A 3B4A in hex is in binary answer. Or use the Scientific Calculator See the process on the next slide 

HexDecHexDecHexDecHexDecHexDec ,53614, ,07228, ,608312, ,144416,38441, ,880520,48051, ,216624,57661, ,752728,67271, ,288832,76882, ,824936,86492, A655,360A40,960A2,560A160A10 B720,896B45,056B2,816B176B11 C786,432C49,152C3,072C192C12 D851,968D53,248D3,328D208D13 E917,504E57,344E3,584E224E14 F983,040F61,440F3,840F240F = A A 15,178 = B

Or - Convert Doing the Arithmetic / 16 = Remainder.625 is integer.625 X 16 = 10 (A) 948 / 16 = Remainder.25 is integer.25 X 16 = 4 (4) 59 / 16 = Remainder.6875 is integer.6875 X 16 = 11 (B) 3/16 = Remainder.1875 is integer.1875 X 16 = 3 (3) Using result in reverse order = 3B4A

Converting Zoned to Packed Decimal Use the PACK instruction (p.84 & 85) Read a number from an input file. It is now in memory in zoned- decimal format – you cannot do arithmetic on it, so PACK it first (PACK removes the zones) PACK removes all the zones except the right-most, then reverses the right-most byte See examples on the next slide 

Book Examples ReceivingSending Before: F1 F2 F3 F4 F5 After: FF1 F2 F3 F4 F5 Before:00 00 F2 F6 F4 F8 After: FF2 F6 F4 F8 Before:00 F6 F3 F2 F0 F4 After:20 4FF6 F3 F2 F0 F4 p. 84/85 PACKRECEIVING,SENDING

Converting Packed to Zoned Decimal Use the UNPK instruction (p. 85) You have completed performing arithmetic on a value and you wish to print it – packed decimal data is not printable UNPK puts zones back in the numbers and reverses the two right-most characters. See examples on the next slide 

Book Examples ReceivingSending Before: F After:F5 F6 F4 F3 F F Before: C After:F0 F0 F0 F3 C403 4C Before: D After:F1 D D p. 85 UNPKRECEIVING,SENDING

Quick Review of Data ZD=F2 F0 F5 F5 F9 F7 F4 F7 F4 PD= F Hex=0C 41 2B 22 Bin= p. 76

Instruction Formats Page 76 - bottom

Instruction Lengths 2 addresses – sending and receiving fields M2

Sending and Receiving Fields (A Reminder) ReceivingSending Before:F0 F4 F3 F9 F9F0 F0 F7 F0 F1 After:F0 F0 F7 F0 F1 See page 77 at the top

A Typical 6-byte Instruction

Sample 4-byte Instruction

And A 2-byte Instruction

Decimal Arithmetic Add Decimal APM1(L1),M2(L2)6-byte format M1(L1)M2(L2) Before: F01 0F After: C01 0F Before: F F After: C F In the 2 nd Add: high-order digit overflowed and lost

Decimal Arithmetic Subtract Decimal SPM1(L1),M2(L2)6-byte format M1(L1)M2(L2) Before: F75 0F After: C75 0F

Decimal Arithmetic Multiply Decimal MPM1(L1),M2(L2) –L1 has a max length of 16 bytes –L2 has a max length of 8 bytes M1(L1)M2(L2) Before: C50 0F After: C50 0F

Decimal Arithmetic Divide Decimal DPM1(L1),M2(L2)6-byte format M1(L1)M2(L2) Before: C00 7C After: C 00 4C00 7C Quotient Remainder – length of divisor Before the instruction is executed, M2 is the divisor, M1 is the dividend. L1 and L2 are the lengths of each

Decimal Arithmetic Zero-And-Add Packed ZAPM1(L1),M2(L2)6-byte format More like a Move instruction than an Add Instruction M1(L1)M2(L2) Before: C1C After: C1C