0% found this document useful (0 votes)
25 views77 pages

Assembler Unit2

The correct answer is A. General Purpose Registers (GPRs). GPRs are of the most interest to programmers and are used as part of the address for all storage operands and as accumulators and work areas in performing fixed-point arithmetic. Floating point, vector, and control registers are used for more specialized purposes.

Uploaded by

Zeca Sanches
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views77 pages

Assembler Unit2

The correct answer is A. General Purpose Registers (GPRs). GPRs are of the most interest to programmers and are used as part of the address for all storage operands and as accumulators and work areas in performing fixed-point arithmetic. Floating point, vector, and control registers are used for more specialized purposes.

Uploaded by

Zeca Sanches
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 77

Assembler Programming Introduction

Assembler Programming Introduction

UNIT Memory Usage

Topics:
 Hardware Components

 Numbering Systems

 Numeric Conversions

 Data Representation

Page 2 of 77
Assembler Programming Introduction
Unit: Memory Usage

Unit Introduction

When you program in Assembler Language, you are dealing much more closely with the actual computer
hardware than if you were programming in a High Level Language. The Assembler Language programmer
must be intimately acquainted with the computer’s hardware components and how they interact, in order to
write correct, efficient programs.

This unit covers:


• Computer hardware
• Numbering systems
• Converting between numbering systems and data representation

Introduction Page 3 of 77
Assembler Programming Introduction
Unit: Memory Usage

Unit Objectives

At the end of this unit, you will be able to:

• Describe how an Assembler program uses main storage

• Describe the kinds of registers used in the architecture

• Convert numbers between decimal, binary and


hexadecimal systems

• Add and subtract in binary and hexadecimal

• Describe how characters and numbers are stored within


S/390 architecture

Introduction Page 4 of 77
Assembler Programming Introduction

UNIT Memory Usage

Topics:
 Hardware Components

 Numbering Systems

 Numeric Conversions

 Data Representation

Page 5 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Hardware Components

Topic Objectives

At the end of this topic, you will be able to:

• Describe the functions of main storage

• Describe the kinds of registers used in the architecture

• Define a General Purpose Register (GPR) and Program


Status Word (PSW)

Introduction Page 6 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Hardware Components

Main Storage / Memory

What is main storage?

Main storage, or memory, is the location where


programs and data must reside in order to
execute. Main storage contains the programs
and data that are part of the operating system,
and the programs and data that are part of your
program.

What is a byte?
11010010 00001111 01000000 00001000 00011000 00011000
The memory is made up of individual binary
digits or bits. Bits are grouped into units of 8 bits,
called a byte. The byte is the basic unit of

OPERANDS
OP CODE

addressability in the hardware.


BIT NUMBER

11 00 10 10
01 23 45 57
Byte 0 Byte 1 Byte n

Concepts Page 7 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Hardware Components

Main Storage

Modern operating systems such as MVS, are


Virtual Storage:
designed so that “real main storage” is shared
between many users. Only the current executable
portions of the program and data for each user
are present in storage at any point of time.
MVS
The programmers view, however, is of virtual
storage. The whole Assembler program space
resides in virtual storage, in addresses that are
continuous from the start to the end of the
program space. 2 GB
User Area

Program A

Concepts Page 8 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Hardware Components

Registers

What are registers?

Registers are another location where operands GPR – Used by the


General Purpose
reside in an Assembler Language program. There Programmer for Storage
Registers (GPRs)
Address, Accumulator
are several registers in the architecture. and Work Area.

Types of registers in the architecture are:


Floating - Point FPR – Performs Floating
Registers (FPRs) Point Arithmetic.
• General Purpose Registers (GPRs)
• Floating Point Registers (FPRs)
• Control Registers Control Registers and
Control Registers Access Registers –
• Access Registers Used by the Operating
• Vector Registers System.
Access Registers

Vector Registers – Used


Vector Registers for advanced math
calculations

Concepts Page 9 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Hardware Components

General Purpose Registers

What are General Purpose Registers (GPRs)?


General Purpose Registers
GPRs are of the most interest to programmers.
There are 16 general purpose registers (GPRs),
numbered from 0-15. They are referred to with a
prefix of R (R0, R1, R2…. R15). R0 R1 R15

The GPRs are 32 bits in length and can hold


fixed-point values between -2, 147, 483, 648, and
+2, 147, 483, 647.
0 BITS 31
GPRs are used as:
• Part of the address for all storage
operands 1 byte 1 byte 1 byte 1 byte
• As accumulators and work areas in
performing fixed-point arithmetic

Concepts Page 10 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Hardware Components

Program Status Word

What is a Program Status Word (PSW)?

The Program Status Word is a hardware location


where the current status of the Central C P CC
Program
0000 0000
Mask
Processing Unit (CPU) is represented. It is a
register that is of particular interest to the
Assembler Language programmer. 0 8 12 18 20 24 31

Amongst other fields, the PSW contains:

• The address of the next instruction to be 0000 0000 Instruction Address


executed
• The current value of the condition code
(CC) 32 40 63
• Other flags, such as the one to indicate
whether the CPU is in problem state or
supervisor state
Program Status Word (EC Mode)

Concepts Page 11 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Hardware Components

Are We on Track?

Which of the following registers do applications programs use?

A. General Purpose Registers

B. Floating Point Registers

C. Vector Registers

D. Control Registers

Review Page 12 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Hardware Components

Are We on Track?

GPRs are ______________ bits in size.

Review Page 13 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Hardware Components

Glossary

Virtual Storage – Memory that appears to an application to be larger and more uniform than it is.
Virtual storage may be partially simulated by secondary storage such as a hard
disk. Applications access memory through virtual addresses, which are translated
(mapped) by special hardware and software into physical addresses.

Problem State – A CPU state, determined by a bit in the Program Status Word (PSW), in which only
non-privileged instructions may be executed.

Floating-point – A numeric format that can be used to represent very large real numbers and very
small real numbers. Floating-point numbers are stored in two parts, a mantissa and
an exponent. The mantissa specifies the digits in the number, and the exponent
specifies the magnitude of the number.

Floating-Point
Arithmetic – Arithmetic performed on floating-point numbers.

Supervisor State – A CPU state, determined by a bit in the Program Status Word (PSW), in which both
privileged and non-privileged instructions may be executed.

Glossary Page 14 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Hardware Components

Topic Summary

Now that you have completed this topic, you should be able to:

• Describe the functions of main storage

• Describe the kinds of registers used in S/390


architecture

• Describe a General Purpose Register (GPR) and


Program Status Word (PSW)

Summary Page 15 of 77
Assembler Programming Introduction

UNIT Memory Usage

Topics:
 Hardware Components

 Numbering Systems

 Numeric Conversions

 Data Representation

Page 16 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Numbering Systems

Topic Objectives

At the end of this topic, you will be able to:

• Define and understand Base Value

• Define binary and hexadecimal numbers

• Convert binary and hexadecimal numbers to decimal


numbers and vice versa

Introduction Page 17 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Numbering Systems

Number System

Although most people are comfortable using the


decimal number system for doing arithmetic, Number System Example
computers are however binary devices, based on
elements which have two states, represented by
the numbers 0 (off) and 1 (on). Decimal 1234

While the HLL programmer does not often have to


work with non-decimal numbers, the Assembler
Language programmer does.
Binary 0110
The Assembler Language programmer also has
to be aware of hexadecimal or base 16 numbers.

Hexadecimal 2E3

Concepts Page 18 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Numbering Systems

Base Value

What is base value?

Every number system has some base value. The


base value of the decimal system is 10. To
represent numbers in a number system of base n,
there must be n unique symbols.

Continued…
Concepts Page 19 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Numbering Systems

Base Value (cont’d)

To represent numbers equal to or greater than the


base, more than one digit is required. 2 4 1
2 1 0
10 10 10
To represent the number ten in decimal, we use
the two digits 10. To represent the number two
Ones
hundred and forty one, we use the three digits 1X1=1
241. What does 241 mean? It means 2 times 100
plus 4 times 10 plus 1.

Tens
4 X 10 = 40

Hundreds
2 X 10 X 10 = 200

So 241= (2*10*10) + (4*10) + (1*1)


Continued…
Concepts Page 20 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Numbering Systems

Base Value (cont’d)

The number 241 can be represented as


(2*102) + (4*101) + (1*100)
2 4 1

To determine the value of a number proceed as


follows:

0
1. Multiply the digit in the rightmost position 1 X 10
by the base raised to power 0, which is 1
2. Add the next leftmost digit multiplied by
the base raised to the power 1, which is
the base
1
3. Add the next digit multiplied by the base 4 X 10
raised to the power of 2 etc., until we run
out of digits

2
2 X 10

Concepts Page 21 of 77
Assembler Programming Introduction
Unit: S/390 Memory Usage Topic: Numbering Systems

Are We on Track?

How many unique symbols are used in the octal (base 8) number system?

A. 2

B. 7

C. 8

D. 9

Review Page 22 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Numbering Systems

Binary Numbers

What are binary numbers?

Binary numbers are numbers represented using


the base 2. Base 2 numbers are represented with 1 0 1 1
(23) (22) (21)
only 2 unique symbols, 0 and 1. The only values (20)
that can be represented with a single binary digit
(or bit) are 0 and 1.
ones

twos

fours

eights

Continued…
Concepts Page 23 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Numbering Systems

Binary Numbers (cont’d)

What decimal value does the binary number


101101 represent ?

To determine this, we can rewrite the number to


represent its meaning more clearly.
1011012 (Binary Value)

= (1 X 25) + (0 X 24) + (1 X 23) + (1 X 22)


+ (0 X 21) + (1 X 20)
= (1 X3210) + (0 X 1610) + (1 X 810) +
(1 X410) + (0 X 210) + (1 X 1)
= 3210 + 810 + 410 + 110

= 4510 (Decimal Value)

A subscript coded after a


number represents its base.

Concepts Page 24 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Numbering Systems

Converting Binary to Decimal Value

Once we get used to using binary notation, it is


easy to convert binary values back to the 1 0 1 1 0 1
equivalent decimal value.

1 X 20 = 10 +

0 X 21 = 0 +

1 X 22 = 4 +

1 X 23 = 8 +

1 X 24 = 0 +

1 X 25 = 32 = 4510 (DECIMAL VALUE)

Remember – Digit positions, from right


to left, represent the values 1,2,4,8,16,
32, 64 and so on.
Continued…
Concepts Page 25 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Numbering Systems

Converting Binary to Decimal Value (cont’d)

In 45 10 = 101101 2 , the value of the number


is the same but, the notation and the base are
different.

4510
= 1011012

Concepts Page 26 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Numbering Systems

Are We on Track?

What is the decimal equivalent of 110112?

A. 20

B. 27

C. 23

D. 26

Review Page 27 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Numbering Systems

Are We on Track?

Match the binary values with their decimal equivalents.

1. 10112 A. 1510

2. 10002 B. 510

3. 11112 C. 1110

4. 01012 D. 810

Review Page 28 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Numbering Systems

Binary System - Limitations

The binary system is important because it is the


way the computer represents numbers internally.
The binary system is difficult to work with large
values, since the number of digit positions 00002 = 010

become very large. As a result, we often use


1011012 = 4510
hexadecimal notation as an alternative to binary
to represent numbers.
1110010002 = 35610
The number 4510 required 6 binary digits to
represent it. The largest 4 digit decimal number, 111100111012 = 92510
9999, requires 14 binary digits. It is difficult to deal
with representations this long without making
100111100011112 = 999910
errors.

Concepts Page 29 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Numbering Systems

Using Hexadecimal Numbers

The symbol A16 is equivalent to 10, B is 11, C is


12, D is 13, E is 14 and F is 15. Since 16 (the BINARY HEXADECIMAL DECIMAL
base of hexadecimal numbers) is 24, there is a 0000 0 0
close equivalent between binary and hexadecimal 0001 1 1
notations. 0010 2 2
0011 3 3
0100 4 4
0101 5 5
0110 6 6
0111 7 7
1000 8 8
1001 9 9
1010 A 10
1011 B 11
1100 C 12
1101 D 13
1110 E 14
Each hexadecimal digit is equal to 4 1111 F 15
binary digits. See these equivalencies
in the table.
Concepts Page 30 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Numbering Systems

Conversion between Binary and Hexadecimal

These equivalencies between binary and


hexadecimal make conversion between these two
bases almost trivial. Assembler language
programmers should be able to perform the
conversions represented in this table almost
without thinking. 1100 C

0100 4

1111 F

Concepts Page 31 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Numbering Systems

Are We on Track?

Which of the following are true?

A. The hexadecimal number system uses 16 unique symbols to represent numbers.

B. The hexadecimal digit C is equivalent to 13 decimal.

C. The hexadecimal number A00 is equal to 10 * 163 in decimal.

D. Values greater than 1510 need more than one digit in their hexadecimal representation.

Review Page 32 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Numbering Systems

Are We on Track?

The binary value of 10011101 is represented in hexadecimal as _____________.

Review Page 33 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Numbering Systems

Converting Binary, Hexadecimal to Decimal

In the case of binary to hexadecimal, group the


binary digits into groups of four, starting at the Hexadecimal
right and replace each group of 4 binary digits by
the corresponding hexadecimal digits. You may C 4 F
have to add some leading zeroes to the left most
group to get up to four bits.

1111

0100

Binary
1100

Continued…
Concepts Page 34 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Numbering Systems

Converting Binary, Hexadecimal to Decimal (cont’d)

Converting between decimal and the other two


bases is a little more complex.

To convert binary or hexadecimal to decimal,


simply multiply each hexadecimal or binary digit Binary to Decimal
by the decimal value of its position and add the
products. 101011012 = 1 + 4 + 8 + 32 + 128
= 17310

Hexadecimal to Decimal

2 AC16 = (2 X 162) + (10 X 161) + (12 X 160)


= 512 + 160 +12
= 68410

Concepts Page 35 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Numbering Systems

Converting from Decimal to Binary and Hexadecimal

83(10) =

1 1 Divide 1 by 2 giving a quotient of 0 and a remainder of 1. 1 is the seventh rightmost digit. Since the
quotient is now zero, we stop.

0 0 Divide 2 by 2 giving a quotient of 1 and a remainder of 0. 0 is the sixth rightmost digit.

1 1 Divide 5 by 2 giving a quotient of 2 and a remainder of 1. 1 is the fifth rightmost digit.

0 0 Divide 10 by 2 giving a quotient of 5 and a remainder of 0. 0 is the fourth rightmost digit.

0 0 Divide 20 by 2 giving a quotient of 10 and a remainder of 0. 0 is the third rightmost digit.

1 1 Divide 41 by 2 giving quotient of 20 and a remainder of 1. 1 is the second rightmost digit.

1 1 Divide 83 by 2 giving quotient of 41 and a remainder of 1. 1 is the rightmost digit of the result.

Such conversions are performed generating one digit at a time, right to left by successive divisions by the
desired base.
Example: To convert 83 decimal to binary we would proceed as follows. We form the binary number from the
digits we have extracted. Thus 8310 = 10100112
Continued…
Concepts Page 36 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Numbering Systems

Converting from Decimal to Binary and Hexadecimal (cont’d)

Conversion from decimal to hexadecimal works in


a similar manner, only now the divisor is 16, which Decimal to Hex
is the base of hexadecimal numbers.

Example: 1205(10) =
To convert 1205 decimal to hexadecimal proceed
as follows. Form the hexadecimal numbers from 4 4 Divide 4 by 16 giving a quotient of 0 and a
remainder of 4.4 is the third rightmost digit
the digits that have been extracted. Thus
120510 = 4B516
B Divide 75 by 16 giving a quotient of 4 and
B a remainder of 11.B is the third rightmost
digit

5 Divide 1205 by 16 giving a quotient of 75


5 and a remainder of 5.5 is the rightmost
digit of the result

Concepts Page 37 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Numbering Systems

Conversion Table

The manual process can be disregarded if the


programmer is in possession of a calculator with
the capability of performing binary to decimal to
hexadecimal conversions.

A table of conversion factors can also save time.

Concepts Page 38 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Numbering Systems

Are We on Track?

To convert decimal numbers to hexadecimal, divide the decimal number by _______________ ,


record the remainder and continue division with the quotient.

Review Page 39 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Numbering Systems

Are We on Track?

Which of the following are equal to decimal 20?

A. 1416

B. 267

C. 346

D. 101002

Review Page 40 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Numbering Systems

Topic Summary

Now that you have completed this topic, you should be able to:

• Define and understand Base Value

• Define binary and hexadecimal numbers

• Convert binary and hexadecimal numbers to decimal


numbers and vice versa

Summary Page 41 of 77
Assembler Programming Introduction

UNIT Memory Usage

Topics:
 Hardware Components

 Numbering Systems

 Numeric Conversions

 Data Representation

Page 42 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Numbering Conversions

Topic Objectives

At the end of this topic, you will be able to:

• Understand simple binary and hexadecimal arithmetic

• Add and subtract with binary and hexadecimal numbers

Introduction Page 43 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Numbering Conversions

Binary Addition

The Assembler Language Programmer will


sometimes be required to do simple arithmetic
with binary and hexadecimal numbers. The
methodology of doing addition and subtraction is
the same as with decimal numbers, except that
the base is different. CCCC

1001011
Example:
First add two binary numbers: + 101101
1001011 1111000
+101101
--------------

In arithmetic addition, a carry occurs when


the sum of a specific position exceeds the
base minus one.

Concepts Page 44 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Numbering Conversions

Hexadecimal Addition

B Finally, 0 + 3 + 8 = B. Record the final digit.


B
36B5 + 83C7 = BA7C. Thus 36B516 + 83C7 = BA7C16

A In the next position 1 + 6 + 3 = A. Record the A and carry 0.


A Carry 0 A in hex represents a 10.
36B5 + 83C7 = A7C

7 In the next rightmost position 0 + B + C = 17. Record the 7 and carry the 1.
Carry 1 36B5 + 83C7 = 7C
7 B + C = 23 which in base 16, can be represented by a 7 for a total of 7 past the base 16(16 + 7 = 23)
and carry the one which is the base 16.

C Again we start in the rightmost position. 5 + 7 = C. Record the C and carry 0.


C Carry 0 36B5 + 83C7 = C
5 + 7 = 12 which in hex is represented by a C.

Example:

Look at an example of hexadecimal addition: 36B5 + 83C7

Concepts Page 45 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Numbering Conversions

Are We on Track?

What is the sum of the following binary numbers?

100101102 + 1110012 = ____________________

Review Page 46 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Numbering Conversions

Are We on Track?

What is the sum of the following hexadecimal numbers?

BC3716 + 179416 = __________________

Review Page 47 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Numbering Conversions

Subtraction in Binary

Subtraction in binary and hexadecimal is


performed similar to decimal subtraction, but
remembering that when having to borrow, the
value borrowed is the base.

Example:
10100110
10100110
- 1101001
-1101001
--------------- 111101
111101

Continued…
Concepts Page 48 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Numbering Conversions

Subtraction in Hexadecimal

Example:

C5E6
-2D47
------------
989F
C5E6
- 2D47
989F

