Page 230 - Mechatronics with Experiments
P. 230
216 MECHATRONICS
it, then output information to the outside world. An I/O device interface chip is also
called peripheral interface adaptor (PIA).
7. A bus to allow communication between the CPU and devices (memory, I/O devices).
The bus includes a set of lines that includes those to provide power, address, data,
and control signals.
Let us assume that the human is supposed to pick a new card from the deck (ROM)
at the tick of every minute of the clock, read it, execute the instruction, and continue this
process until the instruction cards say to stop. Here is a specific example. The program is
to read numbers from the input tray. It reads until five odd numbers are read. It adds the
five odd numbers and writes the result to the output tray at the end. Then, the program
execution stops.
Minute: 1, 2, 3, 4,...- pick a card at the tick of every minute from the deck of cards
(ROM). Assume that the first four cards in the deck include the following instructions.
Card 1: Read a number from the input tray, write it on the card on the left pocket
(Accumulator A).
Card 2: Is the number odd? If yes, write it on the blackboard.
Card 3: Are there five numbers on the black board? If yes – go to Card 4, if no – go to
Card 1.
Card 4: Add all numbers, write the total number to the output tray and stop.
Notice the following characteristics in a computer program:
normally the program instructions are executed sequentially,
the order of execution can be changed using the conditional statements,
the CPU, clock, ROM, RAM and accumulators, and I/O are the key components of a
basic computer operation.
The digital computer is a collection of many ON/OFF switches. The transistor
switches are so small that a 1000 × 1000 array of them (1 000 000 transistor switches) can
be built on a single chip. A combination of transistor switches can be used to realize various
logic functions (i.e., AND, OR, XOR) as well as mathematical operations (+, − ,*,/).
Every CPU has an instruction set that it can understand. This is called the basic
instruction set or the machine instructions. Each instruction has a unique binary code
that tells the CPU what operation to perform and programmable operands for the source
of data. Some microprocessors are designed to have a smaller instruction set. They have
fewer instructions but execute them faster than general purpose microprocessors. Such
microprocessors are called reduced instruction set computers (RISC).
Assembly language is a set of mnemonic commands corresponding to the basic
instruction set. The mnemonic commands make it easier for programmers to remember the
instructions instead of trying to remember their binary code (also called hex code, because
it is easier to code each of four binary digits with one hex character 0–9 and A–F). A
program written in assembly language must be converted to machine instructions before it
can be run on a computer. This is done by the assembler.
All of the instructions in a program written in a high level language must first be
reduced to the combinations of the basic instruction set the CPU understands. This is
done by the compiler and the linker, which translates the high level instructions to low level
machine instructions. The basic instruction set is microprocessor specific. The build process
(compile and link) of the C18 compiler generates various files including the executable file
with extension “*.hex”. In addition, the filename extensions “*.map” contains the list of
variable names and the allocated memory address for them. The filename extension “*.lst”