Programs & Defining Data
-
Upload
hadassah-floyd -
Category
Documents
-
view
39 -
download
0
description
Transcript of Programs & Defining Data
![Page 1: Programs & Defining Data](https://reader036.fdocuments.net/reader036/viewer/2022062301/56813877550346895da025d3/html5/thumbnails/1.jpg)
Programs & Defining Data
Ch.5 – pp. 95-109
![Page 2: Programs & Defining Data](https://reader036.fdocuments.net/reader036/viewer/2022062301/56813877550346895da025d3/html5/thumbnails/2.jpg)
Data in Computer Memory
G E 3EGRO 289934
480
481
482
483
484
485
490
See page 69
480
481
482
Byte locations in memory -One character per byte location
483
![Page 3: Programs & Defining Data](https://reader036.fdocuments.net/reader036/viewer/2022062301/56813877550346895da025d3/html5/thumbnails/3.jpg)
Data in Memory
G = C7 = 1100 0111E = C5 = 1100 0101O = D6 = 1101 0110R = D9 = 1101 1001G = C7 = 1100 0111E = C5 = 1100 01013 = F3 = 1111 00114 = F4 = 1111 0100
480
The characters shown in memory are really made up of binary digits (bits) as depicted to the right. In a mainframe computer, the bits are configured as EBCDIC whereas in a PC, the bit configurations are different, in ASCII. Are you comfortable with ASCII and EBCDIC? Are you comfortable with binary/hexadecimal data configurations? If not, check out your textbook on pages: 68-76 in Ch.4
![Page 4: Programs & Defining Data](https://reader036.fdocuments.net/reader036/viewer/2022062301/56813877550346895da025d3/html5/thumbnails/4.jpg)
Decimal Binary Hex
0 0000 0
1 0001 1
2 0010 2
3 0011 3
4 0100 4
5 0101 5
6 0110 6
7 0111 7
8 1000 8
9 1001 9
10 1010 A
11 1011 B
12 1100 C
13 1101 D
14 1110 E
15 1111 F
16 1 0000 10
Hexadecimal conversion chart – the same as shown in your text on page 70.
Representing Data
1 Character = 1 Byte = 2 Hex Digits
![Page 5: Programs & Defining Data](https://reader036.fdocuments.net/reader036/viewer/2022062301/56813877550346895da025d3/html5/thumbnails/5.jpg)
Representing Character Data
Left justified - padded with blanks (40)- truncated to the right
Example:
GEORGE = C7 C5 D6 D9 C7 C5
![Page 6: Programs & Defining Data](https://reader036.fdocuments.net/reader036/viewer/2022062301/56813877550346895da025d3/html5/thumbnails/6.jpg)
Define Storage / Constant
[label] DS CLnn
[label] DC CLnn’character data’
![Page 7: Programs & Defining Data](https://reader036.fdocuments.net/reader036/viewer/2022062301/56813877550346895da025d3/html5/thumbnails/7.jpg)
Defining Storage
• Reserve Storage with no initialization• See Data Definitions topic beginning p.103• Used to allow a symbolic name for an area of memory• symbolicname DS definition
1-8 alphanumeric characters1st must be alphabetic
1. Duplication factor2. Type code3. Length
![Page 8: Programs & Defining Data](https://reader036.fdocuments.net/reader036/viewer/2022062301/56813877550346895da025d3/html5/thumbnails/8.jpg)
Defining Storage Example
• Output buffer area that will be printed – allows each sub-field to be identified and accessed symbolically and the entire area can also be accessed as OWKAREA. Example:
• MOVE OWKPRICE,INVCOST *MOVE COST TO PRICEMOVE OWKONHND,INVHAND *MOVE ONHAND TO ONHANDPUT OUTFILE,OWKAREA *PRINT ENTIRE O/P RECORD
OWKAREA DS 0CL50 OWKITNBR DS CL5 OWKITDES DS CL20 DS CL5 OWKPRICE DS CL5 OWKORDPT DS CL5 OWKONHND DS CL5 OWKONORD DS CL5
p. 103
![Page 9: Programs & Defining Data](https://reader036.fdocuments.net/reader036/viewer/2022062301/56813877550346895da025d3/html5/thumbnails/9.jpg)
5 20 5 5555
OWKAREA
OWKITNBROWKITDES
OWKPRICEOWKORDPT
OWKONHNDOWKONORD
The numbers within the orange boxes represent the field lengths in bytes. The labels represent the subfield name (statement label). The entire field (made up of 7 subfields) constitutes the output buffer. Each subfield can be manipulated, then accessed together and in the same order as parts of OWKAREA
![Page 10: Programs & Defining Data](https://reader036.fdocuments.net/reader036/viewer/2022062301/56813877550346895da025d3/html5/thumbnails/10.jpg)
And the Memory Reserved?
UNPK OWKPRICE(5),PPRICE Print from OWKAREA
![Page 11: Programs & Defining Data](https://reader036.fdocuments.net/reader036/viewer/2022062301/56813877550346895da025d3/html5/thumbnails/11.jpg)
[label] DS CLnn
[label] DC CLnn
TEN DC CL2’10’ HRLY_PAY DC CL5’17.65’ DATE DC CL6’020807’ (MMDDYY) MONTH DC C’FEBRUARY’ LENGTH IMPLIED = 8 BYTES DEPTNO DC CL3’CIS’
Another Example?
![Page 12: Programs & Defining Data](https://reader036.fdocuments.net/reader036/viewer/2022062301/56813877550346895da025d3/html5/thumbnails/12.jpg)
Initializing Storage Areas
Define Constants – DC, rather than DS
ABC DC C’ABC’ C1 C2 C3
DSIGN DC C’$’ 5B
NO3 DC C’3’ F3
NAME DC C’JOE’ D1 D6 C5
TAXRT DC C’28’ F2 F8
![Page 13: Programs & Defining Data](https://reader036.fdocuments.net/reader036/viewer/2022062301/56813877550346895da025d3/html5/thumbnails/13.jpg)
[label] DS CLnn
[label] DC CLnn
EMPL-IN DS 0CL80 EMPLOYEE INPUT BUFFER EMPL-NO DS CL6 EMPL. SERIAL NUMBER DS CL1 EMPL-NM DS CL20 EMPL. NAME (LAST, FIRST, MI) DS CL1 EMPL-HRS DS CL4 HOURS WORKED (NN.N) DS CL1 EMPL-CD DS CL2 PAY CODE TO DETERMINE PAY RT DS CL1 EMPL-DT DS CL6 DATE (MMDDYY) DS CL38
![Page 14: Programs & Defining Data](https://reader036.fdocuments.net/reader036/viewer/2022062301/56813877550346895da025d3/html5/thumbnails/14.jpg)
Example (w/instructions)
CALC PACK RATE(4),TAXRT
PACK TAXAMT(6),TOTINC
MP TAXAMT(6),RATE
UNPK INCTAX(8),TAXAMT(6)
…..
RATE DS F
TAXRT DC CL2’20’ *F2 F0
TAXAMT DS PL6
TOTINC DC CL’40000’ *F4 F0 F0 F0 F0
INCTAX DS CL8
![Page 15: Programs & Defining Data](https://reader036.fdocuments.net/reader036/viewer/2022062301/56813877550346895da025d3/html5/thumbnails/15.jpg)
Other Data Types
[label] DS/DC C character
X hex
P packed dec.
B binary
F fullword (bin)
H halfword (bin)
D doubleword
![Page 16: Programs & Defining Data](https://reader036.fdocuments.net/reader036/viewer/2022062301/56813877550346895da025d3/html5/thumbnails/16.jpg)
Representing Zoned Decimal
Numbers are left justified, also padded to the right with blanks(same as character data)
1234 = F1 F2 F3 F4 F1 F2 F3 C4
DATE DC CL8'020807'
Feb. 8, 2007
![Page 17: Programs & Defining Data](https://reader036.fdocuments.net/reader036/viewer/2022062301/56813877550346895da025d3/html5/thumbnails/17.jpg)
Representing Packed Decimal
Right justified, padded with leading zeroes
+1234 = 0001234C
-1234 = 0001234D
PAYRATE DC PL5'1785'
The top value is positive and the sign character is the right-most part of the value in memory. The lower value is negative. Notice the difference in the sign character.
![Page 18: Programs & Defining Data](https://reader036.fdocuments.net/reader036/viewer/2022062301/56813877550346895da025d3/html5/thumbnails/18.jpg)
Representing Binary Data
• 1 byte = 8 binary digits (bits)• 1011 0110 (B6)• Halfword = 2 bytes• Fullword = 4 bytes
BIN22 DC BL2'00010110'
BIN22 DC F’22'
The top value, defined as binary digits with length of 2 bytes in memory appears just as the value appears in the DC operand (but with 8 bits of leading 0’s as padding). On the other hand, when defined as a fullword (also binary), in memory, the 1-bits are no different, but there would be 4 bytes instead of 2 bytes –
‘0000 0000 0000 0000 0000 0000 0001 0110’
![Page 19: Programs & Defining Data](https://reader036.fdocuments.net/reader036/viewer/2022062301/56813877550346895da025d3/html5/thumbnails/19.jpg)
Convert Binary to Decimal
0 0 1 1 0 0 1 0 1 0 0 1
2048 1024 512 256 128 64 32 16 8 4 2 1
1 + 8 + 32 + 256 + 512 = 809
Assign positional values to each binary digit beginning on the right – right-most bit is 2º, next bit to the left is 21, then 22, and so forth. Then simply add up the equivalent decimal values where there are 1-bits in the binary field above.
![Page 20: Programs & Defining Data](https://reader036.fdocuments.net/reader036/viewer/2022062301/56813877550346895da025d3/html5/thumbnails/20.jpg)
Use the Scientific Calculator
Calculators are found under the Accessories menu when you ‘click’ on the START button in the lower left corner of your screen.For the Scientific Calculator, click on the VIEW menu in the Calculator Window and choose ‘Scientific’ …Enter your DEC number, then ‘Click’ the BIN button to convert Dec Bin
![Page 21: Programs & Defining Data](https://reader036.fdocuments.net/reader036/viewer/2022062301/56813877550346895da025d3/html5/thumbnails/21.jpg)
Convert Decimal to Binary
• Use the table on the top of page 75 that shows converting hex to decimal, but use it in reverse.
• Example: convert 1517810 to hex• Using entire table, find smallest number less than the
number you are attempting to convert which is 12,228 which is hex 3000 (in Byte 3 in left-hand column). Record the Hex value on your piece of paper…3000.
• Subtract 12,228 from the original number – which is 2890• Find next smallest number again in the next column to
the right (2816). Record the Hex value … B00• And so on until you are at the far right column (64 and
10). Record the Hex values … 40 and A• 3B4A in hex is 0011 1011 0100 1010 in binary answer.• Or use the Scientific Calculator
See the process on the next slide
![Page 22: Programs & Defining Data](https://reader036.fdocuments.net/reader036/viewer/2022062301/56813877550346895da025d3/html5/thumbnails/22.jpg)
Hex Dec Hex Dec Hex Dec Hex Dec Hex Dec
0 0 0 0 0 0 0 0 0 0
1 65,536 1 4,096 1 256 1 16 1 1
2 131,072 2 8,192 2 512 2 32 2 2
3 196,608 3 12,228 3 768 3 48 3 3
4 262,144 4 16,384 4 1,024 4 64 4 4
5 327,880 5 20,480 5 1,280 5 80 5 5
6 393,216 6 24,576 6 1,536 6 96 6 6
7 458,752 7 28,672 7 1,792 7 112 7 7
8 524,288 8 32,768 8 2,048 8 128 8 8
9 589,824 9 36,864 9 2,304 9 144 9 9
A 655,360 A 40,960 A 2,560 A 160 A 10
B 720,896 B 45,056 B 2,816 B 176 B 11
C 786,432 C 49,152 C 3,072 C 192 C 12
D 851,968 D 53,248 D 3,328 D 208 D 13
E 917,504 E 57,344 E 3,584 E 224 E 14
F 983,040 F 61,440 F 3,840 F 240 F 15
4
10 = A
A
15,178 =
15178- 12288
2890
1
3
2 2890- 2816
74
B
3 74 - 64
10
4
![Page 23: Programs & Defining Data](https://reader036.fdocuments.net/reader036/viewer/2022062301/56813877550346895da025d3/html5/thumbnails/23.jpg)
Or - Convert Doing the Arithmetic
15178 / 16 = 948.625Remainder .625 is integer .625 X 16 = 10 (A)
948 / 16 = 59.25Remainder .25 is integer .25 X 16 = 4 (4)
59 / 16 = 3.6875Remainder .6875 is integer .6875 X 16 = 11 (B)
3/16 = 0.1875Remainder .1875 is integer .1875 X 16 = 3 (3)
Using result in reverse order = 3B4A
![Page 24: Programs & Defining Data](https://reader036.fdocuments.net/reader036/viewer/2022062301/56813877550346895da025d3/html5/thumbnails/24.jpg)
Converting Zoned to Packed Decimal
• Use the PACK instruction (p.84 & 85)
• Read a number from an input file. It is now in memory in zoned-decimal format – you cannot do arithmetic on it, so PACK it first (PACK removes the zones)
• PACK removes all the zones except the right-most, then reverses the right-most byte
See examples on the next slide
![Page 25: Programs & Defining Data](https://reader036.fdocuments.net/reader036/viewer/2022062301/56813877550346895da025d3/html5/thumbnails/25.jpg)
Book Examples
Receiving Sending
Before: 99 99 99 F1 F2 F3 F4 F5
After: 12 34 5F F1 F2 F3 F4 F5
Before: 00 00 00 00 F2 F6 F4 F8
After: 00 02 64 8F F2 F6 F4 F8
Before: 00 00 F6 F3 F2 F0 F4
After: 20 4F F6 F3 F2 F0 F4
p. 84/85
PACK RECEIVING,SENDING
![Page 26: Programs & Defining Data](https://reader036.fdocuments.net/reader036/viewer/2022062301/56813877550346895da025d3/html5/thumbnails/26.jpg)
Converting Packed to Zoned Decimal
• Use the UNPK instruction (p. 85)• You have completed performing arithmetic on a value and you
wish to print it – packed decimal data is not printable• UNPK puts zones back in the numbers and reverses the two
right-most characters.
See examples on the next slide
![Page 27: Programs & Defining Data](https://reader036.fdocuments.net/reader036/viewer/2022062301/56813877550346895da025d3/html5/thumbnails/27.jpg)
Book Examples
Receiving Sending
Before: 00 00 00 00 00 56 43 7F
After: F5 F6 F4 F3 F7 56 43 7F
Before: 00 00 00 00 00 03 4C
After: F0 F0 F0 F3 C4 03 4C
Before: 00 00 13 91 2D
After: F1 D2 13 91 2D
p. 85
UNPK RECEIVING,SENDING
![Page 28: Programs & Defining Data](https://reader036.fdocuments.net/reader036/viewer/2022062301/56813877550346895da025d3/html5/thumbnails/28.jpg)
Quick Review of Data
ZD = F2 F0 F5 F5 F9 F7 F4 F7 F4PD = 20 55 97 47 4FHex = 0C 41 2B 22Bin = 0000 1100 0100 0001
0010 1011 0010 0010
p. 76
![Page 29: Programs & Defining Data](https://reader036.fdocuments.net/reader036/viewer/2022062301/56813877550346895da025d3/html5/thumbnails/29.jpg)
Instruction Formats
Page 76 - bottom
![Page 30: Programs & Defining Data](https://reader036.fdocuments.net/reader036/viewer/2022062301/56813877550346895da025d3/html5/thumbnails/30.jpg)
Instruction Lengths
op code R1 R2
op code M1 M2
2 addresses – sending and receiving fields
op code R1 M2M2
![Page 31: Programs & Defining Data](https://reader036.fdocuments.net/reader036/viewer/2022062301/56813877550346895da025d3/html5/thumbnails/31.jpg)
Sending and Receiving Fields(A Reminder)
Receiving Sending
Before: F0 F4 F3 F9 F9 F0 F0 F7 F0 F1
After: F0 F0 F7 F0 F1 F0 F0 F7 F0 F1
See page 77 at the top
![Page 32: Programs & Defining Data](https://reader036.fdocuments.net/reader036/viewer/2022062301/56813877550346895da025d3/html5/thumbnails/32.jpg)
A Typical 6-byte Instruction
Address 2Length Address 1Op. Code
0 8 16 32
Instruction Format:
D2 0-255 D1 D2B1 B2
Example: Move Characters
MVC D1(L,B1),D2(B2)
MVC OUTAREA(10),INAREA
![Page 33: Programs & Defining Data](https://reader036.fdocuments.net/reader036/viewer/2022062301/56813877550346895da025d3/html5/thumbnails/33.jpg)
Sample 4-byte Instruction
Op. Code R1 D2
0 8 12 31
X2(Index)
16
Instruction Format:
5C R1 X2 D2
Example:
M INC,TAXTABLE(RIX)
M R1,D2(X2,B2)
B2
B2
![Page 34: Programs & Defining Data](https://reader036.fdocuments.net/reader036/viewer/2022062301/56813877550346895da025d3/html5/thumbnails/34.jpg)
And A 2-byte Instruction
Op. Code R1 R2
Instruction Format:
0 8 12 15
Example:
1A R1 R2
AR REG2,REG1
AR R1,R2
![Page 35: Programs & Defining Data](https://reader036.fdocuments.net/reader036/viewer/2022062301/56813877550346895da025d3/html5/thumbnails/35.jpg)
Decimal Arithmetic
• Add Decimal • AP M1(L1),M2(L2) 6-byte
format
M1(L1) M2(L2)
Before: 10 00 0F 01 0F
After: 10 01 0C 01 0F
Before: 87 11 0F 40 00 0F
After: 27 11 0C 40 00 0F
In the 2nd Add: high-order digit overflowed and lost
![Page 36: Programs & Defining Data](https://reader036.fdocuments.net/reader036/viewer/2022062301/56813877550346895da025d3/html5/thumbnails/36.jpg)
Decimal Arithmetic
• Subtract Decimal• SP M1(L1),M2(L2) 6-byte format
M1(L1) M2(L2)
Before: 10 00 0F 75 0F
After: 09 25 0C 75 0F
![Page 37: Programs & Defining Data](https://reader036.fdocuments.net/reader036/viewer/2022062301/56813877550346895da025d3/html5/thumbnails/37.jpg)
Decimal Arithmetic
• Multiply Decimal• MP M1(L1),M2(L2)
– L1 has a max length of 16 bytes– L2 has a max length of 8 bytes
M1(L1) M2(L2)
Before: 00 00 8C 50 0F
After: 04 00 0C 50 0F
![Page 38: Programs & Defining Data](https://reader036.fdocuments.net/reader036/viewer/2022062301/56813877550346895da025d3/html5/thumbnails/38.jpg)
Decimal Arithmetic
• Divide Decimal• DP M1(L1),M2(L2) 6-byte format
M1(L1) M2(L2)
Before: 00 00 00 05 3C 00 7C
After: 00 00 7C 00 4C 00 7C
Quotient Remainder – length of divisor
Before the instruction is executed, M2 is the divisor, M1 is the dividend. L1 and L2 are the lengths of each
![Page 39: Programs & Defining Data](https://reader036.fdocuments.net/reader036/viewer/2022062301/56813877550346895da025d3/html5/thumbnails/39.jpg)
Decimal Arithmetic
• Zero-And-Add Packed• ZAP M1(L1),M2(L2) 6-byte format• More like a Move instruction than an Add Instruction
M1(L1) M2(L2)
Before: 12 45 9C 1C
After: 00 00 1C 1C