var inst = document.getElementById("op");
var bin = inst.options[inst.selectedIndex].value;
var val = document.getElementById("val").value;
//TODO conver bin to binary
var instStr = reverse(pad(dec2bin(val),5)) + "0000000" +pad(dec2bin(bin),3)+ "0000000000000000";
document.getElementById("instBin").innerHTML = instStr;
lightHtml = "";
A computer program is list of very simple instructions, which is stored and obeyed in sequence. The computer will start at the beginning and continue through the list unless told to go to another instruction, known as a jump. Jumps may be to forward and backward, or conditional on the result of a calculation. These simple instructions can be used to create loops and other structures.
As well as instructions there is also data – the information the computer works with. In the case of the Baby, this was usually stored after the last instruction of the program.
The are just seven different instructions used when programming the Baby
*Addition was performed by subtracting a minus number e.g. 1+3 = 1- (-3)
|Jump to an instruction||JMP||0||000|
|Skip some number of instructions||JRP||1||001|
|Subtract (same as above)||5||101|
|Skip if last result <0||CMP||6||110|
Each row in the Baby's memory contains just one instruction in the program. The 13th to 15th bits code the type of instruction (subtract, store etc.) with the first five bits coding additional information for that instruction (e.g. which line of memory that instruction should use). The remaining bits of the line can be used for any other purpose (e.g. storing data). If a line is not used to hold an instruction it can be used to store a 32-bit binary number (i.e. data to be used in the program).
The principle in programming modern computers is just the same, the only difference an increase in the number of different types of instructions. Multiplication, and division are examples of instructions now present in modern computers, as although the Baby could perform them by repeated subtraction (see first program below) it was a slow process.
The series of instructions had to be entered line by line, dot by dot. You can learn more about controlling the baby.