go to previous page   go to home page   hear noise   go to next page

Answer:

Yes. Programs and data are both in main memory when they are active.


Example of Machine Language

Say that a light bulb is controlled by a processor running a program in main memory. The controller can turn the light bulb fully on and fully off, can brighten or dim the bulb (but not beyond fully on or off.) The machine instructions are one byte long, and correspond to the following machine operations:

Machine InstructionMachine Operation
00000000Stop Program
00000001Turn bulb fully on
00000010Turn bulb fully off
00000100Dim bulb by 10%
00001000Brighten bulb by 10%
00010000If bulb is fully on, skip over next instruction
00100000If bulb is fully off, skip over next instruction
01000000Go to start of program (address 0)

The bulb is wired so that when the switch is first turned on the instruction at address zero is performed. Then, instructions are performed one at a time, in order, until the "Halt" instruction is encountered or the controller crashes.

The controller crashes if it encounters an instruction not in the table or tries to get an instruction from an address that does not exist.

The A "Skip" instruction checks the brightness of the bulb and possibly skips over the instruction after it.

The "Go back" instruction causes the processor to start again with the instruction at address 0.


Here (let us pretend) is the main memory for the controller:

AddressMachine Instruction
0
1
2
3
4
5
6
7
8
9
10
11
12
light bulb off

Click on the light bulb
to start or stop
the program.


QUESTION 4:

Change the program currently in memory. Fill in instructions starting at address 0. Copy and paste from the list of machine instructions or directly edit the bit patterns.