NextBuild icon indicating copy to clipboard operation
NextBuild copied to clipboard

Stack corruption

Open Duefectu opened this issue 3 years ago • 0 comments

Hello,

In NextLib 7.5 the stack is changed to point to the "nbtempstackstart" label, leaving a stack area of 256 bytes:

asm 		
filename:
	DEFS 255,0
endfilename:	
end asm 

asm 
nbtempstackstart:
	**ld sp,nbtempstackstart**
end asm 

This can cause serious problems, for example in the use of local variables of type string that are a bit big. It would be possible not to alter the SP? I think it would be best to respect the one the main program has, and the library should restore the original stack when finished. Right now, SP is changed directly by doing "#include <NextLib.bas>", and not works if SP is changed to another position.

Thanks a lot for your work!

Duefectu avatar Oct 17 '21 21:10 Duefectu