next up previous
Next: Assembly Language Up: Introduction to C++ Programming Previous: Review Questions


Programming Languages

As noted in section 1.6 all computers have an internal machine language which they execute directly. This language is coded in a binary representation and is very tedious to write. Most instructions will consist of an operation code part and an address part. The operation code indicates which operation is to be carried out while the address part of the instruction indicates which memory location is to be used as the operand of the instruction. For example in a hypothetical computer successive bytes of a program may contain:

operation
code
address meaning
00010101 10100001 load c(129) into accumulator
00010111 10100010 add c(130) to accumulator
00010110 10100011 store c(accumulator) in location 131
where c( ) means `the contents of' and the accumulator is a special register in the CPU. This sequence of code then adds the contents of location 130 to the contents of the accumulator, which has been previously loaded with the contents of location 129, and then stores the result in location 131. Most computers have no way of deciding whether a particular bit pattern is supposed to represent data or an instruction.

Programmers using machine language have to keep careful track of which locations they are using to store data, and which locations are to form the executable program. Programming errors which lead to instructions being overwritten with data, or erroneous programs which try to execute part of their data are very difficult to correct. However the ability to interpret the same bit pattern as both an instruction and as data is a very powerful feature; it allows programs to generate other programs and have them executed.



Subsections
next up previous
Next: Assembly Language Up: Introduction to C++ Programming Previous: Review Questions
Peter JB King
1999-08-31