Jobs Available

Moderators: None (Apply to moderate this forum)
Number of threads: 1874
Number of posts: 2760

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Need Someone to write a C++ program. Will compensate for trouble. Posted by TruZy on 9 Oct 2009 at 6:25 PM
PROGRAMMING PROJECT #2
DUE: October 13, 2009 12:00 midnight

A stack machine is a model for executing computer programs. There are compilers that translate a high-level computer language into a set of instructions to be executed using a stack machine model. A stack machine consists of operands, instructions, a stack, and an evaluation model.

Consider the following stack machine instructions and their purpose.
INSTRUCTION PURPOSE EXAMPLE
push push the value onto the stack push 8
pushc push the contents of the variable onto the stack push x
add pop two operands from the stack, add them, and push the result onto the stack push 6
push 10
add
mult pop two operands from the stack, multiply them, and push the result onto the stack push 61
push 38
mult
sub pop two operands from the stack, subtract them (top element is subtracted from the second from the top), and push the result onto the stack. push 5
push 8
sub
div pop two operands from the stack, divide them (top element is divided by the second from the top), and push the result onto the stack. push 5
push 10
div
assn pops two values from the stack and assigns the value of the top element to the variable that is second from the top push 4
push x
assn
dspy pops and prints the value at the top of the stack push 10
dspy

Imagine a hypothetical compiler that translates a computer program written in a language called fluffy (funny language used for fun yall) into an equivalent set of stack machine instructions. These instructions are then executed by the stack machine's evaluation model to carry out the meaning of the computer program. Here are example fluffy programs and their equivalent stack instructions.

fluffy stack machine instructions
output 8 + 6 push 8
push 6
add
dspy

fluffy stack machine instructions
x = 4
y = (7+x)*9
output y push 4
push x
assn
push 7
pushc x
add
push 9
mult
push y
assn
dspy


For this assignment you are to write a program that will act as an interpreter for stack machine instructions. The input to your program will be a file containing stack machine instructions. Your program will execute those instructions. Any output generated by the instructions should display to the screen.



The basic algorithm for a stack machine evaluation model is:

1. Create a stack
2. Create a symbol table for the variables x,y, and z. This is an array of size 3. Array position 0 is for x, position 1 is for y, and position 2 is for z.
2. while there are more instructions to evaluate do
get next instruction
if the instruction is 'push' then push the operand onto the stack
if the instruction is 'pushc' then get value of operand from the symbol table and push it onto the stack
if the instruction is 'add', 'mult', 'div', or 'sub', pop two operands from the stack and perform the operation. push the result back onto the stack
if the instruction is 'assn' pop two operands from the stack, put the value of the top element in the symbol table for the second top element
if the instruction is 'dspy' pop an operand from the stack stack and print it to the screen
end do


fluffy
To run your program, the user will be prompted for a file name containing a list of instructions.
Your program will open the file, and read and execute the instructions, sending any output to the screen. You can assume the file contains an error-free and correct set of instructions.
Use either a Linked Stack or an array-based Stack to implement this program.
Report
Re: Need Someone to write a C++ program. Will compensate for trouble. Posted by RanSin on 21 Oct 2009 at 10:08 PM
Experienced web and programming team seeking project


Dedicated and expert Cornell University web and programming team with India offices seek 2 projects. You get competitive Indian pricing with top of the line New York CEO project Management - a former Cornell University computing graduate. We will only take on two projects for our 16 seat Indian staff. We are office in New York City One Penn plaza 49TH floor and in India.

Our team has exceptional focus in the following projects

WEBSITE DESIGN / DEVELOPMENT

E-COMMERCE CREATION / DEVELOPMENT

FLASH ANIMATION DESIGN

PAID SEARCH PLACEMENT

WEBSITE MAINTENANCE

SOFTWARE DEVELOPMENT

GRAPHIC DESIGN

ERP-CLASS SYSTEMS AND DATABASE DEVELOPMENT

FLASH,FLEX

CMS INTEGRATION

SEO

WEBSITE PROMOTION

3D DESIGN

CONTENT MANAGEMENT, MAINTENANCE AND SUPPORT

FACEBOOK APPLICATIONS DEVELOPMENT

SOFTWARE DEVELOPMENT

UI DESIGN

SOFTWARE ARCHITECTURE DESIGN

DATABASE DEVELOPMENT

CLINT / SERVER APPLICATION DEVELOPMENT

SOFTWARE TESTING (INCLUDING AUTOMATED TESTING)

MOBILE AND PDA APPLICATION

We provide web solutions that work properly in Internet Explorer, Firefox, Safari and Opera. All of our websites have a convenient, easy-to-use admin panel and content management system (CMS). We develop websites that are already SEO optimized, so you don't need to spend extra money on optimization.


Please email rs@ldjcapital.com head of business development




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.