Concepts Page 49 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Numbering Conversions

Are We on Track?

To borrow in subtraction subtract 1 from the digit position n+1 and add the ___________
value to position n.

Review Page 50 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Numbering Conversions

Are We on Track?

What is the difference when subtracting the following hexadecimal numbers?

D08C16 - 531616 = ________________

Review Page 51 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Numbering Conversions

Glossary

Binary Numbers – A number expressed in binary form, having 2 as its base, so values are expressed
as combinations of digits 0 and 1. These two digits can represent the logical
values true and false as well as numerals.

Glossary Page 52 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Numbering Conversions

Topic Summary

Now that you have completed this topic, you should be able to do:

• Simple binary and hexadecimal arithmetic

• Addition and subtraction with binary and hexadecimal


numbers

Summary Page 53 of 77
Assembler Programming Introduction

UNIT Memory Usage

Topics:
 Hardware Components

 Numbering Systems

 Numeric Conversions

 Data Representation

Page 54 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Data Representation

Topic Objectives

At the end of this topic, you will be able to:

• Describe Data Representation. Understand EBCDIC

• Describe different kinds of arithmetic instructions –


Fixed-Point arithmetic and Floating-Point arithmetic

• Describe types of decimal numbers – Packed and Zoned


decimal

Introduction Page 55 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Data Representation

Data Representation

How is data represented?

Contents of main storage consist of, at the lowest


level of just binary digits (bits) grouped into 8 bit
units called bytes. However, all data is encoded Name 1.0083
and must be interpreted according to its type.

Data representing textual information is


represented differently than data representing
decimal or fixed point numbers.

Continued…
Concepts Page 56 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Data Representation

Data Representation (cont’d)

In S/390 architecture characters are


represented using the Extended Binary Coded
Decimal Interchange Code (EBCDIC).

Each character is represented by one byte code,


a combination of eight bits.

Many printers and terminals are built to convert


EBCDIC data into display characters.

EBCDIC is a different code from ASCII,


which is used in many other computer
architectures.
Concepts Page 57 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Data Representation

EBCDIC Representation

The table shown here shows some of the more


common characters, and their EBCDIC
representation, expressed in hexadecimal.

LETTERS DIGITS

A C1 0 F0
B C2 1 F1
C C3 2 F2
3 F3
SPECIAL CHARACTERS 4 F4
5 F5
$ 5B 6 F6
/ 61 7 F7
% 6C 8 F8
9 F9

Continued…
Concepts Page 58 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Data Representation

EBCDIC Representation (cont’d)

The EBCDIC representation of the string "System


/390" would be the hexadecimal string
E2A8A2A385944061F3F9F0.

It is highly desirable for the Assembler Language


programmer to have a reference card containing
all the characters and their representation in the
EBCDIC code. Most experienced Assembler
Language programmers have memorized the
codes for the most common characters.

Concepts Page 59 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Data Representation

Are We on Track?

What is the acronym for EBCDIC?

A. Extended Binary Coded Decimal Interchange Code

B. Enhanced Binary Coding for Decimal Integers and Characters

C. Exceptional Basis for Corporate Data Information Coding

D. Exemplary Binary Coding Defined for Integrated Computers

Review Page 60 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Data Representation

Are We on Track?

What would be the EBCDIC representation of ‘CAB’?

A. C1C2C3

B. C2C3C1

C. C3C1C2

D. C3C2C1

Review Page 61 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Data Representation

Arithmetic Instructions

Although EBCDIC represents numbers in


character form, it cannot be used for arithmetic
operations.

Fixed Point
What are the kinds of arithmetic instructions? 0111111111111111
(Binary)

Fixed-Point (Binary) arithmetic and Decimal


arithmetic are integer based, handling only whole
numbers . Floating-Point arithmetic handles real
Decimal:
numbers, numbers with fractional portions. Zoned Decimal
F3F2F7F6C7
32767C
Packed Decimal

Floating Point: 278.31924

Briefly look at each of the types and how it


is used to represent numeric values.

Concepts Page 62 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Data Representation

Fixed-Point Arithmetic

What is Fixed-Point arithmetic?


0 2
Fixed-Point arithmetic uses three data types: HALF HALFWORD = 2 bytes
• Full words – sometimes called a word, is
four bytes (32 bits) in length 2 bytes x 8 Bits = 16 Bits
• Half words – 2 bytes (16 bits) in length 0 4
• Double words – 8 bytes (64 bits) in FULL
FULLFWORD = 4 bytes
length
4 bytes x 8 Bits = 32 Bits
What do fixed-point numbers consist of?
0 8

Fixed-point numbers consist of two parts, a sign DOUBLE


and a magnitude. The sign is in the leftmost, or 8 bytes x 8 Bits = 64 Bits DOUBLEWORD = 8 bytes
high-order bit, and the magnitude occupies the
rest of the field.
0 0 0 0 1 0 0 1

A zero bit represents a positive sign, a one bit a Magnitude


negative sign.
Sign

Continued…
Concepts Page 63 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Data Representation

Fixed-Point Arithmetic (cont’d)

For positive numbers, the magnitude is


represented in true binary. A half word value of +25
would be represented as:
0000 0000 0001 1001
Halfword Value of + 25
For negative numbers the magnitude is expressed
in twos-complement form. To convert a binary
value to twos-complement, flip all the bits, change 0000 0000 0001 1001
1s to 0 and 0s to 1, and then add one. A halfword
value of -25 would be represented as: 1111 1111 1110 0110 = +25
REVERSE
1111 1111 1110 0111 BITS
TWOS-COMPLEMENT 1
ADD + 1
1111 1111 1110 0111 = -25

Halfword Value of - 25

Concepts Page 64 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Data Representation

Leading Zeros and Twos-complement

Leading zeroes
Positive Numbers:
Note that in positive numbers, leading zeroes (0s)
are insignificant, and in negative numbers, leading
one (1s) are insignificant. In general, bits equal to 0000 1000 0001

the sign bit are insignificant.


Leading Zeros

Twos-complement
Negative Numbers:
Twos-complement notation used to represent
negative fixed-point numbers makes doing 1111 0111 1111
arithmetic easy for the computer.

Leading Ones

Concepts Page 65 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Data Representation

Types of Decimal Numbers

Decimal numbers are of the following two types:

• Zoned Decimal
• Packed Decimal Zoned Decimal

What is packed decimal?


1 to 16
Packed decimal requires less storage than DIGITS
EBCDIC, since each number is represented by
half a byte (4 bits). Arithmetic is only done on
packed decimal numbers.

What is zoned decimal?


Packed Decimal

Zoned decimal is an intermediate format, used in


converting numbers from characters to packed
1 to 31
decimal. Packed numbers can be from 1 to 31 DIGITS
digits in length, while zoned can be from 1 to 16
digits.

Concepts Page 66 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Data Representation

Zoned Decimal Number

What is a zone nibble?


Zoned Decimal Number:

Each byte in a zoned decimal number consists of


Numeric nibble
a zone nibble and a numeric nibble. The zone
nibble is the first half of each byte, and the
numeric nibble is the second half.

Each numeric nibble contains the decimal digit


F 0 F 4 F 5 F 2 C 1
value for that position. All zone nibbles except the
rightmost contain the hex value F (one one
binary). The rightmost nibble contains the sign.
The hex character C represents a positive sign Sign
and D represents a negative sign.
Zone nibble

A nibble is half a byte.

Concepts Page 67 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Data Representation

Packed Decimal Number

Packed decimal notation adds one decimal digit


into each nibble, except for the rightmost nibble, Packed Decimal Number:
which contains the sign. The sign is coded the -2 digits/byte

same way as for zoned decimal.

Byte 1 Byte 2 Byte 3


