- ******************************************************
- * Roger He, Stanley Au
- * ECE 222 Lab 4
- ******************************************************
- cpu 5307
- PROGRAM equ $10200000
- OPERAND equ $10201000
- BUFFER equ $10202000
- STACK equ $10203000
- ERR_FLG equ $10240001
- CR equ $0D
- LF equ $0A
- AST equ $2A ; Asterisk (Multiply)
- PLS equ $2B ; Plus (Add)
- HYP equ $2D ; Hyphen (Minus)
- SLS equ $2F ; Slash (Divide)
- EQL equ $3D ; Equal Sign
- BS equ $08 ; Clear
- org PROGRAM
- lea STACK, A7
- jmp init
- ******************************************************
- * modules
- ******************************************************
- include coldfire.asm
- include keypad.asm
- include output.asm
- include input.asm
- include calc.asm
- include timer.asm
- ******************************************************
- * End of subroutines
- ******************************************************
- init
- move.l #$0003ED7E, D0
- move.l D0, IMR ;assign the correct value to the IMR
- move.w SR, D0
- andi.l #$f8ff, D0
- move.w D0, SR ;Unmask SR
- bsr tmr_init
- bsr tmr_pause
- move.l #43201, D6
- start
- lea MENU,A1 ; Point to start of MENU
- bsr.w out_string ; Show menu display
- bsr.w out_crlf ; Go to next line
- lea BUFFER,A1
- bsr.w in_string
- bsr.w out_crlf
- bsr.w parse_ascii ; Parse selection, Selected option stored in D0
- cmp.l #3,D0 ; Check D0 and run corresponding subroutine
- bne l_skipoption_3
- move.l A1,-(A7)
- lea CALC_INIT,A1
- bsr.w out_string
- bsr.w out_crlf
- move.l (A7)+,A1 ; Start Calculator Mode
- bsr.w calc_start
- bra start
- l_skipoption_3
- cmp.l #2,D0
- bne l_skipoption_2
- bsr tmr_in
- bra start
- l_skipoption_2
- cmp.l #1,D0
- bne l_skipoption_1
- bsr tmr_mode
- bra start
- l_skipoption_1
- tst.l D0
- bne l_skipoption_0
- move.l #$0000,d0
- TRAP #15
- l_skipoption_0
- move.l A1,-(A7)
- lea INVAL_FN,A1
- bsr.w out_string
- bsr.w out_crlf
- move.l (A7)+,A1
- bra start ; Loop back to start if not exit
- org OPERAND ; Set the origin of the data in memory
- MENU
- dc.b "0. Return to Monitor",CR,LF
- dc.b "1. Clock Display",CR,LF
- dc.b "2. Enter Clock Mode",CR,LF
- dc.b "3. Enter Calculator Mode",CR,LF,CR,LF
- dc.b "Enter selection: ",0
- TEST_STR
- dc.b ".",0
- TMR_PROMPT
- dc.b "Timer Display:",CR,LF,0
- TMR_MISSING_INIT
- dc.b "Timer not initiated. Please use enter clock mode to initiate timer.",CR,LF,0
- TMR_INITIALIZED
- dc.b "Timer has been initialzed",CR,LF,0
- NO_FN
- dc.b "This option is currently unavailable.",CR,LF,0
- dc.b "Please select option 0 or 3.",CR,LF,0
- INVAL_FN
- dc.b "Invalid selection! Please try again.",CR,LF,0
- CALC_INIT
- dc.b "#CALCULATOR MODE#",CR,LF,0
- dc.b "To exit, Press Enter (or '=') without input data.",CR,LF,0
- CALC_PROMPT
- dc.b "Ready to Calculate",CR,LF,0
- CALC_INVALID
- dc.b "Invalid character encountered!",CR,LF,0
- CALC_OVERFLOW
- dc.b "Out of range!",CR,LF,0
- CALC_DIVBYZERO
- dc.b "Divide by zero error!",CR,LF,0
- CALC_TRUNCATED
- dc.b "Instruction Truncated!",CR,LF,0
- end
