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

Subversion Repositories aemb

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

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

Line No. Rev Author Line
1 107 sybreon
/* $Id: stack.hh,v 1.1 2008-04-09 19:48:37 sybreon Exp $
2
**
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
namespace aemb {
31
 
32
  /**
33
  Reads the size of the memory space allocated for the stack in bytes.
34
  @return size of stack
35
  */
36
 
37
  inline int getStackSize()
38
  {
39
    int tmp;
40
    asm ("la %0, r0, _STACK_SIZE":"=r"(tmp));
41
    return tmp;
42
  }
43
 
44
  /**
45
  Reads the end of the memory space allocated for the stack.
46
  @return end of stack
47
  */
48
 
49
  inline int getStackEnd()
50
  {
51
    int tmp;
52
    asm ("la %0, r0, _stack_end":"=r"(tmp));
53
    return tmp;
54
  }
55
 
56
  /**
57
  Reads the top of the memory space allocated for the stack.
58
  @return top of stack
59
  */
60
 
61
  inline int getStackTop()
62
  {
63
    int tmp;
64
    asm ("la %0, r0, _stack":"=r"(tmp));
65
    return tmp;
66
  }
67
 
68
  /**
69
  Reads register R1 which is the designated stack pointer.
70
  @return stack pointer
71
  */
72
 
73
  inline int getStack()
74
  {
75
    int tmp;
76
    asm ("or %0, r0, r1":"=r"(tmp));
77
    return tmp;
78
  }
79
 
80
  /**
81
  Sets register R1 to the new stack pointer.
82
  @param stk new stack pointer
83
  */
84
 
85
  inline void setStack(int stk)
86
  {
87
    asm ("or r1, r0, %0"::"r"(stk));
88
  }
89
}
90
 
91
#endif
92
 
93
/*
94
  $Log: not supported by cvs2svn $
95
*/

powered by: WebSVN 2.1.0

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