PDP12.ORG Logo

PDP-8 Minis
PDP-8 (0)
PDP-8/E (3)
PDP-8/M (2)
PDP-8/S (0)
PDP-11 Minis
PDP-12 Minis
PDP-12 Front View
Front View of HP-9100
Monroe 630
Tektronix 909
Test Equipment
Front View of HP-3440
Marconi 2955B
Front View of IBM 360 Front Panel
Help the Museum
Contact Us
Hosted by KRTEN.COM

PDP-8 Programming Idioms

The PDP-8 is a dead-simple machine, and yet there are all kinds of interesting programming idioms:

I'll be adding more; if you have any suggestions, please, email me!


The "PDP8 8/e 8/f 8/m Pocket Reference Card" lists some single-instruction constant idioms. These are "one word wonders" that load the AC with a given value:

CLA CLL / loads 0000 (0 decimal) CLA CLL IAC / loads 0001 (1 decimal) CLA CLL IAC RAL / loads 0002 (2 decimal) CLA CLL CML RTL / loads 0002 (2 decimal) CLA CLL CML IAC RAL / loads 0003 (3 decimal) CLA CLL IAC RTL / loads 0004 (4 decimal) CLA CLL CML IAC RTL / loads 0006 (6 decimal) CLA IAC BSW / loads 0100 (64 decimal) CLA CLL CML RTR / loads 2000 (1024 decimal) CLA CLL CMA RAR / loads 3777 (2047 decimal) CLA CLL CML RAR / loads 4000 (-2048 decimal. See Note 1, below) CLA CLL CMA RTR / loads 5777 (-1025 decimal) CLA CLL CML IAC RTL / loads 6000 (-1024 decimal) CLA CLL CMA RTL / loads 7775 (-3 decimal) CLA CLL CMA RAL / loads 7776 (-2 decimal) CLA CLL CMA / loads 7777 (-1 decimal)

If you consider the fact that the accumulator and link are cleared before these constants are loaded, it's really equivalent to a CLA CLL followed by a TAD instruction, which makes the argument for two or three word variations as still being code and data space efficient (i.e., you'd need the CLA CLL, the TAD, and the actual data value, thus consuming three words to load an arbitrary constant with the accumulator and link in an arbitrary state initially.)

Note 1: The pocket reference card lists the constant 4000 as "-0 decimal", but if you add it to 2048 you end up with zero, so it really behaves more like -2048. YMMV :-)

setjmp() And longjump()

Traditional C language programmers will recognize the setjmp() and longjmp() functions in PDP-8 assembler:

SETJMP, 0 / return area JMP I SETJMP / return LONGJMP, 0 / unused return area JMP I SETJMP / return to previously established address

I first encountered this while doing some disassembly and couldn't understand why the code kept calling a subroutine that always just immediately returned. The longjmp() part of the equation was buried in another subroutine call somewhere else, so I didn't make the connection right away.

Latest Updates
Master Reference
PDP-12 is alive!
New machine: PDP-8/L

Contact us This page was updated on Fri Feb 19 00:10:36 EST 2010 © 2000-2007 by Robert Krten.
All rights reserved.
Areas of expertise: 8044, 8051, ARC/CBS, ARCNet, ARM, ASM-86, Automated Disassembly, Avanza, Avionics Software, awk, bash, Bell 103, Bell 202, BITBus, Bootloaders, C, Call Processing, Caller ID, CF-UTTH, Clear Thinking and Common Sense, Client/Server, CMR-91, Code Analysis, Cold Standby, Computer Based Training, Course Developemnt, Course Presentation, CRS-1, curl, cvs, Czech Language, Databases, Data Acquisition, Data Recovery, Decompilation, Debugging, Distributed Processing, DMS-100, Documentation, Drivers, DSP, DTMF, E.164, Embedded Systems, Emulation, Equinox, expect, Fault Tolerance, FFT, Filesystems, Firewalls, Fractals, FreeBSD, FSK, Gammacell 40/1000/3000, Graphics, GSR-12000, Hardware, High Availability, Home Automation, Hot Standby, HTML, HTTP, IDA Pro, IIDS, Image Processing, In-Service Upgrade, Industrial Automation, Infrastructure, Internationalization, iRMX-86/286, ISBT-128, Kernels, ksh, Ladder Logic, Lexical Analyzers, Linux, Loggers, m4, make, Medical Devices, Memory Constrained Environments, Message Passing, Microcontrollers, MIDI, MIL-STD-2167A, NNTP, OpenBSD, Optimization, OrCAD, Oscilloscopes, PABX, Parallel Processing, Parsing, PDP-8, Photon, Porting, POSIX, POVRay, Powerpoint, PowerPC, Preprocessor, Process Control, Program Flow Analysis, Project Management, Prototyping, Public Speaking, QNET, QNX 2, QNX 4, QNX 6 (Neutrino), Radarsat, rcs, Realtime Techniques, Recursive Descent Parsers, Regression Testing, Regular Expressions, Requirements Analysis, Resource Managers, Restoration, Reverse Engineering, Scripting, Security Systems, sed, Serial Protocols, SGML, Simulation, SMDR, SMTP, Soldering, svn, SX-20, Synthesizers, System Architecture, T.4, T.30, TCL, TCP/IP, Technical Presentations, Technical Writing, Telecoms, Testcases, Testjigs, Text Processing, Threads, Tools, Traceability Matrices, TTL, UNIX, Utilities, UUCP, Validation Protocols, Vaulting, VAX/VMS, vi, Virtual Filesystems, Warm Standby, wget, Wirewrap, X-10, X.25, x86