EE 308

Homework Assignment 4
Due Feb. 11, 1999

  1. Find the values of the N, C, Z, and V bits of the CCR register after execution of each of the following instructions, given that [A] = 0x50 and the condition flags are N=0, C=1, Z=1, and V=0. (Assume these are the values before each instruction starts -- e.g., do not use the flag state resulting from the intstruction in part (a) as the initial state for part (b).)
    1. TSTA
    2. ADDA #$67
    3. LSLA
    4. CMPA #$60
    5. SUBA #$70
    6. RORA
  2. Write a program to compute the sum of the positive numbers of an array with 0x30 signed eight-bit numbers. Store the sum at 0x0900-0x0901. The array starts at 0xe000.
  3. Write a program that puts the smallest one-byte signed number from memory locations 0xFCE0 through 0xFCFF in accumulator A and memory location 0x0900. (Note: The smallest possible one-byte signed number is 0x80 = -12810.)
  4. Write a subroutine that can generate a delay of 1 millisecond to 65,535 milliseconds and a program to call the subroutine. The program should write a 0x55 to memory location 0x0000, call the subroutine to delay for 10 milliseconds, then write a 0xAA to memory location 0x0000. then delay for 20 milliseconds. It should continue writing alternating 0x55 and 0xAA to memory location 0x0000, and increasing the delay by 10 milliseconds each time. After the delay of 65,530 ms, it should start the program over again. The delay in milliseconds should be passed to the subroutine in the X index register.
  5. The following is the output from a program assembled using the CA6812 assembler. In a few cases the assembler output has been replaced by blanks. Fill in the blanks to show what the assembler output really was.
       1                     ; Example program for Homework 4
       2                     
       3       00000800      prog:    equ     $0800
       4       ________      data:    equ     $0900
       5                     
       6                     
       7       00000004      LEN:    equ     $04
       8                     
       9                     
      10                     CODE:   section .text   
      11  0800                       org     prog
      12  0800 de01          start:  ldx     val2
      13  ____ cc3344                ldd     #$3344
      14  0805 52                    ____    
      15  0806 6b__                  stab    LEN,x
      16  0808 9603                  ldaa    val2+2
      17  080a 5a04                  staa    _____
      18  080c ______                inc     count
      19  080f 3f            last:   swi
      20                     
      21                     
      22                     DATA:   section .data    
      23  0000 0a            val1:   dc.b    10
      24  0001 c200          val2:   dc.w    $c200
      25  ____ f0                    dc.b    ____
      26  0004 00000000      table:  ds.b    LEN
      27  0008 __            count:  dc.b    -10
    
    
    
    Map of junk.h12 from link file hw04.lkf - Fri Feb 05 16:29:50 1999
    
    LEN     00000004  
    count   00000008  
    data    00000900  
    ____    0000080f  
    prog    00000800  
    start   ________  
    table   00000004  
    val1    00000000  
    val2    00000001  
    
    


Bill Rison, <rison@ee.nmt.edu >