Skip to content

73B SetMaxBytes

Validated   MON 73B (59 decimal) · Mnemonic SMAX · Group: File Operations (manual section 2.4)

Available from: All programs (manual compatibility box)

Emulation source: src/handlers/mon_73B_SetMaxBytes.c

Description

Sets the value of the maximum byte pointer in an opened file (i.e. the number of bytes minus 1). The specified number of bytes are stored when the file is closed. The error code 3 is returned if you later try to read beyond this size. Error code 3 means end of file.

  • The file must be opened for write.
  • This monitor call is only relevant for sequential access.

Parameters

Name Type Direction Description
FileNumber INTEGER In File number. See OpenFile.
MaxBytePointer INTEGER4 In Maximum file size in bytes (32-bit value).

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

See also

GetBytesInfile, SetStartByte

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 : FileNumber
INTEGER4 : MaxBytePointer
...
ON ROUTINEERROR DO
    IF ErrCode > 0 THEN ...
ENDON
Monitor_Call('SetMaxBytes', FileNumber, MaxBytePointer)
INTEGER FileNumber
INTEGER*4 MaxBytePointer
...
Monitor_Call('SetMaxBytes', FileNumber, MaxBytePointer)
IF (ErrCode .NE. 0) THEN ...
FileNumber : INTEGER2;
MaxBytePointer : LONGINT;
...
SetMaxBytes(FileNumber, MaxBytePointer);
IF ErrCode <> 0 THEN ...
01 FileNumber COMP.
01 MaxBytePointer COMP PIC S9(10).
01 ErrCode COMP.
...
MONITOR-CALL "SetMaxBytes" USING FileNumber, MaxBytePointer.
CALL "CbError" USING ErrCode.
IF ErrCode NOT = 0 GO ...
FileNumber : W BLOCK 1
MaxBytePointer : W BLOCK 1
ErrCode : W BLOCK 1
SetMaxBytes : EQU 37B9 + 73B
...
CALLG SetMaxBytes, 2, FileNumber, MaxBytePointer
    IF K GO ERROR
...
ERROR : W1 =: ErrCode              %ErrorCode in W1 register.
LDT  FILNO      %File number returned from earlier open.
LDD  POINT      %Maximum byte pointer.
MON  73         %Monitor call SetMaxBytes.
JMP  ERROR      %Error return from monitor call.
...             %Normal return.
ERROR,          %Error number in register A.
...
FILNO,
...
POINT,          %A double word.
...

ndmonlib implementation

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

Handler mon_73B_SetMaxBytes
Code lines 51 (non-blank, non-comment lines in the file)

Notes from the handler source

src/handlers/mon_73B_SetMaxBytes.c line 76

Set max bytes (pointer + 1 = number of bytes).
Per the carved L07 SMAX: this only RECORDS the logical max-byte length; the
physical file length is applied at CLOSE, not now. Immediately ftruncate-ing
here shortens a scratch file under the program's feet and makes a later
read-back deliver a truncated image. So just record the logical length; do
NOT touch the host file. (CLOSE/43B applies it.)

src/handlers/mon_73B_SetMaxBytes.c line 82

MaxBytePointer == 0xFFFFFFFF is the SINTRAN "unlimited / do not limit"
sentinel. new_size = ptr + 1 would overflow to 0 here, and CLOSE would
then truncate the file to zero bytes (silently destroying a just-written
object). Treat the sentinel as "no logical max": leave the file's actual
length alone and do NOT arm the CLOSE-time truncation.

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

Parameter notes

1. MaxBytePointer

Field Value
Note This is the maximum byte POINTER, i.e. the number of bytes MINUS 1. The handler stores max_byte_ptr + 1 as the logical length. Off-by-one here silently truncates one byte off every file.
Verified Yes

2. both parameters

Field Value
Note On ND-500 both are 32-bit words ('W BLOCK' in the manual's assembly_500 example), not halfwords.
Verified Yes

Return contract

  • Success: K flag cleared. The call only RECORDS the logical length; nothing is written to the file and the file is NOT truncated at this point.
  • Errors

    Code Octal Meaning
    87 127B File number out of range
    90 132B No file opened with this number
    111 157B Missing parameter
    124 174B Illegal parameter (file not open for write)

Verified

1. SMAX must NOT truncate the host file immediately. It records the logical max-byte length; the physical length is applied at CLOSE (43B).

Field Value
Evidence Carved L07 SMAX: the physical file length is applied at CLOSE, not by SMAX. The premature ftruncate was observed shortening NC's scratch file under its feet, so a later read-back delivered a truncated image. nd500x now sets a max_bytes_set flag consumed by mon_close_file. Commit 2618145.

2. This call's own manual text is the authoritative source for the SINTRAN end-of-file error code.

Field Value
Evidence "Error code 3 is returned if you later try to read beyond this size" - this is the cite that established EOF = 3 (003B) for 117B RFILE, which had wrongly used 55. Commit 01c286e.

Unverified

  • The carve does NOT byte-prove the SMAX -> CLOSE link. "SMAX records, CLOSE applies" is the consistent model adopted after the immediate-truncate was proven harmful; it is INFERRED, not read from the carve.
  • The manual says "This monitor call is only relevant for sequential access". nd500x accepts it for any write-capable open mode and only rejects ACCESS_SEQ_READ / ACCESS_RAND_READ.
  • nd500x never truncates a SCRATCH file at close even when SMAX ran (the scratch is about to be unlinked). Whether real SINTRAN applies the length to a scratch is unproven.
  • The error the real system returns when the file is not open for write is not established; nd500x returns 174B.

Discrepancies

Was Is Evidence
Emulator defect (fixed): SMAX ftruncate-d the host file immediately. SMAX records the length only; CLOSE applies it. Commit 2618145; carved L07 SMAX applies the length at CLOSE.

Sources

Doc Note Commit
SINTRAN III Monitor Calls (ND-860228.2 EN) The manual page this YAML was extracted from. Its "Error code 3 means end of file" line is the authoritative EOF-code cite for the whole file group.
nd500x/docs/MON_CSHARP_SYNC_HANDOFF.md Section "73B SMAX + 43B CLOSE - truncation deferral".
2618145 (nd500x) - SMAX records, CLOSE applies
01c286e (nd500x) - EOF code 3 established from this call's manual text

Source

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