Advertisement
heavenriver

Temperature.asm

May 11th, 2012
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. org 400h
  2. thermo0 EQU 0h                    ;Declaring all temperature sensors...
  3. thermo1 EQU 5h
  4. thermo2 EQU 10h
  5. thermo3 EQU 15h
  6. alert EQU 20h                     ;Alarm device
  7. min EQU 0h                        ;Sets the minimum temperature to 0°C
  8. max EQU 28h                       ;Sets the maximum temperature to 40°C
  9. code
  10. start0: JNR thermo0, start0       ;Busy waiting on all thermometers
  11. START thermo0                     ;Starts thermometer when ready
  12. start1: JNR thermo1, start1
  13. START thermo1
  14. start2: JNR thermo2, start2
  15. START thermo2
  16. start3: JNR thermo3, start3
  17. START thermo3
  18. ;SETI                              ;Enables CPU interrupt
  19. SETIM thermo0                     ;Enables device interrupt
  20. SETIM thermo1
  21. SETIM thermo2
  22. SETIM thermo3
  23. MOVB #4h, R0                      ;Averages the temperature values every four operations and then resets the counter
  24. MOVL #0h, alert                   ;Initializes the alarm value to 0, to be changed to 1 in case average temperature goes out of range (0°~40°)
  25. CLRIM alert                       ;Disables alarm interrupt
  26. XORL R2, R2                       ;Resets R2 to zero, then adds temperature measurements when ready
  27. measure: JMP measure              ;Loops instruction until one of the devices interrupts
  28. halt
  29. driver 0h, 600h                   ;A given device driver location
  30. meas0: INL thermo0, R3            ;Transfers measured temperature to R3
  31. ADDL R3, R2                       ;Adds measured temperature to total
  32. SUBB #1h, R0                      ;Subtracts from counter
  33. JZ mean                           ;If the counter has reached 0 (four measurements have been made), the program jumps to the averaging subroutine...
  34. JMP measure                       ;...Otherwise, it keeps measuring
  35. driver 5h, 700h
  36. meas1: INL thermo1, R3
  37. ADDL R3, R2
  38. SUBB #1h, R0
  39. JZ mean
  40. JMP measure
  41. driver 10h, 800h
  42. meas2: INL thermo2, R3
  43. ADDL R3, R2
  44. SUBB #1h, R0
  45. JZ mean
  46. JMP measure
  47. driver 15h, 900h
  48. meas3: INL thermo3, R3
  49. ADDL R3, R2
  50. SUBB #1h, R0
  51. JZ mean
  52. JMP measure
  53. mean: ASRL #2, R2                 ;Divides the sum by four
  54. CMPL max, R2                      ;Checks if the average temperature exceeds the maximum
  55. JNN alarm                         ;Sends alarm signal if it does
  56. CMPL min, R2                      ;Checks if the average temperature is below the minimum
  57. JN alarm                          ;Sends alarm signal if it is
  58. MOVL #0h, alert                   ;Sets alarm signal to 0 (temperature within range)
  59. CLRIM alert                       ;Disables alarm interrupt
  60. XORL R2, R2                       ;Resets R2 again
  61. MOVB #4h, R0                      ;Resets counter
  62. JMP measure                       ;Resumes measuring
  63. alarm: MOVL #1h, alert            ;Sets alarm signal to 1 (temperature out of range)
  64. SETIM alert                       ;Enables alarm interrupt
  65. MOVL #4h, R0                      ;Resets counter
  66. JMP measure
  67. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement