1 / 77

UNIT

UNIT. Memory Usage. Topics:. Hardware Components Numbering Systems Numeric Conversions Data Representation. Unit: Memory Usage. Unit Introduction.

calder
Télécharger la présentation

UNIT

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. UNIT Memory Usage Topics: • Hardware Components • Numbering Systems • Numeric Conversions • Data Representation

  2. Unit: Memory Usage Unit Introduction • When you program in Assembler Language, you are dealing much more closely with the actual computer hardware than if you were programming in a High Level Language. The Assembler Language programmer must be intimately acquainted with the computer’s hardware components and how they interact, in order to write correct, efficient programs. • This unit covers: • Computer hardware • Numbering systems • Converting between numbering systems and data representation Introduction

  3. Unit: Memory Usage Unit Objectives • At the end of this unit, you will be able to: • Describe how an Assembler program uses main storage • Describe the kinds of registers used in the architecture • Convert numbers between decimal, binary and hexadecimal systems • Add and subtract in binary and hexadecimal • Describe how characters and numbers are stored within S/390 architecture Introduction

  4. UNIT Memory Usage Topics: • Hardware Components • Numbering Systems • Numeric Conversions • Data Representation

  5. Topic: Hardware Components Unit: Memory Usage Topic Objectives • At the end of this topic, you will be able to: • Describe the functions of main storage • Describe the kinds of registers used in the architecture • Define a General Purpose Register (GPR) and Program Status Word (PSW) Introduction

  6. Topic: Hardware Components Unit: Memory Usage Main Storage / Memory • What is main storage? • Main storage, or memory, is the location where programs and data must reside in order to execute. Main storage contains the programs and data that are part of the operating system, and the programs and data that are part of your program. • What is a byte? • The memory is made up of individual binary digits or bits. Bits are grouped into units of 8 bits, called a byte. The byte is the basic unit of addressability in the hardware. 00001111 01000000 00001000 00011000 00011000 11010010 OPERANDS OP CODE BIT NUMBER 11 00 10 10 01 23 45 57 Byte 1 Byte n Byte 0 Concepts

  7. Topic: Hardware Components Unit: Memory Usage Main Storage • Modern operating systems such as MVS, are designed so that “real main storage” is shared between many users. Only the current executable portions of the program and data for each user are present in storage at any point of time. • The programmers view, however, is of virtual storage. The whole Assembler program space resides in virtual storage, in addresses that are continuous from the start to the end of the program space. Virtual Storage: MVS 2 GB User Area Program A Concepts

  8. Topic: Hardware Components Unit: Memory Usage Registers • What are registers? • Registers are another location where operands reside in an Assembler Language program. There are several registers in the architecture. • Types of registers in the architecture are: • General Purpose Registers (GPRs) • Floating Point Registers (FPRs) • Control Registers • Access Registers • Vector Registers General Purpose Registers (GPRs) GPR – Used by the Programmer for Storage Address, Accumulator and Work Area. Floating - Point Registers (FPRs) FPR – Performs Floating Point Arithmetic. Control Registers Control Registers and Access Registers – Used by the Operating System. Access Registers Vector Registers – Used for advanced math calculations Vector Registers Concepts

  9. Topic: Hardware Components Unit: Memory Usage General Purpose Registers • What are General Purpose Registers (GPRs)? • GPRs are of the most interest to programmers. • There are 16 general purpose registers (GPRs), • numbered from 0-15. They are referred to with a • prefix of R (R0, R1, R2…. R15). • The GPRs are 32 bits in length and can hold • fixed-point values between -2, 147, 483, 648, and • +2, 147, 483, 647. • GPRs are used as: • Part of the address for all storage operands • As accumulators and work areas in performing fixed-point arithmetic General Purpose Registers R1 R15 R0 0 BITS 31 1 byte 1 byte 1 byte 1 byte Concepts

  10. Topic: Hardware Components Unit: Memory Usage Program Status Word • What is a Program Status Word (PSW)? • The Program Status Word is a hardware location • where the current status of the Central • Processing Unit (CPU) is represented. It is a • register that is of particular interest to the • Assembler Language programmer. • Amongst other fields, the PSW contains: • The address of the next instruction to be executed • The current value of the condition code (CC) • Other flags, such as the one to indicate whether the CPU is in problem state or supervisor state Program Mask CC C P 0000 0000 0 31 8 12 18 20 24 Instruction Address 0000 0000 32 63 40 Program Status Word (EC Mode) Concepts

  11. Topic: Hardware Components Unit: Memory Usage Are We on Track? • Which of the following registers do applications programs use?A. General Purpose Registers • B. Floating Point Registers • C. Vector Registers • D. Control Registers Review

  12. Topic: Hardware Components Unit: Memory Usage Are We on Track? • GPRs are ______________ bits in size. Review

  13. Topic: Hardware Components Unit: Memory Usage Glossary • Virtual Storage – Memory that appears to an application to be larger and more uniform than it is. Virtual storage may be partially simulated by secondary storage such as a hard disk. Applications access memory through virtual addresses, which are translated (mapped) by special hardware and software into physical addresses. • Problem State – A CPU state, determined by a bit in the Program Status Word (PSW), in which only non-privileged instructions may be executed. • Floating-point – A numeric format that can be used to represent very large real numbers and very small real numbers. Floating-point numbers are stored in two parts, a mantissa and an exponent. The mantissa specifies the digits in the number, and the exponent specifies the magnitude of the number. • Floating-Point • Arithmetic – Arithmetic performed on floating-point numbers. • Supervisor State – A CPU state, determined by a bit in the Program Status Word (PSW), in which both privileged and non-privileged instructions may be executed. Glossary

  14. Topic: Hardware Components Unit: Memory Usage Topic Summary • Now that you have completed this topic, you should be able to: • Describe the functions of main storage • Describe the kinds of registers used in S/390 architecture • Describe a General Purpose Register (GPR) and Program Status Word (PSW) Summary

  15. UNIT Memory Usage Topics: • Hardware Components • Numbering Systems • Numeric Conversions • Data Representation

  16. Topic: Numbering Systems Unit: Memory Usage Topic Objectives • At the end of this topic, you will be able to: • Define and understand Base Value • Define binary and hexadecimal numbers • Convert binary and hexadecimal numbers to decimal numbers and vice versa Introduction

  17. Topic: Numbering Systems Unit: Memory Usage Number System • Although most people are comfortable using the • decimal number system for doing arithmetic, • computers are however binary devices, based on • elements which have two states, represented by • the numbers 0 (off) and 1 (on). • While the HLL programmer does not often have to • work with non-decimal numbers, the Assembler • Language programmer does. • The Assembler Language programmer also has • to be aware of hexadecimal or base 16 numbers. Number System Example 1234 Decimal Binary 0110 2E3 Hexadecimal Concepts

  18. Topic: Numbering Systems Unit: Memory Usage Base Value • What is base value? • Every number system has some base value. The • base value of the decimal system is 10. To • represent numbers in a number system of base n, • there must be n unique symbols. Continued… Concepts

  19. Topic: Numbering Systems Unit: Memory Usage Base Value (cont’d) • To represent numbers equal to or greater than the • base, more than one digit is required. • To represent the number ten in decimal, we use • the two digits 10. To represent the number two • hundred and forty one, we use the three digits • 241. What does 241 mean? It means 2 times 100 • plus 4 times 10 plus 1. 2 4 1 1 2 0 10 10 10 Ones 1 X 1 = 1 Tens 4 X 10 = 40 Hundreds 2 X 10 X 10 = 200 So 241= (2*10*10) + (4*10) + (1*1) Continued… Concepts

  20. Topic: Numbering Systems Unit: Memory Usage Base Value (cont’d) • The number 241 can be represented as • (2*102) + (4*101) + (1*100) • To determine the value of a number proceed as follows: • Multiply the digit in the rightmost position by the base raised to power 0, which is 1 • Add the next leftmost digit multiplied by the base raised to the power 1, which is the base • Add the next digit multiplied by the base raised to the power of 2 etc., until we run out of digits 1 2 4 0 1 X 10 1 4 X 10 2 2 X 10 Concepts

  21. Topic: Numbering Systems Unit: S/390 Memory Usage Are We on Track? • How many unique symbols are used in the octal (base 8) number system? • A. 2 • B. 7 • C. 8 • D. 9 Review

  22. Topic: Numbering Systems Unit: Memory Usage Binary Numbers • What are binary numbers? • Binary numbers are numbers represented using • the base 2. Base 2 numbers are represented with • only 2 unique symbols, 0 and 1. The only values • that can be represented with a single binary digit • (or bit) are 0 and 1. 1 1 0 1 (23) (22) (21) (20) ones twos fours eights Continued… Concepts

  23. Topic: Numbering Systems Unit: Memory Usage Binary Numbers (cont’d) • What decimal value does the binary number 101101 represent ? • To determine this, we can rewrite the number to represent its meaning more clearly. 1011012 (Binary Value) = (1 X 25) + (0 X 24) + (1 X 23) + (1 X 22) + (0 X 21) + (1 X 20) = (1 X3210) + (0 X 1610) + (1 X 810) + (1 X410) + (0 X 210) + (1 X 1) = 3210 + 810 + 410 + 110 = 4510 (Decimal Value) A subscript coded after a number represents its base. Concepts

  24. Topic: Numbering Systems Unit: Memory Usage Converting Binary to Decimal Value • Once we get used to using binary notation, it is • easy to convert binary values back to the • equivalent decimal value. 1 0 1 1 0 1 1 X 20 = 10 + 0 X 21 = 0 + + 1 X 22 = 4 + 1 X 23 = 8 + 1 X 24 = 0 4510 (DECIMAL VALUE) = 1 X 25 = 32 Remember – Digit positions, from right to left, represent the values 1,2,4,8,16, 32, 64 and so on. Continued… Concepts

  25. Topic: Numbering Systems Unit: Memory Usage Converting Binary to Decimal Value (cont’d) • In 45 10 = 101101 2 , the value of the number • is the same but, the notation and the base are • different. 4510 1011012 = Concepts

  26. Topic: Numbering Systems Unit: Memory Usage Are We on Track? • What is the decimal equivalent of 110112? • A. 20 • B. 27 • C. 23 • D. 26 Review

  27. Topic: Numbering Systems Unit: Memory Usage Are We on Track? • Match the binary values with their decimal equivalents. • 1. 10112 A. 1510 • 2. 10002 B. 5103. 11112 C. 11104. 01012 D. 810 Review

  28. Topic: Numbering Systems Unit: Memory Usage Binary System - Limitations • The binary system is important because it is the • way the computer represents numbers internally. • The binary system is difficult to work with large • values, since the number of digit positions • become very large. As a result, we often use • hexadecimal notation as an alternative to binary • to represent numbers. • The number 4510 required 6 binary digits to • represent it. The largest 4 digit decimal number, • 9999, requires 14 binary digits. It is difficult to deal • with representations this long without making • errors. 00002 = 010 1011012 = 4510 1110010002 = 35610 111100111012 = 92510 100111100011112 = 999910 Concepts

  29. Topic: Numbering Systems Unit: Memory Usage Using Hexadecimal Numbers • The symbol A16 is equivalent to 10, B is 11, C is • 12, D is 13, E is 14 and F is 15. Since 16 (the • base of hexadecimal numbers) is 24, there is a • close equivalent between binary and hexadecimal • notations. HEXADECIMAL BINARY DECIMAL 0000 0 0 0001 1 1 0010 2 2 0011 3 3 0100 4 4 0101 5 5 0110 6 6 0111 7 7 1000 8 8 1001 9 9 1010 A 10 1011 B 11 1100 C 12 1101 D 13 1110 E 14 Each hexadecimal digit is equal to 4 binary digits. See these equivalencies in the table. 1111 F 15 Concepts

  30. Topic: Numbering Systems Unit: Memory Usage Conversion between Binary and Hexadecimal • These equivalencies between binary and hexadecimal make conversion between these two bases almost trivial. Assembler language programmers should be able to perform the conversions represented in this table almost without thinking. 1100 C 4 0100 1111 F Concepts

  31. Topic: Numbering Systems Unit: Memory Usage Are We on Track? • Which of the following are true? • A. The hexadecimal number system uses 16 unique symbols to represent numbers. • B. The hexadecimal digit C is equivalent to 13 decimal. • C. The hexadecimal number A00 is equal to 10 * 163 in decimal. • D. Values greater than 1510 need more than one digit in their hexadecimal representation. Review

  32. Topic: Numbering Systems Unit: Memory Usage Are We on Track? • The binary value of 10011101 is represented in hexadecimal as _____________. Review

  33. Topic: Numbering Systems Unit: Memory Usage Converting Binary, Hexadecimal to Decimal • In the case of binary to hexadecimal, group the • binary digits into groups of four, starting at the • right and replace each group of 4 binary digits by • the corresponding hexadecimal digits. You may • have to add some leading zeroes to the left most • group to get up to four bits. Hexadecimal C 4 F 1111 0100 Binary 1100 Continued… Concepts

  34. Topic: Numbering Systems Unit: Memory Usage Converting Binary, Hexadecimal to Decimal (cont’d) • Converting between decimal and the other two • bases is a little more complex. • To convert binary or hexadecimal to decimal, • simply multiply each hexadecimal or binary digit • by the decimal value of its position and add the • products. Binary to Decimal 101011012 = 1 + 4 + 8 + 32 + 128 = 17310 Hexadecimal to Decimal 2 AC16 = (2 X 162) + (10 X 161) + (12 X 160) = 512 + 160 +12 = 68410 Concepts

  35. Topic: Numbering Systems Unit: Memory Usage Converting from Decimal to Binary and Hexadecimal • Such conversions are performed generating one digit at a time, right to left by successive divisions by the • desired base. • Example: To convert 83 decimal to binary we would proceed as follows. We form the binary number from the • digits we have extracted. Thus 8310 = 10100112 83(10) = 1 Divide 1 by 2 giving a quotient of 0 and a remainder of 1. 1 is the seventh rightmost digit. Since the quotient is now zero, we stop. 1 0 Divide 2 by 2 giving a quotient of 1 and a remainder of 0. 0 is the sixth rightmost digit. 0 1 1 Divide 5 by 2 giving a quotient of 2 and a remainder of 1. 1 is the fifth rightmost digit. 0 Divide 10 by 2 giving a quotient of 5 and a remainder of 0. 0 is the fourth rightmost digit. 0 0 0 Divide 20 by 2 giving a quotient of 10 and a remainder of 0. 0 is the third rightmost digit. 1 1 Divide 41 by 2 giving quotient of 20 and a remainder of 1. 1 is the second rightmost digit. 1 1 Divide 83 by 2 giving quotient of 41 and a remainder of 1. 1 is the rightmost digit of the result. Continued… Concepts

  36. Topic: Numbering Systems Unit: Memory Usage Converting from Decimal to Binary and Hexadecimal (cont’d) • Conversion from decimal to hexadecimal works in • a similar manner, only now the divisor is 16, which • is the base of hexadecimal numbers. • Example: • To convert 1205 decimal to hexadecimal proceed • as follows. Form the hexadecimal numbers from • the digits that have been extracted. Thus • 120510 = 4B516 Decimal to Hex 1205(10) = 4 Divide 4 by 16 giving a quotient of 0 and a remainder of 4.4 is the third rightmost digit 4 B Divide 75 by 16 giving a quotient of 4 and a remainder of 11.B is the third rightmost digit B 5 Divide 1205 by 16 giving a quotient of 75 and a remainder of 5.5 is the rightmost digit of the result 5 Concepts

  37. Topic: Numbering Systems Unit: Memory Usage Conversion Table • The manual process can be disregarded if the • programmer is in possession of a calculator with • the capability of performing binary to decimal to • hexadecimal conversions. • A table of conversion factors can also save time. Concepts

  38. Topic: Numbering Systems Unit: Memory Usage Are We on Track? • To convert decimal numbers to hexadecimal, divide the decimal number by _______________ , record the remainder and continue division with the quotient. Review

  39. Topic: Numbering Systems Unit: Memory Usage Are We on Track? • Which of the following are equal to decimal 20? • A. 1416 • B. 267 • C. 346 • D. 101002 Review

  40. Topic: Numbering Systems Unit: Memory Usage Topic Summary • Now that you have completed this topic, you should be able to: • Define and understand Base Value • Define binary and hexadecimal numbers • Convert binary and hexadecimal numbers to decimal numbers and vice versa Summary

  41. UNIT Memory Usage Topics: • Hardware Components • Numbering Systems • Numeric Conversions • Data Representation

  42. Topic: Numbering Conversions Unit: Memory Usage Topic Objectives • At the end of this topic, you will be able to: • Understand simple binary and hexadecimal arithmetic • Add and subtract with binary and hexadecimal numbers Introduction

  43. Topic: Numbering Conversions Unit: Memory Usage Binary Addition • The Assembler Language Programmer will • sometimes be required to do simple arithmetic • with binary and hexadecimal numbers. The • methodology of doing addition and subtraction is • the same as with decimal numbers, except that • the base is different. • Example: • First add two binary numbers: • 1001011 • +101101 • -------------- CCCC 1001011 + 101101 1111000 In arithmetic addition, a carry occurs when the sum of a specific position exceeds the base minus one. Concepts

  44. Topic: Numbering Conversions Unit: Memory Usage Hexadecimal Addition • Example: • Look at an example of hexadecimal addition: 36B5 + 83C7 B Finally, 0 + 3 + 8 = B. Record the final digit. 36B5 + 83C7 = BA7C. Thus 36B516 + 83C7 = BA7C16 B A In the next position 1 + 6 + 3 = A. Record the A and carry 0. Carry 0 A in hex represents a 10. 36B5 + 83C7 = A7C A 7 In the next rightmost position 0 + B + C = 17. Record the 7 and carry the 1. Carry 1 36B5 + 83C7 = 7C B + C = 23 which in base 16, can be represented by a 7 for a total of 7 past the base 16(16 + 7 = 23) and carry the one which is the base 16. 7 C Again we start in the rightmost position. 5 + 7 = C. Record the C and carry 0. Carry 0 36B5 + 83C7 = C 5 + 7 = 12 which in hex is represented by a C. C Concepts

  45. Topic: Numbering Conversions Unit: Memory Usage Are We on Track? • What is the sum of the following binary numbers? 100101102 + 1110012 = ____________________ Review

  46. Topic: Numbering Conversions Unit: Memory Usage Are We on Track? • What is the sum of the following hexadecimal numbers? • BC3716 + 179416 = __________________ Review

  47. Topic: Numbering Conversions Unit: Memory Usage Subtraction in Binary • Subtraction in binary and hexadecimal is • performed similar to decimal subtraction, but • remembering that when having to borrow, the • value borrowed is the base. • Example: • 10100110 • -1101001 • --------------- • 111101 10100110 - 1101001 111101 Continued… Concepts

  48. Topic: Numbering Conversions Unit: Memory Usage Subtraction in Hexadecimal • Example: • C5E6 • -2D47 • ------------ • 989F C5E6 - 2D47 989F Concepts

  49. Topic: Numbering Conversions Unit: Memory Usage Are We on Track? • To borrow in subtraction subtract 1 from the digit position n+1 and add the ___________ • value to position n. Review

More Related