Re: Write to unused memory-mapped IO address (0xfffffffc)



In article <dmd9sn$4j1$1@xxxxxxxxxxxxxxxxx>, Paminu <asdad@xxxxxxx> wrote:

[ snip ]

>Think you are right. I have now intialized the stack-pointer before I use
>it:
>
>ori $sp, $0, 0xfffc # Init stack
>$sp = 0000FFFC
>

I'm not sure you need to do this. When I've run programs under spim,
it has seemed to be the case that $sp already has a sensible value.
My understanding is that part of what SPIM simulates is a very,
very rudimentary operating system (just enough code to load programs
and process a few simple system calls for I/O). I would think that
assigning a sensible value to the stack pointer, before calling a
just-loaded program, would be part of that.

>
>I would then like to make room for 3 (3*4 = 12 Bytes) arguments and an array
>with 10 integers (a[10] = 40 Bytes). I therefore decrement the stack-pointer
>with 52
>
>addi $29, $29, -52
>$sp = 0000FFC8
>
>I would the like to store the return address as the first item on the stack:
>
>sw $31, 48($29) # main's $ra is first item on stack.
>
>but then I get this error (taken form SPIM):
>
>[0x00400014] 0xafbf0030 sw $31, 48($29) ; 10: sw $31,
>48($29) # main's $ra is first item on stack.
>Exception occurred at PC=0x00400014
> Bad address in data/stack read: 0x0000fff8
>Can't expand stack segment by 16777216 bytes to 16842752 bytes
>Use -lstack # with # > 16842752
>
>Why is it impossible to store $ra from 0x0000fff8??
>

Interesting question. It sounds (from the error message,
particularly the reference to "stack segment") like maybe SPIM is
making some attempt to manage its memory, and 0x0000fff8 is either
outside the memory area it thinks should be used for the stack,
or it's outside the memory area that can be referenced at all.
32-bit addresses make for a pretty big address space, and it
wouldn't surprise me at all to know that SPIM won't let you access
all possible addresses.

A shorter answer is that this problem may go away once you stop
trying to assign your own value to $sp. (How did you pick fffc,
by the way?)

--
| B. L. Massingill
| ObDisclaimer: I don't speak for my employers; they return the favor.
.



Relevant Pages

  • Re: Write to unused memory-mapped IO address (0xfffffffc)
    ... > to communicate with devices or device controllers. ... > for this purpose but not actually used, and therefore SPIM is not ... I would the like to store the return address as the first item on the stack: ...
    (comp.programming)
  • Re: How does managed code work?
    ... Does it work the same way as the native stack with a frame pointer that is the head of a linked list of stack frames where each time we enter a function we create a new stack frame in which new variables are pushed and each time we exit a function the entire stack frame is popped? ... Can someone point me to a discussion of the managed heap? ... How does it prevent memory leaks that occur in COM when two objects reference each other and keep the others reference count nonzero? ... Because objects don't go out of scope, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Difference between nullable class and nullable<> structure
    ... Page 313 (Understanding Value Types and Reference Types): ... a .NET data type may be value-based or ... the heap and the stack is, at a minimum, bound to fall short of precision, ... If the student already understand planetary orbital ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: How java passes object references?
    ... uses the same sort of stack convention as many other languages, including C++ and C#. Local variables are allocated on the stack, not the heap. ... But my understanding is that Java byte-code is compiled "just-in-time" into a platform-efficient representation that is actually executed, and that would mean using platform-supported run-time mechanisms like a stack. ... It's theoretically possible to implement Java with individual heap allocations for each function call, but that would be relatively inefficient and I don't believe any mainstream implementation of Java would do it that way. ... At least then you won't risk confusing people who think you're saying, "pass by reference", which Java doesn't have. ...
    (comp.lang.java.programmer)
  • Re: [PATCH] Introduce nodemask_t ADT [0/7]
    ... I know that a richer repertoire of operations will reduce the stack ... > it calls change things, and which don't, letting it pass a pointer to ... make sense to pass it by reference. ... > If one needs an explicit call by reference to avoid passing a multi-word ...
    (Linux-Kernel)