Computer Science > QUESTIONS & ANSWERS > Northwestern UniversityEECS 213 HOMEWORK 2 SOLUTION FALL 2020 (All)

Northwestern UniversityEECS 213 HOMEWORK 2 SOLUTION FALL 2020

Document Content and Description Below

EECS­213, Fall 2015 HOMEWORK 2 SOLUTION Problem 1 (20 points) For each IA32 assembly code sequence below on the left, fill in the missing portion of corresponding C line on the right. Simplify th... e C code as much as possible. foo: pushl %ebp movl %esp,%ebp movl 8(%ebp),%eax sall $5,%eax subl 8(%ebp),%eax movl %ebp,%esp popl %ebp ret int foo(int x) { return 31*x; // (x<<5) ­ x } foo: pushl %ebp movl %esp,%ebp movl 8(%ebp),%eax testl %eax,%eax jge .L4 addl $3,%eax .L4: sarl $2,%eax movl %ebp,%esp popl %ebp ret int foo(int x) { return x/4; // (x>=0 ? x:(x+3)) >> 2; } foo: pushl %ebp movl %esp,%ebp movl 8(%ebp),%eax shrl $16,%eax movl %ebp,%esp popl %ebp ret int foo(int x) { return (int) ((unsigned int)x >> 16); } foo: pushl %ebp movl %esp,%ebp movl 8(%ebp),%eax sall $4,%eax addl 8(%ebp),%eax addl %eax,%eax movl %ebp,%esp popl %ebp ret int foo(int x) { return 34*x; // 2*(x<<4 + x); } foo: pushl %ebp movl %esp,%ebp movl 8(%ebp),%edx movl 12(%ebp),%eax movl %ebp,%esp movl (%edx),%edx addl %edx,(%eax) movl %edx,%eax popl %ebp ret int foo(int *xp, int *yp) { int x = *xp; *yp += *xp; // or *yp += x; return x; } This study source was downloaded by 100000784424693 from CourseHero.com on 04-28-2021 01:53:06 GMT -05:00 https://www.coursehero.com/file/14225010/HW2sol/ his stu ed via y re | ourse urce wa Hero.co sha Problem 2 (20 points) Consider the following assembly representation of a function forloop containing a loop: forloop: pushl %ebp movl %esp, %ebp subl $16, %esp movl $1, ­4(%ebp) movl $0, ­8(%ebp) jmp .L2 .L3: movl ­8(%ebp), %eax addl %eax, %eax addl $5, %eax addl %eax, ­4(%ebp) addl $1, ­8(%ebp) .L2: movl ­8(%ebp), %eax cmpl 8(%ebp), %eax jl .L3 movl ­4(%ebp), %eax leave ret Fill in the blanks to provide the functionality of the loop. Note that 8(%ebp) stores the argument a. int​forloop​ (​ int​a) { ​ int​i; ​ int​result ​ =​1; ​ for​ (​i ​ =​​ 0​ ;​i ​ <​a​ ;​i​ ++​​ )​{ result ​ +=​​ (​ 2​ *​ i ​ +​​ 5​ ); }​re turn​result; } W hat is the size of stack frame in bytes (including %ebp and %esp)? 20 ... a ret address forloop %ebp result [Show More]

Last updated: 1 year ago

Preview 1 out of 8 pages

Reviews( 0 )

Recommended For You

 *NURSING> QUESTIONS & ANSWERS > NCSBN TEST BANK for the NCLEX-RN & NCLEX-PN. Contains More than 2000 Q&A Plus Review and Rationale in 517 PAGES. (All)

preview
NCSBN TEST BANK for the NCLEX-RN & NCLEX-PN. Contains More than 2000 Q&A Plus Review and Rationale in 517 PAGES.

NCSBN TEST BANK -for the NCLEX-RN & NCLEX-PN. Updated 2022/2023. Contains More than 2000 Q&A Plus Review and Rationale in 517 PAGES. (All Testable Questions for NCLEX-RN & NCLEX-PN)

By Expert1 , Uploaded: Jul 28, 2020

$20

 Business> QUESTIONS & ANSWERS > CLM 031 EXAM (All)

preview
CLM 031 EXAM

CLM 031 = 100% Question 1: 5b Select the statement that is correct concerning performance work statement (PWS) requirements: - All answers are correct. - PWS should describe requirements necessary...

By Book Worm, Certified , Uploaded: Nov 03, 2022

$5

 *NURSING> QUESTIONS & ANSWERS > PHIL 347 Week 6 Checkpoint Quiz. Score 100/100 (All)

preview
PHIL 347 Week 6 Checkpoint Quiz. Score 100/100

Question: What are the three fundamental reasoning strategies listed in the text? Question: What is comparative reasoning? On what skill is it based? Question: We learned four tests for evaluating...

By Amanda Rosales , Uploaded: Mar 24, 2021

$7

 Business> QUESTIONS & ANSWERS > BUSINESS 1007 (All)

preview
BUSINESS 1007

BUSINESS 1007 07 Key 1. (p. 178) Managers utilize organizational resources such as employees, information, and equipment to accomplish goals. 2. (p. 178) The main job of managers today is to w...

By Kirsch , Uploaded: Oct 19, 2019

$6

 Anthropology> QUESTIONS & ANSWERS > KOR 352 FA19 101 week 8 Quiz. Already Graded A (All)

preview
KOR 352 FA19 101 week 8 Quiz. Already Graded A

KOR 352 FA19 101: Week 8 Quiz Question 1 (0.25 points) Which of the following is not true of Kim and Finch’s observations during their field research in South Korea from 1997 to 2000? Question 1 o...

By Kirsch , Uploaded: Oct 17, 2019

$9

 E-Commerce> QUESTIONS & ANSWERS > ESOC 316 Digital Commerce - University Of Arizona. Midterm Quiz. 20 Q&A. 100% Score (All)

preview
ESOC 316 Digital Commerce - University Of Arizona. Midterm Quiz. 20 Q&A. 100% Score

ESOC 316 Digital Commerce - University Of Arizona. Midterm Quiz. 20 Q&A. 100% Score ESOC316 MIDTERM QUIZQuestion 6 (1 point) Saved Information has several properties that make information goods...

By Kirsch , Uploaded: Oct 15, 2019

$9.5

 Marketing> QUESTIONS & ANSWERS > Marketing Management Chapter 2 to Chapter 10 Q&A (All)

preview
Marketing Management Chapter 2 to Chapter 10 Q&A

Chapter 2 to Chapter 10 Chapter 2: Developing Marketing Strategies and Plans GENERAL CONCEPT QUESTIONS Multiple Choice 66 Chapter 1: Marketing: Managing Profitable Customer Relationships...

By Kirsch , Uploaded: Oct 14, 2019

$10

 Marketing> QUESTIONS & ANSWERS > MKT 530 Customer Relationship Management. 155 Questions and Answers (All)

preview
MKT 530 Customer Relationship Management. 155 Questions and Answers

MKT 530 All Questions and Answers MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. 1) As the manager of an organization that is att...

