20201219 Computing Programming Technique Computing
20201219 Computing Programming Technique Computing
Procedures are another type of subroutine that do not return a value to the main program. They may be useful to
break up a program into modules.
Local variables only exist while the subroutine is executing. They are only accessible within
the subroutine.
Constants follow the same rules as variables. A constant declared in the main program can be seen and used, but
not changed, in any function
Global variables are variables that can be seen and used anywhere in the program.
Verification is used to double-check that the data has been typed in correctly. For example, a user setting a new
password may be asked to type it in twice. If the two passwords don’t match, they will be asked to start again.
Authentication routines are used to make sure a person is who they claim to be
The computer can decode and execute a machine code instruction directly. All computers execute machine code
instructions but you don’t have to write in machine code.
A computer cannot execute a program instruction until it is translated into machine code.
Machine code: 101011001001 – this means LOAD the value 1 into the accumulator
Assembly language is also processor specific. It has to be translated into machine code before it can be executed.
Like machine code, it is classified as a low-level language.
Assembly language: LDA 51 – this means Load the contents of memory location 51 into the accumulator
High-level languages generally have statements that look a bit like English or maths so they are relatively easy to
learn and understand:
area = (base * height) / 2
print (area)
• They have selection and iteration constructs
• They use Boolean operators such as AND, OR, NOT
• They have data structures such as arrays and records
• A single statement usually translates into several machine code instructions
All high level languages must be translated into machine code. The translation is done by a program which may be
either a compiler or an interpreter
A different compiler or interpreter is used for each type of processor to translate the high level language code into
machine code
Assembly language is often used to develop software for embedded systems because it can be used to control and
manipulate specific hardware components.
2. An interpreter - An interpreter is another type of program that translates a high-level language into machine
code. Unlike a compiler, no object code is produced. It translates each line of code and executes it
immediately. If it reaches a line with a syntax error, it stops and displays an error message
3. An Assembler - An assembler is a program which translates assembly code into machine code.
There is generally a 1:1 (one-to-one) correspondence between each assembly code statement and the equivalent
machine code statement.