Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

/prog/ challenge

Name: Anonymous 2011-02-09 9:52

write a program to test, whether the stack grows upwards or downwards

I don't give a fuck about your exotic architecture and neither does anybody else. so please fuck off, ``faggot''.

Name: Anonymous 2011-02-09 10:00

>>1
I don't give a fuck about your exotic architecture and neither does anybody else
enum { UP, DOWN };

int stack_direction() {
return DOWN;
}

Name: Anonymous 2011-02-09 10:22

>>3
(define (syndrome) 'down)

Name: Anonymous 2011-02-09 10:29


#include <stdio.h>

int main()
{
    volatile int x = 0x11223344;
    volatile int y = 0x55667788;
    if(&x-&y > 0)puts("grows to 0");
    else puts("grows to 0xFFFF...");
}

Name: Anonymous 2011-02-09 10:32

>>5
the compiler could rearrange x and y ;(

Name: Anonymous 2011-02-09 10:42

>>6 not on my anus!

int* my_anus()
{
    int y = 0x55667788;
    return &y;
}

int main()
{
    int x = 0x11223344;
    if(&x-(my_anus()) > 0)puts("grows to 0");
    else puts("grows to 0xFFFF...");
}


for better result put my_anus into different translation unit

Name: Anonymous 2011-02-09 11:09

>>7
U MENA

#include <stdio.h>

static char *f(void)
{
        char c;
        return &c;
}

int main(void)
{
        char c;
        puts(&c < f() ? "upwards" : "downwards");
        return 0;
}

Name: Anonymous 2011-02-09 11:18

>>1
write a program to test, whether the stack grows upwards or downwards

Do you mean upwards like a bamboo, with new addresses near the bottom, or upwards like a fir, with new addresses at the top?

Name: Anonymous 2011-02-09 15:02

My architecture has no stack.

How does it make function calls? Memory!

Name: Anonymous 2011-02-09 18:13

>>16

how could you possibly have an "architecture" without a stack? please provide a brief description so i can reprogram my register machine.

you can find an example of a description on the internet by pointing your browser towards http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-31.html#%_sec_5.1.5

Name: Anonymous 2017-02-04 1:53


#include <stdio.h>
#include <stdlib.h>

long p1, p2;

void f2() {
int x = 27;
p2 = (long) &x;
}
void f1() {
int x = 5;
p1 = (long) &x;
f2();
}


int main(void) {
f1();
printf("The stack grows %s.\n", p2 > p1 ? "upwards" : "downwards");
return(EXIT_SUCCESS);
}

Don't change these.
Name: Email:
Entire Thread Thread List