;*****************************************************************
;* 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 32-bit variables arg1, arg2, and 64-bit result
arg1        DS.W  2
arg2        DS.W  2
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 $01234567 into arg1 
            LDD #$0123
            STD arg1
            LDD #$4567
            STD arg1+2
            ;load $11223344 into arg2
            LDD #$1122
            STD arg2
            LDD #$3344
            STD arg2+2

            ;call 64 bit multiply 
            BSR mul64 
            
            ;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 mul subrouting
mul64:
			;TODO implement mul64
			; 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
