Write a program in Assembly language to control a sump pump. A sump well collect
ID: 3768698 • Letter: W
Question
Write a program in Assembly language to control a sump pump. A sump well collects water runoff. The sump pump pumps out the well whenever it fills up. When the level rises to a high limit, the pump turns on. It stays on until the level drops to a low limit. Then the pump shuts off. It does not turn on again until the well fills up to the high limit. Data is stored in the following three addresses:
The level has a range of $00 to $FF, representing empty to full. You can set the low and high limits to values within the range (e.g.,$10 and $F0, you can use "mm" command to set these values or use assembly program to initialize the values). Sending a value of $FF to LEDs turns on the pump. Sending a value of $00 turns it off. You can test your program operation by changing the DIP switch and see the LEDs turn on and off based on the switch value (water level).
Address Data $2100 High Limit $2101 Low Limit DIP_SW Level Reading (SW_PORT) Port B Pump Control (LED_PORT)Explanation / Answer
Source Code
BEGIN
LDAA $02000 ; Loads current water level
LDAB $2101 ; Loads low limit of water level
CBA ; Compares current level to low limit
BEQ OFF ; Jumps to instruction to turn pump off
LDAB $2100 ; Loads high limit of water level
CBA ; Compares current level to high limit
BEQ ON ; Jumps to instruction to turn pump on
BRA BEGIN ; Repeats the program
OFF
LDAA #$00 ; Loads ACCA with $00 (signal for off)
STAA $0040 ; Sends signal to pump control
BRA BEGIN ; Repeats program
ON
LDAA #$01 ; Loads ACCA with $01 (signal for on)
STAA $0040 ; Sends signal to pump control
BRA BEGIN ; Repeats program
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.