422B GetScratchSegment¶
Validated MON 422B (274 decimal) · Mnemonic GSWSP · Group: Segment Administration (manual section 2.12)
Available from: not known - no compatibility box captured from the manual
Emulation source: src/handlers/mon_422B_GetScratchSegment.c
Description¶
Connects an empty data segment to the user's domain and reserves space for it on the swap file. The segment is assigned the default name "SCRATCH-SEGMENT:DSEG".
Parameters¶
| Name | Type | Direction | Description |
|---|---|---|---|
SizeInBytes |
INTEGER | In | Segment size in bytes. |
LogSegmentNo |
INTEGER | In | Logical segment number to use. Use 0 for system to select first available free segment. |
RetLogSegmentNo |
INTEGER | Out | Returns the logical segment number actually selected. |
Direction: In = the program supplies the value, Out = the call returns it, In/Out = both.
See also¶
Compatibility¶
| ND-100 | ND-500 | User programs | RT programs | System programs |
|---|---|---|---|---|
| No | No | Yes | Yes | No |
From the YAML extraction; this call's page in the manual had no compatibility box that was captured.
Examples¶
From the manual (OCR text, not corrected).
INTEGER : SizeInBytes, LogSegmentNo, RetLogSegNo
...
ON ROUTINEERROR DO
IF ErrCode >< 0 THEN ...
ENDON
Monitor_Call('GetScratchSegment', SizeInBytes, LogSegmentNo, RetLogSegNo)
INTEGER SizeInBytes, LogSegmentNo, RetLogSegmentNo
...
Monitor_Call('GetScratchSegment', SizeInBytes, LogSegmentNo, RetLogSegmentNo)
IF (ErrCode .NE. 0) THEN ...
SizeInBytes, LogSegmentNo, RetLogSegmentNo : LONGINT;
...
GetScratchSegment(SizeInBytes, LogSegmentNo, RetLogSegmentNo);
IF ErrCode <> 0 THEN ...
01 SizeInBytes COMP.
01 LogSegmentNo COMP.
01 RetLogSegmentNo COMP.
01 ErrCode COMP.
...
MONITOR-CALL "GetScratchSegment" USING SizeInBytes, LogSegmentNo, RetLogSegmentNo.
CALL "CbError" USING ErrCode.
IF ErrCode NOT = 0 GO ...
SizeInBytes : W BLOCK 1
LogSegmentNo : W BLOCK 1
RetLogSegmentNo : W BLOCK 1
ErrCode : W BLOCK 1
GetScratchSegment : EQU 37B9 + 422B
...
CALLG GetScratchSegment, 3, SizeInBytes, LogSegmentNo, RetLogSegmentNo
IF K GO ERROR
...
ERROR : W1 := ErrCode %ErrorCode in W1 register.
ndmonlib implementation¶
Validated Registered MON_STATUS_VALIDATED in src/core/mon_registry.c: implemented, tested and working.
| Handler | mon_422B_GetScratchSegment |
| Code lines | 31 (non-blank, non-comment lines in the file) |
Emulation research¶
Source
This section comes from the emulation: block of the call's YAML file in the NDInsight repo. It records what was learned while implementing the call in nd500x; its status is nd500x's, not ndmonlib's.
| Status (nd500x) | verified |
| nd500x handler | nd500x/src/libmon/handlers/mon_422B_GetScratchSegment.c |
| Last updated | 2026-07-17 |
Note¶
HEALTHY. This is the call to copy when implementing a segment-returning MON call. It does real work through the host allocate_segment callback (a genuine MMU/PST-backed scratch segment), and it WRITES ITS OUT PARAMETER. Contrast 412B FSCNT, which was bookkeeping-only and did NOT write its OUT parameter - see the defect-class note below.
Parameter notes¶
1. RetLogSegmentNo
| Field | Value |
|---|---|
| Note | OUT PARAMETER - AND THIS IS THE WHOLE POINT. nd500x writes it with mon_write_param_word(ctx, 2, assigned_segment) whenever arg_count >= 3. THE OUT-PARAMETER DEFECT CLASS: a handler that returns SUCCESS without writing its OUT/IO parameter causes failures that surface TENS OF THOUSANDS of instructions later, in a completely unrelated place. Confirmed instances: 412B FSCNT (commit 73ac594 - the caller read 0 from the stale cell, addressed segment 0, read zeros 67 times at vaddr 0x00000000, never touched the real mapping at 0x20000000, and failed with "ERROR can't generate code" WITHOUT EVER READING ITS INPUT) and 144B MAGTP function 0 (commit 6ad9c09 - the linker''s tables stayed blank, it walked blank memory as records, computed a bogus pointer 0x40404040, took a protect violation, and the symptom appeared ~83000 instructions later as a stack overflow). If a call has an OUT or IO parameter, the write IS the contract. 422B GSWSP is the reference for doing it right - commit 73ac594 fixed 412B by making it write "like 422B GSWSP''s mon_write_param_word". |
| Verified | Yes |
2. SegmentSize / LogSegmentNo / RetLogSegmentNo
| Field | Value |
|---|---|
| Note | On ND-500 all three INTEGER parameters are 32-bit words (W BLOCK). SegmentSize is in BYTES. LogSegmentNo = 0 asks the system to pick the first available free segment. |
| Verified | Yes |
3. RetLogSegmentNo
| Field | Value |
|---|---|
| Note | The handler header says it is "only written if LogSegmentNo was 0", but the code writes it UNCONDITIONALLY whenever a third argument is present. Writing it always is the safer behaviour and nothing has been observed to object; the header text is the stale one. |
| Verified | Yes |
Observed calls¶
1. CAT-500 code generator (cat-cat5-b06.dom), startup
| Field | Value |
|---|---|
| Params | Logsegmentno: 0 |
| Expectation | Returns AssignedSeg=2 (observed 2026-07-17). CAT-500 issues GSWSP as part of its fixed startup sequence (11B TIME, 114B TUSED, 143B RSIO, 422B GSWSP, 41B ROBJE, 76B SETBS, 62B RMAX, 73B SMAX, 504B DVOUTS, 503B DVINST) before its banner and "Cat-500:" prompt. |
| Note | Audited clean: "422B GSWSP: segment mapping clean" (docs/HANDOFF_MON_COMPLETENESS.md); "422B GSWSP uses the real allocate_segment callback (genuine MMU-backed scratch segment - not a blocker)" (docs/CAT500_UECOM_CSHARP_HANDOFF.md Part C). |
Return contract¶
- Success: K flag cleared; RetLogSegmentNo written with the assigned logical segment number; the segment is connected to the caller''s domain and MMU-backed.
-
Errors
1. -1
Field Value Octal None Meaning NOT a SINTRAN code. Internal guard when the host allocate_segment callback is absent. 2. None
Field Value Octal None Meaning On allocation failure the handler passes the CALLBACK''S return code straight through to mon_set_error. Those values are host-internal and are NOT the SINTRAN Appendix A codes.
Verified¶
1. nd500x allocates a real MMU/PST-backed segment and reports its number.
| Field | Value |
|---|---|
| Evidence | Handler calls ctx->allocate_segment(cpu, machine, 0xFF, requested_segment, segment_size, &assigned_segment) - 0xFF is the sentinel for "use the current domain", which the callback reads from cpu->CED. Observed AssignedSeg=2 for CAT-500. Audited "segment mapping clean". |
2. 422B is the model for the OUT-parameter contract.
| Field | Value |
|---|---|
| Evidence | Commit 73ac594 and docs/MON_CSHARP_SYNC_HANDOFF.md PART C: "412B FSCNT: return the assigned SegmentNo through the OUTPUT arg slot (like 422B GSWSP''s mon_write_param_word), not the deprecated W1/error-code channel". |
Unverified¶
- NO CARVED WORKER EXISTS FOR THIS CALL. 422B belongs to the ND-500 monitor family (410B-427B) dispatched through the S3SM5 numeric vector table, and its vector slot is EMPTY: slot 0x0284 = 0x0000, byte-proven, in segment 030-S3SM5 (load base 40000B). The actual servicing point is NOT LOCATED. The carve folder deliberately contains no .ASM and no .pseudo.c - "there is no worker in any carved segment ... Fabricating one would be wrong". The short name GSWSP appears in no carved segment''s symbol table.
- Therefore SINTRAN''s real error codes for this call are UNKNOWN. nd500x returns host callback codes, which are certainly not them.
- The default segment name "SCRATCH-SEGMENT:DSEG" the manual documents is not modelled - nd500x names nothing.
- "Reserves space for it on the swap file" has no emulator analogue; there is no swap file.
- The handler does not check arg_count before reading arguments 0 and 1.
Sources¶
| Doc | Note |
|---|---|
| NDInsight/tools/sintran-segment-carver/versions/L-VSX-500/re/mon-analysis/422B-GetScratchSegment/README.md | Documents the ABSENCE: S3SM5 vector slot 0x0284 = 0x0000 (byte-proven), servicing point NOT LOCATED, no worker body anywhere. |
| nd500x/docs/CAT500_UECOM_CSHARP_HANDOFF.md | Part C - GSWSP is clean; the CAT-500 blocker is 412B FSCNT, not this call. |
| nd500x/docs/HANDOFF_MON_COMPLETENESS.md | Audit line: "422B GSWSP: segment mapping clean". |
Source¶
SINTRAN III Monitor Calls (ND-860228.2 EN).