0% found this document useful (0 votes)
5 views5 pages

Merged

The document describes a programming task for an 8085 microprocessor to control traffic signals and pedestrian signs with specified on/off times. It includes a problem statement, program analysis, and a detailed program with memory addresses, mnemonics, and comments for each instruction. Additionally, it discusses subroutine documentation and parameter passing, emphasizing the importance of clarity in subroutine functions and the management of registers used within them.

Uploaded by

Chayanika Das
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
5 views5 pages

Merged

The document describes a programming task for an 8085 microprocessor to control traffic signals and pedestrian signs with specified on/off times. It includes a problem statement, program analysis, and a detailed program with memory addresses, mnemonics, and comments for each instruction. Additionally, it discusses subroutine documentation and parameter passing, emphasizing the importance of clarity in subroutine functions and the management of registers used within them.

Uploaded by

Chayanika Das
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 5
310 Time Sequence in Seconds 0 as) 15 5) 4 20 (20) | 40 PROGRAMMING THE 8085 stack pointer register is upgraded to the next location, 23FFH. During M,, the next byte— 20H—is copied from the stack and stored in register W, and the stack pointer register is again upgraded to the next location, 2400H. ‘The program sequence is transferred to location 2043H by placing the contents of the W/Z. registers on the address bus at the beginning of the next instruction cycle. 9.2.1 Illustrative Program: Traffic Signal Controller PROBLEM STATEMENT Write a program to provide the given on/off time (o three traflic lights (Green, Yellow, and Red) and two pedestrian signs (WALK and DON'T WALK). The signal lights and signs are turned on/off by the data bits of an output port as shown below: Lights Data Bits On Time 1. Green Do 15 seconds 2. Yellow D; 5 seconds 3. Red Dy 20 seconds 4. WALK Ds 15 seconds. 5. DON'T WALK D; 25 seconds ‘The traffic and pedestrian flow are in the same direct road when the Green light is on, ; the pedestrian should cross the PROBLEM ANALYSIS ‘The problem is primarily concerned with providing vai time delays for a complete se- quence of 40 seconds. The on/off times for the traffic signals and pedestrian signs are as follows: DON’T Hex WALK WALK Red Yellow Green Code D, De Ds Dy Ds Dp D Do 0 = 41H 0 = 84H 0 = 90H ‘The Green light and the WALK sign can be turned on by the output port. The 15-second delay can be provided by usi nding data byte 41H to -second subroutine and STACK AND SUBROUTINES 311 a counter with a count of 15;o. Similarly, the next wo bytes, 84H and 90H, will turn on/off the appropriate lights/signs as shown in the flowchart (Figure 9.13). The necessary time delays are provided by changing the values of the count in the counter. allel for 15 Seconds + Tum off Green and Walk Sign + Turn on Yellow and Don’t Walk Sign ‘Tum off Yellow ‘Tum on Red FIGURE 9.13 Flowchar' for ‘Traffic Signal Controller PROGRAM Memory Address Code Mnemonics Comments XX00 31 o1 99 LXI SP,XX99 ialize stack pointer at location XX99H 02 XX High-order address (page) of user memory 03 3E START: MYLA IH sLoad accumulator with the bit pattern for 4 41 Green light and WALK sign 05 D3 OUT PORTH urn on Green light and WALK sign 312 06 07 08 09 0A OB oc oD OE oF 10 " 12 13 4 15 16 7 18 19 1A 1B Ic ID 1E IF 0 XX50 51 52 53 4 55 56 37 58 59 SA PORTH 06 oF cb 50 XX 3E 84 D3 PORTH 06 05 cD 50 XX 3E 90 D3 PORTH 06 4 cb 50 XX, 3 03 XX LAY: This is a I-second delay subrout according to the param iput: Number of seconds i mput: None MVI B.OFH CALL DELAY MVLA84H OUT PORT# MVI B05 CALL DELAY MVIA,90H OUT PORTH MVIB,I4H CALL DELAY JMP START sRegisters Modified: Register B bs FS " LO HI 1B 7A B3 Q 55 XX DELAY: SECOND: LXI D,COUNT Loop: PUSH D PUSH PSW DCX D. MOV A,D ORAE JINZ LOOP PROGRAMMING THE 8085 sUse B as a counter to count 15seconds. B is decremented in the subroutine :Call delay subroutine located at XX50H igh-order address (page) of user memory ‘Load accumulator with the bit pattern for Yellow light and DON’T WALK ‘Turn on Yellow light and DON’T WALK and turn off Green light and WALK Set up 5-second delay counter :High-order address of user memory :Load accumulator with the bit pattern for Red light and DON’T WALK {Turn on Red light, keep DON'T WALK on, and turn off Yellow light ;Set up the counter for 20-second delay :Go back to location START to repeat the sequence that provides delay ied in reg din register B ier B Wve contents of DE and accumulator Load register pair DE with a count for 3 F-second delay sDecrement register pair DE SOR (D) and (E) to set Zero flag Jump to Loop if delay count is not equal to 0 STACK AND SUBROUTINES 5B 0S DCR B sc} INZ SECOND sD 32 SE XX igh-order memory address of user memory SF FL POP PSW clrieve contents of saved registers 60 DI POP D ol 9 RET :Return fo main program PROGRAM DESCRIPTION ‘The stack pointer register is a addresses can be stored on the stack whenever a CALL is used. As shown ‘gram loads the appropriate bit pattern in the accumulator, sends it to the output port, and calls the delay routine. Register B is loaded in the main program and used in the subrou- tine to provide appropriate ‘The DELAY subroutine is similar to the delays discussed in Chapter 8 except it quires the instruction RET at the end of the routine, trates the type of subroutine that is called many times from vari- \s illustrated in Figure 9.14, In this program, the subroutine is called from the locations XX09, OA, and OBH. ‘The return address, XXOC, is stored on the stack, and the stack pointer is decremented by two to location XX97H. At the end of the subroutine, the contents of the top two loca- FIGURE 9.14 ‘Multiple-Calling for a Subroutine Subroutine XX50 |_PUSH D 314 PROGRAMMING THE 8085 stack (XXOC) are retrieved, the stack pointer register is incremented by two to the location (XX99H), and the main program is resumed. This sequene: peated (wo more times in the main program, as shown in Figure 9.14. This is called a multiple-calling subroutine. 9.2.2 Subroutine Documentation and Parameter Passing Ina large program, nes are scattered all over the memory map and are called from many locations. Various information is passed between a calling program and a subrou- Line, a procedure called parameter passing. Therefore, itis important to document a sub- routine clearly and carefully, The documentation should include at least the following: 1. Functions of the subroutine 2. Input/Output parameters 3. Registers used or modified 4, List of other subroutines called by this subroutine ‘The delay subroutine in the tra routine documentation, nal controller program shows one example of sub- FUNCTIONS OF THE SUBROUTINE IL is important to state clearly and precisely what the subroutine does. A user should un- derstand the function without going through the instructions. INPUT/OUTPUT PARAMETERS In the delay subroutine illustrated in Section 9.2.1, the information concerning the num- ber of seconds is passed from the main program to the subroutine by loading an appro- priate count in register B. In this example, a register is used to pass the parameter. The parameters passed to a subroutine are inputs, and parameters returned to calling programs are listed as outputs. When many pa the parameters, and HL registers stack is also used to store and pass parameters. s are used to store ions. Similarly, the REGISTERS USED OR MODIFIED n a subroutine also may be used by the calling program. Therefore, it of the calling program on the stack at the be- fe the contents before returning from the sub- Registers used is necessary to save the register contents ginning of the subroutine and to retri routine, in the delay subroutine, the contents of registers DE, the accumulator, and the flag register are pushed on the stack because these registers are used in the subrou- tine, The contents are restored at the end of the routine using the LIFO method. However, the contents of registers that pass pai eters should not be saved on the stack because this could cause irrelevant jon to be retrieved and passed on to the calling program.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy