* ======================================================== *
*  Thomas C. Penick   ID# 452 80 6040         Program   2  *
*  EE319K Microprocessor Programming          due 2/13/98  *
*  Instructor: Laurence                       Section   B  *
*  MC6811 Program Source Code  PA2.asm        Roster#      *
*  Bitwise Logical Operation:  R = (not (L xor M)) and N   *
* ======================================================== *

      org  0          Globals go in Ram
L     rmb  1          Input Variable
M     rmb  1          Input Variable
N     rmb  1          Input Variable
R     rmb  1          Output Variable
      org  $E000      Object code goes in ROM
Main  lds  #$00FF     Stack grows down from $00FF
      clr  Ddrc       Make all pins of Port C input

* Read the Switch Values into the Variables
Start ldaa Portc      Read switch value from Port C
      staa L          Store value at label L
      ldaa Porte      Read switch values from Port E
      staa N          Store value at label N
s1    bclr #N $F0     Clear bits 7,6,5,4 in N (for readability only)

*                     Shift Reg A right 4 times so that positions
*                     7,6,5,4 move to 3,2,1,0 and 7,6,5,4 are 
*                     cleared.
      lsra            Logical shift right
      lsra            Logical shift right
      lsra            Logical shift right
      lsra            Logical shift right
      staa M          Store value at label M

* Perform the operation   R = (not (L xor M)) and N
s2    eora L          L xor M
s3    coma            not (L xor M), by taking 1's complement
s4    anda N          (not (L xor M)) and N, by taking the and

* Manipulate the result
      staa R          Store in R
      staa Portb      Send signal to LED's
s5    bra  Start      Start over
      org  $FFFE
      fdb  Main       Starting address after a RESET
      end


