Presentation is loading. Please wait.

Presentation is loading. Please wait.

Return Stack Lecture L7.3. A 32 x 16 Stack Same as used in the Data Stack in Lab 7.

Similar presentations


Presentation on theme: "Return Stack Lecture L7.3. A 32 x 16 Stack Same as used in the Data Stack in Lab 7."— Presentation transcript:

1 Return Stack Lecture L7.3

2 A 32 x 16 Stack Same as used in the Data Stack in Lab 7

3 A 32 x 16 Stack Module

4 The Return Stack

5 The WC16 WHYP Core

6 CodeNameFunction 0030>R “To-R” Pop T and push it on return stack. 0031R> “R-from” Pop return stack R and push it into T. 0032R@ “R-fetch” Copy R to T and push data stack 0033R>DROP “R-from-drop” Pop return stack R and throw it away 0039LD! “LD store” Store 8-bits of T into the 8-bit LD register Return Stack and I/O Instructions

7 when tor => tload <= '1'; nload <= '1'; tsel <= "111"; nsel <= "01"; dpop <= '1'; rload <= '1'; rpush <= '1'; rinsel <= '1'; “To-R” Pop T and push it on return stack. >R

8 “R-from” Pop return stack R and push it into T. R> when rfrom => tload <= '1'; nload <= '1'; tsel <= "011"; dpush <= '1'; rsel <= '1'; rload <= '1'; rpop <= '1';

9 “R-fetch” Copy R to T and push data stack R@ when rfetch => tload <= '1'; nload <= '1'; tsel <= "011"; dpush <= '1';

10 “R-from-drop” Pop return stack R and throw it away R>DROP when rfromdrop => rsel <= '1'; rload <= '1'; rpop <= '1';

11 CodeNameFunction 0030>R “To-R” Pop T and push it on return stack. 0031R> “R-from” Pop return stack R and push it into T. 0032R@ “R-fetch” Copy R to T and push register stack 0033R>DROP “R-from-drop” Pop return stack R and throw it away 0039LD! “LD store” Store 8-bits of T into the 8-bit LD register Return Stack and I/O Instructions

12 when ldstore => ldload <= '1'; tload <= '1'; nload <= '1'; tsel <= "111"; nsel <= "01"; dpop <= '1'; “LD store” Store 8-bits of T into the 8-bit LD register and pop data stack LD! ldreg LD(7:0) clr clk ldload

13 CodeNameFunction 0103DRJNE Decrement R and jump if R is not zero 0104CALL Call subroutine 0105RET Subroutine return Transfer Instructions

14 >R Decrement top of return stack and branch back to if not equal to zero. Therefore, are executed n times. FOR…NEXT Loop n FOR NEXT drjne

15 Decrement R and jump if R is not zero DRJNE when drjne => rdec <= not r1; pload <= not r1; psel <= '0'; pinc <= r1; rsel <= r1; rload <= r1; rpop <= r1; -- r1 <= '1' if R-1 is all zeros r1 := '0'; for i in width-1 downto 1 loop r1 := r1 or R(i); end loop; r1 := (not r1) and R(0);

16 The Return Stack

17 Call subroutine Jump to address M and push address of next instruction (P + 1) on return stack CALL when call => pload <= '1'; rload <= '1'; rpush <= '1'; call, X”1234”, --12 --14 In ROM:

18 Subroutine return Jump to address on top of the return stack, and pop the return stack RET when ret => psel <= '1'; pload <= '1'; rsel <= '1'; rload <= '1'; rpop <= '1';


Download ppt "Return Stack Lecture L7.3. A 32 x 16 Stack Same as used in the Data Stack in Lab 7."

Similar presentations


Ads by Google