ECE 3430 Exam 1 Solutions



ECE 3430 Exam #1 Solutions (Fall 2014)Your Name: Matt Laubhan(127 points possible)You may use your calculator, pencil, and scratch paper if you need it. No phones! Datasheets are provided with this exam. For multiple-choice questions, circle the single correct answer to each question. For short answer questions, write your answer in the space provided on this exam paper. Remember to include the number base for any numerical answers—else it will get counted wrong!Which of the following is an assembler directive and not processed by the MSP430 CPU? [2 points]movdssubxorWhich of the following is not one of the fundamental components of all microcomputers: [2 points]InputOutputControl unitMemoryDatapathTimersmov.w @R5, 8(R4) exhibits which MSP430 addressing modes? [2 points]Register direct, register directAbsolute, indexedRegister indirect, indexedSymbolic, register indirectThe MSP430 assembler recognizes instruction mnemonics and assembler directives as the: [2 points]First fieldSecond fieldThird fieldForth fieldA peripheral device that provides input to a microcontroller and reacts to changes in the environment is called a/an: [2 points]SensorActuatorSignal conditioning circuitDevice driverWhich of the following registers in the MSP430 controls the directionality of bi-directional pins in port 1: [2 points]P1OUTP1DIRP1INP1RENWhat is the minimum number of bus cycles required to move a 16-bit word of data in the MSP430? [2 points]1 bus cycle (since the data bus is 16-bits wide)The LaunchPad (housing the MSP430 microcontroller) communicates with the host PC in the laboratory: [2 points]Using a parallel cable and port 1Via a USB-based emulator chipUsing the RS-232 transceiver and the MSP430 SCI subsystemUsing a wireless adapterA certain byte-addressable microprocessor has 20 address lines. How many bytes can be addressed by this microprocessor? [2 points]1 MB or 1,048,576 bytesThe MSP430 “mov” instruction supports a total of ____ destination addressing modes (only consider the 4 fundamental addressing modes): [2 points]1234An MSP430 instruction using absolute addressing for both the source and destination operand occupies a total of ____ words of memory: [2 points]1234The number prefix “#” identifies what to the MSP430 assembler? [2 points]A commentAbsolute addressingA hex numberA binary numberImmediate addressingDS is an: [2 points]MSP430 assembly language directive used to reserve initialized data memoryMSP430 assembly language directive used to reserve uninitialized data memoryMSP430 instruction used to reserve initialized data memoryMSP430 instruction used to reserve uninitialized data memoryIf R5 contained the number 0x1234, “mov @R5,R6” means what? [2 points]Initialize the register R6 to the number 0x1234Initialize the register R6 to the contents of memory location 0x1234Copy the contents of R5 into R6The MSP430 instruction “mov.w R4, 0x0136” means which of the following to the CPU? [2 points]Store the upper part of R4 to memory location 0x0137 and the lower half of R4 to memory location 0x0136Store the upper part of R4 to memory location 0x0136 and the lower half of R4 to memory location 0x0137`Assume R7 contains the value 0x1273. The MSP430 instruction “mov.b 3(R7),R8” means which of the following to the CPU? [2 points]Load the byte stored in 0x1276 into the lower part of R8Load the byte stored in 0x1276 into the upper part of R8Load the value 0x12 into the lower part of R8 and 0x76 into the upper part of R8Load the value 0x76 into the lower part of R8 and 0x12 into the upper part of R8Assembly language programs: [2 points]Allow the programmer to optimize space, power, and speedMust be executed via read-only memoryMust be executed via read-write memoryUse all of the available addressing modes while C/C++ programs only use extended and immediate addressing modesThe instruction “mov #45, &0x5678” requires how many 16-bit operands? [2 points]2 (45 and 0x5678)Fill out the contents of the MSP430 registers for the given code segment. Your answers should reflect the content after each instruction has executed. If the contents are unknown, write a question mark (?) in the blank. All numbers should be given in hex! [10 points, 1 point each]ORG0x0200Florian:DS2Ralf: DS2ORG0xC000main:mov.w #0x1234, R4PC = C004mov.w R4, Florian M(Florian) = 1234 mov.w#Ralf, R6 R6 = 0202 mov.w #0x1230, R6 R6 = 1230 mov.w#0x1235, R7 R7 = 1235add.wR6, R7R7 = 2465sub.wR6, R7R7 = 1235 bis.w#00001111b, R4R4 = 123Fxor.wR7, R7R7 = 0000 and.w R4, R4 R4 = 123FHand assemble (or encode) the following assembly code into machine code. All answers should be in hex format! Write the instruction code (IC) as a 16-bit value and all operands as 16-bit values. [10 points, 2 points each] ORG0xC000main:and.b R10,0x0040IC = FAC0Operand(s) = 403E mov.w R4,R13IC = 440DOperand(s) = <none> bis.w @R11,R12IC = DB2COperand(s) = <none> add.w &0x0200, R5IC = 5215Operand(s) = 0200 xor.w #0x5678, R8IC = E038Operand(s) = 5678…Decode (or reverse-assemble or inverse-assemble) the following machine code back to the original assembly code. Each line decodes to a single instruction. Each instruction code and operand is provided as a 16-bit value. [8 points, 2 points each]C000:47C90008 mov.b R7,8(R9)C004:5429 add.w @R4,R9C006:8E3A sub.w @R14+,R10C008:E05F1234 xor.b0x1234(R0),R15orxor.b 0xD23E,R15The MSP430 address bus is ___ bits wide and the data bus is ____ bits wide. [2 points]16, 16When using immediate addressing, the operand(s) provide: [2 points]The address of the data to work withThe actual data to work withAssume we want to set bit 4 and clear bit 2 (set bit 4 to a 1 and bit 2 to a 0) in an 8-bit control register mapped to memory location 0x0008 simultaneously (in the control register) and without affecting the state of the other bits in that memory location. Show the assembly code required to pull this off. Use only R4 from the programming model. [4 points]mov.b0x0008, R4 or mov.b &0x0008, R4bis.b#00010000b,R4 or bis.b #0x10, R4and.b#11111011b,R4 or and.b #0xFB, R4mov.bR4, 0x0008 or mov.b R4, &0x0008Which of the following needs two 16-bit machine code operands? [2 points]xor#0x0040, R5mov0x0234, 0x0456subR5, 0x0056add@R7+, 0x0078Which of the following requires no machine code operands? [2 points]mov#0x0040, R5sub@R9+, R10add4(R5), 0x0056bic@R7, 0x0078Which of the following is an illegal operation on the MSP430? [2 points]mov#0x0051, R5mov0x0053, R11movR5, 0x0086bis@R7+, 0x0068What the 4 significant status register flags controlled directly by the ALU and potentially modified by the completion of an instruction? [2 points]N (negative), Z (zero), V (two’s complement overflow), and C (carry)Approximately how long would it take the MSP430 (if the MCLK frequency were 2 MHz) to execute the following code segment? [2 points]Cycles:Words:main: add.w 0x1234, R7 32xor.b#0x10, R822-----5 cycles * 500 ns/cycle = 2.5 usHow many words of memory are consumed by the above chunk of code (in question #29)? [2 points]4 wordsWhich two MSP430 registers have “constant generator” capabilities? [2 points]R2/SR and R3How many writes and reads are performed to and from memory on the MSP430 address/data bus for the given assembly instruction: [2 points]sub.w &0x0200, R7Machine code: 0x8217 0x0200Number of reads = 2 (to read in machine code) + 1 (to read source) = 3Number of writes = 0 (destination is in CPU)How many writes and reads are performed to and from memory on the MSP430 address/data bus for the given assembly instruction: [2 points]add.wR6, 3(R5)Machine code: 0x5685 0x0003Number of reads = 2 (to read in machine code) + 1 (to read destination) = 3Number of writes = 1 (to write back to the destination)Name one thing that makes a microcontroller different from a microprocessor: [2 points]Many answers are acceptable. Most notably, microcontrollers have on-chip peripheral devices (while microprocessors do not). A microcontroller is a “computer on a chip” (since it has all 5 classic components of a computer) and a microprocessor (by itself) is not a computer.Which of the following fundamental RAM technologies traditionally has a faster read access time and a faster write time—but takes up more silicon space? [2 points]SRAMDRAMShow the optimized machine code for the following instruction—making use of the constant generators: [2 points]add.w #-1, R100x533A (constant generator R3 is used with As = 11 to generate the constant -1 or 0xFFFF)Show the optimized machine code for the following instruction—making use of the constant generators: [2 points]mov.w #0, R110x430B (constant generator R3 is used with As = 00 to generate the constant 0)Name one fundamental ROM technology discussed in lecture: [2 points]MROM, PROM, EPROM, EEPROM, Flash (any are acceptable).When doing a number base conversion from decimal to binary, what phenomenon terminates the consecutive divisions by 2 (when converting the whole number part)? [2 points]When overflow occursAlways after eight division operationsThe remainder becomes 0The quotient becomes 0Give one reason (other than saving money) why saving power in a design (through efficient software and hardware design) is a good idea—even if your design does not run on a limited power supply (a battery). [2 points]Consuming power leads to heat generation—which brings on a new problem—the need to dissipate the heat to keep from overheating the circuit. When circuits overheat, they first malfunction—then eventually burn up. Solutions to dissipate heat can become expensive and/or require large cooling fans that tend to be noisy.Which of the following 16-bit operations will result in two’s complement overflow (all numbers are presented in decimal)? [2 points]-32 – 281270 – 12000-12760 – 20240 (-33000 is not in the signed range for 16-bit numbers)32766 + 1Show how the 16-bit value 0xABCD would be stored to memory location 0x0200 on both a big endian and little endian machine. Assume the CPU and memory architecture is byte addressable. Write a “?” in the blank if the contents are unknown. Write all answers in hex. [4 points]Big Endian: M(0x01FF) = ?M(0x0200) = 0xABM(0x0201) = 0xCDLittle Endian M(0x01FF) = ?M(0x0200) = 0xCDM(0x0201) = 0xABWhich of the bitwise logical instructions available on MSP430 can be used to flip all bits in a register to the opposite state and could also be used to compare two registers for equality? [2 points]“xor” (exclusive OR)What bitwise logical MSP430 instruction should be used to force selected bits to one within a byte without impacting other bits? [2 points]“or” or “bis” (bit set)State one good reason why an engineer would want to run an operating system on a microcontroller or a microprocessor: [2 points]Many answers are acceptable. Threading, memory management, et cetera are all good reasons.What does the following assembly code do? [2 points]ORG0xC000DW0xABCDInitializes the contents of 0xC000 to 0xABCD. You could also say it initializes the contents of 0xC000 and 0xC001 to 0xCD and 0xAB respectively (on a little-endian architecture). Why would using DB and DW within a section of memory mapped to RAM not be a good idea? [2 points]The initialized memory (initialized at download-time) would be lost when power is lost. However, the program code memory (in flash) would persist. Following a power-cycle, the program would work on uninitialized data.What does the following assembly code do? [2 points]ORG 0xC000DB“Hi”Places the ASCII code for ‘H’ into memory location 0xC000 and the ASCII code for ‘i’ in memory location 0xC001. The double-quotes cause 0xC002 to be initialized to the ASCII NUL character (0). This terminates the string.Give one good reason why a radix-2 multiplication algorithm involving shifts and adds (as discussed in lecture) would be preferable over just adding a value to itself n-1 times. [2 points]Less operations, less time to execute, less memory consumption as numbers become large.Show the 8-bit binary representation of -2 (decimal) using the following historical signed number encodings: [3 points]Sign-Magnitude:1000 0010Ones Complement:1111 1101Twos Complement:1111 1110 ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download