Homework 1 08s

Homework 1 08s - LSU EE 4720 Homework 1 Solution Due: 29...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: LSU EE 4720 Homework 1 Solution Due: 29 September 2008 To answer the first question below see the MIPS32 Architecture manual linked to the course references page. Problem 1: The MIPS I bgtz and bltz instructions compare a register to zero, but cant compare two registers (unless the second one is the zero register). Consider an extension of MIPS I that allowed branch greater than and branch less than instructions to compare two registers, call the new instructions bgt and blt . Explain why the existing bgtz opcode could be used for bgt but why the bltz opcode could not be used for blt . Hint: See bltzal . The opcode for bgtz is 0x07 and the value that the ISA specifies for the rt field is 0. Assuming that no other instruction uses opcode 0x07 , the rt field could be used for the second comparison register. (This would not be incompatible with its current use because in its current use it is comparing the rs register to 0 so it wouldnt matter if rt held a register number.) In the bltz instruction the rt field is being used as an extension of the opcode field and so it cannot be used for a register number. A new blt instruction would need its own opcode. 1 Problem 2: A C function and a part of a MIPS equivalent are shown below. The C function looks at the attributes of a car and decides what to pack in a promotional giveaway to the car buyer. The assembler code corresponds to the C function up until the last line (checking for a sun roof). #define FE_SPORTY 0x1 #define FE_OFF_ROAD 0x2 #define FE_EFFICIENT 0x4 #define FE_SUN_ROOF 0x10000 #define FE_MANUAL_TRANSMISSION 0x20000 enum Giveaways { G_Food, G_Hiking_Boots, G_Sunblock, G_Driving_Gloves }; void prepare_promotion_package(Car_Object *car) { int car_features = car->features; if ( car_features & FE_OFF_ROAD ) pack(car, 1200, G_Hiking_Boots); if ( car_features & FE_SUN_ROOF ) pack(car, 200, G_Sunblock); } # MIPS-I Equivalent of C code....
View Full Document

Page1 / 4

Homework 1 08s - LSU EE 4720 Homework 1 Solution Due: 29...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online