Just a Bit
Part Two - Challenge #08

This challenge will introduce you to data character encoding – a skill required to understand computer and network technology.

Background:


Learn about Bits, Nibbles, Bytes, Hexadecimal, EBCDIC, ASCII, and BCD

Classic school education involves arithmetic and script symbols for alphanumeric and special characters. Computer and network technology expertise requires additional knowledge of data character encoding.

If you are not familiar with Bits, Nibbles, Bytes, Hexadecimal, EBCDIC, ASCII, and BCD, then the section below is mandatory Use this as reference as you complete the challenge.

The digital world operates using electronic signals where a signal is either off (0) or on (1). A light switch is a good analogy. The light switch is either off or on.

Everything builds upon the word binary. Binary, 0 or 1, is the lowest level of our digital world. Computer instructions, alphanumeric and special characters are binary at the lowest level.


A bit is a binary state, either state 0 (off) or 1 (on).

Computer processing and network transmission involves probably more bits than grains of sand. Everything in computer processing and network transmission is a massive stream of bits. When you type a character, a small stream of bits is generated to represent the character. System commands and programming language verbs are a stream of bits.

No one codes a stream of bits (0's and 1's) when typing characters nor codes of stream bits when programming. So, how are the stream of bits organized to form characters, commands, etc.?

The answer starts with hexadecimal.

Hexadecimal is a more human friendly method to represent a defined string of bits. Hexadecimal requires a thinking adjustment because our mind muscle is trained in decimal.

The word 'deci' means 10, therefore there are ten numbers (digits) in the decimal number system. The valid numbers in a base 10 number system are: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9.

Hexadecimal has 16 positions (0-9 and A-F representing positions 10-15).

To further complicate matters, 2 different character encoding standards evolved at roughly the same time. Each character encoding standard assigned a different hexadecimal value to alphabetic characters, numbers, and special characters. Those 2 character encoding standards are:

  1. EBCDIC, Extended Binary Coded Decimal Interchange Code
  2. ASCII, American Standard Code for Information Interchange

The good news is EBCDIC and ASCII have hexadecimal in common.

Two separate character encoding standards were developed in the early 1960's, EBCDIC and ASCII.

EBCDIC, Extended Binary Coded Decimal Interchange Code, was devised in 1963 and 1964 by IBM and was announced with the release of the IBM System/360 line of mainframe computers. It is an eight-bit character encoding. The IBM System/360 is the foundation and original DNA for today's IBM Z.

ASCII, American Standard Code for Information Interchange, was developed from telegraph code. Its first commercial use was as a seven-bit teleprinter code promoted by Bell data services. ASCII codes represent text in computers, telecommunications equipment, and other devices.

Many of today's personal computers and smaller servers use ASCII as a character encoding standard.

IBM Z mainframes use EBCDIC as a default character encoding standard. However, IBM Z mainframes can store and process ASCII character encoding.

A third numeric only standard exists for binary encoding of decimal numbers, Binary Coded Decimal (BCD). BCD is used to store numbers with positive (+) and negative (-) values. Wikipedia explanation of Binary Coded Decimal


Terminology

  • Bit, a binary state either 0 or 1
  • Nibble, 4 Bits used to encode a hexadecimal digit (0 - F)
  • Byte, 8 Bits used to encode a single character
      A Byte is 2 Nibbles or 2 hexadecimal digits
      A Nibble is also known as a half Byte

Challenge 8 explores the binary world of Bits, Nibbles, Bytes, Hexadecimal, EBCDIC, ASCII, and BCD. If the binary world is new to you, show your persistence by completing challenge 8 and you will have the elementary fundamentals applied to the digital world forever.

References drop down includes a Character Encoding Summary with Hexadecimal format for each displayable EBCDIC and ASCII character. As a starting point, observe lowercase a in the table as EBCDIC x'81' and ASCII x'61'
Character Encoding Summary


Challenge:

Use ISPF editor to explore Hexadecimal, EBCDIC, ASCII, and BCD

EBCDIC Character Encoding

Use ISPF editor to explore Hexadecimal and EBCDIC

  1. Edit Z#####.PDS.DATA
      Remember to substitute your ID for Z#####
  2. Select s new member name EBCDIC
  3. Enter ISPF primary command copy 'zos.mtm2019.public.shared.data(ebcdic)'
      As previously mentioned, z/OS is EBCDIC by default
      Observe the numbers, lowercase alphabet, uppercase alphabet, and special characters
  4. Enter ISPF primary command hex on
      Hexadecimal values for each character are shown vertically in the two rows below the character.
      Enter ISPF primary command cols to display a columns line serving as a column ruler
    cols can be used on the command line or on a line number

      Observe line 000004, column 1 is 0 and the associated hexadecimal value is F0
       - x'F0' is short for hexadecimal value F0
      Press F3 to exit the ISPF edit session of member name EBCDIC

Observe Figure #0

The result of hex on and cols ISPF commands
is displayed. Line 00004 column 1 shows EBCDIC character 0 represented by x'F0'

Figure #0


ASCII Character Encoding

You should still be in Z#####.PDS.DATA partitioned data set. If not, then edit Z######.PDS.DATA.

  1. Select s new member name ASCII
  2. Enter ISPF primary command copy 'zos.mtm2019.public.shared.data(ascii)'

Observe Figure #1

As previously mentioned, z/OS can store, read, and update ASCII while EBCDIC is the default

  • Some lines you can read because it is EBCDIC, the z/OS default encoding format.
  • Some lines have unreadable text because it is ASCII
  • Enter primary command hex on to display hexadecimal representation of each text character
  • Enter primary commands reset to suppress the ==MSG> lines

Figure #1


Observe Figure #2

The result of hex on displays the hexadecimal value for both ASCII and EBCDIC characters

  • Line 1 consists of ASCII alphabet characters
  • Line 3 consists of EBCDIC alphabet characters and number characters
  • Line 4 consists of ASCII number characters which unreadable
  • Enter ISPF primary command source ascii to change display output from EBCDIC to ASCII

Figure #2


Observe Figure #3

The result of source ascii is ASCII characters are readable and EBCDIC characters are unreadable

EBCDIC and ASCII use a common hexadecimal character encoding

  • Line 1 consists of ASCII alphabet characters now readable
  • Line 3 consists of EBCDIC alphabet characters and number characters now unreadable
  • Line 4 consists of ASCII number characters now readable

Figure #3


Observe Figure #4

Enter ISPF line command cols on line 4 as seen in Figure #4

Figure #4


Observe Figure #5

ASCII alphabet and numbers are readable as a result of command 'source ascii'.

Line 4 has ASCII 0-9 starting in column 1.

Line 4 columns 20-29 are x'20' values. x'20' is an ASCII space.

Overtype hexadecimal x'20' values to x'F0' to x'F9' on line 4, columns 20-29, as shown.

x'F0' to x'F9' are the hexadecimal values for EBCDIC 0 - 9.

Figure #5

Depending upon the emulator, the above Figure #5 might display a few strange fonts in column 20 - 29. Just ignore it.


Observe Figure #6

The result of entering x'F0' to x'F9' on line 4, columns 20-29 are unreadable.

Enter ISPF editor primary command reset

Figure #6


Observe Figure #7

The result of ISPF primary command reset is a return to EBCDIC character encoding.

Line 4, columns 1-10 are unreadable with unprintable hexadecimal values.

Line 4, columns 20-29 now read EBCDIC 0-9

Saving the changes is unnecessary, enter ISPF primary command cancel

Figure #7


BCD and Packed Decimal Character Encoding
  1. Edit Z#####.PDS.DATA
      Remember to substitute your ID for Z#####
  2. Select s new member name packed
  3. Enter ISPF primary command copy 'zos.mtm2019.public.shared.data(packed)'

Observe Figure #8

  • Overtype line 5 with cols
  • Overtype line 6 with hx
  • Overtype line 9 with hx
  • Overtype line 12 with hx

