# HW5.pdf - CS 252 Introduction to Computer Engineering Fall...

• 4

This preview shows page 1 out of 4 pages.

Unformatted text preview: CS​ ​252​ ​Introduction​ ​to​ ​Computer​ ​Engineering,​ ​Fall​ ​‘17 Homework​ ​5 Student​ ​Details: Student​ ​Name:​ ​___________________ Section:​ ​___________________ Net​ ​ID:​ ​___________________ Course​ ​Details: Sections​ ​2​ ​and​ ​5 Instructor:​ ​Prof.​ ​Adil​ ​Ibrahim TAs:​ ​Lan​ ​Bai,​ ​Amogh​ ​Joshi,​ ​Gautham​ ​Sunjay,​ ​Huawei​ ​Wang,​ ​Ammar​ ​Mahmood Course​ ​URL:​ ​ Homework​ ​to​ ​be​ ​submitted​ ​individually.​ ​Please​ ​write​ ​your​ ​Name,​ ​Section​ ​and​ ​NetID​ ​on​ ​all pages​ ​and​ ​staple​ ​all​ ​pages​ ​together​ ​before​ ​submission. Problem​ ​1​ ​(2​ ​points) Suppose​ ​we​ ​increase​ ​the​ ​number​ ​of​ ​registers​ ​in​ ​the​ ​LC-3​ ​to​ ​128​ ​and​ ​keep​ ​the​ ​instruction​ ​size​ ​at 16​ ​bits.​ ​Will​ ​this​ ​cause​ ​any​ ​problems​ ​with​ ​the​ ​ADD​ ​(non-immediate)​ ​instruction?​ ​Explain. Problem​ ​2​ ​(3​ ​points) How​ ​many​ ​times​ ​does​ ​the​ ​LC-3​ ​make​ ​a​ ​read​ ​or​ ​write​ ​request​ ​to​ ​memory​ ​during​ ​the​ ​processing of​ ​following​ ​instructions? ● ● ● LDR LDI LEA Student​ ​Details: Student​ ​Name:​ ​___________________ Section:​ ​___________________ Net​ ​ID:​ ​___________________ Problem​ ​3​ ​(4​ ​points) Write​ ​the​ ​LC-3​ ​machine​ ​instructions​ ​in​ ​hex​​ ​that​ ​will​ ​implement​ ​the​ ​following.​ ​Give​ ​a​ ​solution​ ​that is​ ​1-2​ ​instructions​ ​long​ ​and​ ​uses​ ​a​ ​minimal​​ ​number​ ​of​ ​registers. ● Suppose​ ​PC​ ​=​ ​0x2000​ ​and​ ​R1​ ​=​ ​0x3000.​ ​Store​ ​the​ ​1's​ ​complement​ ​of​ ​the​ ​value​ ​at memory​ ​address​ ​0x3003​ ​into​ ​R2​ ​without​ ​overwriting​ ​R1. ● Assume​ ​PC​ ​=​ ​0x4000​ ​and​ ​the​ ​value​ ​at​ ​memory​ ​address​ ​0x400A​ ​is​ ​0x8000.​ ​Store​ ​the most​ ​significant​ ​bit​ ​of​ ​R2​ ​into​ ​R0. Student​ ​Details: Student​ ​Name:​ ​___________________ Section:​ ​___________________ Net​ ​ID:​ ​___________________ Problem​ ​4​ ​(8​ ​points) a)Write​ ​what​ ​each​ ​instruction​ ​does​ ​in​ ​the​ ​“comment”​ ​section.​ ​The​ ​first​ ​one​ ​is​ ​completed​ ​for​ ​you Address Instruction Comment X0123 1110​ ​0001​ ​1111​ ​1011 R​0​​ ​<-​ ​PC​ ​-​ ​5 X0124 0001​ ​0010​ ​0010​ ​1010 X0125 0011​ ​0011​ ​1111​ ​1011 X0126 0101​ ​0010​ ​0110​ ​0000 X0127 0001​ ​0010​ ​0110​ ​0100 X0128 0111​ ​0010​ ​0000​ ​1010 X0129 1010​ ​0101​ ​1111​ ​0111 b)​ ​What​ ​is​ ​the​ ​value​ ​stored​ ​in​ ​R2​ ​and​ ​PC​ ​at​ ​the​ ​end​ ​of​ ​execution​ ​of​ ​all​ ​the​ ​commands? Problem​ ​5​ ​(8​ ​points) a. Give​ ​the​ ​instructions​ ​JMP,​ ​AND,​ ​LD​ ​and​ ​ ​NOT,​ ​identify​ ​whether​ ​they​ ​are​ ​operate instructions,​ ​data​ ​movement​ ​instructions​ ​or​ ​control​ ​instructions. b. List​ ​all​ ​the​ ​addressing​ ​modes​ ​that​ ​can​ ​be​ ​used​ ​with​ ​the​ ​instructions​ ​mentioned​ ​above. Student​ ​Details: Student​ ​Name:​ ​___________________ Section:​ ​___________________ Net​ ​ID:​ ​___________________ Problem​ ​6​ ​(3​ ​points) The​ ​LC3​ ​instruction​ ​set​ ​does​ ​not​ ​have​ ​an​ ​opcode​ ​for​ ​the​ ​logical​ ​function​ ​NOR.​ ​However,​ ​this can​ ​be​ ​implemented​ ​with​ ​the​ ​existing​ ​instructions.​ ​Given​ ​two​ ​numbers​ ​already​ ​stored​ ​in registers​ ​R1​ ​and​ ​R2,​ ​list​ ​down​ ​the​ ​instructions​ ​required​ ​to​ ​perform​ ​NOR​ ​on​ ​the​ ​contents​ ​of​ ​R1 and​ ​R2.​ ​Store​ ​the​ ​result​ ​in​ ​any​ ​of​ ​the​ ​other​ ​registers. Instruction Comment Problem​ ​7​ ​(3​ ​points) Assume​ ​the​ ​current​ ​value​ ​in​ ​the​ ​PC​ ​to​ ​be​ ​x4012​. a. Write​ ​the​ ​BR​​ ​instruction​ ​to​ ​unconditionally​​ ​branch​ ​to​ ​the​ ​instruction​ ​located​ ​at​ ​an​ ​offset of​ ​x0D9​. b. What​ ​will​ ​the​ ​PC​ ​point​ ​to​ ​after​ ​the​ ​BR​​ ​statement​ ​in​ ​(a)​ ​is​ ​executed?​ ​Show​ ​the hexadecimal​ ​representation. c. If​ ​unconditional​ ​branching​ ​is​ ​possible​ ​using​ B ​ R​,​ ​why​ ​do​ ​we​ ​need​ ​the​ ​JMP​ ​instruction? ...
View Full Document

• Spring '13
• GuriSohi

{[ snackBarMessage ]}

###### "Before using Course Hero my grade was at 78%. By the end of the semester my grade was at 90%. I could not have done it without all the class material I found."
— Christopher R., University of Rhode Island '15, Course Hero Intern

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern