Home Java Java-tips Background Architecture Computer Architecture and Programming Languages

Ask Questions?

View Latest Questions



Computer Architecture and Programming Languages
Posted on: April 17, 2011 at 12:00 AM
This page discusses - Computer Architecture and Programming Languages

Computer Architecture and Programming Languages

  • CPU - Central Processing Unit - The "brains" that performs the computations.
  • Main Memory - Where everything must be for the CPU to use it.
  • Input and Output - Devices used to enter or display information.
    • Storage - A disk (or similar device) for saving programs and data.
  • IFSM 310 is an entire course about computer architecture.

Main Memory / RAM

  • Main memory is also known as RAM (Random Access Memory)
  • To run any program, it must be loaded from the disk into RAM.
  • RAM is volatile - All memory is lost when the power is off.
  • For something to be permanent, it must be written to a disk (storage).
  • RAM is composed of bits.

Bits - Binary Digits

  • A bit has two possible values: 0 or 1.
  • Hardware representation: voltage, current, magnetic field, reflectivity, ...
  • Everything is represented as bits. (numbers, characters, sound, images, program instructions, ...)
  • Groups of 8 bits are called called bytes.
  • A common size for RAM is 256 MB (megabytes).
  • Each byte has an identifying address.

CPU - Central Processing Unit

  • CPU is typically implemented as one chip.
  • The CPU gets machine instructions from memory, and does them one at a time.
  • An machine instruction contains an opcode that tells what to do and generally one or more operand addresses that specify what to do it to.
  • Machine instructions are very small steps: eg, add the byte at location 253398 to the byte a location 84992 and store the result in byte 234344.
  • The CPU is able to do these instructions very rapidly. A common speed might be 1 GHz, which means that it does something (part or all of an instruction) in a billionth of a second.
  • Different types of CPUs use different instructions (Intel x86, Power PC, Sparc, ...).
  • Unfortunately, humans cannot easily work with binary machine instructions (hence the use of programming languages).

Input / Output

  • Input / Output devices transfer bits into or out of memory or CPU.
  • The hard disk is like other devices, but is sometimes grouped separately because of its use to store programs and data (storage).
  • Relatively slow compared to CPU and RAM.

Machine-Human Mismatch - Programming languages

  • Machine instructions are difficult for humans to use (eg, 0000011011000101)
  • Human language can not be understood by machines, at least directly.
  • The compromise is to choose a "programming language" that humans can read and write, and that can be translated by a program into machine instructions.

Hierarchy of Programming Languages

  1. Machine instructions - Too difficult for humans.
  2. Assembly language
    • Each machine instruction represented symbolically. Eg "AR R12, R5".
    • Easy to understand and translate, but tediously detailed.
    • Not portable - specific to one type of CPU.
    • Is not commonly used for mainstream programming.
  3. High-level language - Mainstream programming.
    • Human "readable" language
      if (age > 21)
         canDrink = true;
    • Usually portable - can be translated for different CPUs.
    • Examples: Pascal, Cobol, Perl, Visual Basic, C, C++, Java, C#, ...
    • Human writes "source program". It's translated into an "object program" by a compiler.
  4. Natural languages (English, Deutsch, ...)
    • Impractical to translate into machine instructions.
    • Surprisingly ambiguous. "He saw a bottle of wine on the table and drank a glass of it."