| | |
C++ Virtual Stack
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: May 2007
Posts: 69
Reputation:
Solved Threads: 1
My first school project after first year of c++ studying in 10 grade for summer to code virtual stack emulation in C++..
Well i've done it perfectly finished just today !!
It supposed to be for all summer I finished in fast in 1 day lol not nerd
Just wana share it because its very interesting and beginners just like me can play with it and gain cool knowledge how ASM stack works..
My Virtual Stack works just like ASM method LIFO and its Draw it perfectly you will see..
VirtualStack.h
VirtualStack.cpp
main.cpp
You can play with it use all basic funcs like push pop and even more advanced i made to emulate and get more femiliar with stack
isnt that cool lol i only learned 1 year !!!! i'm so l33t!
Well i've done it perfectly finished just today !!
It supposed to be for all summer I finished in fast in 1 day lol not nerd

Just wana share it because its very interesting and beginners just like me can play with it and gain cool knowledge how ASM stack works..
My Virtual Stack works just like ASM method LIFO and its Draw it perfectly you will see..
VirtualStack.h
C++ Syntax (Toggle Plain Text)
#include <cstdlib> #include <iostream> #include <windows.h> using namespace std; class VirtualStack { int WordsAmmount; WORD *StackBase; WORD *SP; public: //Constructor Destructor VirtualStack(int); ~VirtualStack(); //Additional void DisplayStack(); void ResetStackBytes(); void ChangeStackElementByID(WORD,WORD); void ChangeSpRegisterByElementID(WORD); //Basic void Push(WORD); void Pop(WORD&); };
VirtualStack.cpp
C++ Syntax (Toggle Plain Text)
#include "VirtualStack.h" //Shit static variable related to some graphic stuff static int SchemeNumber = 1; //Cool shit that makes loading dots hehe void LoadingDotsBySleepTime(int SleepingTime,int DotsAmmount) { for(int x = 1; x<=DotsAmmount; x++) { cout << "."; Sleep(SleepingTime); } } VirtualStack::VirtualStack(int Size) { WordsAmmount = Size; cout << "Creating Virtual Stack";LoadingDotsBySleepTime(500,5); cout << endl << endl; cout << "Allocating Virtual Bytes"; LoadingDotsBySleepTime(200,4); cout << endl << endl; StackBase = new WORD[Size]; SP = &StackBase[WordsAmmount-1]; Sleep(1000); } VirtualStack::~VirtualStack() { delete[] StackBase; MessageBox(0,"Stack Destroyed","Stack Information",MB_OK); } void VirtualStack::DisplayStack() { cout << "Preparing to Draw Scheme Number: " << SchemeNumber; LoadingDotsBySleepTime(400,5); cout << endl << endl; cout << "SP register: " << SP << endl << endl; for(int Obj = (WordsAmmount-1); Obj >= 0; Obj--) { cout << "[" << Obj << "] "; cout << "[" << &StackBase[Obj] << "]" << " Cell Value: " << StackBase[Obj]; if( SP == &StackBase[Obj]) cout << " ---> SP Register Points Here"; cout << endl; } cout << endl << endl << endl; SchemeNumber++; } void VirtualStack::ResetStackBytes() { for(int Obj = 0; Obj <= (WordsAmmount-1); Obj++) { StackBase[Obj]=0; } } void VirtualStack::Push(WORD WordValue) { SP--; *SP = WordValue; } void VirtualStack::Pop(WORD &Destination) { Destination = *SP; SP++; } void VirtualStack::ChangeStackElementByID(WORD ElementID,WORD ElementValue) { StackBase[ElementID] = ElementValue; } void VirtualStack::ChangeSpRegisterByElementID(WORD ElementID) { SP = &StackBase[ElementID]; }
main.cpp
C++ Syntax (Toggle Plain Text)
#include "VirtualStack.h" int main() { VirtualStack VSObject(8); VSObject.ResetStackBytes(); VSObject.Push(100); VSObject.Push(50); VSObject.Push(10); VSObject.DisplayStack(); VSObject.ChangeSpRegisterByElementID(3); VSObject.DisplayStack(); VSObject.ChangeStackElementByID(3,90); VSObject.DisplayStack(); system("PAUSE"); return 0; }
You can play with it use all basic funcs like push pop and even more advanced i made to emulate and get more femiliar with stack
isnt that cool lol i only learned 1 year !!!! i'm so l33t!
![]() |
Similar Threads
- IIS .NET2 virtual directory not working (ASP.NET)
- Virtual Reality and Gaming (Geeks' Lounge)
- Senior Ruby On Rails Developer (VIRTUAL) (Software Development Job Offers)
- Senior Mac Java Developer - Virtual Office (Software Development Job Offers)
- Dead TCP/IP Stack = DEAD VISTA !! (Windows Vista and Windows 7)
- stack reduction (C)
- Linked Lists and Copy Constructor (C++)
- Help With Pointer Stack (C++)
Other Threads in the C++ Forum
- Previous Thread: file.open() not working in loop
- Next Thread: g++ warnings
| Thread Tools | Search this Thread |
api array arrays based beginner binary bitmap c++ c/c++ calculator char class classes code compile compiler console conversion count data delete deploy desktop developer directshow dll download dynamic encryption error file forms fstream function functions game getline givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory news node number output parameter pointer problem program programming project proxy python read recursion recursive return string strings struct temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets





