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: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 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);
}