CS400 Fall 2021 : Machine Level Programming
Contents
CS400 Fall 2021 : Machine Level Programming#
- A Hodge-Podge of this that and the other things that go into computer systems#
Jonathan Appavoo, PhD.#
Pronouns: He, Him, His#
This document is a Juypter notebook designed to be viewed using the RISE presentation notebook extension
To get us into the Spirit of things – Let’s build a computer!#
Inspired by Ben Eater’s : Build a 6502 Computer project (https://eater.net/6502)
The Appavoo II#
|
|
A CPU#
|
Extract from 1975 Manual
|
At the heart of the machine is a CPU
so lets start there
It is a physical device with each “pin” connecting it to the outside world via electricity.
Show a chip
Each pin is designed for a special purpose : Connecting 8 and 21 to powers up the chip and it begins to operate
Here’s what the manual has to say about how it operates. But what does this really mean?
Lets get a more visceral feel for this
by building a physical machine that lets us see this in action
easier than you might think.
TIC-TOCK The System Clock – Driving the Loop#
|
The Clock Pin \({\phi}_0\) : INPUT ONLY#
Attach it to an oscillator
voltage will swing between +5 and close to 0
producing a continue even beat of alternating 1’s and 0’s
each cycle drives the internal operation of the CPU forward
each instruction can take several cycles
operation of a single cycle is actually broken down into half cycles
we are going to drive the clock with a Button
High light pin 37 clock in But needs a period pulse to cause the loop to happen otherwise just sits there
If we just feed clock 0 or 1 – the loop will not go forward
however 0 1 0 and we get the loop to move forward on cycle
draw clock
Ok now we are cooking
The Address Pins - The Address Bus#
|
Pins A0 - A15 : OUTPUT ONLY#
The largest logic block of pins
The Address Bus
Connect the CPU to the rest of the computer
Devices are wired on to the address bus
A device will be responsible for a particular range of address
We will put some lights on it
The Loop:
read instruction – means
address of next instruction on to the address bus
Circle the address pins
The Data Pins and R/W pin - Data Bus and direction#
|
Pins D0 - D7 : INPUT AND OUTPUT#
and R/W : OUTPUT ONLY#
The D0-D7 pins on which a byte comes into or goes out of the CPU
R/W indicates if CPU is
sending the value of the pins to an external device (WRITE)
or receiving the value from a device which sets the pins (READ)
The Data Bus
Connect the CPU to the rest of the compter
Devices are wired on to the data bus
Address value enables a particular device
the device is then responsible for either receiving the value on the data bus or setting a value on to the data bus
Reset – Getting the loop going#
|
The Reset Pin (RES) : INPUT ONLY#
Allows us to use a button to get the CPU into a know state and working under “our” control!
|
But how do we know where to begin?
Processor manual tells us that the computer designer can use the reset pin to get the loop under control.
Pull the reset to 0 for two clock cycle
7 cycles later processor will fetch first instruction address
pc low: FFFC high: FFFD
Three things the designer of the reset of the computer does
a way to toggle reset pin
pick where the program instructions will be located – make sure they are there some how
make sure this address is feed when processor requests FFFC,FFFD
Our computer#
CPU
push button clock
leds on address and data bus
so that we can see “values”
8 switch on the data bus
so that we can respond to the CPU’s requests
Draw on chalk board and then lets switch over the the real thing
Do Demo and switch back for instruction
The instruction set#
https://www.masswerk.at/6502/6502_instruction_set.html
display(Markdown(htmlFig("images/6502opctbl.png")))
|
https://www.masswerk.at/6502/6502_instruction_set.html#NOP
NOP
No Operation
---
N Z C I D V
- - - - - -
addressing assembler opc bytes cycles
implied NOP EA 1 2
Context for this Course#
New on-line, open source textbook: “Under the Covers : The Secret Life of Software
participate in my mission to
create and publish : a modern on-line systems textbook, lecture notes and lab manual
Every thing needed is “Built-In”
free
open source
accessible to anyone
ensure anyone can learn about how computers work
Syllabus#
Lectures:#
Mondays and Wednesdays 12:20 to 1:35PM
Location: STH113
Instructor:#
Jonathan Appavoo, Associate Professor
pronouns: He, Him, His
Office: MCS 227E
Office hours:
Monday 2:00 to 3:30PM
Wednesday 4:00 to 5:30PM
Pre-requisites#
Have not covered assembly code with the instructor in the past
Important Semester Dates:#
Last day to drop without a ‘W’ grade is Oct 7, 2021
Last day to drop with a ‘W’ is Nov 5, 2021
Note about dropping: If you think you might need to drop please talk to the instructor as early as possible given the impact on a team project.
Infrastructure:#
UC-SLS:
Lecture “Notes”
Portions of the book that I can get done
Container Environment : https://github.com/jappavoo/bu-cs-book-dev
self hosted
online service maybe
Gradescope:https://www.gradescope.com/courses/303761
GitLab:https://cs400-gitlab.bu.edu
Grade breakdown#
Project : 60%
Lecture
Final Report
Demo/Oral
Problem Sets : 20%
Participation : 20%
The Lectures#
Lecture breaks down into three parts
number of lectures is a rough break down and we will adjust based on our progress and interests
Tools of the Trade – UNIX : ~5 lectures
Assembly Programming – Revisiting the Von Neumann Architecture from an assembly language perspective : ~10 lectures
C - Looking at C via Assembly Language : ~5 lectures
Project Lectures: ~5 lectures
Problems Sets#
Based on lecture material and Readings.
Roughly bi-weekly
Largely “paper” based questions and small programming exercises
Gradscope submission
programming exercises may have a gitlab repo associated
Participation#
attending and participating in lectures
you will receive credit for each “Exercise/Question” you contribute
standing gradescope assignments for each lecture
Based on the lecture or any associated sections in UC-SLS you can submit
Exercises / Questions for the material
You will also receive acknowledge in the book for anything you contribute
fixes
text
exercises
Late Policy#
In general if there is a posted deadline and you are not able to meet it please contact the instructor as soon as possible. Project deadline are in place to ensure your success and you should work hard to meet any deadline for proposals, mid-semester reports, etc.
Academic Conduct#
Academic standards and the code of academic conduct are taken very seriously at our university. Please take the time to review the CAS Academic Conduct Code if you are unfamiliar with the contents. See the http://www.bu.edu/academics/resources/academic-conduct-code/ for the CAS Academic Conduct Code, in particular regarding plagiarism and cheating on exams. Copies of the CAS Academic Conduct Code are also available in room CAS 105. A student suspected to violate this code will be reported to the Academic Conduct Committee, and if found culpable, the student will receive a grade of “F” for the course.
Project#
Requirements:#
Ideally 2-3 members
Have a git repository for ALL work – all must contribute
Code
Documentation
Reports
Log.md of meetings, weekly status and etc
Lecture presentation material
Involve some degree of
C and or Assembly code
Studying of a hardware documentation or low-level programming interfaces
Unix Integration – eg. a Unix command line interface
Weekly status updates
documented in Log.md of repo
and office hour meetings
End of semester lecture
For all other groups you will submit a summary of their lecture and answer any quiz questions they give after.
Final group report
Self and group assessment report - submitted individually
Your project contribution and learning
Each of your group members contribution and effort
Final individual project oral interview with professor
Time line#
Week 1: Form group - create repository on any git base service you like (eg. GitHub, GitLab) - You must add the professor as a member.
Week 2: Meet with Professor to discuss project ideas
Week 3: Submit proposal
Status meeting with Professor
Mid Semester Demo/Report to Professor
Work with Professor on draft of lecture (last month of class)
Final few weeks of semester present lecture - sign up service once we settle on project numbers
Reports and all other project material due last day of semester
Professor will provide sign service for 10 minute oral project slots
likely during the slot we are assigned for a final
or another time that is convenient for you.
Project Ideas#
javascript Computer emulator
-
dbb
mar
memory load
byte inspector
animate
ARM
RISCV
ATMEL
TOOLCHAIN
-
Work on SOL6502 - in coordination with undergrad term project that is going on
add arduino monitor/control board and code
uart board
pixel output board
interrupt board with input latch
demo of how blocking I/O works:
poll vs interrupt
why we need more than simple input and output registers
Extend/Resurrect/Riff-off any one of my half-baked starters
The Door
The Wand
resurrect the Reminder Fob
resurrect ClaraBell
extend the led timer cube – create the emoticon
extend humidifier controller with a proper blue tooth or other interface
extend universal wireless keyboard box
Programmable Universal Learning remote
ISA study
GPU Project
FPGA Project
Hardware concurrency (multi-threading/multi-core) Project
HW Technology Review
NEXT Class intro to the concepts behind UNIX Shell Interaction#
Reads from UC:SLS#
“Operating Systems and UNIX”
“What is a Terminal and why do we still use them”
“Organizing and Managing Information as a Tree of Files and Directories”
and maybe : “The Shell - Part I: Having an ASCII conversation with the OS”
Once Piazza is up and running I will post links