Skip to content

13B ClearInBuffer

Validated   MON 13B (11 decimal) · Mnemonic CIBUF · Group: Input and Output Monitor Calls (manual section 2.5)

Available from: All programs (manual compatibility box)

Emulation source: src/handlers/mon_13B_ClearInBuffer.c

Description

Clears a device input buffer. Input from character devices, e.g. terminals, are temporarily stored in this buffer.

  • You can use logical device number 1 for your own terminal in background programs.

Parameters

Name Type Direction Description
DeviceNumber INTEGER In Logical device number. See appendix B.

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

See also

@CLEAR-DEVICE, ClearOutBuffer, and DeviceControl

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 Yes Yes No

Examples

From the manual (OCR text, not corrected).

INTEGER : DeviceNumber
...
ON ROUTINEERROR DO
    IF ErrCode >< 0 THEN ...
ENDON
Monitor_Call('ClearInBuffer', DeviceNumber)
INTEGER DeviceNumber
...
Monitor_Call('ClearInBuffer', DeviceNumber)
IF (ErrCode .NE. 0) THEN ...
DeviceNumber : INTEGER2;
...
ClearInBuffer(DeviceNumber);
IF ErrCode <> 0 THEN ...
01 DeviceNumber COMP.
01 ErrCode COMP.
...
MONITOR-CALL "ClearInBuffer" USING DeviceNumber.
CALL "CbError" USING ErrCode.
IF ErrCode NOT = 0 GO ...
DeviceNumber : W BLOCK 1
ErrCode : W BLOCK 1
ClearInBuffer : EQU 37B9 + 13B
...
CALLG ClearInBuffer, 1, DeviceNumber
IF K GO ERROR
...
ERROR : W1 =: ErrCode            %ErrorCode in W1 register.
LDT   DEVNO       %Load register T with logical device number.
MON   13          %Monitor call ClearInBuffer.
JMP   ERROR       %Error return from monitor call.
...               %Normal return.
ERROR, ...        %Error number in register A.
...
DEVNO, ...

ndmonlib implementation

Validated Registered MON_STATUS_VALIDATED in src/core/mon_registry.c: implemented, tested and working.

Handler mon_13B_ClearInBuffer
Code lines 14 (non-blank, non-comment lines in the file)

Notes from the handler source

src/handlers/mon_13B_ClearInBuffer.c line 17

CIBUF discards any UNREAD, type-ahead input pending in a character
device's buffer. The emulator has no separate hardware type-ahead
buffer to flush, and the queued-console input models the program's
OWN scripted command stream - clearing that would drop commands the
program still intends to read. So this is a success no-op: there is
no pending device-buffer state to clear.

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) stub
nd500x handler nd500x/src/libmon/handlers/mon_13B_ClearInBuffer.c
Last updated 2026-07-17

Stub behaviour

SUCCESS NO-OP - SAY SO. 13B CIBUF returns success WITHOUT DISCARDING ANYTHING. Two reasons, both deliberate: (1) the emulator has no separate hardware type-ahead buffer to flush; (2) the queued-console input models the program's OWN SCRIPTED command stream, and clearing it would drop commands the program still intends to read. A guest that relies on CIBUF actually discarding type-ahead will NOT behave correctly here.

Observed calls

Caller Params Expectation Note
ND linker (linker-b01.dom), startup Devicenumber: not recorded Called during linker startup terminal configuration. The linker only needs it not to fail; the success no-op is enough for it to proceed. Before this handler existed the auto-generated stub returned error -1 and the linker crashed in startup device configuration. Commit 940ba39.

Return contract

  • Success: K flag cleared.
  • Errors

    Code Octal Meaning
    111 157B Missing parameter (no CALLG args)

Verified

Claim Evidence
The linker proceeds past its startup with the success no-op. Commit 940ba39: "13B CIBUF (ClearInBuffer): success no-op". The linker then advanced to MON 144B MAGTP. ctest 16/16 green, 58/58 MON unit tests.

Unverified

  • THE CARVE WAS NOT MINED FOR THIS ENTRY. A carve folder exists at NDInsight/tools/sintran-segment-carver/versions/L-VSX-500/re/mon-analysis/013B-ClearInBuffer/ and has NOT been read into this block. The real worker's semantics (which buffer, what it does to a pending break count, what it returns for a non-terminal device) are therefore unknown here.
  • nd500x ignores DeviceNumber entirely - it does not validate the device class and does not reject file numbers. Whether real CIBUF errors on a file number is unknown.

Sources

Doc Note
SINTRAN III Monitor Calls (ND-860228.2 EN) The manual body of this YAML.

Source

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