hardware, software, data
A program is a collection of commands or instructions for the computer to perform.
Machine language is the form that all instructions must be in before the computer can do them. This form consists of binary numbers or binary code.
A stored-program computer is a computing device with a memory which contains both a program (the instructions of what to do) and the data needed for computing by the program. (von-Neumann computer)
3.2 The Robot Computer and Machine Language
The ROBOT's Domain (Fig. 3.1)
Programming the ROBOT (Fig. 3.2.1)
ROBOT Characteristics: (Fig. 3.2.2)
The ROBOT has a memory where the instructions are stored
The ROBOT can fetch instructions from its memory, decode their meaning, and
execute them.
ROBOT's MEMORY - 32 memory locations numbered 0-31 each capable of storing one
ROBOT instruction
INSTRUCTION - 8 bits (3 bit opcode and 5 bit operand) [Fig. 3.3]
FETCH - ROBOT can retrieve one instruction at a time from the memory.
DECODE - splits instruction into opcode and operand and sends signals to appropriate
part of ROBOT according to the opcode [Fig. 3.3.1]
EXECUTE - ROBOT executes the instructions based on the opcode
ROBOT's program stored in ROBOT's memory [Fig. 3.4]
low-level language: 1) non-symbolic; 2) pedestrian (micro-instructions)
Using the ROBOT
problem -> solution (algorithm) -> program
An algorithm is a step by step process used to solve a problem. It is essentially the
solution to the problem and is usually implemented by a program
PROBLEM #1: Cause the ROBOT to take a step.
00000000 STEP
11100000 STOP
An algorithm should be general.
PROBLEM #2: Cause the ROBOT to walk to the nearest wall and stop with its arms
lowered.
Solution 1: 00000000 STEP Difficulty: Infinite Loop 10100000 GOTO Location 0 (never reaches STOP) 11100000 STOPSolution 2: [Fig. 3.4.4] Difficulty: Never lowers arms and stops one short of wall
Solution: 01000000 RAISE 01100000 LOWER 00000000 STEP 10100000 Goto 0 11000000 LIGHT 00100000 TURN 01000000 RAISE 01100000 LOWER 00000000 STEP 10100110 Goto 6 11000000 LIGHT 11100000 STOP
Solution: 01000000 RAISE 01100000 LOWER 00000000 STEP 11100000 STOP 11000000 LIGHT 00100000 TURN 00100000 TURN 00000000 STEP 11100000 STOP
0 1 2 11001111 3 01101111 4 01001110 5 10001111 6 11100010 7 00000000 8 12 16 20 24 28 29 30 00000001 31 00001010
----------------------- 00000010 | ----------------------- Program Counter