//Modified for Carthage CSC_4730 P4 | Caleb Collar & Kai Kuebler //Stack Test #include "types.h" #include "user.h" #define STACK_GULP (1 << 10) void Foo(int counter) { unsigned char a[STACK_GULP]; printf(1, "Iteration: %d - %d bytes added to stack - 0x%d\n", ++counter, STACK_GULP, a); Foo(counter); } int main(int argc, char ** argv) { int heap_amount; void * p; if (argc > 1) { heap_amount = atoi(argv[1]); printf(1, "Attempting to allocate: %d bytes from the heap\n", heap_amount); p = malloc(heap_amount); printf(1, "malloc() returns: 0x%x\n", p); if (p == 0) { exit(); } } printf(1, "Starting descent into stack space\n"); Foo(0); exit(); }