Advertisement
heavenriver

TempAlert.asm

May 26th, 2012
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ORG 400h
  2. interrupter EQU 0h           ;Interrupts every 10 milliseconds to check temperature
  3. thermometer EQU 1h           ;Measures temperature
  4. dmac EQU 6h                  ;DMA controller: activates the interrupter whenever necessary
  5. video EQU 11h                ;Video peripheral; displays error message whenever necessary
  6. membuffer EQU 0000BBBBh      ;Initial alarm message location
  7. maxcount EQU 10              ;Sets milliseconds amount to check temperature (10 ms)
  8. maxtemp EQU 40               ;Sets maximum possible value for temperature (40°C)
  9. counter DL 0                 ;Milliseconds counter
  10. temperature DB 25            ;Initializes temperature to a mild/warm value (25°C)
  11. CODE
  12. START interrupter            ;Starts all peripherals
  13. START thermometer
  14. START dmac
  15. START video
  16. SETIM interrupter            ;Enables interrupter and thermometer to interrupt
  17. SETIM thermometer
  18. CLRIM dmac                   ;Disables DMAC interruptions (will be allowed whenever necessary)
  19. loop: JMP loop               ;Loops instruction while waiting for interrupts
  20. HALT
  21. driver 0h, 1500h             ;Initializes the driver of the 0h peripheral, located at 1500h in memory
  22. INL interrupter, R0          ;Saves milliseconds to R0
  23. MOVL R0, counter             ;Updates milliseconds counter
  24. CMPL maxcount, R0            ;Verifies if 10 ms have passed
  25. JZ check                     ;If so, the temperature is checked
  26. JNN check                    ;(Does the same if more than 10 ms have passed)
  27. JMP loop                     ;Else, keeps looping
  28. driver 1h, 1700h
  29. check: MOVL #0h, counter     ;Resets counter
  30. INB thermometer, R0          ;Saves temperature to R0
  31. MOVB R0, temperature         ;Updates temperature
  32. CMPB maxtemp, R0             ;Verifies if temperature is above 40°C
  33. JNN alert                    ;If so, starts the DMAC to send the alarm signal
  34. JMP loop                     ;Else, keeps looping
  35. driver 6h, 1900h
  36. alert: SETIM dmac            ;Enables DMAC interruptions
  37. CLRIM interrupter            ;Disables all other interruptions while executing
  38. MOVL #0h, counter            ;Resets counter
  39. JSR alarm                    ;Jumps to subroutine: transfers alarm message
  40. CLRIM dmac                   ;Disables DMAC interrupt until further notice
  41. SETIM interrupter            ;Re-enables interruptions
  42. JMP loop                     ;Keeps looping
  43. alarm: PUSH R0               ;Saves register values to stack
  44. PUSH R1
  45. PUSH R2
  46. MOVL membuffer, R0           ;Saves memory buffer initial location to R0
  47. MOVL #200h, R2               ;Initializes counter to maximum data transfers (512 in hex)
  48. write: OUTL R0, video        ;Displays error message
  49. ADDL #4h, R0                 ;Proceeds to next data location
  50. SUBL #1h, R2                 ;Updates counter
  51. JNZ write                    ;If data transferring isn't done yet, keeps looping
  52. POP R2                       ;Restores register values
  53. POP R1
  54. POP R0
  55. RTI                          ;Returns from subroutine
  56. END                          ;Terminates program
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement