Assembler Unit2
Assembler Unit2
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.
Introduction Page 3 of 77
Assembler Programming Introduction
Unit: Memory Usage
Unit Objectives
Introduction Page 4 of 77
Assembler Programming Introduction
Topics:
Hardware Components
Numbering Systems
Numeric Conversions
Data Representation
Page 5 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Hardware Components
Topic Objectives
Introduction Page 6 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Hardware Components
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
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
Program A
Concepts Page 8 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Hardware Components
Registers
Concepts Page 9 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Hardware Components
Concepts Page 10 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Hardware Components
Concepts Page 11 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Hardware Components
Are We on Track?
C. Vector Registers
D. Control Registers
Review Page 12 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Hardware Components
Are We on Track?
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:
Summary Page 15 of 77
Assembler Programming Introduction
Topics:
Hardware Components
Numbering Systems
Numeric Conversions
Data Representation
Page 16 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Numbering Systems
Topic Objectives
Introduction Page 17 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Numbering Systems
Number System
Hexadecimal 2E3
Concepts Page 18 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Numbering Systems
Base Value
Continued…
Concepts Page 19 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Numbering Systems
Tens
4 X 10 = 40
Hundreds
2 X 10 X 10 = 200
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
twos
fours
eights
Continued…
Concepts Page 23 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Numbering Systems
Concepts Page 24 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Numbering Systems
1 X 20 = 10 +
0 X 21 = 0 +
1 X 22 = 4 +
1 X 23 = 8 +
1 X 24 = 0 +
4510
= 1011012
Concepts Page 26 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Numbering Systems
Are We on Track?
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?
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
Concepts Page 29 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Numbering Systems
0100 4
1111 F
Concepts Page 31 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Numbering Systems
Are We on Track?
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?
Review Page 33 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Numbering Systems
1111
0100
Binary
1100
Continued…
Concepts Page 34 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Numbering Systems
Hexadecimal to Decimal
Concepts Page 35 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Numbering Systems
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.
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
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
Concepts Page 37 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Numbering Systems
Conversion Table
Concepts Page 38 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Numbering Systems
Are We on Track?
Review Page 39 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Numbering Systems
Are We on Track?
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:
Summary Page 41 of 77
Assembler Programming Introduction
Topics:
Hardware Components
Numbering Systems
Numeric Conversions
Data Representation
Page 42 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Numbering Conversions
Topic Objectives
Introduction Page 43 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Numbering Conversions
Binary Addition
1001011
Example:
First add two binary numbers: + 101101
1001011 1111000
+101101
--------------
Concepts Page 44 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Numbering Conversions
Hexadecimal Addition
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.
Example:
Concepts Page 45 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Numbering Conversions
Are We on Track?
Review Page 46 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Numbering Conversions
Are We on Track?
Review Page 47 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Numbering Conversions
Subtraction in Binary
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?
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:
Summary Page 53 of 77
Assembler Programming Introduction
Topics:
Hardware Components
Numbering Systems
Numeric Conversions
Data Representation
Page 54 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Data Representation
Topic Objectives
Introduction Page 55 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Data Representation
Data Representation
Continued…
Concepts Page 56 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Data Representation
EBCDIC Representation
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
Concepts Page 59 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Data Representation
Are We on Track?
Review Page 60 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Data Representation
Are We on Track?
A. C1C2C3
B. C2C3C1
C. C3C1C2
D. C3C2C1
Review Page 61 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Data Representation
Arithmetic Instructions
Fixed Point
What are the kinds of arithmetic instructions? 0111111111111111
(Binary)
Concepts Page 62 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Data Representation
Fixed-Point Arithmetic
Continued…
Concepts Page 63 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Data Representation
Halfword Value of - 25
Concepts Page 64 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Data Representation
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
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
• Zoned Decimal
• Packed Decimal Zoned Decimal
Concepts Page 66 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Data Representation
Concepts Page 67 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Data Representation
F0 F4 F5 F2 C1
Concepts Page 68 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Data Representation
1.74642 X 1017
= 174642000000000000
Concepts Page 69 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Data Representation
Floating-Point Numbers
8 bytes LONG
Concepts Page 70 of 77
Assembler Programming Introduction
Unit: Memory Usage Topic: Data Representation
Floating-Point Formats
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?
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.
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:
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:
Continued…
Summary Page 77 of 77