; ---------------------------------------------------------------_x000D_
_x000D_
; A general purpose time delay procedure._x000D_
_x000D_
; The delay is controlled by the value in AL._x000D_
_x000D_
; When the procedure terminates, the CPU registers are_x000D_
; restored to the same values that were present before _x000D_
; the procedure was called. Push, Pop, Pushf and Popf_x000D_
; are used to achieve this. In this example one procedure _x000D_
_x000D_
; is re-used three times. This re-use is one of the main _x000D_
; advantages of using procedures._x000D_
_x000D_
;------ The Main Program ----------------------------------------_x000D_
Start:_x000D_
MOV AL,8 ; A short delay._x000D_
CALL 30 ; Call the procedure at address [30]_x000D_
_x000D_
MOV AL,10 ; A middle sized delay._x000D_
CALL 30 ; Call the procedure at address [30]_x000D_
_x000D_
MOV AL,20 ; A Longer delay._x000D_
CALL 30 ; Call the procedure at address [30]_x000D_
_x000D_
JMP Start ; Jump back to the start._x000D_
_x000D_
; ----- Time Delay Procedure Stored At Address [30] -------------_x000D_
ORG 30 ; Generate machine code from address [30]_x000D_
_x000D_
PUSH AL ; Save AL on the stack._x000D_
PUSHF ; Save the CPU flags on the stack._x000D_
Rep:_x000D_
DEC AL ; Subtract one from AL._x000D_
JNZ REP ; Jump back to Rep if AL was not Zero._x000D_
_x000D_
POPF ; Restore the CPU flags from the stack._x000D_
POP AL ; Restore AL from the stack._x000D_
_x000D_
RET ; Return from the procedure._x000D_
; ---------------------------------------------------------------_x000D_
END_x000D_
; ---------------------------------------------------------------_x000D_
_x000D_
TASK_x000D_
_x000D_
Re-do the traffic lights program and use this procedure _x000D_
to set up realistic time delays. 02tlight.asm (See below)
; ===== CONTROL THE TRAFFIC LIGHTS =============================_x000D_
_x000D_
CLO ; Close unwanted windows._x000D_
Start:_x000D_
; Turn off all the traffic lights._x000D_
MOV AL,0 ; Copy 00000000 into the AL register._x000D_
OUT 01 ; Send AL to Port One (The traffic lights)._x000D_
; Turn on all the traffic lights._x000D_
MOV AL,FC ; Copy 11111100 into the AL register._x000D_
OUT 01 ; Send AL to Port One (The traffic lights)._x000D_
JMP Start ; Jump back to the start._x000D_
END ; Program ends._x000D_
_x000D_
; ===== Program Ends ==========================================
Looking for a similar assignment? Our writers will offer you original work free from plagiarism. We follow the assignment instructions to the letter and always deliver on time. Be assured of a quality paper that will raise your grade.
Order now and Get a 15% Discount! Use Coupon Code "Newclient"