+#ifdef STACKCHECK
+ movw #SPL6,sr | avoid trouble
+ btst #5,sp@ | are we returning to user mode?
+ jne Ldorte1 | no, skip it
+ movl a6,tmpstk-20
+ movl d0,tmpstk-76
+ moveq #0,d0
+ movb sp@(6),d0 | get format/vector
+ lsrl #3,d0 | convert to index
+ lea _exframesize,a6 | into exframesize
+ addl d0,a6 | to get pointer to correct entry
+ movw a6@,d0 | get size for this frame
+ addql #8,d0 | adjust for unaccounted for bytes
+ lea _kstackatbase,a6 | desired stack base
+ subl d0,a6 | - frame size == our stack
+ cmpl a6,sp | are we where we think?
+ jeq Ldorte2 | yes, skip it
+ lea tmpstk,a6 | will be using tmpstk
+ movl sp@(4),a6@- | copy common
+ movl sp@,a6@- | frame info
+ clrl a6@-
+ movl sp,a6@- | save sp
+ subql #4,a6 | skip over already saved a6
+ moveml #0x7FFC,a6@- | push remaining regs (d0/a6/a7 done)
+ lea a6@(-4),sp | switch to tmpstk (skip saved d0)
+ clrl sp@- | is an underflow
+ jbsr _badkstack | badkstack(0, frame)
+ addql #4,sp
+ moveml sp@+,#0x7FFF | restore most registers
+ movl sp@,sp | and SP
+ rte
+Ldorte2:
+ movl tmpstk-76,d0
+ movl tmpstk-20,a6
+Ldorte1:
+#endif