1 / 66

Systems Environment 2

Systems Environment 2. Quick Revision Review of Exercises Processor Instructions Introduction to TOM. Quick Revision. Diagram 3 The CPU Level. Central Processing Unit. Control Unit. Registers. Arithmetic & Logic Unit. The Register Level. A register is a collection of “cells”.

Télécharger la présentation

Systems Environment 2

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. Systems Environment 2 Quick Revision Review of Exercises Processor Instructions Introduction to TOM

  2. Quick Revision

  3. Diagram 3The CPU Level Central Processing Unit Control Unit Registers Arithmetic & Logic Unit

  4. The Register Level A register is a collection of “cells”. Each cell is a “flip-flop” electronic device which can be in one of two stable states.

  5. The Register Level Cells within the register can be held at high or low status. This collection of cells now represents the Binary Number 11011001

  6. The Register Level Information comes in on 8 wires, using a write enable signal. Write Read Information is transferred (read) by using a similar read enable signal

  7. Diagram 3The CPU Level Central Processing Unit Control Unit Registers Arithmetic & Logic Unit

  8. Diagram 4The ALU Level Arithmetic & Logic Unit Arithmetic Operations Logic Operations

  9. Diagram 5The Logic Operation Level Logic Operations AND OR NOT COMPARE

  10. Binary and Hexadecimal

  11. Bytes • The way that information is coded is to use a sequence of zeros and ones • It is usual to have a sequence of 8 bits collected together • This is called a byte 10110101

  12. Bits • A bit is the smallest piece of information in the computer • In a single cell, the digital information is either • One - current is HIGH (ON) • Zero - current is LOW (OFF) • There are no in-between states ON OFF

  13. A 4-bit register • Reading from the right, each bit is worth double the one preceding it. • The sequence, reading from the right is: • 1,2,4,8, ... • If we had more bits, it would continue: • ... 16, 32, 64, etc. 8 4 2 1 4 is ON 1 is ON

  14. Binary Numbers 1 • The register shown on the right represents the binary number 0101 • This has ones in the 1 and 4 cells, and zeroes in the others. • The number represented is 5 8 4 2 1 0101 4 1 4+1 = 5

  15. Binary Numbers 2 • By Binary, we mean that numbers are written in powers of two • These are 1, 2, 4, 8, 16 etc. • So that: 10100 = • Which is 16 + 4 = 20 16 8 4 2 1 1 0 1 0 0

  16. Converting Binary to Decimal • Example: 101101 • Reading from right to left the columns are 1,2,4,8 etc. i.e. 32 16 8 4 2 1 1 0 1 1 0 1 • So the number in decimal notation is: 32 + 8 + 4 + 1 = 45

  17. Converting Decimal to Binary:An example • Convert 117 to binary: • 117÷ 2 = 58 remainder 1 • 58 ÷ 2 = 29 remainder 0 • 29 ÷ 2 = 14 remainder 1 • 14 ÷ 2 = 7 remainder 0 • 7 ÷ 2 = 3 remainder 1 • 3 ÷ 2 = 1 remainder 1 • 1 ÷ 2 = 0 remainder 1 • In binary the number is: 1110101

  18. There are only four possible combinations. The first three are “obvious” The last one is special (remember 1 + 1 = 2, which is 10 in binary) 0 + 0 = 0 0 + 1 = 1 1 + 0 = 1 1 + 1 = 0, carry 1 Adding in Binary

  19. Adding in Binary • The answer: 1 0 1 1 1 + 1 1 1 0 1 1 1 0 1 0 0 1 1 1 1 1 1 + 1 = 10 i.e. two in binary 1 + 1 + 1 = 11 i.e. three in binary

  20. These numbers are written in base 16, so that a number like 9E means the 9 is 9 x 16 = 144 the E is 14 x 1 = 14 Altogether this would be 158 Dec Hex 0  0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 A 11 B 12 C 13 D 14 E 15 F Hexadecimal Numbers

  21. Hexadecimal Numbers • Normally in the context of computers, we will only be considering two-digit Hexadecimal numbers like A3 or 4E • When the numbers have more digits we tend to split them up into two-digit pairs. • This makes interpretation a lot easier

  22. Hexadecimal to Decimal For example: • The number 4E in Hexadecimal, is: 16 1 4 E • That is 4 x 16 = 64 • and E (= 14) x 1 = 14 • Total : 78 (Decimal Notation)

  23. Converting Decimal to Hexadecimal Example: Convert 181 to Hexadecimal 181  16 = 11 remainder 5 In Hexadecimal 11 = B In Hexadecimal 5 = 5 This means: 181 = B5 DecimalHexadecimal

  24. The easiest way to convert Hex to Binary is by using a ‘look-up’ table to find the Binary equivalents for the Hex digits 0 to F For example, the Binary for 6A would just be: 6 = 0110 A = 1010 6A = 0110 1010 Hex Binary 0  0000 1  0001 2  0010 3  0011 4  0100 5  0101 6  0110 7  0111 8  1000 9  1001 A  1010 B  1011 C  1100 D  1101 E  1110 F  1111 Hexadecimal to Binary

  25. Converting Binary to Hex can be done in exactly the same way, by using a look-up table For example the binary number 10011011 will be: 1001 = 9 1011 = B So that 10011011 = 9B Binary Hex 0000  0 0001 1 0010 2 0011 3 0100 4 0101 5 0110 6 0111 7 1000 8 1001 9 1010 A 1011 B 1100 C 1101 D 1110 E 1111 F Binary to Hexadecimal

  26. Activity 1 We will now review the answers to Exercise 2 pp 18-19, Nos 1,2,3 & 4.

  27. Adding in Hexadecimal 28 9B C3 1 8 + B = 13 (i.e. nineteen written in hexadecimal) 2 + 9 +1 = C (i.e. twelve written in hexadecimal)

  28. Activity 2 • If you have not already done so, complete exercise 2.5 • If you have completed this, work out thes challenges: • In Hexadecimal: • F1 – A9 = • D x 15 = • 012C  FF = • 2A =

  29. Processor Instructions

  30. Diagram 3The CPU Level RAM Control Unit Registers Near the control unit is the Program Counter (PC) This indicates which instruction is currently being processed. The most Important of the registers is the Accumulator (ACC) ALL Data and Instructions must pass through the here. Arithmetic & Logic Unit

  31. Processor instructions are normally split into two parts: The Operation Code which is written to the IR The Operand which is written to the MRB IR Instruction Register MRB Memory Read Buffer Processor Instruction Set Note that some instructions consist only of an Op Code, and do not require Operands. Op Code Operand IR MRB

  32. Instruction Types Instructions beginning STx • These are instructions to STORE data at some RAM Memory Location Instructions beginning LDx • These are instructions to LOAD Data into the Accumulator Instructions beginning ADx • These are instructions to ADD data to the contents of the Accumulator

  33. Instruction Types Instructions ending xxI • These instructions use the Immediately following operand as the data Instructions ending xxD • These instructions use the operand as an Address Directly to Access the data Instructions ending xxN • These instructions use the operand as an address iNdirectly, to locate the address where the data is to be found.

  34. Instruction Types Instructions not requiring an Operand: IN • This inputs data into the processor from an external source OUT • This outputs data to the VDU STP • This stops the processor.

  35. LDI 34 STD 25 ADN 43 Loads 34 Immediately into the Accumulator Stores the contents of the accumulator at memory address 25 Finds memory address 43, there goes to the location specified there. Takes the data at this second location and adds it to the value in the accumulator Examples

  36. 00 LDI 08 STN 01 15 09 12 02 STD 10 STP 03 12 11 00 04 LDD 12 22 05 13 13 33 06 ADD 14 01 07 14 15 78 Trace through this program to see what it does. You will need to keep careful track both of the accumulator and of memory locations 11 to 15 A Working Program (1)

  37. 00 LDI08 STN 011509 12 02 STD 10 STP 03 12 11 00 04 LDD 12 22 05 13 13 33 06 ADD 14 01 07 14 15 78 ACC: 15 RAM 11 00 12 22 13 33 14 01 15 78 Program Working Load 15 immediately into the Accumulator

  38. 00 LDI 08 STN 01 15 09 12 02 STD10 STP 031211 00 04 LDD 12 22 05 13 13 33 06 ADD 14 01 07 14 15 78 ACC: 15 RAM 11 00 12 15 13 33 14 01 15 78 Program Working Store the contents of the accumulator Directly at location 12

  39. 00 LDI 08 STN 01 15 09 12 02 STD 10 STP 03 12 11 00 04LDD12 22 051313 33 06 ADD 14 01 07 14 15 78 ACC: 33 RAM 11 00 12 15 13 33 14 01 15 78 Program Working Load the accumulator Directly with the contents of location 13

  40. 00 LDI 08 STN 01 15 09 12 02 STD 10 STP 03 12 11 00 04 LDD 12 22 05 13 13 33 06ADD14 01 07 1415 78 ACC: 34 RAM 11 00 12 15 13 33 14 01 15 78 Program Working Add the contents location 14 Directly to the Accumulator

  41. 00 LDI 08STN 01 15 0912 02 STD 10 STP 03 12 11 00 04 LDD 12 22 05 13 13 33 06 ADD 14 01 07 14 15 78 ACC: 34 RAM 11 00 12 15 13 33 14 01 15 34 Program Working Store the contents of the accumulator inDirectly at the address specified by location 12

  42. 00 LDI 08 STN 01 15 09 12 02 STD 10STP 03 12 11 00 04 LDD 12 22 05 13 13 33 06 ADD 14 01 07 14 15 78 ACC: 34 RAM 11 00 12 15 13 33 14 01 15 34 Program Working Stop Processing

  43. 00 LDI * Load 15 into Accumulator 01 15 02 STD * Store Accumulator contents 03 12 directly at location 12 04 LDD * Load Accumulator with contents of 05 13 location 13 06 ADD * Add contents of Location 14 to 07 14 Accumulator 08 STN * Store contents of Accumulator at 09 12 address specified at location 12 10 STP * Stop Processing Interpretation of the Instructions

  44. 00 LDD 01 11 02 ADD 03 11 04 STN 05 10 06 STN 07 09 08 STP 09 25 10 09 11 05 Working Program (2) Interpret these instructions, and write them out fully. Then execute the program, to see what effect it has on locations 9,10 and 11.

  45. 00 LDD * Load the contents of location 11 01 11 into the Accumulator 02 ADD * Add contents of location 11 03 11 to the Accumulator 04 STN * Store the contents of Accumulator 05 10 at address specified in location 10 06 STN * Store the contents of Accumulator 07 09 at address specified in location 9 08 STP * Stop Processing 0910 1010 1105 Full Interpretation (2)

  46. More Instructions These commands work by changing the value in the PC These instructions all divert processing to different locations in RAM: JMP xx • The program counter changes to XX and processing continues from there. JZ xx • If the Accumulator is Zero, the program counter changes to xx and processing continues from there. JMI xx • If the Accumulator is Negative, the program counter changes to xx and continues processing from there.

  47. 00 IN 01 JZ 02 07 03 STD 04 10 05 STP 06 00 07 JMP 08 00 09 STP 10 27 Working Program (3) Translate this program into full instructions, Then execute the program, to see what effect it has.

  48. 00 IN * Input 01 JZ * If Accumulator Zero, 02 07 jump to location 7 03 STD * Store contents of Accumulator. 04 10 directly at location 10. 05 STP * Stop 06 00 --- No Command --- 07 JMP * Jump immediately 08 00 to location 00 09 STP * Stop Processing 10?? --- value is first non-zero input -- Full Interpretation (3)

  49. Program CheckZero Begin Repeat Input Value Until Value <> 0 Let A = Value End High-Level PseudoCode This summarises what the program does in a more succinct manner.

  50. Program (name) Begin do things End If (condition) Then do things Else do things Endif For Count = 1 to X do things EndFor While (condition) do things EndWhile Write (number) Read (number) A: = (something) PseudoCode Commands

More Related