Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
20 views
11 pages
Stack and Delay
Uploaded by
Ahuja Ahuja
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
Download
Save
Save Stack and Delay For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
20 views
11 pages
Stack and Delay
Uploaded by
Ahuja Ahuja
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
Carousel Previous
Carousel Next
Download
Save
Save Stack and Delay For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 11
Search
Fullscreen
STACK Opeode it Pus Pus Pus Pus PUSH Operand srs tit gees gees 1 Lag Suck Pointer 1 La tho stack poimsr register with» 162i aiess The EX! insractions were dicased in Chapter 7 Store Regier Param Sack 1D This is. byt nsstion 1 Ieoopies the conten ofthe speed ester pron the stack as described below 10 The tack pln eps s decremented, and the con- tens of te high-order epter (eg. reisor B) se ‘apie in he cation sh by the stack pointer ester (© Te stack pointer eps agin decremented, a the content ofthe laure oie (erie C) ae copied in tht action 10 The operands, D, and H represent register pais BC, DDE, ond IL, respeatively 11 The opera PSW resents Progra Status Wont meaning the contents ofthe secular al he Has Retrieve Reps Pi rom Sick 10 Thiisa rhs insrction 1 teeopis the contents oF ths top eo memary cations ‘ofthe ck ino the specified regis pt 12 Fist the coments ofthe memory leatio inated by ‘he ack pine register se copied into he low-order gine (eg. register Land then the tick pointer re ister is incremented by 1 1D The comers ofthe next memory location are coped Into te high order epee. seis), and the stack pointer register i gai incremented by 1Cees Prey ns Contents onthe Stak and in the Rect Aor tho PUSH InstructionPROBLEM STATEMENT Write a program to perform the following functions: 1, Clear all the fags. 2. Load OOH in the accumulator, and demonstrate thatthe Zero fla data transfer instruction, 3. Logically OR the accumulator with itself to set the Zero flag, and display the flag at PORT! or store all the flags on the stack. not affected by theMachine ‘Code nstretions| XI SPXXOOIE MMVI L008 ust Por PSW ME ACOEL ust PSw por MOV AL. OUT PORTO MVIA.oOH ORAA PUSH FSW POP H MOV AL ANT AOH our port! her Comments Inialire the stack ‘Clear, Place (L) om stack “Clear Bags {Loa OOH ‘Save ays on sack ‘Retrieve flags in Display Mags ‘Load 00H again 'Set flags and vest CY, AC ‘Save flags on stack Retrieve flags in L ‘Mask all Mags except Z dof program Stig ia Mer Alera om oe irs we NVIADON oO gin * ” ona Sas an at C¥ md AC 5 Fusi'sw ‘Segsen * ir ae on Rag RegiserSUBROUTINE Opeode CALL RET Operand 16-bit memory address of a subroutine Call Subroutine Unconditionally (I This is a 3-byte instruction that transfers the program sequence (0 a subroutine address 7 Saves the contents of the program counter (the ad- dress of the next instruction) on the stack i Decrements the stack pointer register by two Jumps unconditionally to the memory location speci- fied by the second and third bytes. The second byte specifies a line number and the third byte specifies a page number This instruction is accompanied by a ret tion in the subroutine Return from Subroutine Unconditional This is a I-byte instruction C1 Inserts the two bytes from the top of the stack into the program counter and inerements the stack pointer register by two 1 Unconditionally returns from a subroutine instruMemory Address 2000 2040 2041 2042, 2043 205F 2070 207F 2080 2398 23FF 2400 LXI SP2400H Lu CALL. 2070H NEXT INSTRUCTION | HLT First Subroutine Instruction + RET L Other Subroutines Empty Space 4 sTnitialize the stack pointer at 2400H ;Call the subroutine located at 2070H. This is + a 3-byte instruction The address of the next instruction following the CALL instruction :End of the main program ‘Beginning of the subroutine End of the subroutine ‘The stack is initialized at 2400HMemory Address 2040 2001 2082 2083 Mnemonics CALL 2070H INSTRUCTION Call subroutine located at them Comments very location 2070H 2000 Subroutine 2042 ——————- 2070 2043 205F 201FPROBLEM Write a program to provide the given owoff time to thre trafic lights (Green, Yellow, and Red) and two pedestrian signs (WALK and DON'T WALK). The signal lights and signs are urned onoft by the data bits of an output port as shown below: Data Bits On Time 1, Green 15 seconds 2. Yellow 5 seconds 3. Red 20 seconds 4. WALK 15 seconds 5. DON'T WALK 25 seconds ‘The traffic and pedestrian flow are in the same direction; the pedestrian should cross the road when the Green Sequence DON'T Hex Im Seconds. WALK WALK Red Yellow Green Code o Dy BR oP bh Db Db Bm ay 4 15 10:00 - 4H ol 20 oo = MH mt 4 ed ' o 0 © 0 0 = 8HMemory Address Xx00 o1 a 03 04 05 06 07 08 09 0A, op. oc op 0 OF 10 u 12 3 Code 31 9 LXI SPXX99 XX 3E START: MVIAAIH a m court port# PORTH 06 MVIBOFH oF cD CALL. DELAY 50 XX 3B MVIAS4H a4 pa our PoRT# PORTH 06 MYI BOS 05 cD ‘CALL DELAY 50 Mnemonics Comments sInitialize stack pointer at location XX99H ‘High-order address (page) of user memory ‘Load accumulator with the bit pattern for + Green light and WALK sign “Turn on Geen lioht and WALK sion :Use B as a counter to count 1Sseconds. + Bis decremented in the subroutine :Call delay subroutine located at XXSOH ‘igh-order address (page) of user memory :Load accumulator with the bit pattern for i Yellow light and DON'T WALK Turn on Yellow light and DON'T WALK 5 and turn off Green light and WALK {Set up 5-second delay counter14 15 16 7 18 19 1A 1B Ic 1D IE IF 20 Xxx 3E 90 D3 PORTH 06 4 cD 50 XX G 03 XX MVIA,90H OUT PORT# MVIB,14H CALL DELAY JMP START ;sHigh-order address of user memory :Load accumulator with the bit pattern for 3 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 sequencesDELAY: This is @ [-second delay subroutine that provides delay according (othe parameter specified in register B XxX50 3 52 53 55 56 37 58 59 5A SB 5c sD SE sr 60 61 slnput: Number of seconds is :Ouaput: None Registers Modified: Register B bs DELAY: PUSH D FS PUSH PSW 1 SECOND: LXID,COUNT Lo HI 1B Loop: DCX D A MOV A.D BB. ORAE a INZ LOOP 55 XxX 05 DCRB Q JNZ SECOND 52 XX FI POP PSW DI POP D o RET specified in register B ‘Save contents of DE and accumulator Load register pair DE with a count for + I-second delay {Decrement register pair DE OR (D) and (E) to set Zero fla Jump to Loop if delay count is not equal to 0 End of I second delay; decrement the counter Is this the end of time needed? If not, go back to repeat I-second delay High-order memory address of user memory Retrieve contents of saved registers sReturn to main program,
You might also like
Stack and Subroutines
PDF
No ratings yet
Stack and Subroutines
25 pages
Laboratory Exercise 2 (MIDTERM)
PDF
50% (2)
Laboratory Exercise 2 (MIDTERM)
4 pages
1 Interfacing Stepper Motor To 8086 Using 8255
PDF
82% (11)
1 Interfacing Stepper Motor To 8086 Using 8255
40 pages
Computer Organization & Architecture: Exercises 1
PDF
100% (1)
Computer Organization & Architecture: Exercises 1
13 pages
Advanced CPU Instructions: Laboratory Exercise #5
PDF
0% (1)
Advanced CPU Instructions: Laboratory Exercise #5
4 pages
Tutorial 07 - Mid Paper Discussion (LO1 - LO3)
PDF
No ratings yet
Tutorial 07 - Mid Paper Discussion (LO1 - LO3)
6 pages
Lecture 12 Stack and Subroutines
PDF
No ratings yet
Lecture 12 Stack and Subroutines
24 pages
Jump, Loop and Call Instructions: The 8051 Microcontroller and Embedded Systems: Using Assembly and C
PDF
No ratings yet
Jump, Loop and Call Instructions: The 8051 Microcontroller and Embedded Systems: Using Assembly and C
25 pages
Stacks & Subroutines
PDF
No ratings yet
Stacks & Subroutines
35 pages
Practical 8 Call and Subroutine
PDF
50% (2)
Practical 8 Call and Subroutine
5 pages
SAP Report Group 2
PDF
0% (1)
SAP Report Group 2
14 pages
Microcontroller 8051
PDF
No ratings yet
Microcontroller 8051
72 pages
CHP 5 Pic Micro Controller Instruction Set
PDF
100% (1)
CHP 5 Pic Micro Controller Instruction Set
75 pages
Examples Stack N SR
PDF
No ratings yet
Examples Stack N SR
11 pages
Microcontroller (1) Lab Manual: Prepared By: Eng: Mohsen Ali AL-awami Supervisered By: DR: 2010-2011
PDF
No ratings yet
Microcontroller (1) Lab Manual: Prepared By: Eng: Mohsen Ali AL-awami Supervisered By: DR: 2010-2011
20 pages
Merged
PDF
No ratings yet
Merged
5 pages
Lecture5 INSTRUCTIONS MICROPROCESSOR APLICATIONS
PDF
No ratings yet
Lecture5 INSTRUCTIONS MICROPROCESSOR APLICATIONS
58 pages
#58 Blinking An Led Using The Atmega328 Assembly Language
PDF
No ratings yet
#58 Blinking An Led Using The Atmega328 Assembly Language
24 pages
Lab 5
PDF
No ratings yet
Lab 5
9 pages
Investigating CPU Instructions
PDF
No ratings yet
Investigating CPU Instructions
4 pages
CS401 Short Notes For Midterm (Study With BRD)
PDF
No ratings yet
CS401 Short Notes For Midterm (Study With BRD)
14 pages
EEE 204 - Lecture 7
PDF
No ratings yet
EEE 204 - Lecture 7
30 pages
Timing Diagram, Routine and Subrotine
PDF
No ratings yet
Timing Diagram, Routine and Subrotine
12 pages
Chapter 7 B
PDF
No ratings yet
Chapter 7 B
34 pages
Lab 4: Digital Input Output: EE222: Microprocessor Systems
PDF
No ratings yet
Lab 4: Digital Input Output: EE222: Microprocessor Systems
5 pages
Subroutines and Loop Delay
PDF
No ratings yet
Subroutines and Loop Delay
8 pages
Stack and Subroutine
PDF
No ratings yet
Stack and Subroutine
6 pages
Programming Model 2 Tutorial
PDF
No ratings yet
Programming Model 2 Tutorial
8 pages
03 Chapter 5
PDF
No ratings yet
03 Chapter 5
60 pages
EE234 - Lec - 04
PDF
No ratings yet
EE234 - Lec - 04
70 pages
MP Unit-4 Part 2 PDF
PDF
No ratings yet
MP Unit-4 Part 2 PDF
13 pages
Computer Science Department: Majlis Arts and Science College, Puramannur
PDF
No ratings yet
Computer Science Department: Majlis Arts and Science College, Puramannur
20 pages
Stack&Subroutine
PDF
No ratings yet
Stack&Subroutine
71 pages
Stack
PDF
No ratings yet
Stack
13 pages
Lecture 5
PDF
No ratings yet
Lecture 5
31 pages
Net3001 5 C
PDF
No ratings yet
Net3001 5 C
48 pages
LABORATORY EXERCISE #6: Investigating CPU Instructions Objectives
PDF
No ratings yet
LABORATORY EXERCISE #6: Investigating CPU Instructions Objectives
6 pages
Stacks & Subroutines
PDF
No ratings yet
Stacks & Subroutines
38 pages
Electric Network Analysis Lab
PDF
No ratings yet
Electric Network Analysis Lab
11 pages
EEE316 Microprocessors: Lecture #3
PDF
No ratings yet
EEE316 Microprocessors: Lecture #3
49 pages
Subroutines & Stack: Dr. Farid Farahmand Updated: 2/18/2019
PDF
No ratings yet
Subroutines & Stack: Dr. Farid Farahmand Updated: 2/18/2019
28 pages
MC Practicals 2
PDF
No ratings yet
MC Practicals 2
12 pages
Module 3
PDF
No ratings yet
Module 3
97 pages
Chapter 08 ARM Subroutines 2 Stack Perserve Environment Edited
PDF
No ratings yet
Chapter 08 ARM Subroutines 2 Stack Perserve Environment Edited
61 pages
Chapter 6
PDF
No ratings yet
Chapter 6
51 pages
8086 Alp Ppts-Final 02
PDF
No ratings yet
8086 Alp Ppts-Final 02
28 pages
MPI GTU Study Material E-Notes Unit-6 13052022115222AM
PDF
No ratings yet
MPI GTU Study Material E-Notes Unit-6 13052022115222AM
14 pages
M PLC Experiments
PDF
No ratings yet
M PLC Experiments
38 pages
DucHuy CA Lab2 2021
PDF
No ratings yet
DucHuy CA Lab2 2021
25 pages
Versions of Table Read and Table Write Instructions
PDF
No ratings yet
Versions of Table Read and Table Write Instructions
7 pages
Lec3 Part2
PDF
No ratings yet
Lec3 Part2
28 pages
MP Module 3
PDF
No ratings yet
MP Module 3
8 pages
MC - Module 3 Notes
PDF
No ratings yet
MC - Module 3 Notes
10 pages
Sharing Third - F48cc5ab 9576 4fbf b1d7 1dfcdc9bcbef
PDF
No ratings yet
Sharing Third - F48cc5ab 9576 4fbf b1d7 1dfcdc9bcbef
43 pages
PIC Architecture and Assembler Programming: (Including Software Time Delay Subroutine)
PDF
No ratings yet
PIC Architecture and Assembler Programming: (Including Software Time Delay Subroutine)
16 pages
Synopsis ON Digital Bus: BY Cetpa Infotech Private Limited
PDF
No ratings yet
Synopsis ON Digital Bus: BY Cetpa Infotech Private Limited
14 pages
Embedded Code Explanation
PDF
No ratings yet
Embedded Code Explanation
14 pages
Assignment
PDF
No ratings yet
Assignment
2 pages
Examples Delay N Counters
PDF
No ratings yet
Examples Delay N Counters
9 pages
2022 Pprs
PDF
No ratings yet
2022 Pprs
13 pages
PCM
PDF
No ratings yet
PCM
6 pages
Error Due To Noise
PDF
No ratings yet
Error Due To Noise
4 pages