By Kirsch , Uploaded: Oct 14, 2019

$10

 Art> QUESTIONS & ANSWERS > MAS 337 Exam 1. Graded A (All)

preview
MAS 337 Exam 1. Graded A

MAS 337 Exam 1 Match the son with its corresponding region. 1.Oaxaca 2.Veracruz 3.Michoacan 4.Jalisco 5.Hidalgo 1. Son istemeno 2. Son Jarocho 3. Son Abajeno 4. Son Jalisciense 5. Son Huast...

By Kirsch , Uploaded: Oct 14, 2019

$6

 Art> QUESTIONS & ANSWERS > MUS 337 Final Exam Graded 100%. (All)

preview
MUS 337 Final Exam Graded 100%.

MUS 337 Final Daisy Moreno-Cota Fri Dec 11 12:59:42 PST 2015 Tone or aural color Volume and articulation of sounds Frequency of the tone Phonic structure or relationships between the sounds Dura...

By Kirsch , Uploaded: Oct 12, 2019

$9

$7.00

Add to cart

Instant download

Can't find what you want? Try our AI powered Search

OR

GET ASSIGNMENT HELP
63
0

Document information


Connected school, study & course



About the document


Uploaded On

Apr 28, 2021

Number of pages

8

Written in

Seller


seller-icon
d.occ

Member since 3 years

226 Documents Sold


Additional information

This document has been written for:

Uploaded

Apr 28, 2021

Downloads

 0

Views

 63

Document Keyword Tags

THE BEST STUDY GUIDES

Avoid resits and achieve higher grades with the best study guides, textbook notes, and class notes written by your fellow students

custom preview

Avoid examination resits

Your fellow students know the appropriate material to use to deliver high quality content. With this great service and assistance from fellow students, you can become well prepared and avoid having to resits exams.

custom preview

Get the best grades

Your fellow student knows the best materials to research on and use. This guarantee you the best grades in your examination. Your fellow students use high quality materials, textbooks and notes to ensure high quality

custom preview

Earn from your notes

Get paid by selling your notes and study materials to other students. Earn alot of cash and help other students in study by providing them with appropriate and high quality study materials.

WHAT STUDENTS SAY ABOUT US


What is Browsegrades

In Browsegrades, a student can earn by offering help to other student. Students can help other students with materials by upploading their notes and earn money.

We are here to help

We're available through e-mail, Twitter, Facebook, and live chat.
 FAQ
 Questions? Leave a message!

Follow us on
 Twitter

Copyright © Browsegrades · High quality services·