New User Special Price Expires in

Let's log you in.

Sign in with Facebook


Don't have a StudySoup account? Create one here!


Create a StudySoup account

Be part of our community, it's free to join!

Sign up with Facebook


Create your account
By creating an account you agree to StudySoup's terms and conditions and privacy policy

Already have a StudySoup account? Login here

CS 2200 HWK 1

Star Star Star Star Star
1 review
by: Ashika Ganesh

CS 2200 HWK 1 CS

Ashika Ganesh
Georgia Tech

Preview These Notes for FREE

Get a free preview of these Notes, just enter your email below.

Unlock Preview
Unlock Preview

Preview these materials now for free

Why put in your email? Get access to more of this material and other relevant free materials for your school

View Preview

About this Document

Homework week 1
Class Notes
hwk cs
25 ?




Star Star Star Star Star
1 review
Star Star Star Star Star
"These were really helpful...I'll be checking back regularly for these"
Litzy Walsh V

Popular in

Popular in Department

This 5 page Class Notes was uploaded by Ashika Ganesh on Thursday January 21, 2016. The Class Notes belongs to CS at Georgia Institute of Technology taught by Lillethun in Spring 2016. Since its upload, it has received 183 views.

Similar to CS at Georgia Tech


Reviews for CS 2200 HWK 1

Star Star Star Star Star

These were really helpful...I'll be checking back regularly for these

-Litzy Walsh V


Report this Material


What is Karma?


Karma is the currency of StudySoup.

You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!

Date Created: 01/21/16
Micro Project 1 CS 2200 - Systems and Networks Spring 2016 Problem 1: Assembly Programming Warmup In this problem, you will be introduced to the 16 bit LC (Little Computer) 2200 assembly language. You will learn the syntax and semantics that underlie each of the supported operations. Although our instruction set is not as extensive as MIPS (Microprocessor without Interlocked Pipeline Stages) or x86, it is still able to solve a multitude of problems. In a LC-2200 computer, the word size is two bytes (16 bits), and there are 16 registers. We restrict memory to be addressable by words. Register Conventions Although the registers are for general-purpose use, we shall place restrictions on their use for the sake of convention and all that is good on this earth. Here is a table of their names and uses: Table 1: Registers and their Uses Register Number Name Use Callee Save? 0 $zero Always Zero NA 1 $at Reserved for the Assembler NA 2 $v0 Return Value No 3 $a0 Argument 1 No 4 $a1 Argument 2 No 5 $a2 Argument 3 No 6 $t0 Temporary Variable No 7 $t1 Temporary Variable No 8 $t2 Temporary Variable No 9 $s0 Saved Register Yes 10 $s1 Saved Register Yes 11 $s2 Saved Register Yes 12 $k0 Reserved for OS and Traps NA 13 $sp Stack Pointer No 14 $fp Frame Pointer Yes 15 $ra Return Address No Register 0 This register is always read as zero. Any values written to it are discarded. Register 1 is a general purpose register, you should not use it because the assembler will use it in processing pseudo-instructions. Register 2 is where you should store any returned value from a subroutine call. Registers 3 to 5 are used to pass arguments into subroutines. Registers 6 to 8 are used to store temporary values. Note that registers 2 through 8 should be placed on the stack if the caller wants to retain those values. These registers are fair game for the callee (the subroutine) to trash. Registers 9 to 11 are the saved registers. The caller may assume that these registers are never tam- pered with by the subroutine. If the subroutine needs these registers, then it should palce them on the stack and restore them before they jump back to the caller’s code. Micro Project 1 CS 2200 - Systems and Networks Spring 2016 Register 12 is used to handle interrupts (something we’ll get to in a few weeks). Register 13 is your anchor on the stack. It keeps track of the top of the activation record for some subroutine. Register 14 is used to point to the ▯rst address on the activation record for the currently executing process. You do not need to worry about using this register. Register 15 is used to store the address a subroutine should return to when it is ▯nished executing. It is only supposed to be used by the JALR (Jump And Link Register) command. Instruction Formats There are four types of instructions: R-Type (Register Type), I-Type (Immediate value Type), J-Type (Jump Type), and S-Type (Stack Type). Here is the instruction format for R-Type instructions (ADD, NAND): Bits 15 - 13 12 - 9 8 - 5 4 - 1 0 Purpose opcode RX RY RZ Unused Here is the instruction format for I-Type instructions (ADDI, LW, SW, BEQ): Bits 15 - 13 12 - 9 8 - 5 4 - 0 Purpose opcode RX RY 2’s Complement O▯set Here is the instruction format for J-Type instructions (JALR): Bits 15 - 13 12 - 9 8 - 5 4 - 0 Purpose opcode RX RY Unused (all 0s) Here is the instruction format for S-Type instructions (SPOP): Bits 15 - 13 12 - 2 1 - 0 Purpose opcode Unused (all 0s) Control Code Symbolic instructions follow the same layout. That is, the order of the registers and o▯set ▯elds align with the order given in the instruction format, ie. instructions in assembly are written as: instruction RX, RY, RZ or instruction RX, [optional o▯set](RY). Micro Project 1 CS 2200 - Systems and Networks Spring 2016 Table 2: Assembly Language Instruction Descriptions Name Type Example Opcode Action add R add $v0, $a0, $a2 000 Add contents of RY with the contents of RZ and store the result in RX. nand R nand $v0, $a0, $a2 001 NAND contents of RY with the con- tents of RZ and store the result in RX. addi I addi $v0, $a0, 7 010 Add contents of RY to the contents of the o▯set ▯eld and store the result in RX. lw I lw $v0, 0x07($sp) 011 Load RX from memory. The memory address is formed by adding the o▯set to the contents of RY. sw I sw $a0, 0x07($sp) 100 Store RX into memory. The memory address is formed by adding the o▯set to the contents of RY. beq I beq $a0, $a1, done 101 Compare the contents of RX and RY. If they are the same, then branch to ad- dress PC + 1 + O▯set, where PC is the address of the beq instruction. Mem- ory is word addressed. Note that if you use a label in a BEQ instruction, it will jump to the relative o▯set of the label. jalr J jalr $at, $ra 110 First store PC + 1 in RY, where PC is the address of the jalr instruciton. Then branch to the address in RX. If RX = RY, then the processor will store PC + 1 into RY and end up branching to PC + 1. spop S spop 0 111 Perform the action as determined by the control code, which is the last two bits (control code = 0 tells the proces- sor to halt). LC 2200 provides a number of pseudo-instructions. Table 3: Assembly Language Pseudo-Instructions Name Example Action halt halt Emits a spop 0 to halt the processor. la la $a0, MyLabel Loads the address of a label into a reg- ister. noop noop No operation, does nothing. It actually does add $zero, $zero, $zero. .word .word 32, .word MyLabel Fills the memory location it is located with a given value or the address of the label. Micro Project 1 CS 2200 - Systems and Networks Spring 2016 Problem 1: Get used to LC 2200 [0 points]Play around with the simulator. Try writing some simple programs to copy values from one register to another or to load/store values from memory. You should get familiar with the syntax for the assembler. When you extract the archive, you will have access to an assembler ( and a sim- ulator ( Please run ‘python -h’ and ‘python -h’ in order to see how to run these programs. The simulator comes with a ‘help’ command to explore all the di▯erent commands. Here is the suggested work ow for writing and running your assembly programs on the simulator: 1. Edit and save your assembly ▯le with your favorite text editor. 2. Assemble your code by running python myFile.s. If this operation is successful, you will have a ▯le called ‘myFile.bin’. 3. You can run your .bin ▯le with the simulator by typing python myFile.bin. Some useful commands are ‘r’ for run, ‘q’ for quit, ‘break [line # or label]’, and ‘help’. Problem 2: Fibonacci Series Test Program In this problem, you have to use the LC 2200 assembly language to write a simple program. 1. [30 points] De▯ne a procedure calling convention for the LC-2200 assembly language. Your answer should have enough detail so that someone else could write a procedure (or procedure call) to be used as part of another program. You can come up with your own convention, but we recommend basing your convention description o▯ of the one shown in class and described above. Be sure to explicitly address the following standard issues: (a) [10/30 points] De▯ne how registers are used. Which registers are used for what? (Specify ALL registers, including those that are not used.) (b) [10/30 points] De▯ne how the stack is accessed. What does the stack pointer point to? In which way does the stack grow in terms of memory addresses? (c) [10/30 points] De▯ne the mechanics of the call, including what the caller does to initiate a procedure call, what the callee does at the beginning of a procedure, what the callee does at the end of a procedure to return to the caller, and what the caller does to clean up after the procedure returned. 2. [70 points] Write a function in LC-2200 to compute fibonacci(num). ▯bonacci(n) = ▯bonacci(n - 1) + ▯bonacci(n - 2) ▯bonacci(0) = 0, and ▯bonacci(1) = 1 NOTE: (a) Your function is required to follow the calling convention you established above. (b) It should work for n >= 0, but you don’t have to handle detecting/handling integer over ow. YOUR FUNCTION MUST BE RECURSIVE, PURELY ITERATIVE SOLUTIONS WILL NOT RECIEVE ANY CREDIT! YOU MUST USE THE STACK AND STACK POINTER TO IMPLEMENT RECURSION FOR FULL CREDIT! Recursive functions always obtain a return address through the function call and return to the callee using the return address. We recommend starting with a solution in a higher level language Micro Project 1 CS 2200 - Systems and Networks Spring 2016 such as C, and then moving to assembly. Feel free to ask us questions in our o▯ce hours, on Piazza, or in the weekly recitation. Make sure that ▯b.s is in a UNIX-readble format (no DOS/Windows nonsense). Comment your code. Assembly is hard to read, and comments aid in debugging while providing clarity Deliverables Turn in ALL of your ▯les in T-Square in a .tar.gz archive. To create a tar.gz archive, use the command ‘tar cvzf hw1.tar.gz <your list of ▯les>’. See the tar man page (>>‘man tar’) for more details on usage. ▯ answers.txt, which has your answers for Problem 2, question 1. ▯ fib.s, which has your assembly code. ▯, the lc2200-16 assembler ▯, the lc2200-16 simulator The TAs should be able to type python fib.s and then python fib.bin to run your code. If you cannot do this with your submission, then you have done something wrong.


Buy Material

Are you sure you want to buy this material for

25 Karma

Buy Material

BOOM! Enjoy Your Free Notes!

We've added these Notes to your profile, click here to view them now.


You're already Subscribed!

Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'

Why people love StudySoup

Steve Martinelli UC Los Angeles

"There's no way I would have passed my Organic Chemistry class this semester without the notes and study guides I got from StudySoup."

Anthony Lee UC Santa Barbara

"I bought an awesome study guide, which helped me get an A in my Math 34B class this quarter!"

Jim McGreen Ohio University

"Knowing I can count on the Elite Notetaker in my class allows me to focus on what the professor is saying instead of just scribbling notes the whole time and falling behind."

Parker Thompson 500 Startups

"It's a great way for students to improve their educational experience and it seemed like a product that everybody wants, so all the people participating are winning."

Become an Elite Notetaker and start selling your notes online!

Refund Policy


All subscriptions to StudySoup are paid in full at the time of subscribing. To change your credit card information or to cancel your subscription, go to "Edit Settings". All credit card information will be available there. If you should decide to cancel your subscription, it will continue to be valid until the next payment period, as all payments for the current period were made in advance. For special circumstances, please email


StudySoup has more than 1 million course-specific study resources to help students study smarter. If you’re having trouble finding what you’re looking for, our customer support team can help you find what you need! Feel free to contact them here:

Recurring Subscriptions: If you have canceled your recurring subscription on the day of renewal and have not downloaded any documents, you may request a refund by submitting an email to

Satisfaction Guarantee: If you’re not satisfied with your subscription, you can contact us for further help. Contact must be made within 3 business days of your subscription purchase and your refund request will be subject for review.

Please Note: Refunds can never be provided more than 30 days after the initial purchase date regardless of your activity on the site.