Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- org 400h
- thermo0 EQU 0h ;Declaring all temperature sensors...
- thermo1 EQU 5h
- thermo2 EQU 10h
- thermo3 EQU 15h
- alert EQU 20h ;Alarm device
- min EQU 0h ;Sets the minimum temperature to 0°C
- max EQU 28h ;Sets the maximum temperature to 40°C
- code
- start0: JNR thermo0, start0 ;Busy waiting on all thermometers
- START thermo0 ;Starts thermometer when ready
- start1: JNR thermo1, start1
- START thermo1
- start2: JNR thermo2, start2
- START thermo2
- start3: JNR thermo3, start3
- START thermo3
- ;SETI ;Enables CPU interrupt
- SETIM thermo0 ;Enables device interrupt
- SETIM thermo1
- SETIM thermo2
- SETIM thermo3
- MOVB #4h, R0 ;Averages the temperature values every four operations and then resets the counter
- MOVL #0h, alert ;Initializes the alarm value to 0, to be changed to 1 in case average temperature goes out of range (0°~40°)
- CLRIM alert ;Disables alarm interrupt
- XORL R2, R2 ;Resets R2 to zero, then adds temperature measurements when ready
- measure: JMP measure ;Loops instruction until one of the devices interrupts
- halt
- driver 0h, 600h ;A given device driver location
- meas0: INL thermo0, R3 ;Transfers measured temperature to R3
- ADDL R3, R2 ;Adds measured temperature to total
- SUBB #1h, R0 ;Subtracts from counter
- JZ mean ;If the counter has reached 0 (four measurements have been made), the program jumps to the averaging subroutine...
- JMP measure ;...Otherwise, it keeps measuring
- driver 5h, 700h
- meas1: INL thermo1, R3
- ADDL R3, R2
- SUBB #1h, R0
- JZ mean
- JMP measure
- driver 10h, 800h
- meas2: INL thermo2, R3
- ADDL R3, R2
- SUBB #1h, R0
- JZ mean
- JMP measure
- driver 15h, 900h
- meas3: INL thermo3, R3
- ADDL R3, R2
- SUBB #1h, R0
- JZ mean
- JMP measure
- mean: ASRL #2, R2 ;Divides the sum by four
- CMPL max, R2 ;Checks if the average temperature exceeds the maximum
- JNN alarm ;Sends alarm signal if it does
- CMPL min, R2 ;Checks if the average temperature is below the minimum
- JN alarm ;Sends alarm signal if it is
- MOVL #0h, alert ;Sets alarm signal to 0 (temperature within range)
- CLRIM alert ;Disables alarm interrupt
- XORL R2, R2 ;Resets R2 again
- MOVB #4h, R0 ;Resets counter
- JMP measure ;Resumes measuring
- alarm: MOVL #1h, alert ;Sets alarm signal to 1 (temperature out of range)
- SETIM alert ;Enables alarm interrupt
- MOVL #4h, R0 ;Resets counter
- JMP measure
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement