Skip to content

313B InBufferState

In progress   MON 313B (203 decimal) · Mnemonic IBRISZ · Group: Input and Output Monitor Calls (manual section 2.5)

Available from: All programs (manual compatibility box)

Emulation source: src/handlers/mon_313B_InBufferState.c

Description

Gets information about an input buffer. The current number of bytes in it, and the number of bytes until a break character, are returned.

  • Use ExecutionInfo to get the logical device number for terminals. You can specify 1 for your own terminal.

Parameters

Name Type Direction Description
DeviceNumber INTEGER In Logical device number. See appendix B.
NoInBuffer INTEGER Out Number of bytes currently in the buffer.
NoUntilBreak INTEGER Out Number of bytes until break character (0 if no break in buffer).

Direction: In = the program supplies the value, Out = the call returns it, In/Out = both.

See also

InBufferSpace, ClearInBuffer, OutBufferSpace

Compatibility

Machines Users Programs
ND-100 and ND-500 All users All programs

The manual's compatibility box for this call, word for word.

Yes/no fields from the YAML extraction (not in the manual's words):

ND-100 ND-500 User programs RT programs System programs
Yes Yes No No No

Examples

From the manual (OCR text, not corrected).

INTEGER : DeviceNumber, NoInBuffer, NoUntilBreak
...
ON ROUTINEERROR DO
  IF ErrCode > 0 THEN ...
ENDON
Monitor_Call('InBufferState', DeviceNumber, NoInBuffer, NoUntilBreak)
INTEGER DeviceNumber, NoInBuffer, NoUntilBreak
...
Monitor_Call('InBufferState', DeviceNumber, NoInBuffer, NoUntilBreak)
IF (ErrCode .NE. 0) THEN ...
DeviceNumber, NoInBuffer, NoUntilBreak : INTEGER2;
...
InBufferState(DeviceNumber, NoInBuffer, NoUntilBreak);
IF ErrCode <> 0 THEN ...
01 DeviceNo COMP.
01 NoInBuffer COMP.
01 NoUntilBreak COMP.
01 ErrCode COMP.
...
MONITOR-CALL "InBufferState" USING DeviceNo, NoInBuffer, NoUntilBreak.
CALL "CbError" USING ErrCode.
IF ErrCode NOT = 0 GO ...
DeviceNumber : W BLOCK 1
NoInBuffer : W BLOCK 1
NoUntilBreak : W BLOCK 1
ErrCode : W BLOCK 1
InBufferState : EQU 3789 + 313B
...
    CALLG InBufferState, 2, DeviceNumber, NoUntilBreak
    IF K GO ERROR
    W1 := NoOfBytes
...
ERROR : W1 =: ErrCode                    %ErrorCode in W1 register.
LDT DEVNO %Logical device number.
MON 313 %Monitor call InBufferState.
JMP ERROR %Error return from monitor call.
STA COUNT %Normal return, store number of bytes in inbuffer.
STX NOBRK %Store number of bytes in inbuffer until break.
...
ERROR, ... %Error number in register A.
...
DEVNO, ...
COUNT, 0
NOBRK, 0

ndmonlib implementation

In progress Registered MON_STATUS_IN_PROGRESS: partly implemented. The dispatcher calls the handler.

Handler mon_313B_InBufferState
Code lines 18 (non-blank, non-comment lines in the file)

Notes from the handler source

src/handlers/mon_313B_InBufferState.c line 18

Implemented against the carved contract (mon-analysis/313B-InBufferState):
  r->T (arg0) = logical device number; returns
    NoInBuffer   = characters currently held in the terminal input ring
    NoUntilBreak = characters before the next break (0 if no break)
Here the "terminal input ring" is our queued console input. The ND LINKER
calls IBRISZ(device=1, &NoInBuffer) (2-arg form) at startup to poll whether a
command is waiting. Report the remaining queued input length so the linker's
command reader proceeds instead of blocking. (device/break accounting is
modelled, not byte-exact - the worker link is uncarved; refine if needed.)

src/handlers/mon_313B_InBufferState.c line 38

arg2 = NoUntilBreak (3-arg form). Per the carved manual contract
(ND-860228 lines 14054-14056): "Number of bytes before break (zero if no
break character in the buffer)." NOT the same as NoInBuffer - a buffer
with no CR yet must report 0.

src/handlers/mon_313B_InBufferState.c line 46

Also return the count in W1. The ND LINKER reads its input-buffer length
from W1 after the IBRISZ CALLG (linker-b01.dom 0xB004DA8F -> W1 =: b.68 ->
used as the command-line length). Without this, W1 keeps the leftover
CALLG target address (0xF80000CB) and the linker's command parser walks
off the end and traps.

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_313B_InBufferState.c
Last updated 2026-07-17

Health note

313B IBRISZ IS PROVEN HEALTHY. It returns the count, it writes its OUT parameter(s), AND it sets W1 - and the carve confirms it reports the TERMINAL input ring. If you are hunting a blocker, it is not here. This is recorded explicitly because 313B sat under suspicion during the linker investigation and was cleared.

Parameter notes

1. NoInBuffer

Field Value
Note Returned THREE ways, and all three matter: in W1 (which is what the ND linker actually reads), and written to CALLG arg 1 as a 32-bit word. The linker uses the 2-arg form IBRISZ(device = 1, &NoInBuffer).
Verified Yes

2. NoUntilBreak

Field Value
Note Only written in the 3-arg form. nd500x returns the SAME value as NoInBuffer, reasoning that its queued input is line-oriented and CR-terminated, so a break is present whenever there is any input. That equality is a MODEL, not a carved behaviour.
Verified No

Observed calls

1. ND linker (linker-b01.dom) @0xB004DA8F

Field Value
Params Devicenumber: 1
Expectation The linker calls IBRISZ at startup to poll whether a command is waiting, then reads its input-buffer length FROM W1 immediately after the CALLG (0xB004DA8F -> W1 =: b.68) and uses it as the command-line length.
Note THE W1 RETURN IS LOAD-BEARING. Without it W1 keeps the leftover CALLG target address 0xF80000CB, which the linker takes as a length of ~4.29e9, walks off the end of its command buffer and takes a protection violation. Writing only the OUT parameter is NOT enough. Commit fc3ac5b.

Return contract

  • Success: K flag cleared; count in W1 and in the OUT parameter(s).
  • Errors

Verified

1. The carved contract: arg0 is the logical device number; the call returns NoInBuffer = characters currently held in the TERMINAL INPUT RING, and NoUntilBreak = characters before the next break (0 if no break, BRKMAX-limited). Terminals walk the input ring; TAD and internal-buffer devices take other paths; FILES ARE NOT VALID HERE.

Field Value
Evidence Carve NDInsight/tools/sintran-segment-carver/versions/L-VSX-500/re/mon-analysis/313B-InBufferState/ - IBRSIZ worker body at 025-S3IRPIT :110543B..110770B (byte offset 47814), real SINTRAN L bytes, structurally IBRSIZ: CALL GET0 / CALL GZTREG prologue, IOF ring scan, LBYT byte walk.

2. GOTAB[313B] = 112164B - level-14 dispatch, byte-proven AND live-confirmed.

Field Value
Evidence SINTRAN-DATA_commoncode :071546B (= GOTAB 071233B + 313), byte offset 59084 -> 94 74 (big-endian 0x9474 = 112164B); matches a live read of the running system. The 112164B stub is real code (JMP I 10) whose pointer word 112174B reads 112247B, in 025-S3IRPIT at byte offset 49384 -> aa 08 cc 4d ba 07 ab 17.

3. Reporting the remaining queued input length makes the linker's command reader proceed instead of blocking.

Field Value
Evidence Commit fc3ac5b - the ~4.29e9 length and its protection violation disappear.

Unverified

  • THE DISPATCH-TO-WORKER LINK IS NOT PROVEN, and the carve says so plainly: on the static evidence GOTAB[313] resolves (via the 112164B stub) to 112247B, NOT to the 110543B IBRSIZ body. The final worker is register-loaded at runtime through a resident second-level / CALLPROC-style computed jump that is not present as a static pointer in ANY carved segment. The worker body is attached by structure and symbol (IBRSIZ / T2P06), and the carve marks that link MISATTRIBUTED.
  • nd500x's device and break accounting is MODELLED, NOT BYTE-EXACT (the handler says so). It ignores DeviceNumber entirely and reports mon_get_console_input_remaining() - the emulator's queued console input - as "the terminal input ring". It does not reject file numbers, which the carve says are not valid here.
  • NoUntilBreak == NoInBuffer is a modelling shortcut. The real call is BRKMAX- limited and returns 0 when there is no break; nd500x never returns a distinct value.

Sources

Doc Note
SINTRAN III Monitor Calls (ND-860228.2 EN) The manual body of this YAML.
NDInsight/tools/sintran-segment-carver/versions/L-VSX-500/re/mon-analysis/313B-InBufferState/README.md Dispatch + IBRSIZ worker carve, including its own honest caveats section.

Source

SINTRAN III Monitor Calls (ND-860228.2 EN), page 317.