ECE 3430 Exam #1 Solutions (Fall 2009)

Your Name: Matt Laubhan

You may use your pink book (or printout of the pink book), calculator, pencil, and scratch paper if you need it. Nothing else! 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!

1)Which of the following is not processed by the HC11 CPU? [2 points]

  1. LSRA
  2. ROLB
  3. JSR
  4. EQU

2)Which of the following is not one of the fundamental components of all microcomputers: [2 points]

  1. Input
  2. Output
  3. Control unit
  4. Memory
  5. Datapath
  6. Port registers

3)LDAA #0101 exhibits which HC11 addressing mode? [2 points]

  1. Immediate
  2. Direct
  3. Extended
  4. Indexed
  5. Relative
  6. Inherent

4)The HC11 assembler recognizes opcodes (or mnemonics/assembler directives) as the: [2 points]

  1. First field
  2. Second field
  3. Third field
  4. Forth field

5)A peripheral device that drives microcontroller inputs and reacts to changes in the environment is called a: [2 points]

  1. Sensor
  2. Signal conditioning circuit
  3. Device driver
  4. Actuator

6)Which of the following registers in the HC11 controls the directionality of bi-directional pins in port D: [2 points]

  1. DDRB
  2. DDRD
  3. PACTL
  4. PORTD

7)The HC11 address bus and data bus are shared with which of the following ports? [2 points]

  1. Port A and port B
  2. Port B and port C
  3. Port C and port D
  4. Only port B

8)The MicroStamp (housing the HC11 microcontroller) communicates with the host PC in the laboratory: [2 points]

  1. Using a parallel cable and port A
  2. Using the RS-232 transceiver and the HC11 SCI subsystem
  3. Using a wireless adapter
  4. Using a USB cable and ports A and D

9)A certain byte-addressable microprocessor has 14 address lines. How many bytes can be addressed by this microprocessor? [2 points]

  1. 14bytes
  2. 64 Kilobytes
  3. 32 Kilobytes
  4. 16 Kilobytes

10)The LDAA instruction supports a total of ____ addressing modes (indexed on X and indexed on Y are not separate addressing modes): [2 points]

  1. 3
  2. 4
  3. 5
  4. 6

11)An HC11 instruction using the extended addressing mode and havinga two-byte opcode occupies a total of ____ bytes of memory: [2 points]

  1. 1
  2. 2
  3. 3
  4. 4

12)The symbol % identifies what to the HC11 assembler? [2 points]

  1. A comment
  2. An addressing mode
  3. A hex number
  4. A binary number
  5. An assembler directive

13)FCC is an: [2 points]

  1. HC11 instruction used to reserve uninitialized data memory
  2. HC11 instruction used to reserve initialized data memory
  3. HC11 assembly language directive used to reserve uninitialized data memory
  4. HC11 assembly language directive used to reserve initialized data memory

14)The HC11 assembly language symbol ,Y (comma followed by Y) identifies the: [2 points]

  1. Immediate addressing mode
  2. Direct addressing mode
  3. Extended addressing mode
  4. Indexed addressing mode
  5. Relative addressing mode
  6. Inherent addressing mode

15)The HC11 instruction LDD $0136 means which of the following to the CPU? [2 points]

  1. Load the value 01 (decimal) and 36 (decimal) into accumulator A and B respectively
  2. Load the value 01 (hex) and 36 (hex) into accumulator A and B respectively
  3. Load the value 01 (hex) and 36 (hex) into accumulator B and A respectively
  4. Load the contents of memory locations $0136 and $0137 into accumulator A and B respectively

