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


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
light bulb off

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


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.

Try to alter the program so that the light bulb blinks on and off without stopping. Or, write a program so that the bulb gradually brightens and dims repeatedly.