EE 2361 - Introduction to Microcontrollers
Summer Term, 2005
Homework Assignment 2
Due: Tuesday, July 5
- Suppose that the contents of accumulator A are $CD.
Give the contents
of accumulator A and the values of the N, Z, V and C
bits of the condition code register after the following
instruction is executed:
adda #$35
- Suppose that the contents of accumulator A are $CD
and the contents of accumulator B are $8A. Give the contents
of accumulators A and B and the values of the N, Z, V and C
bits of the condition code register after the following
instruction is executed:
aba
-
Suppose that the contents of memory starting at address $0030
are the following sequence of bytes: $53, $FA, $E3, $95.
Explain what each step of the following program does
and also give a simple one-sentence explanation
of the overall purpose
of the program. (You do not have to give the condition
code register values after each instruction unless it has a bearing on the
outcome of the program.)
ldaa $31
adda $33
staa $35
ldaa $30
adca $32
staa $34
-
Re-write the previous program using a sequence of only
3 instructions involving accumulator D such that it has the same overall
purpose as the program in the previous problem.
- Suppose that the contents of accumulator A are $00 and
the contents of memory location DATA are $B0. The instruction
cmpa DATA is executed, followed by one of the
following types of conditional
branch instruction. For each type of conditional branch
instruction given below, indicate by "yes" or "no" if the
branch will be taken:
- bge
- ble
- bgt
- blt
- beq
- bne
- bhs
- bls
- bhi
- blo
- Consider the following sequence of instructions:
ldaa #$A0
ldab #$14
mul
- Assuming this represents
an integer multiplication, give the decimal values
of each of the operands and calculate the
decimal value of the product.
- What are the contents of accumulators A and B and the
value of the C bit in the CCR after the mul
instruction has been executed?
- Assuming that this represents fractional multiplication,
give the decimal values of each of the operands and give the
decimal value of the product.
- Show that your answers to parts (b) and (c) are consistent
with each other by interpreting the contents of accumulators
A and B as a fractional value.
- Give the decimal value of the 8-bit fractional approximation
of the 16-bit fractional product if only the contents of accumulator
A are kept. (This represents truncation of the 16-bit fractional
result to 8 bits.)
- Now suppose that the additional instruction adca #$00
is executed. Give the contents of accumulator A (in both
hex and decimal formats) after this
instruction has been executed. (This represents rounding of the 16-bit
fractional result to 8 bits.)
- Calculate (in decimal) the absolute value of the difference
between the truncated and 16-bit results, and the absolute
value of the difference between the rounded and the 16-bit results.
Which value (truncated or rounded) is the better
approximation to the 16-bit result in this case?
- For the following signed division problems,
(dividend/divisor) =
quotient + (remainder/divisor). In all cases, the sign of the remainder
is the same as the sign of the dividend. Also, the following
equality is always satisfied: (divisor)*(quotient) + remainder = dividend.
- For each of the following four division problems (specified in
decimal), give the decimal values of the quotient and the remainder:
26/7, (-26)/7, 26/(-7), (-26)/(-7).
- If the four divisions of part (a) are done
using the idivs
instruction, give the hex values in registers D and X just prior to
and immediately
after the execution of this instruction in each case.
- In unsigned fractional division using the fdiv
instruction, the
dividend is less than the divisor and the quotient is a fractional
value with its radix point to the left of bit 15. For each of the
following five division problems (specified in decimal), give the
hex contents of registers D and X just prior to and immediately after
the execution of this instruction in each case:
1/2, 1/4, 3/4, 1/3, 2/3.