Here's what I have so far

Code:
'-------------- Reset Type -----------------------------------------------------
' manage the RCON/STKPTR flags and come up with a sane reset indication
' there will probably be only one bit set, but anything is possible
' especially with regards to the powerdown bit, which gets set by a SLEEP instr.
'
'  0 brownout, 1 poweron, 2 powerdown, 3 wdt timeout
'  4 reset instruction, 5 (unused), 6 stack underflow, 7 stack full

    ResetTypeMask   var byte
    ResetTypeMask = 0
    
GetResetType:
    ' Brown-out Reset
    if RCON & %11 = %10 then ' BOR 0, POR 1 
        ResetTypeMask.0 = 1
        RCON.0 = 1 ' set BOR
    endif

    if RCON.1 = 0 then ' POR 0
        ResetTypeMask.1 = 1
        RCON.1 = 1 ' set POR
    endif
    
    ' RESET instruction
    if RCON.4 = 0 then ' RI 0
        ResetTypeMask.4 = 1
        RCON.4 = 1  ' set RI
    endif
    
    ' WDT reset
    if RCON.3 = 0 then ' TO 0
        ResetTypeMask.3 = 1
        ' TO is read-only
    endif
    
    ' Stack Full
    if STKPTR.7 = 1 then ' STKFUL 1
        ResetTypeMask.7 = 1
        STKPTR.7 = 0
    endif
    
    ' Stack Underflow
    if STKPTR.6 = 1 then ' STKUNF 1
        ResetTypeMask.6 = 1
        STKPTR.6 = 0
    endif
    
    ' Powerdown Detection
    if RCON.2 = 0 then ' PD 0
        ResetTypeMask.2 = 1
        ' PD is read-only
    endif