;*****************************************************************
;* This stationery serves as the framework for a                 *
;* user application (single file, absolute assembly application  *
;* for 18-348)                                                   *
;*****************************************************************

; export symbols
            XDEF Entry            ; export 'Entry' symbol
            ABSENTRY Entry        ; for absolute assembly: mark this as application entry point


; include derivative specific macros
            INCLUDE 'mc9s12c128.inc'

; variable/data section
            INCLUDE 'RAMLocation.inc'
            
;****************************************************
; ADD GLOBAL VARIABLES HERE
;****************************************************
;declare 64-bit variables arg1, arg2, and result
arg1        DS.W  4
arg2        DS.W  4
result      DS.W  4


ROMStart    EQU  $4000  ; absolute address to place my code/constant data

; code section
            ORG   ROMStart
Entry:
            INCLUDE 'StackInfo.inc'

            CLI                   ; enable interrupts

;*****************************************************
; ADD CODE HERE
;*****************************************************


            ;set up I/O control registers, T as output, AD as input


            ;load $0123456789ABCDEF into arg1
            LDD #$0123
            STD arg1
            LDD #$4567
            STD arg1+2
            LDD #$89AB
            STD arg1+4
            LDD #$CDEF
            STD arg1+6
            ;load $1122334455667788 into arg2
            LDD #$1122
            STD arg2
            LDD #$3344
            STD arg2+2
            LDD #$5566
            STD arg2+4
            LDD #$7788
            STD arg2+6

            ;call 64 bit add
            BSR add64
            BSR sub64
            
            ;TODO output code
            
            ;implement code to monitor the buttons and display the appropriate part
            ;of the value in "result"
            ;PB1 corresponds to MSB
            ;...
            ;PB8 corresponds to LSB
            ;when no button is pressed, the LEDs shall be off.                     
            
            
loopForever:
            BRA loopForever


;each team member should implement the add or subtract subroutine.            

;64 bit add subroutine
add64:
            ;TODO implement add64
            ; be sure to follow the requirements described in the lab.

            RTS
            


;64 bit subtract subroutine
sub64:
            ;TODO implement add64
            ; be sure to follow the requirements described in the lab.

            RTS




            


;*****************************************************
; DO NOT MODIFY OR ADD ANYTHING AFTER THIS POINT
;*****************************************************

;**************************************************************
;*                 Interrupt Vectors                          *
;**************************************************************
            ORG   $FFFE
            DC.W  Entry           ; Reset Vector
