Share Pastebin
Guest
Public paste!

Untitled

By: a guest | Mar 19th, 2010 | Syntax: None | Size: 3.26 KB | Hits: 53 | Expires: Never
Copy text to clipboard
  1. ******************************************************
  2. * Roger He, Stanley Au
  3. * ECE 222 Lab 4
  4. ******************************************************
  5.  
  6.         cpu 5307
  7. PROGRAM     equ $10200000
  8. OPERAND     equ $10201000
  9. BUFFER      equ $10202000
  10. STACK       equ $10203000
  11. ERR_FLG     equ $10240001
  12.  
  13. CR          equ $0D
  14. LF          equ $0A
  15.  
  16. AST         equ $2A             ; Asterisk (Multiply)
  17. PLS             equ     $2B             ; Plus (Add)
  18. HYP             equ     $2D             ; Hyphen (Minus)
  19. SLS             equ     $2F             ; Slash (Divide)
  20. EQL             equ     $3D             ; Equal Sign
  21. BS          equ $08     ; Clear
  22.  
  23.             org PROGRAM
  24.             lea STACK, A7
  25.             jmp init
  26. ******************************************************
  27. * modules
  28. ******************************************************
  29.         include coldfire.asm
  30.                 include keypad.asm
  31.         include output.asm
  32.         include input.asm
  33.         include calc.asm
  34.         include timer.asm
  35. ******************************************************
  36. * End of subroutines
  37. ******************************************************
  38. init
  39.     move.l #$0003ED7E, D0
  40.     move.l D0, IMR ;assign the correct value to the IMR
  41.     move.w SR, D0
  42.     andi.l #$f8ff, D0
  43.     move.w D0, SR ;Unmask SR
  44.     bsr tmr_init
  45.     bsr tmr_pause
  46.     move.l #43201, D6
  47. start
  48.     lea MENU,A1         ; Point to start of MENU
  49.         bsr.w   out_string      ; Show menu display
  50.         bsr.w   out_crlf        ; Go to next line
  51.    
  52.         lea     BUFFER,A1
  53.         bsr.w   in_string
  54.         bsr.w   out_crlf
  55.        
  56.         bsr.w   parse_ascii     ; Parse selection, Selected option stored in D0
  57.        
  58.         cmp.l   #3,D0           ; Check D0 and run corresponding subroutine
  59.         bne     l_skipoption_3
  60.     move.l  A1,-(A7)
  61.     lea     CALC_INIT,A1
  62.     bsr.w   out_string
  63.     bsr.w   out_crlf
  64.     move.l  (A7)+,A1    ; Start Calculator Mode
  65.         bsr.w   calc_start
  66.         bra     start
  67. l_skipoption_3
  68.  
  69.     cmp.l       #2,D0
  70.         bne     l_skipoption_2
  71.     bsr tmr_in
  72.     bra start
  73. l_skipoption_2
  74.  
  75.         cmp.l   #1,D0
  76.         bne     l_skipoption_1
  77.     bsr tmr_mode
  78.     bra start
  79. l_skipoption_1
  80.  
  81.         tst.l   D0
  82.         bne     l_skipoption_0
  83.     move.l #$0000,d0
  84.     TRAP #15
  85. l_skipoption_0
  86.        
  87.         move.l  A1,-(A7)
  88.     lea     INVAL_FN,A1
  89.     bsr.w   out_string
  90.     bsr.w   out_crlf
  91.     move.l  (A7)+,A1
  92.  
  93.     bra     start           ; Loop back to start if not exit
  94.  
  95.         org     OPERAND         ; Set the origin of the data in memory
  96. MENU   
  97.         dc.b    "0. Return to Monitor",CR,LF
  98.         dc.b    "1. Clock Display",CR,LF
  99.         dc.b    "2. Enter Clock Mode",CR,LF
  100.         dc.b    "3. Enter Calculator Mode",CR,LF,CR,LF
  101.         dc.b    "Enter selection: ",0
  102.  
  103. TEST_STR
  104.     dc.b    ".",0
  105. TMR_PROMPT
  106.     dc.b    "Timer Display:",CR,LF,0
  107. TMR_MISSING_INIT
  108.     dc.b    "Timer not initiated. Please use enter clock mode to initiate timer.",CR,LF,0
  109. TMR_INITIALIZED
  110.     dc.b    "Timer has been initialzed",CR,LF,0
  111. NO_FN
  112.     dc.b    "This option is currently unavailable.",CR,LF,0
  113.         dc.b    "Please select option 0 or 3.",CR,LF,0
  114.        
  115. INVAL_FN
  116.         dc.b    "Invalid selection! Please try again.",CR,LF,0
  117.        
  118. CALC_INIT
  119.         dc.b    "#CALCULATOR MODE#",CR,LF,0
  120.         dc.b    "To exit, Press Enter (or '=') without input data.",CR,LF,0
  121. CALC_PROMPT
  122.         dc.b    "Ready to Calculate",CR,LF,0
  123. CALC_INVALID
  124.         dc.b    "Invalid character encountered!",CR,LF,0
  125. CALC_OVERFLOW
  126.         dc.b    "Out of range!",CR,LF,0
  127. CALC_DIVBYZERO
  128.         dc.b    "Divide by zero error!",CR,LF,0
  129. CALC_TRUNCATED
  130.         dc.b    "Instruction Truncated!",CR,LF,0
  131.    
  132.     end