Intel 80C188XL 80C186 INSTRUCTION SET ADDITIONS AND EXTENSIONS, Bp Sp, Old BP BPM BPM BPM BPA

Models: 80C186XL 80C188XL

1 405
Download 405 pages 42.62 Kb
Page 312
Image 312
Old BP

80C186 INSTRUCTION SET ADDITIONS AND EXTENSIONS

BP

SP

15

0

Old BP

BPM

BPM

BPM

BPA*

*BPA = BP Value for Procedure A

Display A

Dynamic

Storage A

A1003-0A

Figure A-4. Stack Frame for Procedure A at Level 2

After Procedure A calls Procedure B, ENTER creates the display for Procedure B. The first word of the display points to the previous value of BP (BPA). The second word points to the value of BP for MAIN (BPM). The third word points to the BP for Procedure A (BPA). The last word points to the current BP (BPB). Procedure B can access variables in Procedure A or Main via the appropriate BP in the display (see Figure A-5).

After Procedure B calls Procedure C, ENTER creates the display for Procedure C. The first word of the display points to the previous value of BP (BPB). The second word points to the value of BP for MAIN (BPM). The third word points to the value of BP for Procedure A (BPA). The fourth word points to the current BP (BPC). Because Procedure B and Procedure C have the same lexical nesting level, Procedure C cannot access variables in Procedure B. The only pointer to Procedure B in the display of Procedure C exists to allow the LEAVE instruction to collapse the Procedure C stack frame (see Figure A-6).

A-5

Page 312
Image 312
Intel 80C188XL 80C186 INSTRUCTION SET ADDITIONS AND EXTENSIONS, Bp Sp, Old BP BPM BPM BPM BPA, Display A Dynamic Storage A