stack.c

00001 /***************************************************************************
00002                           stack.c  -  description
00003                              -------------------
00004     begin                : Sat Feb 14 2004
00005     copyright            : (C) 2004 by Dynacube Team
00006     email                : 
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #include "common/ds/stack.h"
00019  
00020 DD stack[STCK_SIZE];
00021 
00022 DW stck_ptr = 0;
00023 
00024 SDB push(DD val)
00025 {
00026         if(stck_ptr == STCK_SIZE)
00027                 return -1;
00028         else
00029                 stack[stck_ptr++] = val;
00030 }
00031  
00032 SDD pop()
00033 {
00034         if(stck_ptr == 0)
00035                 return -1;
00036         return stack[--stck_ptr];
00037 }
00038 
00039 void printStack()
00040 {
00041         DW i = stck_ptr;
00042         printf("\nStack Print\n");
00043         
00044         while(i > 0)
00045         {
00046                 printf("(%d) %x ",i-1,stack[i-1]);
00047                 i--;
00048         }
00049 }

Generated on Thu Jul 27 23:52:27 2006 for Dynacube by  doxygen 1.4.7