Download presentation

Presentation is loading. Please wait.

Published byMarcos Pennix Modified over 2 years ago

1
Programs & Defining Data Ch.5 – pp. 95-109

2
Data in Computer Memory See page 69 480 481 482 Byte locations in memory - One character per byte location 483

3
Data in Memory G=C7=1100 0111 E=C5=1100 0101 O=D6=1101 0110 R=D9=1101 1001 G=C7=1100 0111 E=C5=1100 0101 3=F3=1111 0011 4=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

4
DecimalBinaryHex 000000 100011 200102 300113 401004 501015 601106 701117 810008 910019 101010A 111011B 121100C 131101D 141110E 151111F 161 000010 Hexadecimal conversion chart – the same as shown in your text on page 70. Representing Data 1 Character = 1 Byte = 2 Hex Digits

5
Representing Character Data Left justified - padded with blanks (40) - truncated to the right Example: GEORGE=C7 C5 D6 D9 C7 C5

6
Define Storage / Constant

7
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 characters 1 st must be alphabetic 1. Duplication factor 2. Type code 3. Length

8
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: MOVEOWKPRICE,INVCOST*MOVE COST TO PRICE MOVEOWKONHND,INVHAND*MOVE ONHAND TO ONHAND PUTOUTFILE,OWKAREA*PRINT ENTIRE O/P RECORD p. 103

9
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

10
And the Memory Reserved? UNPK OWKPRICE(5),PPRICE Print from OWKAREA

11
Another Example?

12
Initializing Storage Areas Define Constants – DC, rather than DS ABCDCC’ABC’C1 C2 C3 DSIGNDCC’$’5B NO3DCC’3’F3 NAMEDCC’JOE’D1 D6 C5 TAXRTDCC’28’F2 F8

14
Example (w/instructions) CALCPACKRATE(4),TAXRT PACKTAXAMT(6),TOTINC MPTAXAMT(6),RATE UNPKINCTAX(8),TAXAMT(6) ….. RATEDSF TAXRTDCCL2’20’*F2 F0 TAXAMTDSPL6 TOTINCDCCL’40000’*F4 F0 F0 F0 F0 INCTAXDSCL8

15
Other Data Types [label]DS/DCCcharacter Xhex Ppacked dec. Bbinary Ffullword (bin) Hhalfword (bin) Ddoubleword

16
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 Feb. 8, 2007

17
Representing Packed Decimal Right justified, padded with leading zeroes +1234=0001234C -1234=0001234D 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.

18
Representing Binary Data 1 byte = 8 binary digits (bits) 1011 0110 (B6) Halfword = 2 bytes Fullword = 4 bytes 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’

19
Convert Binary to Decimal 001100101001 204810245122561286432168421 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 2 1, then 2 2, and so forth. Then simply add up the equivalent decimal values where there are 1-bits in the binary field above.

20
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

21
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 15178 10 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

22
HexDecHexDecHexDecHexDecHexDec 0000000000 165,53614,096125611611 2131,07228,192251223222 3196,608312,228376834833 4262,144416,38441,02446444 5327,880520,48051,28058055 6393,216624,57661,53669666 7458,752728,67271,792711277 8524,288832,76882,048812888 9589,824936,86492,304914499 A655,360A40,960A2,560A160A10 B720,896B45,056B2,816B176B11 C786,432C49,152C3,072C192C12 D851,968D53,248D3,328D208D13 E917,504E57,344E3,584E224E14 F983,040F61,440F3,840F240F15 4 10 = A A 15,178 = 15178 - 12288 2890 1 3 2 2890 - 2816 74 B 3 74 - 64 10 4

23
Or - Convert Doing the Arithmetic 15178 / 16 = 948.625 Remainder.625 is integer.625 X 16 = 10 (A) 948 / 16 = 59.25 Remainder.25 is integer.25 X 16 = 4 (4) 59 / 16 = 3.6875 Remainder.6875 is integer.6875 X 16 = 11 (B) 3/16 = 0.1875 Remainder.1875 is integer.1875 X 16 = 3 (3) Using result in reverse order = 3B4A

24
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

25
Book Examples ReceivingSending Before:99 99 99F1 F2 F3 F4 F5 After:12 34 5FF1 F2 F3 F4 F5 Before:00 00 F2 F6 F4 F8 After:00 02 64 8FF2 F6 F4 F8 Before:00 F6 F3 F2 F0 F4 After:20 4FF6 F3 F2 F0 F4 p. 84/85 PACKRECEIVING,SENDING

26
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

27
Book Examples ReceivingSending Before:00 00 00 00 0056 43 7F After:F5 F6 F4 F3 F756 43 7F Before:00 00 00 00 0003 4C After:F0 F0 F0 F3 C403 4C Before:00 13 91 2D After:F1 D213 91 2D p. 85 UNPKRECEIVING,SENDING

28
Quick Review of Data ZD=F2 F0 F5 F5 F9 F7 F4 F7 F4 PD=20 55 97 47 4F Hex=0C 41 2B 22 Bin=0000 1100 0100 0001 0010 1011 0010 0010 p. 76

29
Instruction Formats Page 76 - bottom

30
Instruction Lengths 2 addresses – sending and receiving fields M2

31
Sending and Receiving Fields (A Reminder) ReceivingSending Before:F0 F4 F3 F9 F9F0 F0 F7 F0 F1 After:F0 F0 F7 F0 F1 See page 77 at the top

32
A Typical 6-byte Instruction

33
Sample 4-byte Instruction

34
And A 2-byte Instruction

35
Decimal Arithmetic Add Decimal APM1(L1),M2(L2)6-byte format M1(L1)M2(L2) Before:10 00 0F01 0F After:10 01 0C01 0F Before:87 11 0F40 00 0F After:27 11 0C40 00 0F In the 2 nd Add: high-order digit overflowed and lost

36
Decimal Arithmetic Subtract Decimal SPM1(L1),M2(L2)6-byte format M1(L1)M2(L2) Before:10 00 0F75 0F After:09 25 0C75 0F

37
Decimal Arithmetic Multiply Decimal MPM1(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 8C50 0F After:04 00 0C50 0F

38
Decimal Arithmetic Divide Decimal DPM1(L1),M2(L2)6-byte format M1(L1)M2(L2) Before:00 00 00 05 3C00 7C After:00 00 7C 00 4C00 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

39
Decimal Arithmetic Zero-And-Add Packed ZAPM1(L1),M2(L2)6-byte format More like a Move instruction than an Add Instruction M1(L1)M2(L2) Before:12 45 9C1C After:00 00 1C1C

Similar presentations

Presentation is loading. Please wait....

OK

Binary Arithmetic Math For Computers.

Binary Arithmetic Math For Computers.

© 2018 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on social networking security Ppt on class 10 hindi chapters Ppt on foldable screen technology Ppt on water scarcity Download ppt on respiration in animals Ppt on shell scripting interview Seminar ppt on cloud computing Ppt on different types of forests images Download ppt on bullet train Ppt on statistics and probability review