IBM Mainframe: Character & Zoned Decimal Data Processing - Definitions, Uses, Instructions, Study notes of Programming Languages

An in-depth exploration of character data and zoned decimal data processing in ibm mainframe computers. It covers the ebcdic character set, character constants, moving and comparing character data, zoned decimal format, and the mvc instruction. It also discusses the differences between literals and immediate operands.

Typology: Study notes

Pre 2010

Uploaded on 08/04/2009

koofers-user-wvb
koofers-user-wvb 🇺🇸

3

(1)

10 documents

1 / 16

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Processing Character Data
We now discuss the definitions and uses of character data in an IBM Mainframe
computer. By extension, we shall also be discussing zoned decimal data.
Character data and zoned decimal data are stored as eight–bit bytes.
These eight–bit bytes are seen by IBM as being organized into two parts.
This division is shown in the following table.
Portion Zone Numeric
Bit 0 1 2 3 4 5 6 7
Note again the bit numbering scheme used by IBM.
Character constants have a few constraints.
1. Their length may be defined from 1 to 256 characters.
Long character constants should be avoided.
2. They may contain any character. Characters not available in the standard
set may be introduced by hexadecimal definitions.
3. The length may be defined either explicitly or implicitly.
It is usually a good idea not to do both.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

Partial preview of the text

Download IBM Mainframe: Character & Zoned Decimal Data Processing - Definitions, Uses, Instructions and more Study notes Programming Languages in PDF only on Docsity!

Processing Character Data

We now discuss the definitions and uses of character data in an IBM Mainframe computer. By extension, we shall also be discussing zoned decimal data. Character data and zoned decimal data are stored as eight–bit bytes. These eight–bit bytes are seen by IBM as being organized into two parts. This division is shown in the following table. Portion Zone Numeric Bit 0 1 2 3 4 5 6 7 Note again the bit numbering scheme used by IBM. Character constants have a few constraints.

  1. Their length may be defined from 1 to 256 characters. Long character constants should be avoided.
  2. They may contain any character. Characters not available in the standard set may be introduced by hexadecimal definitions.
  3. The length may be defined either explicitly or implicitly. It is usually a good idea not to do both.

The EBCDIC Character Set

Here is the set of important EBCDIC codes. Character EBCDIC blank 40 A – I C1 – C J – R D1 – D S – Z E2 – E 0 – 9 F0 – F Note that the EBCDIC codes for the digits ‘0’ through ‘9’ are exactly the zoned decimal representation of those digits. (But see below). The DS declarative is used to reserve storage for character data. The DC declarative is used to reserve initialized storage for character data. We now cover a few topics:

  1. Moving Character Data
  2. Comparing Character Data
  3. Literals and immediate instructions.

The MVC Instruction

The MVC (Move Character) instruction is designed to move character data, but it can be used to move data in any format, one byte at a time. The instruction may be written as MVC DESTINATION,SOURCE The format of the instruction is MVC D1(L,B1),D2(B2) An example of the instruction is MVC F1,F Here are a few comments on MVC.

  1. It may move from 1 to 256 bytes, determined by the use of an 8–bit number as a length field in the machine language instruction. The destination length is first decremented by 1 and then stored in the length byte. This disallows a length of 0, and allows 8 bits to store the value 256.
  2. Data beginning in the byte specified by the source operand are moved one byte at a time to the field beginning with the byte in the destination operand. One of the reasons for complexity of the implementation is that the source and destination regions may overlap.
  3. The length of the destination field determines the number of bytes moved.

More On MVC

The form is MVC D1(L,B1),D2(B2). The object code format is as follows: Type Bytes Form 1 2 3 4 5 6 SS(1) 6 D1(L,B1),D2(B2) OP L B 1 D 1 D 1 D 1 B 2 D 2 D 2 D 2 Consider the example assembly language statement, which moves the string of characters at label CONAME to the location associated with the label TITLE. MVC TITLE,CONAME Suppose that: 1. There are fourteen bytes associated with TITLE , say that it was declared as TITLE DS CL14. Decimal 14 is hexadecimal E.

  1. The label TITLE is referenced by displacement X‘40A’ from the value stored in register R3 , used as a base register.
  2. The label CONAME is referenced by displacement X‘42C’ from the value stored in register R3 , used as a base register. Given that the operation code for MVC is X‘D2’ , the instruction assembles as D2 0D 34 0A 34 2C Length is 14 or X‘0E’; L – 1 is X‘0D’

MVC: Explicit Register Usage (Continued)

Consider again the example: MVC 32(5,7) , NAME. Suppose that the label NAME corresponds to an address given by offset X‘250’ (592 in decimal) from general–purpose register 10 (denoted in object code by X‘A’ ). When the instruction is written in the form MVC D1(L,B1),D2(B2) , we see that it has the form MVC 32(5,7),592(10). ALL NUMBERS ARE DECIMAL. In the object code format, the value stored for the length attribute is one less than the actual length. The length is 5, so the stored value is 4, or X‘04’. The object code format is D2 04 70 20 A2 50. Again, recall the object code format for this instruction. Op Code Length Base Displacement Base Displacement D 2 0 4 7 0 2 0 A 2 5 0

MVC: Example 1

The number of bytes (characters) to move may be explicitly stated. If the number is not explicitly stated, the number is taken as the length (in bytes or characters) of the destination field. Consider the following program fragment. MVC F1,F F1 DC CL4‘JUNE’ F2 DC CL5‘APRIL’ What happens is shown in the next figure. The assembler recognizes F1 as a four–byte field from its declaration by the DC statement. This implicitly sets the number of characters to be moved. The ‘L’ is not moved, as it is the fifth character in F2. It is at address F2+.

MVC: Example 3

We may use relative addressing as well as an explicit length declaration. Consider the following program fragment. MVC F1+1(2),F2+ F1 DC CL4‘JUNE’ F2 DC CL5‘APRIL’ This calls for moving two characters from address F2+2 to address F1+. What two characters are at address F2+2? Answer: “RI”. What two characters are at address F1+1? Answer: “UN”. What happens is shown in the next figure. The other two characters in F1, at addresses F1 and F1+3 , are not changed.

MVC: Example 4

We now consider the explicit use of base registers. Recall the form of the instruction: MVC D1(L,B1),D2(B2). In the following three examples, we suppose that PRINT is a label associated with an output field of length 80 bytes. In reality, it only must be “big enough”. FRAG01 MVC PRINT+60(2),=C‘’ FRAG02 LA R8,PRINT+60 LOAD THE ADDRESS. MVC 0(2,8),=C‘’ DEST ADDRESS IS PRINT+ FRAG03 LA R8,PRINT LOAD THE ADDRESS. MVC 60(2,8),=C‘’ NOTE OFFSET IS 60** Suppose that the address of PRINT is given by base register 12 and displacement X‘200’. Suppose register 12 contains a value of X‘1000’. The label PRINT references address X‘1200’. The value of PRINT+60 is then X‘1200’ + X‘60’ = X‘1260’. We shall repeat this example and discuss similar examples in a future lecture on accessing arrays and tables.

Using the Condition Codes

The character comparison operators, CLC and CLI, set the condition codes. These codes are used by the branching instructions in their non–numeric form. Here are the standard comparisons. BE Branch Equal Condition Code = 0 BNE Branch Not Equal Condition Code  0 BL Branch Low Condition Code = 1 BNL Branch Not Low Condition Code  1 BH Branch High Condition Code = 2 BNH Branch Not High Condition Code  2. Here are two equivalent examples. CLC X, Y CLC X, Y BL J20LOEQ BNH J20LOEQ BE J20LOEQ

CLC: An Example

Consider the following code fragment. Note that the comparison value is given as the seven EBCDIC characters ‘0200000’. Presumably, this would be converted into seven Packed Decimal digits and held to represent the fixed point number 2000.00, presumably $2,000.00. **C20 CLC SALPR,=C‘0200000’ COMPARE TO 2,000. BNH C30 NOT ABOVE 2,000. BL C40 LESS THAN 2,000.

  • EQUAL TO 2,000.** Again, this is presented as representing Packed Decimal data, which it probably does represent. The comparison, however, is an EBCDIC character comparison. Here is another example, built around the first one. It represents an important special case that we shall consider when discussing Packed Decimal format. C20 CLC SALPR,=C‘ ’ IS THE FIELD BLANK? BNE NOTBLNK MVC SALPR,=C‘0000000’ CONVERT BLANKS TO 0’S NOTBLANK PACK SALNUM,SALPR

Character Literals vs. Immediate Operands

The main characteristics of an immediate operation is that the operand, called the “immediate operand” is contained within the instruction. The main characteristic of a literal operand is that it is stored separately from the operand, in a literal pool generated by the assembler. Here are two equivalent instructions to set the currency sign. Use of a literal: MVC DOLLAR,=C’$’ Use of immediate operand MVI DOLLAR,C’$’ Note the “=” in front of the literal. It is not present in the immediate operand.