Presentation is loading. Please wait.

Presentation is loading. Please wait.

Representation of Data - Instructions Start of the lesson: Open this PowerPoint from the A451 page – Representation of Data/ Instructions How confident.

Similar presentations


Presentation on theme: "Representation of Data - Instructions Start of the lesson: Open this PowerPoint from the A451 page – Representation of Data/ Instructions How confident."— Presentation transcript:

1 Representation of Data - Instructions Start of the lesson: Open this PowerPoint from the A451 page – Representation of Data/ Instructions How confident do you feel in: (p) (q)

2 Quick revision – what is a computer system?

3 Quick revision CPU? RAM program executed address data decoded logic ? ? ?

4 Computer Source Code As human beings we find it easier to read and write computer programs if they are written in a language similar to the one we use in everyday life ie English SOURCE CODE IF count < 10 Display “Enter number” accept number END IF

5 Machine Code However computers only understand binary ie machine code Therefore the source code we write must be converted to machine code MACHINE CODE 00101010001101001010 01101110101011000010 01001000100101110100 10010000000100111000 11001010011011001001 00101001010010010110 0001000 SOURCE CODE IF count < 10 Display “Enter number” accept number END IF

6 Turning Source Code into Machine Code Programming languages that are very similar to “human” languages are called high-level languages Examples: COBOL, Python, C++, Java Usually computer programmes in these languages, once written, are compiled into machine code and saved as executables ready for use. This is performed by a compiler. For some languages, however, the source code is converted on the fly as each instruction needs to be performed. This is performed by an interpreter. Programming languages that are very similar to machine code already are called low-level languages Example: Assembly language Assembly language is converted to machine code by an assembler.

7 High level programming language Low level programming language Machine Code Easier to read for a human Easier for the computer to process Drag and drop so the diagram makes sense. Add examples too!

8 Compiler Interpreter Converts high level code into a machine code based executable file. Creates an executable file that is normally machine specific (PC/Mac/Linux/iOS/Android) Example: Java Virtual Machine Example: creating an executable file using Python to run on a PC Each line of code is processed and converted to machine code in real time (‘on the fly’) Allows high level coding to be run on a variety of platforms

9

10 http://peterhigginson.co.uk/LMC/ Little Man Computer

11 BBC Revise Wise http://www.bbc.co.uk/education/guides/z2342 hv/revision http://www.bbc.co.uk/education/guides/z2342 hv/revision Read though the revision guide and complete the test.

12 Cambridge Mooc http://www.cambridgegcsecomputing.org/repr esentation-of-data-in-computer-systems-main http://www.cambridgegcsecomputing.org/repr esentation-of-data-in-computer-systems-main 39 Instructions – complete the test and Activity 1

13 Instructions in Machine Code In machine code the instructions are usually made up of 2 parts, an operation code and a memory address. Example: 01000010 The CPU uses the operation code (for example, the bit pattern 001 could be the code for ADD) to decide what action to take with the second part, which is usually a memory location with some stored data. A particular CPU will be designed to process a particular set of machine code instructions and will know: How many bits are used for each instruction. How many of the instruction bits are used for the operation code (OP code) and how many for the memory address. The set of instructions for a CPU is know as the Instruction Set.

14 Instructions and Memory The number of memory bits needed for each instruction (operation codes plus memory address) is important. If only 8 bits were used then 3 bits could be used for the operation codes leaving 5 for the location in memory where the data is stored. This would be very limiting as there could only be 8 possible operation codes and only memory addresses from 00000 to 11111 could be accessed.

15 The Von Neumann Architecture In computers based upon the Von Neumann Architecture, all program instructions are stored in memory, the same as the data is. The CPU cannot therefore distinguish between instructions and data just by reading the contents of memory since they are both just bit patterns.

16 How does the computer distinguish between instructions and data? 00000000010000200003000040000500006etc 0100001010101111 Memory addresses Instruction (Op code + memory address) Data The program pointer will point to the memory address of the first instruction eg 00000 As the CPU performs the Fetch-Decode-Execute cycle: the contents of the memory address obtained by the Fetch will be treated as an Instruction during the Execute stage the memory address referred to by the instruction will be treated as data and data will either placed copied from it or saved to it Sometimes the CPU will Fetch a value that is really data and not an instruction, usually because the memory address has been overwritten. This will cause an error.

17 Finally… How confident are you feeling now? Let’s quickly revisit our definition of software..


Download ppt "Representation of Data - Instructions Start of the lesson: Open this PowerPoint from the A451 page – Representation of Data/ Instructions How confident."

Similar presentations


Ads by Google