CONVERSION EXAMPLE Convert the decimal number 59.25 to a
short floating-point number. (In anoth­
er appendix are tables for the conver­
sion of hexadecimal and decimal integers
and fractions.)
1. The number is separated into a
decimal integer and a decimal frac­
tion.
59.25 = 59 plus 0.25 2. The decimal integer is converted to
its hexadecimal representation. 59{10} = 3B{16}
3. The decimal fraction is converted
to its hexadecimal representation. 0.25{10} = 0.4{16} 4. The integral and fractional parts
are combined and expressed as a
fraction times a power of 16 (expo­
nent) 3B.4{16} = 0.3B4{16} x 16
2
5. The characteristic is developed
from the exponent and converted to
binary.
base + exponent = characteristic
64 + 2 = 66 = 1000010 6. The fraction is converted to binary
and grouped hexadecimally.
.3B4{16} = .0011 1011 0100 7. The characteristic and the fraction
are stored in the short format.
The sign position contains the sign
of the fraction. Char o 1000010 Fraction 0011 1011 0100 0000 0000 0000 Examples of instruction sequences that
may be used to convert between signed
binary integers and floating-point
numbers are shown in the section
"Floating-Point-Number Conversion" later
in this appendix. INSTRUCTION-USE EXAMPLES
The following examples illustrate the
use of many of the unprivileged
instructions. Before studying one of
these examples, the reader should
consult the instruction description.
The instruction-use examples are written
principally for assembler-language
programmers, to be used in conjunction
with the appropriate assembler-language
pUblications.
Most examples present one particular
instruction, both as it is written in an
assembler-language statement and as it
appears when assembled in storage
(machine format).
In the instruction-use examples, the
notation {2}, {10}, or {16} may be used, indicating that the preceding number is
binary, decimal, or hexadecimal, respec­
tively. MACHINE FORMAT
All machine-format values are given in
hexadecimal notation unless otherwise
specified. Storage addresses are also
given in hexadecimal. Hexadecimal ands are shown converted into binary,
decimal, or both if such conversion
helps to clarify the example for the
reader.
ASSEMBLER-LANGUAGE FORMAT
In assembler-language statements, regis­
ters and lengths are presented in deci­
mal. Displacements, immediate operands,
and masks may be shown in decimal, hexa­
decimal, or binary notation; for
example, 12, X'C', and B'1100' represent
the same value. Whenever the value in a
register or storage location is referred
to as "not significant," this value is
replaced during the execution of the
instruction.
When SS-format instructions are written
in the assembler language, lengths are
given as the total number of bytes in
the field. This differs from the
machine definition, in which the length
field specifies the number of bytes to
be added to the field address to obtain
the address of the last byte of the
field. Thus, the machine length is one
less than the assembler-language length.
The assembler program automatically
subtracts one from the length specified
when the instruction is assembled.
In some of the examples, symbolic
addresses are used in order to simplify
the examples. In assembler-language
statements, a symbolic address is
represented as a mnemonic term written
in all capitals, such as FLAGS, which
may denote the address of a storage
location containing data or program­
control information. When symbolic
addresses are used, the assembler
supplies actual base and displacement
values according to the programmer's
specifications. Therefore, the actual
Appendix A. Number Representation and Instruction-Use Examples A-7
values for base and displacement are not
shown in the assembler-language format or in the machine-language format. For assembler-language formats, in the
labels that designate instruction
fields, the letter "S" is used to indi­
cate the combination of base and
displacement fields for an operand
address. (For example, S2 represents the combination of B2 and D2.) In the
machine-language format, the base and
displacement address components are
shown as asterisks (****). GENERAL INSTRUCTIONS (See Chapter 7 for a complete descrip­
tion of the general instructions.)
ADD HALFWORD (AH)
The ADD HALFWORD instruction algebra­
ically adds the contents of a two-byte
field in storage to the contents of a
register. The storage operand is expanded to 32 bits after it is fetched
and before it is used in the add opera­
tion. The expansion consists in propa­
gating the leftmost (sign) bit 16
positions to the left. For example,
assume that the contents of storage
locations 2000-2001 are to be added to
register 5. Initially:
Register 5 contains 00 00 00 19 = 25{10}. Storage locations 2000-2001 contain FF
FE = -2{10}. Register 12 contains 00 00 18 00. Register 13 contains 00 00 01 50. The format of the required instruction
is:
Machine Format Op Code 4A 5 o C Assembler Format Op Code R"D
2 (X
2 ,B
2
)
AH 5,X'6BO'(13,12) After the instruction is executed, register 5 contains 00 00 00 17 = 23{10}. Condition code 2 is set to
indicate a result greater than zero.
A-8 System/370 Principles of Operation AND (N, NC, NI, NR)
When the Boolean operator AND is applied
to two bits, the result is one when both
bits are onei otherwise, the result is zero. When two bytes are ANDed, each
pair of bits is handled separately;
there is no connection from one bit
position to another. The following is
an example of ANDing two bytes:
First-operand byte: 0011 0101{2} Second-operand byte: 0101 1100{2} Result byte: 0001 0100{2} NI Example
A frequent use of the AND instruction is
to set a particular bit to zero. For
example, assume that storage location
4891 contains 0100 0011{2}. To set the
rightmost bit of this byte to zero
without affecting the other bits, the
following instruction can be used
(assume that register 8 contains 00 00 48 90): Machine Format Op Code 94 FE 8 Assembler Format Op Code D
1 (B
1 ),I
2
NI 1(8),X'FE'
When this instruction is executed, the
byte in storage is ANDed with the imme­
diate byte (the 12 field of the instruc­
tion):
Location 4891: 0100 0011{2} Immediate byte: 1111 1110{2} Result: 0100 0010{2} The resulting byte, with bit 7 set to
zero, is stored back in location 4891. Condition code 1 is set.
LINKAGE INSTRUCTIONS (BAL, BALR, BAS, BASR)
The BRANCH AND LINK (BAL or BALR)
instruction is commonly used to branch
to a subroutine with the option of later
returning to the main instruction
sequence. On models with the
Previous Page Next Page