B.1.6 Stack Protection

Stack overflow and underflow can now be detected. Low and high stack limits can be set on 256-byte boundaries. When a stack-relative memory access occurs within 16 bytes of these limits (or outside of them), a new Priority 3 stack violation interrupt occurs. The 16- byte buffer exists to allow stack protection even if the stack is placed against a memory segment boundary.

Figure B-2shows one possible stack layout. A 2048-byte stack is set up by setting STKHLR to 0xE0, STKLLR to 0xD8, and SP to 0xDFF0. Any stack-relative memory accesses above 0xDFEF (i.e., stack underflow) or below 0xD810 (i.e., overflow) would trigger the stack violation interrupt.

TKHLR = 0xE0

0xE000

0xDFF0

0xDFEF

0xD810

0xD80F

0xD800

TKLLR = 0xD8

Stack access in this region triggers an interrupt

Stack access in this region is allowed

Stack access in this region triggers an interrupt

Figure B-2. Simple Stack Protection Layout

User’s Manual

289

Page 298
Image 298
Jameco Electronics 3000, 2000 manual Figure B-2. Simple Stack Protection Layout