Bài tập Kỹ thuật vi xử lý khoa điện tử viễn thông trường đại học bách khoa đà nẵng
Microprocessors - Semester 2015-2016 - Homework Your Name and Class: For single-choice questions, underline the single correct answer to each question For short answer questions, write your answer in the space provided on this paper Remember to include the number base for any numerical answers—else it will get counted wrong 1) Which of the following is not an instruction mnemonic of the MSP430 CPU: BIS, ORG, JC, XOR, JNZ, BIC, MOV.W 2) Which of the following is not one of the fundamental components of all microcomputers: Input, Output, A/D converter, Control unit, Memory, ALU 3) The instruction mov.w #0x567A, (4)R5 uses which MSP430 addressing modes? a Register direct, register direct b Absolute, register direct c Immediate, register indexed d Symbolic, register indirect e None of the above 4) What is the minimum number of bus cycles required to move a 16-bit word of data from the memory into the MSP430 CPU? Answer: 5) A certain byte-addressable microprocessor has 20-bit address bus How many bytes can be addressed by this microprocessor? Answer: 6) The MSP430 mov instruction supports a total of source addressing modes (only consider basic addressing modes) 7) An MSP430 instruction using indexed addressing for the source operand and absolute addressing for the destination operand occupies a total of words of memory 8) The number prefix “#” identifies what to the MSP430 assembler? a A comment b Absolute addressing mode c A hex number d A binary number e None of the above 9) If the register R5 contained the hex number 0x1234, the instruction mov @R5, R7 means what? a Load the number 0x1234 into the register R7 b Load the contents of memory location 0x1234 into the register R7 c Copy the contents of the register R5 into the register R7 d Store the contents of the register R7 to the memory location 0x1234 e None of the above 1/4 10) The MSP430 instruction mov.w R6, 0x0136 means what? a Store the higher half of R6 to the memory location 0x0137 and the lower half to the memory location 0x0136 b Store the higher half of R6 to the memory location 0x0136 and the lower half to the memory location 0x0137 c None of the above 11) Assume R7 contains the value 0x1273 The MSP430 instruction mov.b 3(R7), R8 means what? a Load the byte stored in 0x1276 into the lower half of R8 b Load the byte stored in 0x1276 into the upper half of R8 c Load the value 0x12 into the lower half of R8 and 0x76 into the upper half of R8 d Load the value 0x76 into the lower half of R8 and 0x12 into the upper half of R8 e None of the above 12) The instruction mov #45,0x1234 requires how many 16-bit operands? Answer: 13) Fill out the contents of the MSP430 registers for the following code segment which starts from 0xC400 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 hexadecimal Assume that MICKEY and JERRY are memory locations at 0x0280 and 0x0282, respectively main: mov.w #0x1234, R4 mov.w R4, MICKEY mov.w #JERRY, R6 mov.w #0x1230, R6 mov.w #0x1235, R7 add.w R6, R7 sub.w R6, R7 bis.w #0x0F, R4 xor.w R7, R7 and.w R7, R4 PC = M(MICKEY) = R6 = R6 = R7 = R7 = R7 = R4 = R7 = R4 = 14) Convert the following assembly code into machine code All answers should be in hexadecimal format Write the instruction word (the first word) as a 16-bit value and all operands as 16-bit values Assume that the code starts at 0xAC00 main: and.b R10,0x4040 mov.w R4,R13 bis.w @R11,R12 add.w &0x0200, R5 xor.w #0x1234, R8 _ … 15) When using the indirect register addressing mode, the operand(s) provide: a The address of the data to work with b The actual data to work with c None of the above 2/4 16) Convert 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 You can use emulated instructions 0xc000: 0xc004: 0xc00a: 0xc00e: 0xc012: 0xc016: 0xc018: 0xc01a: 4031 0280 40B2 5A80 0120 D3D2 0022 E3D2 0021 403F 5000 831F 23FE 3FF9 17) The MSP430 address bus is _ bits wide and the data bus is bits wide 18) Assume we want to set bit and clear bit (set bit to a and bit to a 0) in an 8-bit control register mapped to memory location 0x000A simultaneously (in that control register) and without affecting the state of the other bits in that control register Show the assembly code required to that Use only one general purpose register to that 19) Which of the following needs two 16-bit machine code operands? a xor #0x0040, R5 b mov 0x0234, 0456h c sub R5, 0x0056 d add @R7+, 0x0078 e None of the above 20) Which of the following requires no machine code operands? a mov #0x0040, R5 b add @R9+, R10 c sub 4(R5), 0x0056 d bic @R7, 0x0078 e None of the above 21) What the flags of the status register (SR) control directly the MSP430 MCU? Answer: 22) Approximately how long would it take the MSP430 (if the MCLK frequency were MHz) to execute the following code segment? main: add.w 0x1234,4(R7) xor.b #0x10,R8 Answer: 3/4 23) How many words of memory are consumed by the above chunk of code (in question #22)? Answer: 24) Which two MSP430 registers have “constant generator” capabilities and how many constants can be generated by them? Answer: 25) How many writes and reads are performed to and from memory on the MSP430 address/data bus for the given assembly instruction: sub.w R4, 3(R5) Machine code: 8485 0003 Answer: Number of reads = Number of writes = 26) How many writes and reads are performed to and from memory on the MSP430 address/data bus for the given assembly instruction: add.w &0x0050, R5 Machine code: 5215 0050 Answer: Number of reads = Number of writes = 27) Name one thing that makes a microcontroller different from a microprocessor: Answer: 28) Show the optimized machine code for the following instruction—making use of the constant generators: mov.w #-1, R9 Answer: 29) Show the optimized machine code for the following instruction—making use of the constant generators: mov.w #8, R10 Answer: 30) Show how the 16-bit value 0x3412 would be stored to memory location 0x0040 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 Big Endian: Little Endian: M(0x003F) = _ M(0x003F) = _ M(0x0040) = _ M(0x0040) = _ M(0x0041) = _ M(0x0041) = _ 31) Which of the bit-wise logical instructions available on MSP430 can be used to invert all bits in a register to the opposite state and could also be used to compare two registers for equality? Give an example 32) What bit-wise logical MSP430 instruction should be used to force selected bits to zero within a byte without impacting other bits? Give an example 4/4