250 likes | 366 Views
Systems Software. Program. A program is a set of instructions which tell the CPU what to do Programs are usually written in a team environment. Instructions. Program instructions are written using a special programming language Different languages use different syntax (rules).
E N D
Program • A program is a set of instructions which tell the CPU what to do • Programs are usually written in a team environment
Instructions • Program instructions are written using a special programming language • Different languages use different syntax (rules)
Programming languages • These are classed as follows: • Low Level Language • High Level Language
Low Level Language • A computer language that uses commands that we do not necessarily understand as humans • Machine Code • Assembly Language
Machine Code • A computer language that uses binary numbers to represent commands: 111111111111111111111111 000000000000000000000000 101010101010101010101010 010101010101010101010101
Machine Code • All program instructions must be translated into Machine Code so that the instructions can be carried out by the CPU
Advantages: Machine Code • As this is the computers own language, programs run very fast as the instructions are understood easily (by the computer)
Disadvantages: Machine Code • Difficult for humans to program in Machine Code • Difficult to locate errors (DEBUG)
Assembly Code • A computer language that uses letters, punctuation and numbers to represent commands: • LDA 50 • Load the accumulator with the number 50 • STA &64 • Store the contents of the accumulator in the memory location with address 64
Assembly Code • Instructions written in assembly code must be TRANSLATED into machine code before the CPU understands the instruction
Advantages: Assembly Code • Programs run very quickly as the translation process is fast due to the use of MNEMONICS. • A mnemonic is an abbreviation or shortened word
Disadvantages: Assembly Code • Difficult for humans to program in Assembly Code • Difficult to locate errors (DEBUG)
High Level Language • A computer language that uses commands similar to the English Language • True Basic • Comal • Pascal • Fortran • Prolog
True Basic ! Program by Mr G, 23/10/01 ! This program will display a train PRINT “ ___________ @ “ PRINT “ l __ l _ @ “ PRINT “ _____l l__l l________l l “ PRINT “ l l “ PRINT “ l____ ________ _______l “ PRINT “ O O “ END
Advantages: HLL • Easier to read, understand and write programs • Easier to locate errors (Debug) • Portability: • Programs can be altered so that they can run on different Operating Systems
Disadvantages: HLL • Instructions written in a HLL must be TRANSLATED into machine code before the CPU understands the instruction • This takes time making the program slower to run
Translator Programs • Programs which will translate the instructions of a program into Machine code. • There are 3 types of translator: • Assembler • Interpreter • Complier
Q Questions • Page 77 • All Foundation and General Questions
Assembler • Translates the instructions of an assembly code program into Machine code. LDA &28 00001111 CLE &87 111111111 JMP &4 101010101 STA & 67 000111000 SOURCE CODE OBJECT CODE
Note: Assembler • Changes are not easily made. • The original source code will have to be edited and translated again • Runs fast • Produces Object Code which can be run without the assembler being present in memory - efficient
Interpreter • Translates the instructions of a program written in a HLL into Machine code one instruction at a time. LET TOTAL = 0 000001111010100001101010111 FOR COUNTER = 1 TO 10 PRINT “PLEASE ENTER NUMBER” INPUT NUMBER LET TOTAL = TOTAL+NUMBER NEXT COUNTER PRINT “THE TOTAL IS “;TOTAL END
Note: Interpreter • Easier to learn to program as errors are identified as commands are entered • Changes are made easily • Runs slower • Must have the interpreter for the program to run (requires more memory). • Does not produce Object Code
Compiler • Translates the instructions of a program written in a HLL into Machine code in a single operation. LET TOTAL = 0 000001111010100001101010111 FOR COUNTER = 1 TO 10 101010101010101010101010101 PRINT “PLEASE ENTER NUMBER” 000111000111000111001110010 INPUT NUMBER 111111111111111111111000000 LET TOTAL = TOTAL+NUMBER 111111110000000000000000000 NEXT COUNTER 111111111111000000000011111 PRINT “THE TOTAL IS “;TOTAL 000000000011111111100000001 END 111100001110001110001110001 SOURCE CODE OBJECT CODE
Note: Compiler • Changes are not easily made. • The original source code will have to be edited and translated again • Runs fast • Produces Object Code which can be run without the compiler being present in memory - efficient