Figure #8


Packed Decimal, a form of BCD, is neither EBCDIC or ASCII.

Remember the 'nibble' word? Packed Decimal uses nibbles.

Observe Figure #9

A column ruler is now above line 5

Line 5 is a heading with positive (+) and negative (-) symbols

Line 6 has hexadecimal values under the + and - symbols

  • Column 1 has x'0A' which is 2 nibbles, x'0' and x'A'
      where x'A' is used to denote a packed decimal field as a positive number
  • Column 4 has x'0B' which is 2 nibbles, x'0' and x'B'
      where x'B' is used to denote a packed decimal field as a negative number
  • Column 7 has x'0C' which is 2 nibbles, x'0' and x'C'
      where x'C' is used to denote a packed decimal field as a positive number
  • Column 10 has x'0D' which is 2 nibbles, x'0' and x'D'
      where x'D' is used to denote a packed decimal field as a negative number
  • Column 13 has x'0E' which is 2 nibbles, x'0' and x'E'
      where x'E' is used to denote a packed decimal field as a positive number
  • Column 16 has x'0F' which is 2 nibbles, x'0' and x'F'
      where x'F' is used to denote a packed decimal field as a positive number

Line 9, columns 1-3, is a packed decimal number, x'04096A', a total of 6 nibbles

  1. 1st nibble is 0
  2. 2nd nibble is 4
  3. 3rd nibble is 0
  4. 4th nibble is 9
  5. 5th nibble is 6
  6. 6th nibble is A
      where x'A' nibble means positive +4096  

Another packed decimal format example in Figure #9 -

Line 12, columns 1 and 2, is a packed decimal number, x'256B', a total of 4 nibbles

  1. 1st nibble is 2
  2. 2nd nibble is 5
  3. 3rd nibble is 6
  4. 4th nibble is B
      where x'B' nibble means negative -256

Enter ISPF primary command save. Member packed is read in the next challenge.

Enter ISPF primary commands cancel ; s #08

The result is cancel current ISPF edit session and select a new member (#08) for a new ISPF edit session.

Figure #9

Now you aware of the packed decimal format. Many large financial enterprise store financial numbers in packed decimal to help improve speed of calculations.

The new empty #08 partitioned data set member will be used to complete the challenge by demonstrating your understanding of Hexadecimal, EBCDIC, ASCII, and Packed Decimal.


Complete the Challenge

Observe Figure #10

Do the following actions in order:

  1. Do not press enter key until explicitly reading 'now press enter key'
  2. Tab to first empty line and type 0123456789
  3. Tab to second empty line and type uppercase A
  4. Tab to third empty line and type lowercase z
  5. Tab to forth empty line and type number 4096
  6. Now press enter key
  7. Enter ISPF primary commands cols ; hex on

Figure #10


Observe Figure #11

The result of the previous actions are displayed in Figure #11

Change member #08 as follows:

  1. Change line 2 column 1 from EBCDIC uppercase A to ASCII uppercase A
  2. Change line 3 column 1 from EBCDIC lowercase z to ASCII lowercase z
  3. Change line 4 columns 1-4 from EBCDIC 4096 to Packed Decimal 4096
      Line 4 - Packed Decimal 4096 will leave column 3 unused
      Line 4 - Change column 3 to x'40', an EBCDIC space

There are a couple of ways to accomplish the changes.

If you need to start over, you can delete the lines and start over

Figure #11


Observe Figure #12

Once you feel that you successfully completed the changes,
  type ISPF edit primary command rep p2.output(#08)
  tab to line 1 and overtype line number 000001 with c99
enter to replace z#####.p2.output(#08) with all lines from z#####.pds.data(#08)

Figure #12


Congratulations! You are done with challenge #08 and you ready for the next challenge.

Now that you know about EBCDIC, with a bit more info you could read Adi's t-shirt
(pictured at recent SHARE.org eventalong with a few other mainframers)

Next: Challenge #09