% Common memoir-based style for LibMCPU reference manuals. % Shared XeLaTeX style for LibMCPU reference manuals. \usepackage{fontspec} \defaultfontfeatures{Ligatures=TeX,Scale=MatchLowercase} \setmainfont{Roboto} \setsansfont{Roboto} \setmonofont{DejaVu Sans Mono}[Scale=0.86] \usepackage{polyglossia} \setdefaultlanguage{russian} \setotherlanguage{english} \usepackage{microtype} \usepackage[strings]{underscore} \usepackage{xcolor} \definecolor{McpuBlue}{HTML}{1F3556} \definecolor{McpuBlue2}{HTML}{526A89} \definecolor{McpuGreen}{HTML}{2F8A57} \definecolor{McpuGreenBg}{HTML}{EDF6F0} \definecolor{McpuGrayBg}{HTML}{F4F6F8} \definecolor{McpuBlueBg}{HTML}{EEF3F8} \definecolor{McpuGray}{HTML}{5C6673} \definecolor{McpuRule}{HTML}{B9C6D8} \definecolor{McpuCode}{HTML}{F6F7F8} \definecolor{McpuUrl}{HTML}{B40B22} % A4 layout shared with the restyled LibMCPU book: generous text block, % but enough outer whitespace for technical figures and annotations. \setstocksize{297mm}{210mm} \settrimmedsize{297mm}{210mm}{*} \setlrmarginsandblock{18mm}{15mm}{*} \setulmarginsandblock{17mm}{19mm}{*} \setheadfoot{9mm}{8mm} \setheaderspaces{4mm}{*}{*} \checkandfixthelayout \usepackage{graphicx} \usepackage{tikz} \usetikzlibrary{arrows.meta,positioning,fit,calc,shapes.geometric,decorations.pathreplacing} \usepackage{array} \usepackage{booktabs} \usepackage{tabularx} \usepackage{longtable} \usepackage{multirow} \usepackage{enumitem} \setlist{nosep,leftmargin=2em} \setlist[itemize]{label=\textcolor{McpuBlue}{\small\textbullet}} \usepackage[most]{tcolorbox} \usepackage{listings} \usepackage{fvextra} \usepackage{hyperref} \usepackage{bookmark} \usepackage{needspace} \usepackage{ragged2e} \hypersetup{ unicode=true, colorlinks=true, linkcolor=McpuBlue, urlcolor=McpuUrl, citecolor=McpuBlue, pdfauthor={Andrew V. Kosteltsev}, pdflang={ru-RU} } \bookmarksetup{open,numbered} % memoir section and page styles. \setsecheadstyle{\Large\sffamily\bfseries\color{McpuBlue}} \setsubsecheadstyle{\large\sffamily\bfseries\color{McpuBlue}} \setsubsubsecheadstyle{\normalsize\sffamily\bfseries\color{McpuBlue2}} \setbeforesecskip{1.45\onelineskip} \setaftersecskip{0.55\onelineskip} \setbeforesubsecskip{1.05\onelineskip} \setaftersubsecskip{0.35\onelineskip} \setbeforesubsubsecskip{0.8\onelineskip} \setaftersubsubsecskip{0.25\onelineskip} \makepagestyle{libmcpu} \makeoddhead{libmcpu}{\small\sffamily\color{McpuGray}\DocShortTitle}{}{\small\sffamily\color{McpuGray}LibMCPU} \makeoddfoot{libmcpu}{}{\small\sffamily\thepage}{} \makeheadrule{libmcpu}{\textwidth}{0.3pt} \pagestyle{libmcpu} \setlength{\parindent}{1.25em} \setlength{\parskip}{0.20em} \setlength{\cftsectionnumwidth}{3.2em} \setlength{\cftsubsectionnumwidth}{4.2em} \setlength{\cftsubsubsectionnumwidth}{5.0em} \newtcolorbox{principle}{enhanced,breakable,colback=McpuGreenBg,colframe=McpuGreen,boxrule=0pt,leftrule=3pt,arc=0pt,left=10pt,right=10pt,top=8pt,bottom=8pt,before skip=8pt,after skip=8pt} \newtcolorbox{normative}{enhanced,breakable,colback=McpuBlueBg,colframe=McpuBlue,boxrule=0pt,leftrule=3pt,arc=0pt,left=10pt,right=10pt,top=8pt,bottom=8pt,before skip=8pt,after skip=8pt} \newtcolorbox{warningbox}{enhanced,breakable,colback=yellow!8,colframe=orange!75!black,boxrule=0pt,leftrule=3pt,arc=0pt,left=10pt,right=10pt,top=8pt,bottom=8pt,before skip=8pt,after skip=8pt} \newtcolorbox{codebox}{enhanced,breakable,colback=McpuCode,colframe=McpuRule,boxrule=0.4pt,arc=1pt,left=7pt,right=7pt,top=5pt,bottom=5pt,before skip=7pt,after skip=7pt} \lstdefinelanguage{MCPUAsm}{ morekeywords={LDI,LDR,LDC,MOV,IADD,ISUB,IAND,IOR,IXOR,INOT,ICMP,ITEST,ISHL,ISHR,ISAL,ISAR,IROL,IROR,IRCL,IRCR,ISHLN,ISHRN,ISALN,ISARN,IROLN,IRORN,IRCLN,IRCRN,IINC,IDEC,IXCHG,ICPY,ICVT,IMUL,ISMUL,IDIV,ISDIV,IBITSLEN,RADD,RSUB,RMUL,RDIV,RSQRT,RSIN,RCOS,RTAN,RASIN,RACOS,RATAN,RLOG,RLOG10,RLOG2,REXP,RSINH,RCOSH,RTANH,RPOW,RHYPOT,RATAN2,RNEG,RABS,RCMP,RCPY,RCVT,RFLOOR,RCEIL,RROUND,RFREXP,RLDEXP,RLOGB,RMODF,RREMAIN,RLOG1P,REXPM1,RASINH,RACOSH,RATANH,ITOR,UITOR,RTOI,RTOUI,RISNEG,RSIGN,RISIND,RISNAN,RISNANMAX,RISNANMIN,RISINF,RISSIGNULL,RCONST,CADD,CSUB,CMUL,CDIV,CEXP,CSIN,CCOS,CSINH,CCOSH,CLOG,CSQRT,CPOW,CREAL,CIMAG,CRTOC,CGEN,CPOLAR,CCONJ,CABS,CNORM,CARG,CISEQ,CISNE,CCPY,CCVT,JMP,JSET,JCLR,JMPP,CALL,CALLP,RET,PUSH,POP,LDSP,STSP,ADJSP,PUSHFP,SETFP,RESTSP,POPFP,LDFP,STFP,LEAFP,SETSP,LOAD,STORE,LEA,LEASP,LOADP,STOREP,PTRADD,PTRSUB,PTRDIFF,BMOV,BMOVI,BSWAP,END,EXIT,HALT,SYSCALL}, sensitive=false, morecomment=[l]{;}, morecomment=[l]{\#}, morestring=[b]" } \lstset{ language=MCPUAsm, basicstyle=\ttfamily\small, columns=fullflexible, keepspaces=true, showstringspaces=false, breaklines=true, breakatwhitespace=false, postbreak=\mbox{\textcolor{McpuGray}{$\hookrightarrow$}\space}, frame=single, rulecolor=\color{McpuRule}, backgroundcolor=\color{McpuCode}, aboveskip=7pt, belowskip=7pt, framerule=0.4pt } % Long shell commands and verbatim data must never run outside the page. \DefineVerbatimEnvironment{McpuCommand}{Verbatim}{fontsize=\small,frame=single,framesep=3mm,rulecolor=\color{McpuBlue!35},breaklines=true,breakanywhere=true,breaksymbolleft={},breaksymbolright={},breakindent=1.5em} \DefineVerbatimEnvironment{McpuCode}{Verbatim}{fontsize=\small,frame=single,framesep=3mm,rulecolor=\color{McpuGray!35},breaklines=true,breakanywhere=true,breaksymbolleft={},breaksymbolright={}} \newcolumntype{Y}{>{\raggedright\arraybackslash}X} \newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}} \urlstyle{tt}\newcommand{\code}[1]{\nolinkurl{#1}} \newcommand{\field}[1]{\texttt{#1}} \newcommand{\MCPU}{LibMCPU} \newcommand{\MELF}{MELF} \newcommand{\PTR}{PTR64} \newcommand{\REG}{REG24} \newcommand{\term}[2]{\textbf{#1} (\textit{#2})} \newcommand{\figlabel}[1]{\sffamily\small\color{McpuGray}#1} \newcommand{\tabhead}[1]{\sffamily\bfseries #1} \newcommand{\DocTitlePage}[3]{% \begin{titlingpage} \thispagestyle{empty} \vspace*{30mm} {\sffamily\fontsize{29}{34}\selectfont\bfseries\color{McpuBlue} #1\par} \vspace{8mm} {\sffamily\fontsize{16}{21}\selectfont\color{McpuBlue2} #2\par} \vspace{4mm} {\sffamily\large\color{McpuGray} #3\par} \vfill \begin{tcolorbox}[width=0.86\textwidth,colback=McpuGreenBg,colframe=McpuGreen,boxrule=0pt,leftrule=4pt,arc=0pt] \textbf{Нормативное техническое руководство LibMCPU.} Документ описывает текущий архитектурный контракт и намеренно не привязан к номеру выпуска пакета. \end{tcolorbox} \vfill {\small\sffamily\color{McpuGray}Техническая редакция, октябрь 2026\par} \end{titlingpage} } \setcounter{tocdepth}{2} \setcounter{secnumdepth}{3} % Reference manuals have no chapter level; memoir otherwise prefixes sections % with the implicit chapter number 0. \renewcommand{\thesection}{\arabic{section}} \renewcommand{\thesubsection}{\thesection.\arabic{subsection}} \renewcommand{\thesubsubsection}{\thesubsection.\arabic{subsubsection}} \renewcommand{\thefigure}{\arabic{figure}} \renewcommand{\thetable}{\arabic{table}} \renewcommand{\contentsname}{Содержание} \newcommand{\ManualIntro}[1]{\begin{principle}\textbf{Статус документа.} #1\end{principle}} \newcommand{\smallcapslabel}[1]{\textcolor{McpuBlue}{\textbf{#1}}} \newenvironment{compactdesc}{\begin{description}[style=multiline,leftmargin=48mm,labelwidth=44mm,labelsep=4mm,labelindent=0pt,font=\normalfont\bfseries\color{McpuBlue}]}{\end{description}} \emergencystretch=4em\tolerance=1800 \raggedbottom