You are on page 1of 6

Microprocessor - Semester 2 2016-2017 - Homework 1

Your Name:

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 (except decimal) else it will get
counted wrong.

1) Which of the following is not an instruction mnemonic of the MSP430 CPU:


a. BIS
b. ORG
c. JC
d. XOR
e. JNZ
f. BIC
g. MOV.W

2) Which of the following is not one of the fundamental components of all microcomputers:
a. Input
b. Output
c. A/D converter
d. Control unit
e. Memory
f. 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: 1

5) A certain byte-addressable microprocessor has 20-bit address bus. How many bytes can be
addressed by this microprocessor?
Answer: 3

6) The MSP430 mov instruction supports a total of 5 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 ___3_ words of memory.

8) The number prefix # identifies what to the MSP430 assembler?


a. A comment
1/6
b. Absolute addressing mode
c. A hex number
d. A binary number
e. None of the above
bbvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
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

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. Store the number 0x1236 to the register R6
d. 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 and clear the upper half of
R8
b. Load the byte stored in 0x1276 into the upper half of R8 and clear the lower 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: 3

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 PC = 0xC400


mov.w R4, MICKEY M(MICKEY) = 0x1234
mov.w #JERRY, R6 R6 = 0x0282
mov.w #0x1230, R6 R6 = 0x1230
mov.w #0x1235, R7 R7 = 0x1235
add.w R6, R7 R7 = 0x2465
sub.w R6, R7 R7 = 0x1235
bis.w #0x0F, R4 R4 = 0x123F
xor.w R7, R7 R7 = 0x0000
and.w R7, R4 R4 = 0x0000

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.

2/6
main: and.b R10,0x4040 _____FAC0 4040___________
mov.w R4,R13 _______440D_________
bis.w @R11,R12 _______DB2C________
add.w &0x0200, R5 _______5215 0200_________
xor.w #0x1234, R8 ________E038 1234________

15) When using the indirect register addressing mode, the register provides:
a. The address of the data to work with
b. The actual data to work with
c. The address of the address of the data to work with
d. None of the above

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 in hex. You can
use emulated instructions.

0xc000: 4031 0280 mov.w #0280, SP


0xc004: 40B2 5A80 0120 mov.w #5A80, &0120
0xc00a: D3D2 0022 bis.b #01, &0022
0xc00e: E3D2 0021 xor.b #01, &0021
0xc012: 403F 5000 mov.w #5000, R15
0xc016: 831F sub #1, R15
0xc018: 23FE jne 0x3FC
0xc01a: 3FF9 jmp 0x3F2

17) The MSP430 address bus is _16__ bits wide and the data bus is __16__ bits wide.

18) Assume we want to set bit 7 and clear bit 0 (set bit 7 to a 1 and bit 0 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 do
that. Use only one general purpose register to do that.

- mov.b 0x000A, R9
- bis.b #0x80, R9
- bic.b #0x01, R9
- mov.b R9, 0x000A

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
3/6
d. bic @R7, 0x0078
e. None of the above
21) What the 5 flags of the status register (SR) control directly the MSP430 MCU?
Answer: Carry(CF), zero(ZF), negative(NF), overflow,(VF), interrupt (IF)

22) Approximately how long would it take the MSP430 (if the MCLK frequency were 1 MHz) to
execute the following code segment?
main: add.w 0x1234,4(R7) => 6 cycles
xor.b #0x10,R8 => 2 cycles
Answer: cycles = 6 + 2 = 8 * (1/10^6) = 8 us

23) How many words of memory are consumed by the above chunk of code (in question #22)?
Answer: 5

24) Which two MSP430 registers have constant generator capabilities and what are constants can be
generated by each of them?
Answer: R2: 0, 1, 2, -1; R3: 4, 8, 0

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 = 2 (to read machine code) + 1 (to read destination operand) = 3
Number of writes = 1 (to write destination operand)

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 = 2 (to read machine code) + 1 (to read source operand)
Number of writes = 0 (destination is in CPU)

27) Name one thing that makes a microcontroller different from a microprocessor:
Answer: MCU has all 5 classic component of a computer.

28) Show the optimized machine code for the following instructionmaking use of the constant
generators: mov.w #-1, R9
Answer: 4339

29) Show the optimized machine code for the following instructionmaking use of the constant
generators: mov.w #8, R10
Answer: 423A

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.
4/6
Big Endian: M(0x003F) = ? M(0x0040) = 0x34 M(0x0041) = 0x12
Little Endian: M(0x003F) = ? M(0x0040) = 0x12 M(0x0041) = 0x34

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
* XOR
- Invert: xor #0x0000, R5;
- Comparte: xor #R5, R6 // if R5 = R6 then zero flag = 1;

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
- bic
+ ex: R7 = 0x000F;
+ bic #0x0001, R7 // R7 = 0x000E;
- and
+ and #0xFFFE, R7 // set bit 0 of R7 to zeros

33) Instruction operands can be found in?


a. Registers
b. Memory
c. The Stack
d. In the instruction itself
e. All of the above.
34) All MSP430 assembly instructions
a. affect (change) condition codes (status flags in SR).
b. can execute in one cycle.
c. have an emulated form.
d. store a result.
e. use the ALU.
f. None of the above is true.
35) In an Assembly source program maybe have the followings:
a. Assembly instructions.
b. Directives for Assembler.
c. Comments.
d. Labels.
e. All of the above.
36) Which of the following instruction used to initiate the stack:
a. mov.w #0x0280, R1
b. mov.w #0x0280, R4
c. mov.w #0x0280, R7
d. mov.w #0x0280, R10
e. None of the above
37) Which of the following instruction used to stop the Watchdog Timer:
a. mov.w #0x5A80, &0x0120
b. mov.w #WDTPW + WDTHOLD, R15
c. mov.w #WDTPW, &WDTCTL
d. mov.w #WDTHOLD, &0x0120
e. None of the above
38) The JMP and BR instructions can both reach any memory location from any other memory location.
5/6
a. TRUE
b. FALSE
39) The Call instructions occur at predictable times.
a. TRUE
b. FALSE
40) Interrupts occur at predictable times.
a. TRUE
b. FALSE

6/6

You might also like