A three byte packed decimal number containing
the value 4521 would be represented (in hex) as: 04 52 1C
04521C

Zoned Decimal Number:


-1 digit/byte

F0 F4 F5 F2 C1

Byte 1 Byte 2 Byte 3 Byte 4 Byte 5

Concepts Page 68 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Data Representation

Using Floating Point Numbers

Fixed point and decimal numbers are integers.


Real numbers, numbers with a fractional part, are
represented with floating point numbers. Floating
point numbers allow you to represent a large
range of numbers.

1.74642 X 1017

= 174642000000000000

Concepts Page 69 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Data Representation

Floating-Point Numbers

Following are the 3 data types used for floating-


Floating Point Numbers:
point numbers?

• Short numbers – 4 bytes in length 4 bytes SHORT


• Long - 8 bytes in length
• Extended – 16 bytes in length Mantissa (3 bytes)

8 bytes LONG

A floating-point number consists of the following Mantissa 7 bytes


parts:
16 bytes EXTENDED
• A Sign
Mantissa
• A Mantissa Mantissa
7 bytes 7 bytes
• An Exponent High Order Low Order
1 byte ( Unused)
Sign (1st bit)
0 – Positive Exponent ( 7 bits)
1 - Negative
1 byte 0 1010001

Concepts Page 70 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Data Representation

Floating-Point Formats

The three floating-point formats all provide for


essentially identical ranges of magnitude, since
the exponent is the same size in each.
Floating-Point Formats

Going from short to long or from long to extended


simply increases the length of the mantissa, and
thus provides more precision.
0.32641 X 1070

0.32641347961 X 1070

0.3264134796128439 X 1070

Concepts Page 71 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Data Representation

Are We on Track?

Which of the following data types allow for representing fractional numbers?

A. Packed Decimal

B. Fixed Point

C. Floating Point

D. Zoned Decimal

Review Page 72 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Data Representation

Are We on Track?

Which of the following would describe a field in storage containing 003C?

A. A halfword value of +60

B. A zoned decimal value of +3

C. A character value of ‘C’

D. A packed decimal value of +3

Review Page 73 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Data Representation

Glossary

Fixed-point Binary – A numeric format and a set of machine arithmetic instructions. Fixed-point
arithmetic is integer based using binary for positive numbers and twos-complements
for negative numbers.

Decimal – The base-10 numbering system.

Fixed-Point Arithmetic – Arithmetic performed on fixed-point numbers

Sign – The character used to indicate a positive or negative number. In Assembly-Level


programming, the sign is indicated by the sign bit accompanying the other number.

Leading Zero – A zero that precedes the most significant (leftmost) digit of a number. One or more
leading zeroes may be used as fill characters in a field containing numeric input.
Leading zeroes have no significance in the value of a number.

Twos-Complement – A number in the base-2 system that is the Twos-complement of another number.
Twos-complement are usually derived by reversing the digits in a binary number
and adding 1 to the result. When twos-complement is used to represent negative
numbers, the most significant digit is always 1.

Continued…
Glossary Page 74 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Data Representation

Glossary (cont’d)

Integers – A positive or negative “whole” number such as 37, -50 or 764. Integers are widely
used in programming for counting and numbering purposes due to the fact that
calculations are much faster using integers as opposed to floating-point numbers.

Glossary Page 75 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Data Representation

Topic Summary

Now that you have completed this topic, you learned to:

• Describe Data Representation. Understand EBCDID

• Describe types of decimal numbers – Packed and Zoned


decimal

Summary Page 76 of 77
Assembler Programming Introduction
Unit: Memory Usage

Unit Summary

Now that you have completed this unit, you should be able to:

• Describe how an Assembler program uses main storage

• Describe the kinds of registers used in S/390


architecture

• Convert numbers between decimal, binary and


hexadecimal systems

• Add and subtract in binary and hexadecimal

• Describe how characters and numbers are stored within


S/390 architecture

Continued…
Summary Page 77 of 77

You might also like