Review these notes. As you work through them, think about and answer the questions at the bottom of each page.
Example of Machine Language
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 machine operations at right.
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.
Machine Instruction | Machine Operation |
---|---|
00000000 | Stop Program |
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) |