I think I know where the problem lies. If you're talking about using a SR within the subroutine, I think you have defined the address of the SR as being an OUT vartype in the definition table. Try the same but define the SR address as vartype IN_OUT. That way the subroutine reads the status of the SR address before processing any instruction and writes the new status back after processing the SR.
Kind regards,
Kind regards,