Data Stack Instructions Lab 7. Data Stack WHYP Data Stack Instructions DUP( n -- n n ) SWAP( a b -- b a ) DROP( a -- ) OVER( a b -- a b a ) ROT( a.

Slides:



Advertisements
Similar presentations
Rapid Prototyping using a Microprocessor Core on a Spartan II FPGA
Advertisements

7-Segment Displays Lecture L6.1 Section 6.3. Turning on an LED.
WHYP Test Files Lab 9. y1 The WC16 WHYP Core Modifications for Multiplication and Division.
There are two types of addressing schemes:
CPS3340 COMPUTER ARCHITECTURE Fall Semester, /17/2013 Lecture 12: Procedures Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.
A Simple Microcontroller VHDL Tutorial R. E. Haskell and D. M. Hanna T6: VHDL State Machines.
Forth Lecture L7.1. A Brief History of Programming Languages
Data Stack Lecture 8.2 A VHDL Forth Core for FPGAs: Sect. 3.
Return Stack Lecture 8.4 A VHDL Forth Core for FPGAs: Sect. 5.
Assembly Language for Intel-Based Computers Chapter 5: Procedures Kip R. Irvine.
Project Done By: Apurva Patel Vrajesh Patel Swapna Kalakonda.
Overview Program in LC-3 machine language Use the Editor
Helpful functions and hardware Projects. DigScroll.
Single-Cycle Instructions VHDL Tutorial R. E. Haskell and D. M. Hanna T5: VHDL ROM.
TK 2633 Microprocessor & Interfacing Lecture 3: Introduction to 8085 Assembly Language Programming (2) 1 Prepared By: Associate Prof. Dr Masri Ayob.
Multi-Base Calculator CSE378 Final Project By Matthew Lehn & Yanqing Zhu December 17, 2001 Professor Haskell.
Objective The object of the game is to convert as many hexadecimal numbers to binary coded decimal numbers correctly within thirty (30) seconds. How.
Lab 6 Program Counter and Program ROM Mano & Kime Sections 7-1 – 7-6.
Digilab DIO2 LCD Module F5.1. DIO2 circuit board block diagram.
The FC16 Forth Core Lab 7 Module F4.1. Lab 7 Hex OpcodeNameFunction 0000NOP No operation 0001DUP Duplicate T and push data stack. N
Return Stack Lecture L7.3. A 32 x 16 Stack Same as used in the Data Stack in Lab 7.
Chapter 4 H1 Assembly Language: Part 2. Direct instruction Contains the absolute address of the memory location it accesses. ld instruction:
Consider With x = 10 we may proceed as (10-1) = 9 (10-7) = 3 (9*3) = 27 (10-11) = -1 27/(-1) = -27 Writing intermediates on paper.
A Programming Language for the FC16 Forth Core
Computer Programming 1 Repetition. Computer Programming 2 Objectives Repetition structures Study while and do loops Examine for loops A practical example.
Programming Example Lecture 8.6 A VHDL Forth Core for FPGAs: Sect. 7.
Multiplication and Division Lab 9. Multiplication 13 x = 8Fh 1101 x
Registers Lab 5 Mano and Kime Sections 5-2, 5-3, 5-7.
LCD Display DIO2 Board CPLD. DIO2 Board CPLD Interface LCD Display.
Web siteWeb site ExamplesExamples Irvine, Kip R. Assembly Language for Intel-Based Computers, Stack Operations Runtime Stack PUSH Operation POP.
RS-232 Port Lecture L9.3. Loop feedback RS-232 voltage levels: +5.5 V (logic 0) -5.5 V (logic 1)
Design of Embedded Systems Using 68HC12(11) Microcontrollers - R. E. Haskell Subroutine and Stacks Chapter 2.
4-Bit Binary-to-BCD Converter: case Statement
Other WC16 Instructions Lecture L7.4. OpcodeNameFunctionNumber of Clock Cycles Fetch the byte at address T in RAM and load it into T1 Fetch.
Quick Check Questions 3.1 Business 43B
Operand Addressing and Instruction Representation
Maths with letters!. 12, 6, 2, 3.14, 22,317, -6, 123 Constants (Don’t Change) x, y, z, a, b, c Variables (Unknown Numbers)
Forth A stack language.
CS-280 Dr. Mark L. Hornick 1 ASCII table. 2 Displaying Numbers as Text Problem: display numerical values as text Consider the numerical value 0x5A held.
Assembly Programming on the TI-89 Created By: Adrian Anderson Trevor Swanson.
Stacks and Subroutines ELEC 330 Digital Systems Engineering Dr. Ron Hayne Images Courtesy of Ramesh Gaonkar and Delmar Learning.
CDP ECE Spring 2000 ECE 291 Spring 2000 Lecture 7: More on Addressing Modes, Structures, and Stack Constantine D. Polychronopoulos Professor, ECE.
Computer Architecture EKT 422 Chapter 10 Instruction Sets: Characteristics and Functions (cont.)
When we add or subtract integers we can use a number line to help us see what is happening with the numbers.
Today’s topics Parameter passing on the system stack Parameter passing on the system stack Register indirect and base-indexed addressing modes Register.
1 Control Abstraction (Section ) CSCI 431 Programming Languages Fall 2003 A compilation of material developed by Felix Hernandez-Campos and Michael.
EE3A1 Computer Hardware and Digital Design Lecture 5 Testbenches and Memories in VHDL.
Chapter 5 The LC-3. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 5-2 Data Movement Instructions Load --
5. Assembly Language. Basics of AL Program data Pseudo-ops Array Program structures Data, stack, code segments.
Memory/Storage Architecture Lab 컴퓨터의 개념과 실습 Assembly Example.
The x86 Instruction Set Lecture 16 Mon, Mar 14, 2005.
Lecture 9 (The Stack and Procedures). 1 Lecture Outline Introduction The Stack The PUSH Instruction The POP Instruction Terminology of Procedures INDEC.
CSC 221 Computer Organization and Assembly Language Lecture 15: STACK Related Instructions.
Classification of Instruction Set of 8051
The Forth Language CSC 507 – Roy Ford November 22, 2005.
CS 11 C track: lecture 8 Last week: hash tables, C preprocessor
Stack and Subroutines Module M17.1 Section 11.2.
Unit 1 Transformations in the Coordinate Plane
Fast, Asynchronous SRAM
Warm up A function is even. Point A(-3, 4) is on the even function. Name another point. A function is even. Point B(9, 2) is on the even function.
L13b – 32 bit multiply Department of Electrical and
Objective - To add and subtract decimals.
DIO2 Board Projects.
Rotating Pills CSE 115 Fall 2006 Dr. Mario – Lab 10.
CS334: Number Systems Lab 1.
CS334: MIPS language _Mars simulator Lab 2_1
Rotations.
Return Stack Lab 8.
Let’s start an intro unit to Geometry!!
(The Stack and Procedures)
Presentation transcript:

Data Stack Instructions Lab 7

Data Stack

WHYP Data Stack Instructions DUP( n -- n n ) SWAP( a b -- b a ) DROP( a -- ) OVER( a b -- a b a ) ROT( a b c -- b c a ) -ROT( a b c -- c a b ) NIP( a b -- b ) TUCK( a b -- b a b ) ROT_DROP( a b c -- b c ) ROT_DROP_SWAP ( a b c -- c b ) 2DUP( a b -- a b a b ) Note: 2DUP = OVER OVER

Hex OpcodeNameFunction 0000NOP No operation 0001DUP Duplicate T and push data stack. N <= T; N2 <= N; 0002SWAP Exchange T and N. T <= N; N <= T; 0003DROP Drop T and pop data stack. T <= N; N <= N2; 0004OVER Duplicate N into T and push data stack. T <= N; N <= T; N2 <= N; 0005ROT Rotate top 3 elements on stack clockwise. T <= N2; N <= T; N2 <= N; 0006-ROT Rotate top 3 elements on stack counter-clockwise. T <= N; N <= N2; N2 <= T; 0007NIP Drop N and pop rest of data stack. T is unchanged. N <= N2; 0008TUCK Duplicate T into N2 and push rest of data stack. N2 <= T; 0009ROT_DROP Drop N2 and pop rest of data stack. T and N are unchanged. Equivalent to ROT DROP 000AROT_DROP_SWAP Drop N2 and pop rest of data stack. T and N are exchanged. Equivalent to ROT DROP SWAP Data Stack Instructions

when dup => nload <= '1'; dpush <= '1'; Duplicate T and push data stack. N <= T; N2 <= N; DUP( n -- n n )

Exchange T and N. T <= N; N <= T; when swap => tload <= '1'; nload <= '1'; tsel <= "111"; SWAP ( a b -- b a )

Drop T and pop data stack. T <= N; N <= N2; when drop => tload <= '1'; nload <= '1'; tsel <= "111"; nsel <= "01"; dpop <= '1'; DROP( a -- )

Duplicate N into T and push data stack. T <= N; N <= T; N2 <= N; when over => tload <= '1'; nload <= '1'; tsel <= "111"; dpush <= '1'; OVER( a b -- a b a )

Rotate top 3 elements on stack clockwise. T <= N2; N <= T; N2 <= N; when rot => tload <= '1'; nload <= '1'; tsel <= "110"; dpush <= '1'; dpop <= '1'; ROT( a b c -- b c a )

Rotate top 3 elements on stack counter- clockwise. T <= N; N <= N2; N2 <= T; when mrot => tload <= '1'; nload <= '1'; tsel <= "111"; nsel <= "01"; ssel <= '1'; dpush <= '1'; dpop <= '1'; -ROT( a b c -- c a b )

Drop N and pop rest of data stack. T is unchanged. N <= N2; when nip => nload <= '1'; nsel <= "01"; dpop <= '1'; NIP( a b -- b )

Duplicate T into N2 and push rest of data stack. N2 <= T; when tuck => ssel <= '1'; dpush <= '1'; TUCK( a b -- b a b )

ROT_DROP( a b c -- b c ) Drop N2 and pop rest of data stack. T and N are unchanged. Equivalent to ROT DROP when rot_drop => dpop <= '1';

ROT_DROP_SWAP ( a b c -- c b ) Drop N2 and pop rest of data stack. T and N are exchanged. Equivalent to ROT DROP SWAP when rot_drop_swap => tload <= '1'; nload <= '1'; tsel <= "111"; dpop <= '1';

addsub.whp Write a program to enter two 16-bit hex numbers from the switches, add the two numbers, subtract the two numbers, and then AND the sum and difference. Display all numbers and results on the 7-segment displays.

: MAIN ( -- ) BEGIN waitB4 get un1HI00xx DUP DIG! 8 LSHIFTxx00 waitB4 get un1LOxx00 00yy ORxxyy DUP DIG!\ display un1 waitB4 get un2HIxxyy 00rr DUP DIG! 8 LSHIFTxxyy rr00 waitB4 get un2LOxxyy rr00 00ss ORxxyy rrss DUP DIG!\ display un2 OVER OVER\ 2DUPxxyy rrss xxyy rrss waitB4 +\ addxxyy rrss wwzz DUP DIG!\ display sum -ROT\ save sumwwzz xxyy rrss waitB4 - \ subtractwwzz mmnn DUP DIG!\ display difference waitB4 AND\ sum AND diffaabb DIG!\ display sum AND diff AGAIN ; addsub.whp

wc16.exe WHYP Compiler

type rom_array is array (NATURAL range <>) of STD_LOGIC_VECTOR (15 downto 0); constant rom: rom_array := ( JMP, --0 X"0002", --1 JB4HI, --2 X"0002", --3 JB4LO, --4 X"0004", --5 sfetch, --6 dup, --7 digstore, --8 LIT, --9 X"0008", --a lshift, --b JB4HI, --c X"000c", --d JB4LO, --e X"000e", --f sfetch, --10 orr, --11 dup, --12 digstore, --13 addsub.rom Copy and paste into your Prom.vhd program

JB4HI, --14 X"0014", --15 JB4LO, --16 X"0016", --17 sfetch, --18 dup, --19 digstore, --1a LIT, --1b X"0008", --1c lshift, --1d JB4HI, --1e X"001e", --1f JB4LO, --20 X"0020", --21 sfetch, --22 orr, --23 dup, --24 digstore, --25 over, --26 over, --27 JB4HI, --28 X"0028", --29 JB4LO, --2a X"002a", --2b addsub.rom (cont.)

plus, --2c dup, --2d digstore, --2e mrot, --2f JB4HI, --30 X"0030", --31 JB4LO, --32 X"0032", --33 minus, --34 dup, --35 digstore, --36 JB4HI, --37 X"0037", --38 JB4LO, --39 X"0039", --3a andd, --3b digstore, --3c JMP, --3d X"0002", --3e X"0000" --3f ); addsub.rom (cont.)