Due Feb. 7, 1996
- The following subroutine produces a 10 ms delay on the 68HC11:
ldx #(20000/6) ;1 us = 2 cycles => 10 ms = 20,000 cycles
;loop takes 6 cycles, so run loop 20000/6 times
Write a subroutine called "delay" which will call this routine a number of
times equal to what's in the A accumulator. For example, to create a
1 second delay, do the following:
- Write a program which increments Port B forever. Between each increment,
use your "delay" routine to pause for 100 ms.
- Repeat Problem 2, but decrement Port B instead.
- Write a program which flashes between the binary patterns 0b01010101 and
0b10101010. Call your delay subroutine to delay for 100 ms between
- Write a program which implements a Thunderbird-style turn signal that
alternates between left and right:
- Write a program which reads Port C, and uses bits 5 and 7 to control the
function displayed on the LEDs. The following table shows what function to
implement for different patterns of Port C:
| PC 7 || PC 5 || Port B Function |
| 0 || 0 || Up Counter |
| 0 || 1 || Down Counter |
| 1 || 0 || Flasher |
| 1 || 1 || Turn Signal |
- Write a subroutine which takes the absolute value of the signed 16-bit
number in the D accumulator and puts the result in the D accumulator.