Аналитический ум

5 views
Skip to first unread message

Leo B.

unread,
Jun 13, 2026, 12:20:09 PM (yesterday) Jun 13
to БЭСМ-6
После скармливания ИИ (Claude Opus 4.7) текста Паскаль-компилятора он оказался способен неплохо понимать и комментировать мадленовский текст рантайм-библиотеки Паскаля.

Вот откомментированный  набор процедур работы с файлами P/SYS    https://github.com/leobru/pas2c-metamorph/blob/main/paslib/p_sys.asm

C===========================================================
C P/SYS - core Pascal runtime: file open/get/put/reset/close
C   and the abort handler used by all runtime fatal errors.
C
C Per-call register convention (see FILE.md):
C   M12  = base of the FILE record being acted on
C   M1   = pointer into the runtime constant table.  The
C          read-only constants the routines rely on are at
C          fixed offsets, e.g. [M1+7]='0', [M1+8]=1 (1U used
C          for AOX/ARX/AEX bit-0 work, NOT f^!), [M1+9]=
C          integer-tag mask, [M1+12]=positive-mantissa mask,
C          [M1+25B]=MSB.  The first six slots ([M1+3..+5] and
C          [M1+35B..+37B]) are runtime scratch.
C   M13  = link register set by the calling VJM
C   M14  = secondary link (used inside packed-mode helpers)

...и так далее (видны следы размышлений и дискуссий со мной). 

Механизм работы процедуры динамического выделения памяти тоже был понят довольно неплохо:
https://github.com/leobru/pas2c-metamorph/blob/main/paslib/p_nw.asm

C===========================================
C P/NW: allocate M14 words of heap memory.
C   In:   M14 = requested size in words
C   Out:  ACC = address of newly-allocated block (success)
C         or branches via P/HT after printing "NO GLOBAL MEMORY"
C   M1-relative globals (M1 = 4000000B):
C     27B (=23) HEAPPTR  bump-allocator pointer (top of used heap)
C     30B (=24) HEAPLIM  ~(SP after stack grows) - sentinel for overflow
C     31B (=25) FREELST  head of doubly-linked free-list (0 = empty)
C     32B (=26) HEAPBSE  initial heap base, saved by P/GD
C===========================================

На всякий случай замечу, что библиотека была взята с образа диска из ОИЯИ, где версия собственно компилятора более старая, чем на образах дисков из ИТМиВТ.

А вот описание структуры FILE: 
https://github.com/leobru/pas2c-metamorph/blob/main/FILE.md

Также удалось выяснить назначение недокументированной процедуры PASGVNF из библиотеки Паскаля: https://github.com/leobru/pas2c-metamorph/blob/main/paslib/pasgvnf.asm

C===========================================================
C PASGVNF - "Pascal Give N-th File element".
C
C Random-access GET on a Pascal file: positions f^ on the
C N-th element of file M12 and unpacks it into the user's
C destination, then returns to the caller.  Used by the
C runtime when the program writes `f^[n]`-style indexed
C access on a packed file (the helper-name table in the
C compiler does not call this entry directly; it is
C reached from a wrapper inside another runtime module).


Очень забавно наблюдать, как он сам себе выдумывает расшифровки мадленовских мнемоник команд. Так, например, WTC у него стало "Working Tag Constant". 

Leo
Reply all
Reply to author
Forward
0 new messages