⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pxin2.n

📁 早期freebsd实现
💻 N
📖 第 1 页 / 共 2 页
字号:
.\" Copyright (c) 1979 The Regents of the University of California..\" All rights reserved..\".\" Redistribution and use in source and binary forms, with or without.\" modification, are permitted provided that the following conditions.\" are met:.\" 1. Redistributions of source code must retain the above copyright.\"    notice, this list of conditions and the following disclaimer..\" 2. Redistributions in binary form must reproduce the above copyright.\"    notice, this list of conditions and the following disclaimer in the.\"    documentation and/or other materials provided with the distribution..\" 3. All advertising materials mentioning features or use of this software.\"    must display the following acknowledgement:.\"	This product includes software developed by the University of.\"	California, Berkeley and its contributors..\" 4. Neither the name of the University nor the names of its contributors.\"    may be used to endorse or promote products derived from this software.\"    without specific prior written permission..\".\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION).\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF.\" SUCH DAMAGE..\".\"	@(#)pxin2.n	5.2 (Berkeley) 4/17/91.\".if !\n(xx .so tmac.p.nr H1 1.if n .ND.NHOperations.NH 2Naming conventions and operation summary.PPTable 2.1 outlines the opcode typing convention.The expression ``a above b'' means that `a' is on topof the stack with `b' below it.Table 2.3 describes each of the opcodes.The character `*' at the end of a name specifies thatall operations with the root prefix before the `*'are summarized by one entry.Table 2.2 gives the codes used to describe the type inline data expected by each instruction..sp 2.so table2.1.n.sp 2.so table2.2.n.bp.so table2.3.n.bp.NH 2Basic control operations.LP.SHHALT.IPCorresponds to the Pascal procedure.I halt ;causes execution to end with a post-mortem backtrace as if a run-timeerror had occurred..SHBEG s,W,w,".IPCauses the second part of the block mark to be created, and.I Wbytes of local variable space to be allocated and cleared to zero.Stack overflow is detected here..I wis the first line of the body of this section for error traceback,and the inline string (length s) the character representation of its name..SHNODUMP s,W,w,".IPEquivalent to.SM BEG ,and used to begin the main program when the ``p''option is disabled so that the post-mortem backtrace will be inhibited..SHEND.IPComplementary to the operators.SM CALLand.SM BEG ,exits the current block, calling the procedure.I pcloseto flush buffers for and release any local files.Restores the environment of the caller from the block mark.If this is the end for the main program, all files are.I flushed,and the interpreter is exited..SHCALL l,A.IPSaves the current line number, return address, and active display entry pointer.I dpin the first part of the block mark, then transfers to the entry pointgiven by the relative address.I A ,that is the beginning of a.B procedureor.B functionat level.I l..SHPUSH s.IPClears.I sbytes on the stack.Used to make space for the return value of a.B functionjust before calling it..SHPOP s.IPPop.I sbytes off the stack.Used after a.B functionor.B procedurereturns to remove the arguments from the stack..SHTRA a.IPTransfer control to relative address.I aas a local.B gotoor part of a structured statement..SHTRA4 A.IPTransfer control to an absolute address as part of a non-local.B gotoor to branch over procedure bodies..SHLINO s.IPSet current line number to.I s.For consistency, check that the expression stack is emptyas it should be (as this is the start of a statement.)This consistency check will fail only if there is a bug in theinterpreter or the interpreter code has somehow been damaged.Increment the statement count and if it exceeds the statement limit,generate a fault..SHGOTO l,A.IPTransfer control to address.I Athat is in the block at level.I lof the display.This is a non-local.B goto.Causes each block to be exited as if with.SM END ,flushing and freeing files with.I pclose,until the current display entry is at level.I l..SHSDUP*.IPDuplicate the word or long on the top ofthe stack.This is used mostly for constructing sets.See section 2.11..NH 2If and relational operators.SHIF a.IPThe interpreter conditional transfers all take place using this operatorthat examines the Boolean value on the top of the stack.If the value is.I true ,the next code is executed,otherwise control transfers to the specified address..SHREL* r.IPThese take two arguments on the stack,and the sub-operation code specifies the relational operation tobe done, coded as follows with `a' above `b' on the stack:.DS.mD.TSlb lbc a.Code	Operation_0	a = b2	a <> b4	a < b6	a > b8	a <= b10	a >= b.TE.DE.IPEach operation does a test to set the condition codeappropriately and then does an indexed branch based on thesub-operation code to a test of the condition here specified,pushing a Boolean value on the stack..IPConsider the statement fragment:.DS.mD\*bif\fR a = b \*bthen\fR.DE.IPIf.I aand.I bare integers this generates the following code:.DS.TSlp-2w(8) l.RV4:\fIl	a\fRRV4:\fIl	b\fRREL4	\&=IF	\fIElse part offset\fR.sp.T&c s.\fI\&... Then part code ...\fR.TE.DE.NH 2Boolean operators.PPThe Boolean operators.SM AND ,.SM OR ,and.SM NOTmanipulate values on the top of the stack.All Boolean values are kept in single bytes in memory,or in single words on the stack.Zero represents a Boolean \fIfalse\fP, and one a Boolean \fItrue\fP..NH 2Right value, constant, and assignment operators.SHLRV* l,A.brRV* l,a.IPThe right value operators load values on the stack.They take a block number as a sub-opcode and load the appropriatenumber of bytes from that block at the offset specifiedin the following word onto the stack. As an example, consider.SM LRV4 :.DS.mD_LRV4:	\fBcvtbl\fR	(lc)+,r0	#r0 has display index	\fBaddl3\fR	_display(r0),(lc)+,r1	#r1 has variable address	\fBpushl\fR	(r1)	#put value on the stack	\fBjmp\fR	(loop).DE.IPHere the interpreter places the display level in r0.It then adds the appropriate display value to the inline offset andpushes the value at this location onto the stack.Control then returns to the maininterpreter loop.The.SM RV* operators have short inline data thatreduces the space required to address the first 32K ofstack space in each stack frame.The operators.SM RV14and.SM RV24provide explicit conversion to long as the datais pushed.This saves the generation of.SM STOIto align arguments to .SM Csubroutines..SHCON* r.IPThe constant operators load a value onto the stack from inline code.Small integer values are condensed and loaded by the.SM CON1operator, that is given by.DS.mD_CON1:	\fBcvtbw\fR	(lc)+,\-(sp)	\fBjmp\fR	(loop).DE.IPHere note that little work was required as the required constantwas available at (lc)+.For longer constants,.I lcmust be incremented before moving the constant.The operator.SM CONtakes a length specification in the sub-opcode and can be used to loadstrings and other variable length data onto the stack.The operators .SM CON14and.SM CON24provide explicit conversion to long as the constant is pushed..SHAS*.IPThe assignment operators are similar to arithmetic and relational operatorsin that they take two operands, both in the stack,but the lengths given for them specifyfirst the length of the value on the stack and then the lengthof the target in memory.The target address in memory is under the value to be stored.Thus the statement.DSi := 1.DE.IPwhere.I iis a full-length, 4 byte, integer,will generate the code sequence.DS.TSlp-2w(8) l.LV:\fIl	i\fPCON1:1AS24.TE.DE.IPHere.SM LVwill load the address of.I i,that is really given as a block number in the sub-opcode and anoffset in the following word,onto the stack, occupying a single word..SM CON1 ,that is a single word instruction,then loads the constant 1,that is in its sub-opcode,onto the stack.Since there are not one byte constants on the stack,this becomes a 2 byte, single word integer.The interpreter then assigns a length 2 integer to a length 4 integer using.SM AS24 \&.The code sequence for.SM AS24is given by:.DS.mD_AS24:	\fBincl\fR	lc	\fBcvtwl\fR	(sp)+,*(sp)+	\fBjmp\fR	(loop).DE.IPThus the interpreter gets the single word off the stack,extends it to be a 4 byte integergets the target address off the stack,and finally stores the value in the target.This is a typical use of the constant and assignment operators..NH 2Addressing operations.SHLLV l,W.brLV l,w.IPThe most common operation done by the interpreteris the ``left value'' or ``address of'' operation.It is given by:.DS.mD_LLV:	\fBcvtbl\fR	(lc)+,r0	#r0 has display index	\fBaddl3\fR	_display(r0),(lc)+,\-(sp)	#push address onto the stack	\fBjmp\fR	(loop).DE.IPIt calculates an address in the block specified in the sub-opcodeby adding the associated display entry to theoffset that appears in the following word.The.SM LVoperator has a short inline data that reduces the spacerequired to address the first 32K of stack space in each call frame..SHOFF s.IPThe offset operator is used in field names.Thus to get the address of.LSp^.f1.LE.IP.I piwould generate the sequence.DS.mD.TSlp-2w(8) l.RV:\fIl	p\fPOFF	\fIf1\fP.TE.DE.IPwhere the.SM RVloads the value of.I p,given its block in the sub-opcode and offset in the following word,and the interpreter then adds the offset of the field.I f1in its record to get the correct address..SM OFFtakes its argument in the sub-opcode if it is small enough..SHNIL.IPThe example above is incomplete, lacking a check for a.B nilpointer.The code generated would be.DS.TSlp-2w(8) l.RV:\fIl	p\fPNILOFF	\fIf1\fP.TE.DE.IPwhere the.SM NILoperation checks for a.I nilpointer and generates the appropriate runtime error if it is..SHLVCON s,"

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -