Original Post

Hi guys, I’m experience some very strange behavior while running my code on the VB, however all works just fine in both Rboy and Rdragon .

The problem seems to be related to nested function calls and the size of the call stack, for example:

void callNested5(int* dummy){
vbPrint(0, 1, 5, “5”, 0);
callNested2(dummy);
}

void callNested4(int* dummy){
vbPrint(0, 1, 4, “4”, 0);
callNested5(dummy);
}

void callNested3(int* dummy){
vbPrint(0, 1, 3, “3”, 0);
callNested4(dummy); // if this call is allowed the game crashes on the VB
}

void callNested2(int* dummy){
vbPrint(0, 1, 2, “2”, 0);
callNested3(dummy);
}

void callNested1(int* dummy){
vbPrint(0, 1, 1, “1”, 0);
callNested2(dummy);
}

int callRecursive(int number){

//vbjPrintInt(number, 1, 20);
return 0 == number? 0: callRecursive(–number);
}

int main(void){

vbDisplayOn();

copymem((void*)CharSeg3+(254*16), (void*)ASCII_CH2, 258 << 4); WA[31].head = WRLD_ON; WA[31].w = 384; WA[31].h = 224; WA[30].head = WRLD_END; VIP_REGS[BRTA] = 32; VIP_REGS[BRTB] = 64; VIP_REGS[BRTC] = 32; int dummy = 0; while(1) { callNested1(&dummy); callRecursive(2); } } As soon as I put in the call to callNested4 from callNested3 the screen just stays black on the VB. The recursive call crashes the program too but only in the VB. I'm compiling with GCCVB 4, does anyone else experience the same problem? BTW: I've tried a barebones test program with only libgccvb and the problem does not arises, neither by calling callNested1 nor callRecursive so I suspect that it has to do with the size of my engine, but it buffles me that in the emulator the code works. Is there any way to know how the stack and the .bss sections are related? I have some big structs in the .bss. Jorgeche

2 Replies

Using Rboy’s debugger I’ve made some sense of the memory status, and how the stack relates to the .bss section.

I have reduced the RAM footprint to 15612 bytes, but still it crashes on the real hardware.

The RAM dump doesn’t show anything strange.

  • This reply was modified 10 years, 10 months ago by jorgeche.

 

Write a reply

You must be logged in to reply to this topic.