Yes. Programs and data are both in main memory when they are active.
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 Instruction||Machine Operation|
|00000001||Turn bulb fully on|
|00000010||Turn bulb fully off|
|00000100||Dim bulb by 10%|
|00001000||Brighten bulb by 10%|
|00010000||If bulb is fully on, skip over next instruction|
|00100000||If bulb is fully off, skip over next instruction|
|01000000||Go 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:
Click on the light bulb
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.