225k views
5 votes
You have been asked to write a subroutine using assembly language for a microcontroller within a washing machine. The subroutine will check that the door is closed and the load limit has not been exceeded.

The door sensor generates a decimal value of 0 when the door is closed and 1 when it is open. The sensor makes this value available to the microcontroller by updating memory address 40.

Similarly, the load sensor will output a decimal value of 0 if the load is within limit and a value of 1 if the load limit is exceeded. The corresponding value will appear when reading memory address 41.

Memory addresses 42 and 43 are connected to hardware which presents values written to them as outputs from the microcontroller.

If the door is open, your program will write a decimal value of 1 into memory address 42. The subroutine then continues to monitor the door sensor.

If the load limit is exceeded, the program will write a decimal value of 2 into memory address 42. The subroutine then continues to monitor the sensors.

When both the door is closed and the load is within limit, the program will write a decimal value of 0 into memory address 43 and exit the subroutine.

Your subroutine program should start at memory address 20.

After each instruction, place a semicolon followed by a free text description of the code.

Note: the MOV instruction will set the zero flag appropriate to the value being moved.

1 Answer

4 votes

Final answer:

The task is to create an assembly language subroutine that checks the state of the door and load sensors in a washing machine and reacts accordingly.

Step-by-step explanation:

The question involves creating a subroutine in assembly language for a microcontroller used in a washing machine. This subroutine needs to check two conditions: whether the door is closed and whether the load limit has been exceeded. The status of the door and the load are provided by two sensors that update specific memory addresses with decimal values representing their states. The subroutine writes specific decimal values to output memory addresses based on the condition inputs. When both conditions are met (door closed and load within limit), the subroutine exits.

User Ammar Sani
by
8.1k points