|
| 1 | +# How do we study Computer Systems? |
| 2 | + |
| 3 | +## Admin |
| 4 | + |
| 5 | +- make sure you have a grading contract repo |
| 6 | +- you'll track your progress in your |
| 7 | + |
| 8 | +## Systems |
| 9 | + |
| 10 | + |
| 11 | +## Abstraction |
| 12 | + |
| 13 | +The advantage to assembly is that it is hardware independent and human readable. It is low level and limited to what the hardware *can* do, but it is a version of that that can be run on different hardware. |
| 14 | +```{warning} |
| 15 | +This is incomplete, will come back and fill in later |
| 16 | +``` |
| 17 | + |
| 18 | + |
| 19 | +## Using the simulator |
| 20 | + |
| 21 | +On MacOS: |
| 22 | + |
| 23 | +```bash |
| 24 | +cd path/nand2tetris/tools |
| 25 | +bash CPUEmulator.sh |
| 26 | +``` |
| 27 | + |
| 28 | +On Windows: |
| 29 | +Double click on the CPUEmulator.bat file |
| 30 | + |
| 31 | + |
| 32 | +We're going to use the test cases from the book's project 5: |
| 33 | + |
| 34 | +1. Load Program |
| 35 | +1. Navigate to nand2tetris/projects/05 |
| 36 | + |
| 37 | +We're not going to *do* project 5, which is to build a CPU, but instead to use the test. |
| 38 | + |
| 39 | +For more on how the emulator works see the [CPU Emulator Tutorial](https://www.nand2tetris.org/_files/ugd/44046b_24b3a15aa628404fbf6dacd86d7da3af.pdf). |
| 40 | + |
| 41 | +For much more detail about how this all works [chapter 4](https://www.nand2tetris.org/_files/ugd/44046b_d70026d8c1424487a451eaba3e372132.pdf) of the related text book has description of the machine code and assembly language. |
| 42 | + |
| 43 | + |
| 44 | +## How does the computer actually add constants? |
| 45 | + |
| 46 | +We'll use add.hack first. |
| 47 | + |
| 48 | +This program adds constants, 2+3. |
| 49 | + |
| 50 | +It is a program, assembly code that we are loading to the simulator's ROM, which is memory that gets read only by the CPU. |
| 51 | + |
| 52 | +Run the simulator and watch what each line of the program does. |
| 53 | + |
| 54 | +Notice the following: |
| 55 | +- to compute with a constant, that number only exists in ROM in the instructions |
| 56 | +- to write a value to memory the address register first has to be pointed to what where in the memory the value will go, then the value can be sent there |
| 57 | + |
| 58 | + |
| 59 | +The simulator has a few key parts: |
| 60 | +- address register |
| 61 | +- program counter |
| 62 | + |
| 63 | +If you prefer to read, see [section 5.2.1- 5.2.6 of nan2tetris book](https://www.nand2tetris.org/_files/ugd/44046b_b2cad2eea33847869b86c541683551a7.pdf) |
| 64 | + |
| 65 | +- This program the first instruction puts 2 in the address register from the instructions in ROM. |
| 66 | +- Then it moves the 2 through the ALU to the data register (D) |
| 67 | +- then it puts 3 on the address register |
| 68 | +- then it adds the numbers at D and A |
| 69 | +- then it puts 0 on the address register |
| 70 | +- then it write the output from the ALU (D) to memory (at the location indicated by the A register) |
| 71 | + |
| 72 | +```{admonition} Try if yourself |
| 73 | +- What line do you change to change where it outputs the data? |
| 74 | +- How could you add a third number? |
| 75 | +- How could you add two pairs, saving the intermediate numbers? |
| 76 | +- How could you do (4+4)*(3+2)? |
| 77 | +``` |
| 78 | + |
| 79 | + |
| 80 | + |
| 81 | + |
| 82 | +## Hardware Overview |
| 83 | + |
| 84 | + |
| 85 | +```{important} |
| 86 | +Today is the first day outside of the grade free zone. |
| 87 | +``` |
| 88 | + |
| 89 | +## Review today's class |
| 90 | +(required for a C or better) |
| 91 | + |
| 92 | +```{include} ../_review/2022-09-26.md |
| 93 | +``` |
| 94 | + |
| 95 | +## Prepare for Next Class |
| 96 | +(required for a C or better) |
| 97 | + |
| 98 | + |
| 99 | +```{include} ../_practice/2022-09-26.md |
| 100 | +``` |
| 101 | + |
| 102 | +```{warning} |
| 103 | +the template contracts in the repo have an error in them; use the ones on the [course website](https://introcompsys.github.io/fall2022/syllabus/contract.html). |
| 104 | +``` |
| 105 | + |
| 106 | +## More Practice |
| 107 | + |
| 108 | +(mostly required for a B or better) |
| 109 | + |
| 110 | +```{include} ../_practice/2022-09-26.md |
| 111 | +``` |
| 112 | + |
| 113 | + |
| 114 | + |
| 115 | +## Questions After Class |
| 116 | + |
| 117 | +• more about the hardware architecture abstractions |
| 118 | + |
| 119 | +• When requesting a review for a PR or something similar, would the only thing to do be attaching either you the professor or the teachers assistant? |
| 120 | +With our collaborative repo, would we facilitate the merges and reviews or would you need to have the last review of the information? |
| 121 | +Should we assume that when you ask to write a document, we should create a markdown file with a similar name (as opposed to an assignment with the description "add branches.md to your KWL repo") |
| 122 | + |
| 123 | +• Are there other simulators that we can play with? |
| 124 | + |
| 125 | +• for my grading contract if i choose to go for an A and stick with the A but don't meet the requirements how much is my grade affected |
| 126 | + |
| 127 | +• how the CPU performs addition and stores the result in a memory location on the RAM |
| 128 | + |
| 129 | +• Explain more levels of abstraction and how they are connected |
0 commit comments