Reference no: EM131483508
Copy and paste this code into the simulator's source code editor and save as "Lift".
; ----- EXAMPLE - CONTROLLING THE LIFT --------------------------
Start:
CLO
MOV AL, 00
OUT 06 ; Display lift window
Loop:
IN 06 ; Read lift status
AND AL, 20 ; Isolate UP button bit
JZ Loop ; Loop if UP button not pressed
IN 06 ; Read lift status
AND AL, DF ; Clear UP button bit
OR AL, 01 ; Set UP motor bit
OUT 06 ; Reset UP button and turn on UP motor
JMP Loop
END
; --------------------------------------------------------------
Run the program. Wait for the lift window to appear then click the UP button in the lift window. The lift UP motor is then turned on and the lift will rise until it crashes into the top of the shaft, even if you stop your program. Click the "Repair Crashed Lift" button to restore the lift window.
Note the use of AND to clear a single bit without affecting other bits and OR to set a bit without affecting other bits.
Read the full capabilities of the lift in the Tutorial section on Peripheral Devices.
Each step below adds functionality to the lift. Complete as many steps as you can, saving your program in a different file at each step (take care not to overwrite previous steps). Don't miss out steps and try write the final program in one go or you will have nothing to submit if you fail.
You will need to write compact code to avoid running out of memory. You must not store code in locations reserved for the memory mapped display, [C0] to [FF]. If you use procedures or interrupt routines, you must not store code in locations used by the call stack, [BF] downwards, or your code will be overwritten at run time.
You may use any of the techniques you learned in the tutorials.
Discuss ideas and techniques with colleagues but do not copy code from each other or from the Internet. We will check for plagiarism.
Submit the last WORKING version of your program to NESS.
Marks will be awarded for each step successfully completed and for correct functionality. Programs which do not assemble will receive a zero mark. Programs which do not function will receive a zero mark.
Coursework
Modify your program to:
1. Detect when the lift nears the top of the shaft then turn off the motor before it crashes.
(If you have to make your simulation run Faster to avoid crashing before the limit can be detected, you should consider restructuring your code)
2. Detect a click of the DOWN button then turn on the DOWN motor.
(You may allow the lift to crash into the bottom of the shaft)
3. Detect when the lift nears the bottom of the shaft then turn off the motor before it crashes.
(It should now be impossible to crash the lift no matter when or how many times the UP or DOWN buttons are clicked)
4. Display the lift status on the memory mapped display starting at [C0] without crashing the lift.
(Lift status must be exactly: BOTTOM or UP or TOP or DOWN)
5. Cause the lift to return to the bottom of the shaft immediately if the Enter key (En) is pressed on the numeric keypad peripheral device.
(After returning to the bottom of the shaft, the lift must operate normally)