Binary! Objectives Recap what a instruction is Look at how binary can be used to store – Opcode – data
What are computer instructions? Computers are very efficient data processing machines. First ones literally wired to carry of 1 task – code breaking or a calculation etc If needed to do another task – engineers spend days re-wiring the machine. Had to be a better way WWII – American Scientist John Von Neumann – atomic bomb – idea – digital data & digital instructions are the same. His approach allowed a computer to be re-programmed by changing the instructions rather than re-wiring it. What we have today. The instructions are called software
Binary instructions Software is run on the micro-processor by sending instructions from memory to the micro-processor. It is then decoded and executed. Instructions are run one at a time sequentially. Micro-processors use registers, which are inside the CPU, in order to perform calculations. Some instructions include – ADD SUB JMP DAT You are encouraged to look at the LMC simulator to refresh your memory.
Binary Encoding instructions Instructions have two parts to them. Opcode - a binary value which represents the instruction Data – Could be null or will contain the data needed for the instruction. When a instruction is passed to a micro-processor the first thing which happens is the opcode is decoded. This means the micro-processor will look the binary code up in a table. Once the instruction is found it will execute it.
Binary Encoding instructions NameNumberBinary valueComment ADD Add a register to the ACC SUB Subtract a register to the ACC INP Get a value from the user OUT Display a value LDA Load a register to the ACC STA Store the ACC to a register DAT Set a value to the ACC Note – the binary values are in BCD
Binary Data The second part of an instruction is the data. The program below will add 2 numbers together – DAT 12 STA 1 DAT 4 ADD 1 OUT The highlighted parts are the data parts of the instruction. These are numeric values so are encoded using normal binary.
Binary Encoded Data InstructionOpcodeDataData in binary DAT STA DAT ADD OUT xx
Binary Activity InstructionopcodeDataData in binary INPx STA4 INPx STA3 DAT10 ADD3 SUB4 OUTx Fill out the opcode and binary values for the program below
Binary Activity Make revision notes on opcode and instruction data. You do not need to memorise the codes! You just need to understand how they are stored in binary.