The C start code is probably initializing your variable to 0x00 after you store the 0xbeef code.
What I've done to avoid this is create a separate memory space in the LCF file:
in the MEMORY section, place the following:
DATA_RESET (RW) : ORIGIN = 0x???, LENGTH = 0
And set ORIGIN to some unused RAM (I like to use the on-chip RAM for this if it is available)
Next, define the data section:
.uninitialized_reset_data :
{
*(.ResetData)
. = ALIGN(0x8);
} > DATA_RESET
Finally, you need to declare the variable(s) (I usually put the declaration in the main.c file):
/********************************************************************/
/* RAM variables that are fixed for external access by application */
#pragma define_section ResetData ".ResetData" far_absolute RW
__declspec(ResetData) uint32 d0_reset; // reset d0
__declspec(ResetData) uint32 d1_reset; // reset d1
/********************************************************************/
This code works for coldfire, but I'm not sure how the pragma or __declspec translate to the HC12 compiler so you might have to translate a bit to get it to work on your platform.
Hope this helps,
Joe