├── README.md ├── sctest.asm └── sctest.ls8 /README.md: -------------------------------------------------------------------------------- 1 | # Sprint Challenge: Computer Architecture - Conditional Jumps 2 | 3 | This challenge allows you to practice the concepts and techniques learned over 4 | the past week and apply them in a concrete project. 5 | During this Sprint, you studied CPU components, number bases, bitwise 6 | operations, CPU stack, interrupts, and subroutines. 7 | 8 | In your challenge this week, you will demonstrate proficiency by adding _conditional jumps_ to your LS-8 emulator as well as answering a few questions during a one-on-one session with a PM. 9 | 10 | ## Instructions 11 | 12 | **Read these instructions carefully. Understand exactly what is expected 13 | _before_ starting this Sprint Challenge.** 14 | 15 | This is an individual assessment. All work must be your own. Your challenge 16 | score is a measure of your ability to work independently using the material 17 | covered through this sprint. You need to demonstrate proficiency in the concepts 18 | and objectives introduced and practiced in preceding days. 19 | 20 | You are not allowed to collaborate during the Sprint Challenge. However, you are 21 | encouraged to follow the twenty-minute rule and seek support from your PM and 22 | Instructor in your cohort help channel on Slack. Your work reflects your 23 | proficiency with Computer Architecture and your command of the related concepts 24 | and techniques. 25 | 26 | You have three hours to complete this challenge. Plan your time accordingly. 27 | 28 | ## Commits 29 | 30 | Commit your code regularly and meaningfully. This helps both you (in case you 31 | ever need to return to old code for any number of reasons and your project manager. 32 | 33 | ## Description 34 | 35 | In this code challenge, you will add _conditional jumps_ (AKA _conditional branching_) to your LS-8 emulator. 36 | 37 | ## Project Set Up 38 | 39 | Options for submission, whichever is easier for you: 40 | 41 | * Copy your source into this repo, or... 42 | 43 | * Submit a PR for the Sprint Challenge from the `Computer-Architecture` repo 44 | you've been using all along. 45 | 46 | ## Minimum Viable Product 47 | 48 | Your finished project must include all of the following requirements: 49 | 50 | - [ ] Add the `CMP` instruction and `equal` flag to your LS-8. 51 | 52 | - [ ] Add the `JMP` instruction. 53 | 54 | - [ ] Add the `JEQ` and `JNE` instructions. 55 | 56 | [See the LS-8 spec for details](https://github.com/BloomInstituteOfTechnology/Computer-Architecture/blob/master/LS8-spec.md) 57 | 58 | In your solution, it is essential that you follow best practices and produce 59 | clean and professional results. Schedule time to review, refine, and assess your 60 | work and perform basic professional polishing including spell-checking and 61 | grammar-checking on your work. It is better to submit a challenge that meets MVP 62 | than one that attempts too much and does not. 63 | 64 | Validate your work through testing and ensure that your code operates as designed. 65 | 66 | [Here is some code](sctest.ls8) that exercises the above instructions. It should 67 | print: 68 | 69 | ``` 70 | 1 71 | 4 72 | 5 73 | ``` 74 | 75 | ``` 76 | # Code to test the Sprint Challenge 77 | # 78 | # Expected output: 79 | # 1 80 | # 4 81 | # 5 82 | 83 | 10000010 # LDI R0,10 84 | 00000000 85 | 00001010 86 | 10000010 # LDI R1,20 87 | 00000001 88 | 00010100 89 | 10000010 # LDI R2,TEST1 90 | 00000010 91 | 00010011 92 | 10100111 # CMP R0,R1 93 | 00000000 94 | 00000001 95 | 01010101 # JEQ R2 96 | 00000010 97 | 10000010 # LDI R3,1 98 | 00000011 99 | 00000001 100 | 01000111 # PRN R3 101 | 00000011 102 | # TEST1 (address 19): 103 | 10000010 # LDI R2,TEST2 104 | 00000010 105 | 00100000 106 | 10100111 # CMP R0,R1 107 | 00000000 108 | 00000001 109 | 01010110 # JNE R2 110 | 00000010 111 | 10000010 # LDI R3,2 112 | 00000011 113 | 00000010 114 | 01000111 # PRN R3 115 | 00000011 116 | # TEST2 (address 32): 117 | 10000010 # LDI R1,10 118 | 00000001 119 | 00001010 120 | 10000010 # LDI R2,TEST3 121 | 00000010 122 | 00110000 123 | 10100111 # CMP R0,R1 124 | 00000000 125 | 00000001 126 | 01010101 # JEQ R2 127 | 00000010 128 | 10000010 # LDI R3,3 129 | 00000011 130 | 00000011 131 | 01000111 # PRN R3 132 | 00000011 133 | # TEST3 (address 48): 134 | 10000010 # LDI R2,TEST4 135 | 00000010 136 | 00111101 137 | 10100111 # CMP R0,R1 138 | 00000000 139 | 00000001 140 | 01010110 # JNE R2 141 | 00000010 142 | 10000010 # LDI R3,4 143 | 00000011 144 | 00000100 145 | 01000111 # PRN R3 146 | 00000011 147 | # TEST4 (address 61): 148 | 10000010 # LDI R3,5 149 | 00000011 150 | 00000101 151 | 01000111 # PRN R3 152 | 00000011 153 | 10000010 # LDI R2,TEST5 154 | 00000010 155 | 01001001 156 | 01010100 # JMP R2 157 | 00000010 158 | 01000111 # PRN R3 159 | 00000011 160 | # TEST5 (address 73): 161 | 00000001 # HLT 162 | ``` 163 | 164 | ## Stretch Problems 165 | 166 | After finishing your required elements, you can push your work further. These 167 | goals may or may not be things you have learned in this module but they build on 168 | the material you just studied. Time allowing, stretch your limits and see if you 169 | can deliver on the following optional goals: 170 | 171 | - [ ] Add the ALU operations: `AND` `OR` `XOR` `NOT` `SHL` `SHR` `MOD` 172 | - [ ] Add an `ADDI` extension instruction to add an immediate value to a register 173 | - [ ] Add timer interrupts 174 | - [ ] Add keyboard interrupts 175 | -------------------------------------------------------------------------------- /sctest.asm: -------------------------------------------------------------------------------- 1 | ; Code to test the Sprint Challenge 2 | ; 3 | ; Expected output: 4 | ; 1 5 | ; 4 6 | ; 5 7 | 8 | LDI R0,10 9 | LDI R1,20 10 | LDI R2,Test1 11 | CMP R0,R1 12 | JEQ R2 ; Does not jump because R0 != R1 13 | LDI R3,1 14 | PRN R3 ; Prints 1 15 | 16 | Test1: 17 | 18 | LDI R2,Test2 19 | CMP R0,R1 20 | JNE R2 ; Jumps because R0 != R1 21 | LDI R3,2 22 | PRN R3 ; Skipped--does not print 23 | 24 | Test2: 25 | 26 | LDI R1,10 27 | LDI R2,Test3 28 | CMP R0,R1 29 | JEQ R2 ; Jumps becuase R0 == R1 30 | LDI R3,3 31 | PRN R3 ; Skipped--does not print 32 | 33 | Test3: 34 | 35 | LDI R2,Test4 36 | CMP R0,R1 37 | JNE R2 ; Does not jump because R0 == R1 38 | LDI R3,4 39 | PRN R3 ; Prints 4 40 | 41 | Test4: 42 | 43 | LDI R3,5 44 | PRN R3 ; Prints 5 45 | LDI R2,Test5 46 | JMP R2 ; Jumps unconditionally 47 | PRN R3 ; Skipped-does not print 48 | 49 | Test5: 50 | 51 | HLT 52 | 53 | -------------------------------------------------------------------------------- /sctest.ls8: -------------------------------------------------------------------------------- 1 | # Code to test the Sprint Challenge 2 | # 3 | # Expected output: 4 | # 1 5 | # 4 6 | # 5 7 | 8 | 10000010 # LDI R0,10 9 | 00000000 10 | 00001010 11 | 10000010 # LDI R1,20 12 | 00000001 13 | 00010100 14 | 10000010 # LDI R2,TEST1 15 | 00000010 16 | 00010011 17 | 10100111 # CMP R0,R1 18 | 00000000 19 | 00000001 20 | 01010101 # JEQ R2 21 | 00000010 22 | 10000010 # LDI R3,1 23 | 00000011 24 | 00000001 25 | 01000111 # PRN R3 26 | 00000011 27 | # TEST1 (address 19): 28 | 10000010 # LDI R2,TEST2 29 | 00000010 30 | 00100000 31 | 10100111 # CMP R0,R1 32 | 00000000 33 | 00000001 34 | 01010110 # JNE R2 35 | 00000010 36 | 10000010 # LDI R3,2 37 | 00000011 38 | 00000010 39 | 01000111 # PRN R3 40 | 00000011 41 | # TEST2 (address 32): 42 | 10000010 # LDI R1,10 43 | 00000001 44 | 00001010 45 | 10000010 # LDI R2,TEST3 46 | 00000010 47 | 00110000 48 | 10100111 # CMP R0,R1 49 | 00000000 50 | 00000001 51 | 01010101 # JEQ R2 52 | 00000010 53 | 10000010 # LDI R3,3 54 | 00000011 55 | 00000011 56 | 01000111 # PRN R3 57 | 00000011 58 | # TEST3 (address 48): 59 | 10000010 # LDI R2,TEST4 60 | 00000010 61 | 00111101 62 | 10100111 # CMP R0,R1 63 | 00000000 64 | 00000001 65 | 01010110 # JNE R2 66 | 00000010 67 | 10000010 # LDI R3,4 68 | 00000011 69 | 00000100 70 | 01000111 # PRN R3 71 | 00000011 72 | # TEST4 (address 61): 73 | 10000010 # LDI R3,5 74 | 00000011 75 | 00000101 76 | 01000111 # PRN R3 77 | 00000011 78 | 10000010 # LDI R2,TEST5 79 | 00000010 80 | 01001001 81 | 01010100 # JMP R2 82 | 00000010 83 | 01000111 # PRN R3 84 | 00000011 85 | # TEST5 (address 73): 86 | 00000001 # HLT 87 | --------------------------------------------------------------------------------