OpenCores
URL https://opencores.org/ocsvn/aemb/aemb/trunk

Subversion Repositories aemb

[/] [aemb/] [trunk/] [sw/] [cc/] [aemb/] [stack.hh] - Blame information for rev 128

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 128 sybreon
/* $Id: stack.hh,v 1.3 2008-04-23 14:19:39 sybreon Exp $
2 107 sybreon
**
3
** AEMB2 HI-PERFORMANCE CPU
4
** Copyright (C) 2004-2007 Shawn Tan Ser Ngiap 
5
**
6
** This file is part of AEMB.
7
**
8
** AEMB is free software: you can redistribute it and/or modify it
9
** under the terms of the GNU Lesser General Public License as
10
** published by the Free Software Foundation, either version 3 of the
11
** License, or (at your option) any later version.
12
**
13
** AEMB is distributed in the hope that it will be useful, but WITHOUT
14
** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15
** or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General
16
** Public License for more details.
17
**
18
** You should have received a copy of the GNU Lesser General Public
19
** License along with AEMB. If not, see .
20
*/
21
 
22
/**
23
   Basic stack related functions
24
   @file stack.hh
25
 */
26
 
27
#ifndef AEMB_STACK_HH
28
#define AEMB_STACK_HH
29
 
30 121 sybreon
#ifdef __cplusplus
31 107 sybreon
namespace aemb {
32 121 sybreon
#endif
33 107 sybreon
 
34
  /**
35
  Reads the size of the memory space allocated for the stack in bytes.
36
  @return size of stack
37
  */
38
 
39
  inline int getStackSize()
40
  {
41
    int tmp;
42
    asm ("la %0, r0, _STACK_SIZE":"=r"(tmp));
43
    return tmp;
44
  }
45
 
46
  /**
47
  Reads the end of the memory space allocated for the stack.
48
  @return end of stack
49
  */
50
 
51
  inline int getStackEnd()
52
  {
53
    int tmp;
54
    asm ("la %0, r0, _stack_end":"=r"(tmp));
55
    return tmp;
56
  }
57
 
58
  /**
59
  Reads the top of the memory space allocated for the stack.
60
  @return top of stack
61
  */
62
 
63
  inline int getStackTop()
64
  {
65
    int tmp;
66
    asm ("la %0, r0, _stack":"=r"(tmp));
67
    return tmp;
68
  }
69
 
70
  /**
71
  Reads register R1 which is the designated stack pointer.
72
  @return stack pointer
73
  */
74
 
75
  inline int getStack()
76
  {
77
    int tmp;
78 128 sybreon
    asm ("addk %0, r0, r1":"=r"(tmp));
79 107 sybreon
    return tmp;
80
  }
81
 
82
  /**
83
  Sets register R1 to the new stack pointer.
84
  @param stk new stack pointer
85
  */
86
 
87
  inline void setStack(int stk)
88
  {
89 128 sybreon
    asm ("addk r1, r0, %0"::"r"(stk));
90 107 sybreon
  }
91 121 sybreon
 
92
#ifdef __cplusplus
93 107 sybreon
}
94 121 sybreon
#endif
95 107 sybreon
 
96
#endif
97
 
98
/*
99
  $Log: not supported by cvs2svn $
100 128 sybreon
  Revision 1.2  2008/04/20 16:35:53  sybreon
101
  Added C/C++ compatible #ifdef statements
102
 
103 121 sybreon
  Revision 1.1  2008/04/09 19:48:37  sybreon
104
  Added new C++ files
105
 
106 107 sybreon
*/

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.