Search the FAQ Archives

3 - A - B - C - D - E - F - G - H - I - J - K - L - M
N - O - P - Q - R - S - T - U - V - W - X - Y - Z
faqs.org - Internet FAQ Archives

PDP-8 Frequently Asked Questions (posted every other month)
Section - What does PDP-8 assembly language look like?

( Single Page )
[ Usenet FAQs | Web FAQs | Documents | RFC Index | Forum ]


Top Document: PDP-8 Frequently Asked Questions (posted every other month)
Previous Document: What is the PDP-8 instruction set?
Next Document: What character sets does the PDP-8 support?
See reader questions & answers on this topic! - Help others by sharing your knowledge
There are many different assemblers for the PDP-8, but most use a
compatible basic syntax; here is an example:

	START,	CLA CLL		/ Clear everything
		TAD	X	/ Load X
		AND I	Y	/ And with the value pointed to by Y
		DCA	X	/ Store in X
		HLT		/ Halt

	X,	1 		/ A variable
	Y,	7 		/ A pointer

Note that labels are terminated by a comma, and comments are separated
from the code by a slash.  There are no fixed fields or column
restrictions.  The "CLA CLL" instruction on the first line is an example
of the microcoding of two of the Group 1 operate instructions.  CLA
alone has the code 7200 (octal), while CLL has the code 7100; combining
these as "CLA CLL" produces 7300.  As a general rule, except when memory
reference instructions are involved, the assembler simply ors together
the values of all blank separated fields between the label and comment.
	
Indirection is indicated by the special symbol I in the operand field,
as in the third line of the example.  The typical PDP-8 assembler has no
explicit notation to distinguish between page zero and current page
addresses.  Instead, the assembler is expected to note the page holding
the operand and automatically generate the appropriate mode.  If the
operand is neither in the current page nor page zero, some assemblers
will raise an error, others will automatically generate an indirect
pointer to the off-page operand; this should be avoided because it only
works for directly addressed off-page operands, and only when the memory
management unit is not being used to address a data field other than the
current instruction field.

Note, in the final two lines of the example, that there is no "define
constant" pseudo-operation.  Instead, where a constant is to be
assembled into memory, the constant takes the place of the op-code field.

The PDP-8 has no immediate addressing mode, but most assemblers provide
a notation to allow the programmer to ignore this lack:

		TAD	(3)	/ add 3, from memory on the current page.
		TAD	[5]	/ add 5, from memory on page zero.
		JMP I	(LAB)	/ jump indirect through the address of LAB.

Assemblers that support this automatically fill the end of each page
with constants defined in this way that have been accumulated during the
assembly of that page.  Note that the variants "(3" and "[5" (with no
closing parentheses) are usually allowed but the use of this sloppy form
is discouraged.  Furthermore, the widely used PAL8 assembler interprets
the unlikely operand "(3)+1" as being the same as "(3+1)".

Arithmetic is allowed in operand fields and constant definitions, with
expressions evaluated in strict left-to-right order, as:

		TAD	X+1	/ add the contents of the location after X.
		TAD	(X-1)	/ add the address of the location before X.

Other operators allowed include and (&), or (!), multiply (^) and divide
(%), as well as a unary sign (+ or -).  Unfortunately, one of the most
widely used assemblers, PAL8, has trouble when unary operators are mixed
with multiplication or division.
	
Generally, only the first 6 characters of identifiers are significant
and numeric constants are evaluated in octal.

Other assembly language features are illustrated below:

	/ Comments may stand on lines by themselves
				/ Blank lines are allowed

		*200		/ Set the assembly origin to 200 (octal)

	NL0002=	CLA CLL CML RTL	/ Define new opcode NL0002.

		NL0002		/ Use new opcode (load 0002 in AC)
		JMP	.-1	/ Jump to the previous instruction

	X1=	10		/ Define X1 (an auto-index register address)
	LETA=	"A		/ Define LETA as 000011000001 (ASCII A)

		TAD I	X1	/ Use autoindex register 1

		IAC; RAL	/ Multiple instructions on one line

		$		/ End of assembly

The assembly file ends with a line containing a $ (dollar sign) not in
a comment field.

The $, * and =  syntax used by most PDP-8 assemblers replaces functions
performed by pseudo-operations on many other assemblers.  In addition,
PAL8, the most widely used PDP-8 assembler supports the following
pseudo-operations:

		DECIMAL		/ Interpret numeric constants in base 10
		OCTAL		/ Interpret numeric constants in base 8
		EJECT		/ Force a page eject in the listing
		XLIST		/ Toggle listing
		XLIST	N	/ Turn on listing if N=0, off if N=1
		PAGE 	 	/ Advance location counter to next page
		PAGE 	N	/ Set location counter start of page N
		FIELD	N	/ Assemble into extended memory field N
		TEXT	"STR"	/ Pack STR into consecutive 6 bit bytes
		ZBLOCK	N	/ Allocate N words, initialized to zero
		IFDEF	S <C>	/ Assemble C if symbol S is defined
		IFNDEF	S <C>	/ Assemble C if symbol S is not defined
		IFZERO	E <C>	/ Assemble C if expression E is zero
		IFNZRO	E <C>	/ Assemble C if expression E is not zero
		FIXMRI  OP= VAL	/ Define OP as memory reference instruction

Conditonally assembled code must be enclosed in angle brackets.  The
enclosed code may extend over multiple lines and, because different
assemblers treat comments within conditionals differently, the closing
bracket should not be in a comment and any brackets in comments should
be balanced.

User Contributions:

Comment about this article, ask questions, or add new information about this topic:




Top Document: PDP-8 Frequently Asked Questions (posted every other month)
Previous Document: What is the PDP-8 instruction set?
Next Document: What character sets does the PDP-8 support?

Single Page

[ Usenet FAQs | Web FAQs | Documents | RFC Index ]

Send corrections/additions to the FAQ Maintainer:
jones@cs.uiowa.edu (Douglas W. Jones)





Last Update March 27 2014 @ 02:11 PM