Discussion:
Bug when returning values via stack
(too old to reply)
Troy Mark Gonsalves
2004-05-21 15:25:57 UTC
Permalink
If you're solution to a1p4 returns values
through the stack then your program probably
contains a bug. You'll compute values correctly,
but you'll be doing something very bad in some cases...

I'm not going to tell you exactly what the bug is...that'd be too easy.
Could be worse, I could have said nothing and just let you
(potentially) loose marks...

If you like you can try emailing me you current solution and I'll tell you
if you have this bug...I'm not promising that I'll respond before 6 but I
will try.

Troy
Troy Mark Gonsalves
2004-05-21 17:04:02 UTC
Permalink
Some of the solutions that I'm seeing that "use the stack to return a
value" are actually not _actually_ using the stack. The 'stack' is
everything below the stack pointer (everything with an address
greater than or equal to the value in $30)...if you are returning a value
using an address above the stack pointer you are not _really_ using the
stack. This means that your value is not protected by the stack and may be
overwritten...

Returning a value in an address outside of the stack is not an acceptable
solution.

Returning a value inside the stack results in a bug (at least I haven't
seen a bug free way of doing it, yet).

Troy

Loading...