Download Print this page

Packing And Unpacking Data (Pack And Unpk) - RCA Spectra 70 Training Manual

System
Hide thumbs

Advertisement

Write a routine that will construct one output record
in the following format.
Account No.
Credit Code
Balance
Total Returns
Total Purchases
Name
Street Address
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:
STOCK NO.
8
CODE
2
AMOUNT
8
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
field.
The input area is allocated as follows:
NAME
OPERATION
OPERAND
ORG
3000
STNO
DS
8C
CODE
DS
2C
AMT
DS
8C
The work area for packing the Amount (AMT) field
is as follows:
26
NAME
OPERATION
OPERAND
WAMT
DS
5C
It
should be noted that the unpacked field (AMT) can
be packed into a much smaller field
(W
AMT) .
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) .§
+
1
=
5 (number of
2
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:
UNPACKED
(SENDING
FIELD
ASSEMBLY
INSTRUCTION
GENERATED
INSTRUCTION
PACKED
(RECEIVING)
FIELD
10 11 12 13 14 15 16 17
ZO ZO ZO Z2 Zl Z4 Z9
87
OPERATION
OPERAND
PACK
WAMT(5).AMT(8)
OP
L1
L2
B1
D1
B2
I
F2 16 14
17
1
110
3050 10
1
110
D2
1301010
I
General Register one contains 0000
WAMT
30
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-
tion.
If the receiving field is not large enough to contain
all the digits in the unpacked (sending) field,
then
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
digits.
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,

Advertisement

loading

  Also See for RCA Spectra 70

  Related Manuals for RCA Spectra 70

This manual is also suitable for:

Spectra 70/25