Common Computer Science References
At the end of this lesson, you will be able to:
understand the basics of machine code
and why NO ONE uses it any more!
Von Neumann architecture
now that we know the basics of how every computer works, now we need to program it!
remember, at this point the computer still only does digital logic!
a sequence of 1s & 0s
some of the digits represent what operation should be done:
move 42 to register A
add 10 to register B
move contents of register A to memory location XXX
some of the digits represent data:
the number 42
the number 10
the address that register A should go to
watch this video to see who this digital logic is converted into something that a Von Neumann architecture computer can do something useful
https://www.youtube.com/watch?v=dXdoim96v5A&list=PLowKtXNTBypGqImE405J2565dvjafglHU&index=36
https://www.youtube.com/watch?v=NtAF-WfWyGU
yes, people actually programmed with toggle switches initially!
and this is why NO ONE ever programs machine code any more!
machine code the 8-Bit Breadboard computer
remember the 8-Bit Breadboard computer have 16 memory locations for the program
2⁴ = 16 for what instruction
2⁴ = 16 for the data
2⁴ + 2⁴ = 2⁸ → 8-bit computer!
see image below, for all of the commands in the end it can do
using the same instructions (in binary!), write the following computer program
use the HLT command to end your program
add numbers 5 + 9 and send the result to output
subtract numbers 15 - 3 and send the result to output
now test out your code:
use this repo: https://github.com/Mr-Coxall/TEJ4M-8-Bit-Computer-Emulator
NOTE: it is a fork from another student's final project
python ./cpu.py add.bin
create a xxx.bin file for each of your programs and run them through the emulator
prove your program works, or that the emulator has an error!
write a program that will start at number 12 and count down by 2, stop at 0
not using a loop, sequentially!
NOP - No Operation
LDA - Load to A register
ADD - Add
SUB - Subtract
STA - Store A
LDI - Load Immediate
JMP - Jump
OUT - Output
HLT - Halt
This program:
loads 1
then adds 1 to what is in the register
then prints out the result
I.E.: 1 + 1 = 2!