The Normal Try Statement is an Algol Statement which executes a sequence of statements until one is found which does not cause an exception.
The compiler pushes a a Try Fault Marker on the Stack, and then a PCW to the next Else part of the statement. If a fault occurs in the Try part, the MCP traps the fault and branches to the next Else part.
The next Else part starts by deleting the PCW and replacing it with a new PCW to the following Else part, and then it branches to the start of the code for the current Else part.
This pattern is repeated through the Else parts. The final Else part is not protected, and should a fault occur, then normal fault handling is performed.
At the end of the Try Statement, the two Stack Cells for the Try Fault Marker and the PCW are deleted.
This cod was emitted by the Algol Compiler.
Try J:=A[I] 0003:0001:0 LT48 BE 0003:0002 000000080001 0003:0003:0 LT8 4 B204 0003:0003:2 STAG 95B4 0003:0003:4 MPCW BF 0003:0004:0 0003:0009:2 00040090A003 0003:0005:0 VALC (02,0002) 1002 0003:0005:2 NAMC (02,0004) 5004 Else 0003:0005:4 NXLV AD 0003:0005:5 NTGR 87 0003:0006:0 NAMC (02,0003) 5003 0003:0006:2 STOD B8 0003:0006:3 BRUN 000E:4 A2800E Begin I:=1; J:=A[I]; End 0003:0007:0 ONE B1 0003:0007:1 NAMC (02,0002) 5002 0003:0007:3 STOD B8 0003:0007:3 STON B9 0003:0007:4 NAMC (02,0004) 5004 0003:0008:0 NXLV AD 0003:0008:1 NTGR 87 0003:0008:2 NAMC (02,0003) 5003 0003:0008:4 STOD B8 Else 0003:0008:5 BRUN 000E:4 A2800E 0003:0009:2 DLET B5 0003:0009:3 MPCW BF 0003:000A:0 0003:000D:5 000A00D0A003 0003:000B:0 BRUN 0007:0 A20007 Begin I:=0; J:=A[I]; End; 0003:000B:3 ZERO B0 0003:000B:4 NAMC (02,0002) 5002 0003:000C:0 STOD B8 0003:000C:0 STON B9 0003:000C:1 NAMC (02,0004) 5004 0003:000C:3 NXLV AD 0003:000C:4 NTGR 87 0003:000C:5 NAMC (02,0003) 5003 0003:000D:1 STOD B8 0003:000D:2 BRUN 000F:0 A2000F 0003:000D:5 DLET B5 0003:000E:0 DLET B5 0003:000E:1 BRUN 000B:3 A2600B 0003:0006:3 DBUN-LINK 0009:2 AA0038 0003:000E:4 DLET B5 0003:000E:5 DLET B5
The layout of the Try Fault Marker is defined in the MCP at 24606416,
Tag 4 - Fault Marker | ||
---|---|---|
Field | Name | Description |
[19:3] | FaultMarkF | FaultTryMarkV = 4 |
[4:1] | TryInvalidF | If set, the Try word is invalid. |
[3:1] | TryAllF | If set, this Try word protects from All faults |
[2:3] | TryTypeF | The Type of Try Word, 1 = TryNormalV (Try Normal, GoTo PCW) 2 = TryExitV (Try Limited Error Procedure) 3 = TryReturnV (Try Limited Error Function Value) |
This is the Stack dump from the Try statement,
***************BOUNDS ERROR ************************************************** 0022 7 6000B0 201D50 RCW: ASD=00EA83, LL=2, Normal state [User segment @ 0003:0005:4 (00106000)] Segment Descriptor: C 680000 001D50 ------ BLOCK#1 Code: 3 000000 080001 3 B20495 B4BFFF 3 000400 90A003 >3 100250 04AD87< 3 5003B8 A2800E 0021 -----D[1]=>3 001200 090000 *ENVW: D[0] @ 0009 in the MCP 0020 1 0AC500 150000 *HISW: Previous HISW @ 0015 001F (02,0009) 9 800000 000042 FCW 001E (02,0008) 0 000000 000002 Op: Dec: 2 001D (02,0007) 7 600128 201D50 PCW: ASD=00EA83, LL=2, Segment @ 0003:0009:2, Normal state 001C (02,0006) 4 000000 080001 TRY WORD, Normal Type 001B (02,0005) 6 800000 000800 SCW: Blockexit marker: Single-dim Arrays
See also the Limited Try Statement and the Try Expression.