`

16)Assume index register X contains the value $1273. The HC11 instruction LDAA 3,X means which of the following to the CPU? [2 points]

  1. Load the value $12 into accumulator A and $73 into accumulator B
  2. Load the value $73 into accumulator A and $12 into accumulator B
  3. Load the byte stored in $1276 into accumulator A
  4. Load the byte stored in $1273 into accumulator A

17)Assembly language programs: [2 points]

  1. Must be executed via read-only memory
  2. Allow the programmer to optimize space, power, and speed
  3. Must be executed via read-write memory
  4. Use all of the available addressing modes while C/C++ programs only use extended and immediate addressing modes
  5. Prevent the programmer from accessing the condition codes

18)The directionality of port A, pin 3 (PA3) is set in which of the following HC11 registers? [2 points]

  1. PORTA
  2. DDRA
  3. DIRA
  4. PACTL

19)Fill out the contents of the HC11 registers/accumulators 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]

ORG$0040

BOB:RMB1

TOM: RMB2

ORG$E000

MAIN:LDAA #$AA

STAABOB

LDD#$BBCC

STDTOM

LDX#BOB A = $BBB = $CC D = $BBCC X = $0040 Y = ?

LDD#$0002 A = $00B = $02D = $0002 X = $0040 Y = ?

LDAB#%01001011A = $00B = $4B D = $004B X = $0040 Y = ?

LDY1,XA = $00B = $4B D = $004B X = $0040 Y = $BBCC

SUBA#$10A = $F0B = $4B D = $F04B X = $0040 Y = $BBCC

ADDD#1A = $F0B = $4C D = $F04C X = $0040 Y = $BBCC

ABA A = $3CB = $4C D = $3C4C X = $0040 Y = $BBCC

MULA = $11B = $D0 D = $11D0 X = $0040 Y = $BBCC

STAA $40A = $11B = $D0 D = $11D0 X = $0040 Y = $BBCC

JSRDMPRMA = $11B = $D0 D = $11D0 X = $0040 Y = $BBCC

DONE:BRADONE

20)Hand assemble (or encode) the following assembly code into machine code. All answers should be in hex format! [6 points]

ORG$E000

MAIN:LDAA128Opcode = $96Operand(s) = $80

LDAB#$02Opcode = $C6Operand(s) = $02

LDX$6789Opcode = $FEOperand(s) = $67 $89

XGDXOpcode = $8FOperand(s) = <none>

STX0,XOpcode = $EFOperand(s) = $00

IDIVOpcode = $02Operand(s) = <none>

21)Decode (or reverse-assemble or inverse-assemble) the following machine code back to the original assembly code: [7 points]

Machine code:Assembly code:

M($E000) = $18LDY #$4100

M($E001) = $CE

M($E002) = $41
M($E003) = $00

---

M($E004) = $86LDAA#$10

M($E005) = $10

---

M($E006) = $F6LDAB$E040

M($E007) = $E0

M($E008) = $40

---

M($E009) = $18STD1,Y

M($E00A) = $ED

M($E00B) = $01

---

M($E00C) = $3DMUL

---

M($E00D) = $02IDIV

---

M($E00E) = $20BRA$F0 ($F0 is -16 when interpreted as a signed, 8-bit number, this branches

M($E00F) = $F0 back to the beginning [the LDY #$4100 instruction])

22)The HC11 data bus is ___ bits wide. [2 points]

  1. 4
  2. 8
  3. 16
  4. 32

23)When using immediate addressing, the operand(s) provide: [2 points]

  1. The actual data to work with
  2. The address of the data to work with

24)Assume we want to set bit 4 and clear bit 2 (set bit 4 to a 1 and bit 2 to a 0) in a control register mapped to memory location $0008 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? (do not try to use BSET or BCLR instructions) [4 points]

LDAA$08

ORAA#%00010000

ANDA#%11111011

STAA$08

25)Which of the following exhibits indexed addressing? [2 points]

  1. BNE$34
  2. LDD #$5000
  3. LDD$5000
  4. LDY 0, X

26)Which of the following exhibits relative addressing? [2 points]

  1. LDAA#$50
  2. LDD$5000
  3. BLT $34
  4. LDY 0, X

27)Which of the following is an illegal operation on the HC11? [2 points]

  1. LDAA#$00
  2. LDX#$1200
  3. BNE$1200 (out of range)
  4. LDAB$1200

28)Assume the HC11 is operating at an E-clock frequency of 2 MHz. Give an HC11 instruction that would take 2 us to complete? [2 points]

2 us / 500 ns = 4 cycles. Search pink book for an instruction that takes 4 cycles: ADDA (extended addressing)

Any instruction/addressing mode combination that totals 4 cycles equals a correct answer.

29)Approximately how long would it take the HC11 (if the E-clock frequency were 2 MHz) to execute the following code segment? [2 points]

Cycles:Bytes:

MAIN: LDX$BEEF 53

DEX31

STX$4042

-----

12cycles * 500 ns/cycle = 6us

30)How many bytes of memory are consumed by the above chunk of code (in question #29)? [2 points]

6 bytes

31)Which of the following registers is not considered part of the HC11 programming model? [2 points]

  1. Program counter (PC)
  2. Port B (PORTB)
  3. Stack pointer (SP)
  4. Condition code register (CCR)

32)How many writes and reads are performed to and from memory on the HC11 address/data bus for the given assembly instruction: [2 points]

LDY$DEAFMachine code: $18 $FE $DE$AF

Number of reads = 4 (to read in machine code) + 2 (to read in the bytes in $DEAF and $DEB0) = 6

Number of writes = 0

33)How many writes and reads are performed to and from memory on the HC11 address/data bus for the given assembly instruction: [2 points]

STX2,XMachine code: $EF $02

Number of reads = 2 (to read in machine code) = 2

Number of writes = 2 (to write the upper and lower half of X to M(X + 2) and M(X + 3) respectively) = 2

The 5th cycle is a single processing cycle required to calculate the effective address: X+2.

34)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 amicroprocessor (by itself) is not a computer.

35)Which of the following fundamental RAM technologies has a faster read access time and a faster write time? [2 points]

  1. SRAM
  2. DRAM

36)Which of the following fundamental RAM technologies has the highest bit-to-silicon ratio? In other words, which of these packs the memory bits into the tightest space? [2 points]

  1. SRAM
  2. DRAM

37)Which of the two RAM technologies in question #36 is more common today? [2 points]

DRAM is more popular—particularly because today DRAM speeds rival the speeds of SRAM technology.

38)Name one fundamental ROM technology discussed in lecture: [2 points]

MROM, PROM, EPROM, EEPROM, Flash EEPROM (any are acceptable).

39)When doing a number base conversion from decimal to hex, what phenomenon terminates the consecutive divisions by 16 (when converting the whole number part)? [2 points]

  1. The quotient becomes 0
  2. When overflow occurs
  3. Always after eight division operations
  4. The remainder becomes 0

40)Show the 8-bit binary representation for -50 (decimal) using twos complement encoding. [2 points]

11001110

41)Which of the following 8-bit operations will result in two’s complement overflow (all numbers are presented in decimal)? [2 points]

  1. -100 – 27
  2. 127 – 120
  3. -100 – 28
  4. 100 + 28 (128 is not in the signed range for 8-bit numbers)

42)Show how the 16-bit value $ABCD would be stored to memory location $0040 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. [4 points]

Big Endian: M($0039) = ?M($0040) = $ABM($0041) = $CD

Little Endian M($0039) = ?M($0040) = $CDM($0041) = $AB

43)Which of the following can not be done through the use of the MicroStamp debugging/utility library? [2 points]

  1. Dump the contents of the HC11 programming model to the PC terminal
  2. Show stack contents
  3. Dump the execution time of a block of code to the PC terminal
  4. Dump the contents of any arbitrary memory location to the PC terminal
  5. Cause execution to pause until a key is hit on the PC keyboard
  6. Read keys that are pressed on the PC keyboard

44)Which of the following logical masks should be used to conditionally set a bit in a register (set it to one) without affecting the state of the other bits? [2 points]

  1. AND
  2. OR
  3. EOR
  4. NOT

45)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.

46)Given the following listing file, what does the number in square brackets [] represent? [2 points]

01110040ORG$0040

0112 0040VAR:RMB1

0113

0114e100ORG$E100

0115

0116e1000f[2]MAIN:SEI

0117e10186 0a[2]LDAA#10

0118e10320 fe[3]DONE:BRADONE

0119

0120e10548 69STR:FCC‘Hi’

0121e10704FCB$04

[<number>] represents: cycle count for the instruction

47)In the above listing file, VAR, MAIN, DONE, and STR are called what (in assembler terminology)? [2 points]

Labels.

48)In the above listing file, the FCB line allocates and initializes a byte in memory. What is the purpose of doing this? [2 points]

To terminate the string “Hi”. When processing the string, the microcontroller needs to know where it ends.

49)What would the contents of accumulator D and index register X be following the execution of the following assembly code? Indicate the number base of each number! [2 points]

MAIN:LDX#10

LDD#789

IDIV

567/10: Quotient = 78, Remainder = 9

D = Remainder = 9 ($09)

X = Quotient = 78 ($4E)

50)Show the 8-bit binary representation of -16 (decimal) using the following historical signed number encodings: [3 points]

Sign-Magnitude:10010000

Ones Complement:11101111

Twos Complement:11110000

1/8