Thread: pushing of arguments into the stack?

  1. #31
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    >> then put the definition in your sig

    The only problem with that is the bone heads that think it's part of your response...but yeah, it would probably save me a lot of typing.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  2. #32
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    > 00110000 01111000 00110101 00110011

    what did you say? thems fightin words

  3. #33
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    >> what did you say? thems fightin words

    Exactly. My favorite "often misread" signature, BTW, is Sang-drax's, which reads:

    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  4. #34
    Banned ಠ_ಠ's Avatar
    Join Date
    Mar 2009
    Posts
    687
    Quote Originally Posted by Sebastiani View Post
    >> what did you say? thems fightin words

    Exactly. My favorite "often misread" signature, BTW, is Sang-drax's, which reads:

    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling
    lol, I remember seeing that
    ╔╗╔══╦╗
    ║║║╔╗║║
    ║╚╣╚╝║╚╗
    ╚═╩══╩═╝

  5. #35
    Registered User
    Join Date
    Jul 2009
    Posts
    6
    How do you even know there is a stack (used for parameter passing) ?

  6. #36
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    yeah, you don't. they could be passed in registers or using the new foobar gadget for all ISO C cares.

  7. #37
    Registered User
    Join Date
    Jul 2009
    Posts
    6
    Or the hardware doesn't know how to handle a stack, hardware stack handling is not a prerequisite as far as I know...

  8. #38
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    >> Or the hardware doesn't know how to handle a stack, hardware stack handling is not a prerequisite as far as I know...

    To be sure, though, even if it didn't have one (rare, I imagine), you could simply simulate one in software. It would be easiest if you had a spare register (two would be better, of course, so that you could have a base pointer), but even if you didn't you could simply use some hard-coded address or such to store it. My point is, a stack is just a simple data structure that happens to be implemented in hardware because it's, well, so useful, but hardware support isn't strictly necessary.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  9. #39
    Registered User
    Join Date
    Jul 2009
    Posts
    6
    Quote Originally Posted by Sebastiani View Post
    [...] but hardware support isn't strictly necessary.
    I agree. It seems, though, that many C students think that there is a stack (ie. hardware SP, and related addressing mode(s), bound checking etc.).

  10. #40
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    >> It seems, though, that many C students think that there is a stack

    Well, on most systems these days, there is. My only point was that it could be simulated, which to be fair, isn't immediately obvious unless you've done some assembly programming or whatnot. A lot of people don't know you could use an xor gate to test for inequality either, for example (which is kind of a lame example, I know), but that's less a matter of ignorance so much as it is a lack of arcane knowledge that can only come with experience.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  11. #41
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    Is there a way to implement recursive functions without a stack/LIFO, either in software or in hardware?

  12. #42
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    >> Is there a way to implement recursive functions without a stack/LIFO, either in software or in hardware?

    Of course not.

    EDIT: Sorry, that probably sounded rude. No offense intended.

    And just to clarify, the reason is quite simple: a stack *is* recursion. And if you get right down to it, it's such a simple, basic data structure that it isn't even meaningful to somehow discard it completely. Having said all that, you could implement it in a number of ways - you might use a linked list for example. But that doesn't change the fact that it's still logically a stack, if you get what I mean. So in that sense, the answer is still no.
    Last edited by Sebastiani; 07-09-2009 at 01:26 PM.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. stack and pointer problem
    By ramaadhitia in forum C Programming
    Replies: 2
    Last Post: 09-11-2006, 11:41 PM
  2. Question about a stack using array of pointers
    By Ricochet in forum C++ Programming
    Replies: 6
    Last Post: 11-17-2003, 10:12 PM
  3. error trying to compile stack program
    By KristTlove in forum C++ Programming
    Replies: 2
    Last Post: 11-03-2003, 06:27 PM
  4. What am I doing wrong, stack?
    By TeenyTig in forum C Programming
    Replies: 2
    Last Post: 05-27-2002, 02:12 PM
  5. Stack Program Here
    By Troll_King in forum C Programming
    Replies: 7
    Last Post: 10-15-2001, 05:36 PM