A Peek(0) gets R0, where the register value of MCUSR was saved by Bascom.
Main program an bootloader don't know each other and so they don't share any variables, so the bootloader must save the result from R0, where the main program can retrieve it.
One possibility is an EEProm cell, another a GPIO-register, some AVR's provide, a third a SRam cell at a fixed location.
For the latter the main program must use $noramclear, as otherwise SRam is cleared by Bascom's startup routine.
Be aware, that by using $noramclear, global variables are not initialized with 0. If your code depends on initialized variables, it may show erratic behaviour then.
↧