Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ORG 400h
- interrupter EQU 0h ;Interrupts every 10 milliseconds to check temperature
- thermometer EQU 1h ;Measures temperature
- dmac EQU 6h ;DMA controller: activates the interrupter whenever necessary
- video EQU 11h ;Video peripheral; displays error message whenever necessary
- membuffer EQU 0000BBBBh ;Initial alarm message location
- maxcount EQU 10 ;Sets milliseconds amount to check temperature (10 ms)
- maxtemp EQU 40 ;Sets maximum possible value for temperature (40°C)
- counter DL 0 ;Milliseconds counter
- temperature DB 25 ;Initializes temperature to a mild/warm value (25°C)
- CODE
- START interrupter ;Starts all peripherals
- START thermometer
- START dmac
- START video
- SETIM interrupter ;Enables interrupter and thermometer to interrupt
- SETIM thermometer
- CLRIM dmac ;Disables DMAC interruptions (will be allowed whenever necessary)
- loop: JMP loop ;Loops instruction while waiting for interrupts
- HALT
- driver 0h, 1500h ;Initializes the driver of the 0h peripheral, located at 1500h in memory
- INL interrupter, R0 ;Saves milliseconds to R0
- MOVL R0, counter ;Updates milliseconds counter
- CMPL maxcount, R0 ;Verifies if 10 ms have passed
- JZ check ;If so, the temperature is checked
- JNN check ;(Does the same if more than 10 ms have passed)
- JMP loop ;Else, keeps looping
- driver 1h, 1700h
- check: MOVL #0h, counter ;Resets counter
- INB thermometer, R0 ;Saves temperature to R0
- MOVB R0, temperature ;Updates temperature
- CMPB maxtemp, R0 ;Verifies if temperature is above 40°C
- JNN alert ;If so, starts the DMAC to send the alarm signal
- JMP loop ;Else, keeps looping
- driver 6h, 1900h
- alert: SETIM dmac ;Enables DMAC interruptions
- CLRIM interrupter ;Disables all other interruptions while executing
- MOVL #0h, counter ;Resets counter
- JSR alarm ;Jumps to subroutine: transfers alarm message
- CLRIM dmac ;Disables DMAC interrupt until further notice
- SETIM interrupter ;Re-enables interruptions
- JMP loop ;Keeps looping
- alarm: PUSH R0 ;Saves register values to stack
- PUSH R1
- PUSH R2
- MOVL membuffer, R0 ;Saves memory buffer initial location to R0
- MOVL #200h, R2 ;Initializes counter to maximum data transfers (512 in hex)
- write: OUTL R0, video ;Displays error message
- ADDL #4h, R0 ;Proceeds to next data location
- SUBL #1h, R2 ;Updates counter
- JNZ write ;If data transferring isn't done yet, keeps looping
- POP R2 ;Restores register values
- POP R1
- POP R0
- RTI ;Returns from subroutine
- END ;Terminates program
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement