Write a routine that will construct one output record
in the following format.
City State Code
Allocate memory for the input record at location
2000 and for the output record at location 2100.
Coding is to begin at 2300. Assume the record is
present in memory.
PACKING AND UNPACKING DATA
The previous section discussed the movement of a
data field from one to another area of memory using
the Move Character instruction. This instruction
moved byte(s) without changing their structure.
As outlined in the section on Data Format, data must
be in packed format before decimal arithmetic oper-
ations maybe performed. Data must be in unpacked
format before any type of display output (such as
printing) may be performed. The Pack and Unpack
instructions enable the user to perform these opera-
tions as the data is moved.
PACK INSTRUCTION (PACK)
To illustrate use of the Pack instruction assume that
an area must be allocated for input transactions (Un-
packed) which are in the format as follows:
One area is allocated for reading in the transaction,
and another (a work area) for packing the Amount
field prior to updating the Master.Record balance
The input area is allocated as follows:
The work area for packing the Amount (AMT) field
is as follows:
should be noted that the unpacked field (AMT) can
be packed into a much smaller field
The least significant byte of the unpacked field is the
only byte that fully occupies a byte position in the
packed field. All other bytes are stripped of the
zone portion before transfer to the packed field.
Therefore, a quick way of determining the number
of bytes necessary in the packed field is to divide
by two the size (in bytes) of the unpacked field and
add 1. Thus, (Unpacked field) .§
5 (number of
bytes for packed result).
Assuming the amount (AMT) field contained the value
as indicated below, the instruction to pack the field
in WAMT and the resulting packed field are shown:
10 11 12 13 14 15 16 17
ZO ZO ZO Z2 Zl Z4 Z9
F2 16 14
General Register one contains 0000
50 51 52 53 54
00 00 21 49 7S
The receiving field is considered the controlling
field for terminating the execution of the instruc-
If the receiving field is not large enough to contain
all the digits in the unpacked (sending) field,
truncation of the high-order digits takes place.
If the receiving field is larger than necessary to
contain all digits in the sending field, the high-order
half-bytes of the packed field are filled with zero
The programmer must be sure that he is dealing with
valid fields for both the packing and unpacking oper-
ations. There is no hardware check, for example,