1
0
mirror of https://github.com/DoctorWkt/pdp7-unix.git synced 2026-01-13 23:36:52 +00:00

Merge remote-tracking branch 'origin/master'

This commit is contained in:
Warren Toomey 2016-03-02 18:00:56 +10:00
commit 9fcffe7e43
23 changed files with 4291 additions and 610 deletions

View File

@ -225,7 +225,7 @@ bits:
sza = 0740200 " OPR: skip on zero AC
snl = 0740400 " OPR: skip on non-zero link
skp = 0741000 " OPR: skip unconditionally
sna = 0741200 " OPR: skip on negative AC
sna = 0741200 " OPR: skip on non-zero AC
szl = 0741400 " OPR: skip on zero link
rtl = 0742010 " OPR: rotate two left
rtr = 0742020 " OPR: rotate two right
@ -240,8 +240,8 @@ With some limitations, OPR instructions can be OR-ed together.
order in the source!!):
sna cla " skip on negative AC, clear AC
sna spa " skip on negative or positive AC
sna ral " skip on negative AC, rotate AC left
sna spa " skip on non-zero or positive AC(??)
sna ral " skip on non-zero AC, rotate AC left
cla cll sza " skip on AC zero, clear AC, clear LINK
The last "operate" instruction is not microcoded:

8
pdp7parse/.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
/**/*.log
/**/.DS_Store
/**/.project
/**/.classpath
/**/.settings/
/**/target
/**/test-output
ANTLRv4Lexer.g4

7
pdp7parse/README.md Normal file
View File

@ -0,0 +1,7 @@
PDP7Parse
---
PDP7Parse is an example of parsing PDP7 using an [Antlr4](http://www.antlr.org/) grammar. The authoritative home of the grammar file is on Antlr4 [grammars-v4](https://github.com/antlr/grammars-v4) tree.
PDP7Parse could be extended to implement a simple assembler for pdp7-unix.

58
pdp7parse/pom.xml Normal file
View File

@ -0,0 +1,58 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.khubla.pdp7</groupId>
<artifactId>pdp7parse</artifactId>
<packaging>jar</packaging>
<name>khubla.com PDP7 Parser</name>
<version>1.0</version>
<properties>
<antlr.version>4.5</antlr.version>
</properties>
<dependencies>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.2</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4-runtime</artifactId>
<version>${antlr.version}</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.antlr</groupId>
<artifactId>antlr4-maven-plugin</artifactId>
<version>${antlr.version}</version>
<configuration>
<grammars>pdp7.g4</grammars>
<outputDirectory>src/main/java</outputDirectory>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,281 @@
/*
BSD License
Copyright (c) 2013, Tom Everett
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. Neither the name of Tom Everett 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 COPYRIGHT HOLDERS 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 COPYRIGHT
HOLDER 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.
*/
grammar pdp7;
prog
: line +
;
line
: declarations? comment? eol
;
declarations
: declaration (';' declaration)*
;
// multiple labels can occur on the same line
declaration
: label* (instruction | assignment | expression)*
;
instruction
: opcode argument*
;
argument
: expression
;
assignment
: (variable | LOC | RELOC) '=' expression
;
expression
: multiplyingExpression ((PLUS | MINUS) multiplyingExpression)*
;
multiplyingExpression
: atom ((TIMES | DIV) atom)*
;
atom
: variable
| LOC
| RELOC
| string
| DECIMAL
| DECIMAL_MINUS
| OCTAL
| signednumber
;
// string chars, then potentially more than 1 octal constant, then potentially '>'
string
: STRING NUMERIC_LITERAL* '>'?
;
signednumber
: '-'? NUMERIC_LITERAL
;
eol
: EOL
;
comment
: COMMENT
;
label
: LABEL
;
variable
: IDENTIFIER
;
opcode
: 'dac'
| 'jms'
| 'dzm'
| 'lac'
| 'xor'
| 'add'
| 'tad'
| 'xct'
| 'isz'
| 'and'
| 'sad'
| 'jmp'
| 'nop'
// | 'i'
| 'law'
| 'cma'
| 'las'
| 'ral'
| 'rar'
| 'hlt'
| 'sma'
| 'sza'
| 'snl'
| 'skp'
| 'sna'
| 'szl'
| 'rtl'
| 'rtr'
| 'cil'
| 'rcl'
| 'rcr'
| 'cia'
| 'lrs'
| 'lrss'
| 'lls'
| 'llss'
| 'als'
| 'alss'
| 'mul'
| 'idiv'
| 'lacq'
| 'clq'
| 'omq'
| 'cmq'
| 'lmq'
| 'dscs'
| 'dslw'
| 'dslm'
| 'dsld'
| 'dsls'
| 'dssf'
| 'dsrs'
| 'iof'
| 'ion'
| 'caf'
| 'clon'
| 'clsf'
| 'clof'
| 'ksf'
| 'krb'
| 'tsf'
| 'tcf'
| 'tls'
| 'sck'
| 'cck'
| 'lck'
| 'rsf'
| 'rsa'
| 'rrb'
| 'psf'
| 'pcf'
| 'psa'
| 'cdf'
| 'rlpd'
| 'lda'
| 'wcga'
| 'raef'
| 'rlpd'
| 'beg'
| 'spb'
| 'cpb'
| 'lpb'
| 'wbl'
| 'dprs'
| 'dpsf'
| 'dpcf'
| 'dprc'
| 'crsf'
| 'crrb'
| 'sys'
| 'czm'
| 'irss'
| 'dsm'
;
LOC
: '.'
;
RELOC
: '..'
;
PLUS
: '+'
;
MINUS
: '-'
;
TIMES
: '*'
;
DIV
: '/'
;
LABEL
: [a-zA-Z0-9.] + ':'
;
// the period is considered a letter
IDENTIFIER
: [a-zA-Z] [a-zA-Z0-9.]*
;
NUMERIC_LITERAL
: [0-9][0-9a-f]*
;
DECIMAL
: 'd' [0-9] +
;
OCTAL
: 'o' [0-7] +
;
DECIMAL_MINUS
: 'dm' [0-9] +
;
STRING
: '<' [a-zA-Z0-9$*,%/]*
;
COMMENT
: '"' ~ [\r\n]*
;
EOL
: [\r\n]+
;
WS
: [ \t] -> skip
;

View File

@ -0,0 +1,62 @@
package com.khubla.pdp7parse;
import java.io.File;
import java.io.FileInputStream;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.OptionBuilder;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.PosixParser;
/**
* @author tom
*/
public class PDP7Parse {
public static void main(String[] args) {
try {
System.out.println("khubla.com PDP7 Parser");
/*
* options
*/
final Options options = new Options();
OptionBuilder.withArgName(INPUT_FILE_OPTION);
OptionBuilder.isRequired();
OptionBuilder.withType(String.class);
OptionBuilder.hasArg();
OptionBuilder.withDescription("file to read");
final Option ifo = OptionBuilder.create(INPUT_FILE_OPTION);
options.addOption(ifo);
/*
* parse
*/
final CommandLineParser parser = new PosixParser();
CommandLine cmd = null;
try {
cmd = parser.parse(options, args);
} catch (final Exception e) {
e.printStackTrace();
final HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("posix", options);
System.exit(0);
}
/*
* get file
*/
final String inputFileName = cmd.getOptionValue(INPUT_FILE_OPTION);
final File inputFile = new File(inputFileName);
if (inputFile.exists()) {
PDP7Parser.parse(new FileInputStream(inputFile), System.out);
}
} catch (final Exception e) {
e.printStackTrace();
}
}
/**
* file option
*/
private static final String INPUT_FILE_OPTION = "file";
}

View File

@ -0,0 +1,31 @@
package com.khubla.pdp7parse;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.Reader;
import org.antlr.v4.runtime.ANTLRInputStream;
import org.antlr.v4.runtime.CommonTokenStream;
import com.khubla.pdp7parse.antlr4.pdp7Lexer;
import com.khubla.pdp7parse.antlr4.pdp7Parser;
import com.khubla.pdp7parse.antlr4.pdp7Parser.ProgContext;
public class PDP7Parser {
public static ProgContext parse(InputStream inputStream, OutputStream outputStream) throws Exception {
try {
if (null != inputStream) {
final Reader reader = new InputStreamReader(inputStream, "UTF-8");
final pdp7Lexer lexer = new pdp7Lexer(new ANTLRInputStream(reader));
final CommonTokenStream commonTokenStream = new CommonTokenStream(lexer);
final pdp7Parser parser = new pdp7Parser(commonTokenStream);
return parser.prog();
} else {
throw new IllegalArgumentException();
}
} catch (final Exception e) {
throw new Exception("Exception reading and parsing file", e);
}
}
}

View File

@ -0,0 +1,244 @@
// Generated from com/khubla/pdp7parse/antlr4/pdp7.g4 by ANTLR 4.5
package com.khubla.pdp7parse.antlr4;
import org.antlr.v4.runtime.ParserRuleContext;
import org.antlr.v4.runtime.misc.NotNull;
import org.antlr.v4.runtime.tree.ErrorNode;
import org.antlr.v4.runtime.tree.TerminalNode;
/**
* This class provides an empty implementation of {@link pdp7Listener},
* which can be extended to create a listener which only needs to handle a subset
* of the available methods.
*/
public class pdp7BaseListener implements pdp7Listener {
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterProg(pdp7Parser.ProgContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitProg(pdp7Parser.ProgContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterLine(pdp7Parser.LineContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitLine(pdp7Parser.LineContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterDeclarations(pdp7Parser.DeclarationsContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitDeclarations(pdp7Parser.DeclarationsContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterDeclaration(pdp7Parser.DeclarationContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitDeclaration(pdp7Parser.DeclarationContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterInstruction(pdp7Parser.InstructionContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitInstruction(pdp7Parser.InstructionContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterArgument(pdp7Parser.ArgumentContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitArgument(pdp7Parser.ArgumentContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterAssignment(pdp7Parser.AssignmentContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitAssignment(pdp7Parser.AssignmentContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterExpression(pdp7Parser.ExpressionContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitExpression(pdp7Parser.ExpressionContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterMultiplyingExpression(pdp7Parser.MultiplyingExpressionContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitMultiplyingExpression(pdp7Parser.MultiplyingExpressionContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterAtom(pdp7Parser.AtomContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitAtom(pdp7Parser.AtomContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterString(pdp7Parser.StringContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitString(pdp7Parser.StringContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterSignednumber(pdp7Parser.SignednumberContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitSignednumber(pdp7Parser.SignednumberContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterEol(pdp7Parser.EolContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitEol(pdp7Parser.EolContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterComment(pdp7Parser.CommentContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitComment(pdp7Parser.CommentContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterLabel(pdp7Parser.LabelContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitLabel(pdp7Parser.LabelContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterVariable(pdp7Parser.VariableContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitVariable(pdp7Parser.VariableContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterOpcode(pdp7Parser.OpcodeContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitOpcode(pdp7Parser.OpcodeContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterEveryRule(ParserRuleContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitEveryRule(ParserRuleContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void visitTerminal(TerminalNode node) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void visitErrorNode(ErrorNode node) { }
}

View File

@ -0,0 +1,372 @@
// Generated from com/khubla/pdp7parse/antlr4/pdp7.g4 by ANTLR 4.5
package com.khubla.pdp7parse.antlr4;
import org.antlr.v4.runtime.Lexer;
import org.antlr.v4.runtime.CharStream;
import org.antlr.v4.runtime.Token;
import org.antlr.v4.runtime.TokenStream;
import org.antlr.v4.runtime.*;
import org.antlr.v4.runtime.atn.*;
import org.antlr.v4.runtime.dfa.DFA;
import org.antlr.v4.runtime.misc.*;
@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"})
public class pdp7Lexer extends Lexer {
static { RuntimeMetaData.checkVersion("4.5", RuntimeMetaData.VERSION); }
protected static final DFA[] _decisionToDFA;
protected static final PredictionContextCache _sharedContextCache =
new PredictionContextCache();
public static final int
T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, T__5=6, T__6=7, T__7=8, T__8=9,
T__9=10, T__10=11, T__11=12, T__12=13, T__13=14, T__14=15, T__15=16, T__16=17,
T__17=18, T__18=19, T__19=20, T__20=21, T__21=22, T__22=23, T__23=24,
T__24=25, T__25=26, T__26=27, T__27=28, T__28=29, T__29=30, T__30=31,
T__31=32, T__32=33, T__33=34, T__34=35, T__35=36, T__36=37, T__37=38,
T__38=39, T__39=40, T__40=41, T__41=42, T__42=43, T__43=44, T__44=45,
T__45=46, T__46=47, T__47=48, T__48=49, T__49=50, T__50=51, T__51=52,
T__52=53, T__53=54, T__54=55, T__55=56, T__56=57, T__57=58, T__58=59,
T__59=60, T__60=61, T__61=62, T__62=63, T__63=64, T__64=65, T__65=66,
T__66=67, T__67=68, T__68=69, T__69=70, T__70=71, T__71=72, T__72=73,
T__73=74, T__74=75, T__75=76, T__76=77, T__77=78, T__78=79, T__79=80,
T__80=81, T__81=82, T__82=83, T__83=84, T__84=85, T__85=86, T__86=87,
T__87=88, T__88=89, T__89=90, T__90=91, T__91=92, T__92=93, T__93=94,
LOC=95, RELOC=96, PLUS=97, MINUS=98, TIMES=99, DIV=100, LABEL=101, IDENTIFIER=102,
NUMERIC_LITERAL=103, DECIMAL=104, OCTAL=105, DECIMAL_MINUS=106, STRING=107,
COMMENT=108, EOL=109, WS=110;
public static String[] modeNames = {
"DEFAULT_MODE"
};
public static final String[] ruleNames = {
"T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", "T__7", "T__8",
"T__9", "T__10", "T__11", "T__12", "T__13", "T__14", "T__15", "T__16",
"T__17", "T__18", "T__19", "T__20", "T__21", "T__22", "T__23", "T__24",
"T__25", "T__26", "T__27", "T__28", "T__29", "T__30", "T__31", "T__32",
"T__33", "T__34", "T__35", "T__36", "T__37", "T__38", "T__39", "T__40",
"T__41", "T__42", "T__43", "T__44", "T__45", "T__46", "T__47", "T__48",
"T__49", "T__50", "T__51", "T__52", "T__53", "T__54", "T__55", "T__56",
"T__57", "T__58", "T__59", "T__60", "T__61", "T__62", "T__63", "T__64",
"T__65", "T__66", "T__67", "T__68", "T__69", "T__70", "T__71", "T__72",
"T__73", "T__74", "T__75", "T__76", "T__77", "T__78", "T__79", "T__80",
"T__81", "T__82", "T__83", "T__84", "T__85", "T__86", "T__87", "T__88",
"T__89", "T__90", "T__91", "T__92", "T__93", "LOC", "RELOC", "PLUS", "MINUS",
"TIMES", "DIV", "LABEL", "IDENTIFIER", "NUMERIC_LITERAL", "DECIMAL", "OCTAL",
"DECIMAL_MINUS", "STRING", "COMMENT", "EOL", "WS"
};
private static final String[] _LITERAL_NAMES = {
null, "';'", "'='", "'>'", "'dac'", "'jms'", "'dzm'", "'lac'", "'xor'",
"'add'", "'tad'", "'xct'", "'isz'", "'and'", "'sad'", "'jmp'", "'nop'",
"'law'", "'cma'", "'las'", "'ral'", "'rar'", "'hlt'", "'sma'", "'sza'",
"'snl'", "'skp'", "'sna'", "'szl'", "'rtl'", "'rtr'", "'cil'", "'rcl'",
"'rcr'", "'cia'", "'lrs'", "'lrss'", "'lls'", "'llss'", "'als'", "'alss'",
"'mul'", "'idiv'", "'lacq'", "'clq'", "'omq'", "'cmq'", "'lmq'", "'dscs'",
"'dslw'", "'dslm'", "'dsld'", "'dsls'", "'dssf'", "'dsrs'", "'iof'", "'ion'",
"'caf'", "'clon'", "'clsf'", "'clof'", "'ksf'", "'krb'", "'tsf'", "'tcf'",
"'tls'", "'sck'", "'cck'", "'lck'", "'rsf'", "'rsa'", "'rrb'", "'psf'",
"'pcf'", "'psa'", "'cdf'", "'rlpd'", "'lda'", "'wcga'", "'raef'", "'beg'",
"'spb'", "'cpb'", "'lpb'", "'wbl'", "'dprs'", "'dpsf'", "'dpcf'", "'dprc'",
"'crsf'", "'crrb'", "'sys'", "'czm'", "'irss'", "'dsm'", "'.'", "'..'",
"'+'", "'-'", "'*'", "'/'"
};
private static final String[] _SYMBOLIC_NAMES = {
null, null, null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null, null, null, null, "LOC",
"RELOC", "PLUS", "MINUS", "TIMES", "DIV", "LABEL", "IDENTIFIER", "NUMERIC_LITERAL",
"DECIMAL", "OCTAL", "DECIMAL_MINUS", "STRING", "COMMENT", "EOL", "WS"
};
public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES);
/**
* @deprecated Use {@link #VOCABULARY} instead.
*/
@Deprecated
public static final String[] tokenNames;
static {
tokenNames = new String[_SYMBOLIC_NAMES.length];
for (int i = 0; i < tokenNames.length; i++) {
tokenNames[i] = VOCABULARY.getLiteralName(i);
if (tokenNames[i] == null) {
tokenNames[i] = VOCABULARY.getSymbolicName(i);
}
if (tokenNames[i] == null) {
tokenNames[i] = "<INVALID>";
}
}
}
@Override
@Deprecated
public String[] getTokenNames() {
return tokenNames;
}
@Override
public Vocabulary getVocabulary() {
return VOCABULARY;
}
public pdp7Lexer(CharStream input) {
super(input);
_interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
}
@Override
public String getGrammarFileName() { return "pdp7.g4"; }
@Override
public String[] getRuleNames() { return ruleNames; }
@Override
public String getSerializedATN() { return _serializedATN; }
@Override
public String[] getModeNames() { return modeNames; }
@Override
public ATN getATN() { return _ATN; }
public static final String _serializedATN =
"\3\u0430\ud6d1\u8206\uad2d\u4417\uaef1\u8d80\uaadd\2p\u02b7\b\1\4\2\t"+
"\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13"+
"\t\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22"+
"\4\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30\4\31\t\31"+
"\4\32\t\32\4\33\t\33\4\34\t\34\4\35\t\35\4\36\t\36\4\37\t\37\4 \t \4!"+
"\t!\4\"\t\"\4#\t#\4$\t$\4%\t%\4&\t&\4\'\t\'\4(\t(\4)\t)\4*\t*\4+\t+\4"+
",\t,\4-\t-\4.\t.\4/\t/\4\60\t\60\4\61\t\61\4\62\t\62\4\63\t\63\4\64\t"+
"\64\4\65\t\65\4\66\t\66\4\67\t\67\48\t8\49\t9\4:\t:\4;\t;\4<\t<\4=\t="+
"\4>\t>\4?\t?\4@\t@\4A\tA\4B\tB\4C\tC\4D\tD\4E\tE\4F\tF\4G\tG\4H\tH\4I"+
"\tI\4J\tJ\4K\tK\4L\tL\4M\tM\4N\tN\4O\tO\4P\tP\4Q\tQ\4R\tR\4S\tS\4T\tT"+
"\4U\tU\4V\tV\4W\tW\4X\tX\4Y\tY\4Z\tZ\4[\t[\4\\\t\\\4]\t]\4^\t^\4_\t_\4"+
"`\t`\4a\ta\4b\tb\4c\tc\4d\td\4e\te\4f\tf\4g\tg\4h\th\4i\ti\4j\tj\4k\t"+
"k\4l\tl\4m\tm\4n\tn\4o\to\3\2\3\2\3\3\3\3\3\4\3\4\3\5\3\5\3\5\3\5\3\6"+
"\3\6\3\6\3\6\3\7\3\7\3\7\3\7\3\b\3\b\3\b\3\b\3\t\3\t\3\t\3\t\3\n\3\n\3"+
"\n\3\n\3\13\3\13\3\13\3\13\3\f\3\f\3\f\3\f\3\r\3\r\3\r\3\r\3\16\3\16\3"+
"\16\3\16\3\17\3\17\3\17\3\17\3\20\3\20\3\20\3\20\3\21\3\21\3\21\3\21\3"+
"\22\3\22\3\22\3\22\3\23\3\23\3\23\3\23\3\24\3\24\3\24\3\24\3\25\3\25\3"+
"\25\3\25\3\26\3\26\3\26\3\26\3\27\3\27\3\27\3\27\3\30\3\30\3\30\3\30\3"+
"\31\3\31\3\31\3\31\3\32\3\32\3\32\3\32\3\33\3\33\3\33\3\33\3\34\3\34\3"+
"\34\3\34\3\35\3\35\3\35\3\35\3\36\3\36\3\36\3\36\3\37\3\37\3\37\3\37\3"+
" \3 \3 \3 \3!\3!\3!\3!\3\"\3\"\3\"\3\"\3#\3#\3#\3#\3$\3$\3$\3$\3%\3%\3"+
"%\3%\3%\3&\3&\3&\3&\3\'\3\'\3\'\3\'\3\'\3(\3(\3(\3(\3)\3)\3)\3)\3)\3*"+
"\3*\3*\3*\3+\3+\3+\3+\3+\3,\3,\3,\3,\3,\3-\3-\3-\3-\3.\3.\3.\3.\3/\3/"+
"\3/\3/\3\60\3\60\3\60\3\60\3\61\3\61\3\61\3\61\3\61\3\62\3\62\3\62\3\62"+
"\3\62\3\63\3\63\3\63\3\63\3\63\3\64\3\64\3\64\3\64\3\64\3\65\3\65\3\65"+
"\3\65\3\65\3\66\3\66\3\66\3\66\3\66\3\67\3\67\3\67\3\67\3\67\38\38\38"+
"\38\39\39\39\39\3:\3:\3:\3:\3;\3;\3;\3;\3;\3<\3<\3<\3<\3<\3=\3=\3=\3="+
"\3=\3>\3>\3>\3>\3?\3?\3?\3?\3@\3@\3@\3@\3A\3A\3A\3A\3B\3B\3B\3B\3C\3C"+
"\3C\3C\3D\3D\3D\3D\3E\3E\3E\3E\3F\3F\3F\3F\3G\3G\3G\3G\3H\3H\3H\3H\3I"+
"\3I\3I\3I\3J\3J\3J\3J\3K\3K\3K\3K\3L\3L\3L\3L\3M\3M\3M\3M\3M\3N\3N\3N"+
"\3N\3O\3O\3O\3O\3O\3P\3P\3P\3P\3P\3Q\3Q\3Q\3Q\3R\3R\3R\3R\3S\3S\3S\3S"+
"\3T\3T\3T\3T\3U\3U\3U\3U\3V\3V\3V\3V\3V\3W\3W\3W\3W\3W\3X\3X\3X\3X\3X"+
"\3Y\3Y\3Y\3Y\3Y\3Z\3Z\3Z\3Z\3Z\3[\3[\3[\3[\3[\3\\\3\\\3\\\3\\\3]\3]\3"+
"]\3]\3^\3^\3^\3^\3^\3_\3_\3_\3_\3`\3`\3a\3a\3a\3b\3b\3c\3c\3d\3d\3e\3"+
"e\3f\6f\u0279\nf\rf\16f\u027a\3f\3f\3g\3g\7g\u0281\ng\fg\16g\u0284\13"+
"g\3h\3h\7h\u0288\nh\fh\16h\u028b\13h\3i\3i\6i\u028f\ni\ri\16i\u0290\3"+
"j\3j\6j\u0295\nj\rj\16j\u0296\3k\3k\3k\3k\6k\u029d\nk\rk\16k\u029e\3l"+
"\3l\7l\u02a3\nl\fl\16l\u02a6\13l\3m\3m\7m\u02aa\nm\fm\16m\u02ad\13m\3"+
"n\6n\u02b0\nn\rn\16n\u02b1\3o\3o\3o\3o\2\2p\3\3\5\4\7\5\t\6\13\7\r\b\17"+
"\t\21\n\23\13\25\f\27\r\31\16\33\17\35\20\37\21!\22#\23%\24\'\25)\26+"+
"\27-\30/\31\61\32\63\33\65\34\67\359\36;\37= ?!A\"C#E$G%I&K\'M(O)Q*S+"+
"U,W-Y.[/]\60_\61a\62c\63e\64g\65i\66k\67m8o9q:s;u<w=y>{?}@\177A\u0081"+
"B\u0083C\u0085D\u0087E\u0089F\u008bG\u008dH\u008fI\u0091J\u0093K\u0095"+
"L\u0097M\u0099N\u009bO\u009dP\u009fQ\u00a1R\u00a3S\u00a5T\u00a7U\u00a9"+
"V\u00abW\u00adX\u00afY\u00b1Z\u00b3[\u00b5\\\u00b7]\u00b9^\u00bb_\u00bd"+
"`\u00bfa\u00c1b\u00c3c\u00c5d\u00c7e\u00c9f\u00cbg\u00cdh\u00cfi\u00d1"+
"j\u00d3k\u00d5l\u00d7m\u00d9n\u00dbo\u00ddp\3\2\n\6\2\60\60\62;C\\c|\4"+
"\2C\\c|\3\2\62;\4\2\62;ch\3\2\629\b\2&\',,..\61;C\\c|\4\2\f\f\17\17\4"+
"\2\13\13\"\"\u02bf\2\3\3\2\2\2\2\5\3\2\2\2\2\7\3\2\2\2\2\t\3\2\2\2\2\13"+
"\3\2\2\2\2\r\3\2\2\2\2\17\3\2\2\2\2\21\3\2\2\2\2\23\3\2\2\2\2\25\3\2\2"+
"\2\2\27\3\2\2\2\2\31\3\2\2\2\2\33\3\2\2\2\2\35\3\2\2\2\2\37\3\2\2\2\2"+
"!\3\2\2\2\2#\3\2\2\2\2%\3\2\2\2\2\'\3\2\2\2\2)\3\2\2\2\2+\3\2\2\2\2-\3"+
"\2\2\2\2/\3\2\2\2\2\61\3\2\2\2\2\63\3\2\2\2\2\65\3\2\2\2\2\67\3\2\2\2"+
"\29\3\2\2\2\2;\3\2\2\2\2=\3\2\2\2\2?\3\2\2\2\2A\3\2\2\2\2C\3\2\2\2\2E"+
"\3\2\2\2\2G\3\2\2\2\2I\3\2\2\2\2K\3\2\2\2\2M\3\2\2\2\2O\3\2\2\2\2Q\3\2"+
"\2\2\2S\3\2\2\2\2U\3\2\2\2\2W\3\2\2\2\2Y\3\2\2\2\2[\3\2\2\2\2]\3\2\2\2"+
"\2_\3\2\2\2\2a\3\2\2\2\2c\3\2\2\2\2e\3\2\2\2\2g\3\2\2\2\2i\3\2\2\2\2k"+
"\3\2\2\2\2m\3\2\2\2\2o\3\2\2\2\2q\3\2\2\2\2s\3\2\2\2\2u\3\2\2\2\2w\3\2"+
"\2\2\2y\3\2\2\2\2{\3\2\2\2\2}\3\2\2\2\2\177\3\2\2\2\2\u0081\3\2\2\2\2"+
"\u0083\3\2\2\2\2\u0085\3\2\2\2\2\u0087\3\2\2\2\2\u0089\3\2\2\2\2\u008b"+
"\3\2\2\2\2\u008d\3\2\2\2\2\u008f\3\2\2\2\2\u0091\3\2\2\2\2\u0093\3\2\2"+
"\2\2\u0095\3\2\2\2\2\u0097\3\2\2\2\2\u0099\3\2\2\2\2\u009b\3\2\2\2\2\u009d"+
"\3\2\2\2\2\u009f\3\2\2\2\2\u00a1\3\2\2\2\2\u00a3\3\2\2\2\2\u00a5\3\2\2"+
"\2\2\u00a7\3\2\2\2\2\u00a9\3\2\2\2\2\u00ab\3\2\2\2\2\u00ad\3\2\2\2\2\u00af"+
"\3\2\2\2\2\u00b1\3\2\2\2\2\u00b3\3\2\2\2\2\u00b5\3\2\2\2\2\u00b7\3\2\2"+
"\2\2\u00b9\3\2\2\2\2\u00bb\3\2\2\2\2\u00bd\3\2\2\2\2\u00bf\3\2\2\2\2\u00c1"+
"\3\2\2\2\2\u00c3\3\2\2\2\2\u00c5\3\2\2\2\2\u00c7\3\2\2\2\2\u00c9\3\2\2"+
"\2\2\u00cb\3\2\2\2\2\u00cd\3\2\2\2\2\u00cf\3\2\2\2\2\u00d1\3\2\2\2\2\u00d3"+
"\3\2\2\2\2\u00d5\3\2\2\2\2\u00d7\3\2\2\2\2\u00d9\3\2\2\2\2\u00db\3\2\2"+
"\2\2\u00dd\3\2\2\2\3\u00df\3\2\2\2\5\u00e1\3\2\2\2\7\u00e3\3\2\2\2\t\u00e5"+
"\3\2\2\2\13\u00e9\3\2\2\2\r\u00ed\3\2\2\2\17\u00f1\3\2\2\2\21\u00f5\3"+
"\2\2\2\23\u00f9\3\2\2\2\25\u00fd\3\2\2\2\27\u0101\3\2\2\2\31\u0105\3\2"+
"\2\2\33\u0109\3\2\2\2\35\u010d\3\2\2\2\37\u0111\3\2\2\2!\u0115\3\2\2\2"+
"#\u0119\3\2\2\2%\u011d\3\2\2\2\'\u0121\3\2\2\2)\u0125\3\2\2\2+\u0129\3"+
"\2\2\2-\u012d\3\2\2\2/\u0131\3\2\2\2\61\u0135\3\2\2\2\63\u0139\3\2\2\2"+
"\65\u013d\3\2\2\2\67\u0141\3\2\2\29\u0145\3\2\2\2;\u0149\3\2\2\2=\u014d"+
"\3\2\2\2?\u0151\3\2\2\2A\u0155\3\2\2\2C\u0159\3\2\2\2E\u015d\3\2\2\2G"+
"\u0161\3\2\2\2I\u0165\3\2\2\2K\u016a\3\2\2\2M\u016e\3\2\2\2O\u0173\3\2"+
"\2\2Q\u0177\3\2\2\2S\u017c\3\2\2\2U\u0180\3\2\2\2W\u0185\3\2\2\2Y\u018a"+
"\3\2\2\2[\u018e\3\2\2\2]\u0192\3\2\2\2_\u0196\3\2\2\2a\u019a\3\2\2\2c"+
"\u019f\3\2\2\2e\u01a4\3\2\2\2g\u01a9\3\2\2\2i\u01ae\3\2\2\2k\u01b3\3\2"+
"\2\2m\u01b8\3\2\2\2o\u01bd\3\2\2\2q\u01c1\3\2\2\2s\u01c5\3\2\2\2u\u01c9"+
"\3\2\2\2w\u01ce\3\2\2\2y\u01d3\3\2\2\2{\u01d8\3\2\2\2}\u01dc\3\2\2\2\177"+
"\u01e0\3\2\2\2\u0081\u01e4\3\2\2\2\u0083\u01e8\3\2\2\2\u0085\u01ec\3\2"+
"\2\2\u0087\u01f0\3\2\2\2\u0089\u01f4\3\2\2\2\u008b\u01f8\3\2\2\2\u008d"+
"\u01fc\3\2\2\2\u008f\u0200\3\2\2\2\u0091\u0204\3\2\2\2\u0093\u0208\3\2"+
"\2\2\u0095\u020c\3\2\2\2\u0097\u0210\3\2\2\2\u0099\u0214\3\2\2\2\u009b"+
"\u0219\3\2\2\2\u009d\u021d\3\2\2\2\u009f\u0222\3\2\2\2\u00a1\u0227\3\2"+
"\2\2\u00a3\u022b\3\2\2\2\u00a5\u022f\3\2\2\2\u00a7\u0233\3\2\2\2\u00a9"+
"\u0237\3\2\2\2\u00ab\u023b\3\2\2\2\u00ad\u0240\3\2\2\2\u00af\u0245\3\2"+
"\2\2\u00b1\u024a\3\2\2\2\u00b3\u024f\3\2\2\2\u00b5\u0254\3\2\2\2\u00b7"+
"\u0259\3\2\2\2\u00b9\u025d\3\2\2\2\u00bb\u0261\3\2\2\2\u00bd\u0266\3\2"+
"\2\2\u00bf\u026a\3\2\2\2\u00c1\u026c\3\2\2\2\u00c3\u026f\3\2\2\2\u00c5"+
"\u0271\3\2\2\2\u00c7\u0273\3\2\2\2\u00c9\u0275\3\2\2\2\u00cb\u0278\3\2"+
"\2\2\u00cd\u027e\3\2\2\2\u00cf\u0285\3\2\2\2\u00d1\u028c\3\2\2\2\u00d3"+
"\u0292\3\2\2\2\u00d5\u0298\3\2\2\2\u00d7\u02a0\3\2\2\2\u00d9\u02a7\3\2"+
"\2\2\u00db\u02af\3\2\2\2\u00dd\u02b3\3\2\2\2\u00df\u00e0\7=\2\2\u00e0"+
"\4\3\2\2\2\u00e1\u00e2\7?\2\2\u00e2\6\3\2\2\2\u00e3\u00e4\7@\2\2\u00e4"+
"\b\3\2\2\2\u00e5\u00e6\7f\2\2\u00e6\u00e7\7c\2\2\u00e7\u00e8\7e\2\2\u00e8"+
"\n\3\2\2\2\u00e9\u00ea\7l\2\2\u00ea\u00eb\7o\2\2\u00eb\u00ec\7u\2\2\u00ec"+
"\f\3\2\2\2\u00ed\u00ee\7f\2\2\u00ee\u00ef\7|\2\2\u00ef\u00f0\7o\2\2\u00f0"+
"\16\3\2\2\2\u00f1\u00f2\7n\2\2\u00f2\u00f3\7c\2\2\u00f3\u00f4\7e\2\2\u00f4"+
"\20\3\2\2\2\u00f5\u00f6\7z\2\2\u00f6\u00f7\7q\2\2\u00f7\u00f8\7t\2\2\u00f8"+
"\22\3\2\2\2\u00f9\u00fa\7c\2\2\u00fa\u00fb\7f\2\2\u00fb\u00fc\7f\2\2\u00fc"+
"\24\3\2\2\2\u00fd\u00fe\7v\2\2\u00fe\u00ff\7c\2\2\u00ff\u0100\7f\2\2\u0100"+
"\26\3\2\2\2\u0101\u0102\7z\2\2\u0102\u0103\7e\2\2\u0103\u0104\7v\2\2\u0104"+
"\30\3\2\2\2\u0105\u0106\7k\2\2\u0106\u0107\7u\2\2\u0107\u0108\7|\2\2\u0108"+
"\32\3\2\2\2\u0109\u010a\7c\2\2\u010a\u010b\7p\2\2\u010b\u010c\7f\2\2\u010c"+
"\34\3\2\2\2\u010d\u010e\7u\2\2\u010e\u010f\7c\2\2\u010f\u0110\7f\2\2\u0110"+
"\36\3\2\2\2\u0111\u0112\7l\2\2\u0112\u0113\7o\2\2\u0113\u0114\7r\2\2\u0114"+
" \3\2\2\2\u0115\u0116\7p\2\2\u0116\u0117\7q\2\2\u0117\u0118\7r\2\2\u0118"+
"\"\3\2\2\2\u0119\u011a\7n\2\2\u011a\u011b\7c\2\2\u011b\u011c\7y\2\2\u011c"+
"$\3\2\2\2\u011d\u011e\7e\2\2\u011e\u011f\7o\2\2\u011f\u0120\7c\2\2\u0120"+
"&\3\2\2\2\u0121\u0122\7n\2\2\u0122\u0123\7c\2\2\u0123\u0124\7u\2\2\u0124"+
"(\3\2\2\2\u0125\u0126\7t\2\2\u0126\u0127\7c\2\2\u0127\u0128\7n\2\2\u0128"+
"*\3\2\2\2\u0129\u012a\7t\2\2\u012a\u012b\7c\2\2\u012b\u012c\7t\2\2\u012c"+
",\3\2\2\2\u012d\u012e\7j\2\2\u012e\u012f\7n\2\2\u012f\u0130\7v\2\2\u0130"+
".\3\2\2\2\u0131\u0132\7u\2\2\u0132\u0133\7o\2\2\u0133\u0134\7c\2\2\u0134"+
"\60\3\2\2\2\u0135\u0136\7u\2\2\u0136\u0137\7|\2\2\u0137\u0138\7c\2\2\u0138"+
"\62\3\2\2\2\u0139\u013a\7u\2\2\u013a\u013b\7p\2\2\u013b\u013c\7n\2\2\u013c"+
"\64\3\2\2\2\u013d\u013e\7u\2\2\u013e\u013f\7m\2\2\u013f\u0140\7r\2\2\u0140"+
"\66\3\2\2\2\u0141\u0142\7u\2\2\u0142\u0143\7p\2\2\u0143\u0144\7c\2\2\u0144"+
"8\3\2\2\2\u0145\u0146\7u\2\2\u0146\u0147\7|\2\2\u0147\u0148\7n\2\2\u0148"+
":\3\2\2\2\u0149\u014a\7t\2\2\u014a\u014b\7v\2\2\u014b\u014c\7n\2\2\u014c"+
"<\3\2\2\2\u014d\u014e\7t\2\2\u014e\u014f\7v\2\2\u014f\u0150\7t\2\2\u0150"+
">\3\2\2\2\u0151\u0152\7e\2\2\u0152\u0153\7k\2\2\u0153\u0154\7n\2\2\u0154"+
"@\3\2\2\2\u0155\u0156\7t\2\2\u0156\u0157\7e\2\2\u0157\u0158\7n\2\2\u0158"+
"B\3\2\2\2\u0159\u015a\7t\2\2\u015a\u015b\7e\2\2\u015b\u015c\7t\2\2\u015c"+
"D\3\2\2\2\u015d\u015e\7e\2\2\u015e\u015f\7k\2\2\u015f\u0160\7c\2\2\u0160"+
"F\3\2\2\2\u0161\u0162\7n\2\2\u0162\u0163\7t\2\2\u0163\u0164\7u\2\2\u0164"+
"H\3\2\2\2\u0165\u0166\7n\2\2\u0166\u0167\7t\2\2\u0167\u0168\7u\2\2\u0168"+
"\u0169\7u\2\2\u0169J\3\2\2\2\u016a\u016b\7n\2\2\u016b\u016c\7n\2\2\u016c"+
"\u016d\7u\2\2\u016dL\3\2\2\2\u016e\u016f\7n\2\2\u016f\u0170\7n\2\2\u0170"+
"\u0171\7u\2\2\u0171\u0172\7u\2\2\u0172N\3\2\2\2\u0173\u0174\7c\2\2\u0174"+
"\u0175\7n\2\2\u0175\u0176\7u\2\2\u0176P\3\2\2\2\u0177\u0178\7c\2\2\u0178"+
"\u0179\7n\2\2\u0179\u017a\7u\2\2\u017a\u017b\7u\2\2\u017bR\3\2\2\2\u017c"+
"\u017d\7o\2\2\u017d\u017e\7w\2\2\u017e\u017f\7n\2\2\u017fT\3\2\2\2\u0180"+
"\u0181\7k\2\2\u0181\u0182\7f\2\2\u0182\u0183\7k\2\2\u0183\u0184\7x\2\2"+
"\u0184V\3\2\2\2\u0185\u0186\7n\2\2\u0186\u0187\7c\2\2\u0187\u0188\7e\2"+
"\2\u0188\u0189\7s\2\2\u0189X\3\2\2\2\u018a\u018b\7e\2\2\u018b\u018c\7"+
"n\2\2\u018c\u018d\7s\2\2\u018dZ\3\2\2\2\u018e\u018f\7q\2\2\u018f\u0190"+
"\7o\2\2\u0190\u0191\7s\2\2\u0191\\\3\2\2\2\u0192\u0193\7e\2\2\u0193\u0194"+
"\7o\2\2\u0194\u0195\7s\2\2\u0195^\3\2\2\2\u0196\u0197\7n\2\2\u0197\u0198"+
"\7o\2\2\u0198\u0199\7s\2\2\u0199`\3\2\2\2\u019a\u019b\7f\2\2\u019b\u019c"+
"\7u\2\2\u019c\u019d\7e\2\2\u019d\u019e\7u\2\2\u019eb\3\2\2\2\u019f\u01a0"+
"\7f\2\2\u01a0\u01a1\7u\2\2\u01a1\u01a2\7n\2\2\u01a2\u01a3\7y\2\2\u01a3"+
"d\3\2\2\2\u01a4\u01a5\7f\2\2\u01a5\u01a6\7u\2\2\u01a6\u01a7\7n\2\2\u01a7"+
"\u01a8\7o\2\2\u01a8f\3\2\2\2\u01a9\u01aa\7f\2\2\u01aa\u01ab\7u\2\2\u01ab"+
"\u01ac\7n\2\2\u01ac\u01ad\7f\2\2\u01adh\3\2\2\2\u01ae\u01af\7f\2\2\u01af"+
"\u01b0\7u\2\2\u01b0\u01b1\7n\2\2\u01b1\u01b2\7u\2\2\u01b2j\3\2\2\2\u01b3"+
"\u01b4\7f\2\2\u01b4\u01b5\7u\2\2\u01b5\u01b6\7u\2\2\u01b6\u01b7\7h\2\2"+
"\u01b7l\3\2\2\2\u01b8\u01b9\7f\2\2\u01b9\u01ba\7u\2\2\u01ba\u01bb\7t\2"+
"\2\u01bb\u01bc\7u\2\2\u01bcn\3\2\2\2\u01bd\u01be\7k\2\2\u01be\u01bf\7"+
"q\2\2\u01bf\u01c0\7h\2\2\u01c0p\3\2\2\2\u01c1\u01c2\7k\2\2\u01c2\u01c3"+
"\7q\2\2\u01c3\u01c4\7p\2\2\u01c4r\3\2\2\2\u01c5\u01c6\7e\2\2\u01c6\u01c7"+
"\7c\2\2\u01c7\u01c8\7h\2\2\u01c8t\3\2\2\2\u01c9\u01ca\7e\2\2\u01ca\u01cb"+
"\7n\2\2\u01cb\u01cc\7q\2\2\u01cc\u01cd\7p\2\2\u01cdv\3\2\2\2\u01ce\u01cf"+
"\7e\2\2\u01cf\u01d0\7n\2\2\u01d0\u01d1\7u\2\2\u01d1\u01d2\7h\2\2\u01d2"+
"x\3\2\2\2\u01d3\u01d4\7e\2\2\u01d4\u01d5\7n\2\2\u01d5\u01d6\7q\2\2\u01d6"+
"\u01d7\7h\2\2\u01d7z\3\2\2\2\u01d8\u01d9\7m\2\2\u01d9\u01da\7u\2\2\u01da"+
"\u01db\7h\2\2\u01db|\3\2\2\2\u01dc\u01dd\7m\2\2\u01dd\u01de\7t\2\2\u01de"+
"\u01df\7d\2\2\u01df~\3\2\2\2\u01e0\u01e1\7v\2\2\u01e1\u01e2\7u\2\2\u01e2"+
"\u01e3\7h\2\2\u01e3\u0080\3\2\2\2\u01e4\u01e5\7v\2\2\u01e5\u01e6\7e\2"+
"\2\u01e6\u01e7\7h\2\2\u01e7\u0082\3\2\2\2\u01e8\u01e9\7v\2\2\u01e9\u01ea"+
"\7n\2\2\u01ea\u01eb\7u\2\2\u01eb\u0084\3\2\2\2\u01ec\u01ed\7u\2\2\u01ed"+
"\u01ee\7e\2\2\u01ee\u01ef\7m\2\2\u01ef\u0086\3\2\2\2\u01f0\u01f1\7e\2"+
"\2\u01f1\u01f2\7e\2\2\u01f2\u01f3\7m\2\2\u01f3\u0088\3\2\2\2\u01f4\u01f5"+
"\7n\2\2\u01f5\u01f6\7e\2\2\u01f6\u01f7\7m\2\2\u01f7\u008a\3\2\2\2\u01f8"+
"\u01f9\7t\2\2\u01f9\u01fa\7u\2\2\u01fa\u01fb\7h\2\2\u01fb\u008c\3\2\2"+
"\2\u01fc\u01fd\7t\2\2\u01fd\u01fe\7u\2\2\u01fe\u01ff\7c\2\2\u01ff\u008e"+
"\3\2\2\2\u0200\u0201\7t\2\2\u0201\u0202\7t\2\2\u0202\u0203\7d\2\2\u0203"+
"\u0090\3\2\2\2\u0204\u0205\7r\2\2\u0205\u0206\7u\2\2\u0206\u0207\7h\2"+
"\2\u0207\u0092\3\2\2\2\u0208\u0209\7r\2\2\u0209\u020a\7e\2\2\u020a\u020b"+
"\7h\2\2\u020b\u0094\3\2\2\2\u020c\u020d\7r\2\2\u020d\u020e\7u\2\2\u020e"+
"\u020f\7c\2\2\u020f\u0096\3\2\2\2\u0210\u0211\7e\2\2\u0211\u0212\7f\2"+
"\2\u0212\u0213\7h\2\2\u0213\u0098\3\2\2\2\u0214\u0215\7t\2\2\u0215\u0216"+
"\7n\2\2\u0216\u0217\7r\2\2\u0217\u0218\7f\2\2\u0218\u009a\3\2\2\2\u0219"+
"\u021a\7n\2\2\u021a\u021b\7f\2\2\u021b\u021c\7c\2\2\u021c\u009c\3\2\2"+
"\2\u021d\u021e\7y\2\2\u021e\u021f\7e\2\2\u021f\u0220\7i\2\2\u0220\u0221"+
"\7c\2\2\u0221\u009e\3\2\2\2\u0222\u0223\7t\2\2\u0223\u0224\7c\2\2\u0224"+
"\u0225\7g\2\2\u0225\u0226\7h\2\2\u0226\u00a0\3\2\2\2\u0227\u0228\7d\2"+
"\2\u0228\u0229\7g\2\2\u0229\u022a\7i\2\2\u022a\u00a2\3\2\2\2\u022b\u022c"+
"\7u\2\2\u022c\u022d\7r\2\2\u022d\u022e\7d\2\2\u022e\u00a4\3\2\2\2\u022f"+
"\u0230\7e\2\2\u0230\u0231\7r\2\2\u0231\u0232\7d\2\2\u0232\u00a6\3\2\2"+
"\2\u0233\u0234\7n\2\2\u0234\u0235\7r\2\2\u0235\u0236\7d\2\2\u0236\u00a8"+
"\3\2\2\2\u0237\u0238\7y\2\2\u0238\u0239\7d\2\2\u0239\u023a\7n\2\2\u023a"+
"\u00aa\3\2\2\2\u023b\u023c\7f\2\2\u023c\u023d\7r\2\2\u023d\u023e\7t\2"+
"\2\u023e\u023f\7u\2\2\u023f\u00ac\3\2\2\2\u0240\u0241\7f\2\2\u0241\u0242"+
"\7r\2\2\u0242\u0243\7u\2\2\u0243\u0244\7h\2\2\u0244\u00ae\3\2\2\2\u0245"+
"\u0246\7f\2\2\u0246\u0247\7r\2\2\u0247\u0248\7e\2\2\u0248\u0249\7h\2\2"+
"\u0249\u00b0\3\2\2\2\u024a\u024b\7f\2\2\u024b\u024c\7r\2\2\u024c\u024d"+
"\7t\2\2\u024d\u024e\7e\2\2\u024e\u00b2\3\2\2\2\u024f\u0250\7e\2\2\u0250"+
"\u0251\7t\2\2\u0251\u0252\7u\2\2\u0252\u0253\7h\2\2\u0253\u00b4\3\2\2"+
"\2\u0254\u0255\7e\2\2\u0255\u0256\7t\2\2\u0256\u0257\7t\2\2\u0257\u0258"+
"\7d\2\2\u0258\u00b6\3\2\2\2\u0259\u025a\7u\2\2\u025a\u025b\7{\2\2\u025b"+
"\u025c\7u\2\2\u025c\u00b8\3\2\2\2\u025d\u025e\7e\2\2\u025e\u025f\7|\2"+
"\2\u025f\u0260\7o\2\2\u0260\u00ba\3\2\2\2\u0261\u0262\7k\2\2\u0262\u0263"+
"\7t\2\2\u0263\u0264\7u\2\2\u0264\u0265\7u\2\2\u0265\u00bc\3\2\2\2\u0266"+
"\u0267\7f\2\2\u0267\u0268\7u\2\2\u0268\u0269\7o\2\2\u0269\u00be\3\2\2"+
"\2\u026a\u026b\7\60\2\2\u026b\u00c0\3\2\2\2\u026c\u026d\7\60\2\2\u026d"+
"\u026e\7\60\2\2\u026e\u00c2\3\2\2\2\u026f\u0270\7-\2\2\u0270\u00c4\3\2"+
"\2\2\u0271\u0272\7/\2\2\u0272\u00c6\3\2\2\2\u0273\u0274\7,\2\2\u0274\u00c8"+
"\3\2\2\2\u0275\u0276\7\61\2\2\u0276\u00ca\3\2\2\2\u0277\u0279\t\2\2\2"+
"\u0278\u0277\3\2\2\2\u0279\u027a\3\2\2\2\u027a\u0278\3\2\2\2\u027a\u027b"+
"\3\2\2\2\u027b\u027c\3\2\2\2\u027c\u027d\7<\2\2\u027d\u00cc\3\2\2\2\u027e"+
"\u0282\t\3\2\2\u027f\u0281\t\2\2\2\u0280\u027f\3\2\2\2\u0281\u0284\3\2"+
"\2\2\u0282\u0280\3\2\2\2\u0282\u0283\3\2\2\2\u0283\u00ce\3\2\2\2\u0284"+
"\u0282\3\2\2\2\u0285\u0289\t\4\2\2\u0286\u0288\t\5\2\2\u0287\u0286\3\2"+
"\2\2\u0288\u028b\3\2\2\2\u0289\u0287\3\2\2\2\u0289\u028a\3\2\2\2\u028a"+
"\u00d0\3\2\2\2\u028b\u0289\3\2\2\2\u028c\u028e\7f\2\2\u028d\u028f\t\4"+
"\2\2\u028e\u028d\3\2\2\2\u028f\u0290\3\2\2\2\u0290\u028e\3\2\2\2\u0290"+
"\u0291\3\2\2\2\u0291\u00d2\3\2\2\2\u0292\u0294\7q\2\2\u0293\u0295\t\6"+
"\2\2\u0294\u0293\3\2\2\2\u0295\u0296\3\2\2\2\u0296\u0294\3\2\2\2\u0296"+
"\u0297\3\2\2\2\u0297\u00d4\3\2\2\2\u0298\u0299\7f\2\2\u0299\u029a\7o\2"+
"\2\u029a\u029c\3\2\2\2\u029b\u029d\t\4\2\2\u029c\u029b\3\2\2\2\u029d\u029e"+
"\3\2\2\2\u029e\u029c\3\2\2\2\u029e\u029f\3\2\2\2\u029f\u00d6\3\2\2\2\u02a0"+
"\u02a4\7>\2\2\u02a1\u02a3\t\7\2\2\u02a2\u02a1\3\2\2\2\u02a3\u02a6\3\2"+
"\2\2\u02a4\u02a2\3\2\2\2\u02a4\u02a5\3\2\2\2\u02a5\u00d8\3\2\2\2\u02a6"+
"\u02a4\3\2\2\2\u02a7\u02ab\7$\2\2\u02a8\u02aa\n\b\2\2\u02a9\u02a8\3\2"+
"\2\2\u02aa\u02ad\3\2\2\2\u02ab\u02a9\3\2\2\2\u02ab\u02ac\3\2\2\2\u02ac"+
"\u00da\3\2\2\2\u02ad\u02ab\3\2\2\2\u02ae\u02b0\t\b\2\2\u02af\u02ae\3\2"+
"\2\2\u02b0\u02b1\3\2\2\2\u02b1\u02af\3\2\2\2\u02b1\u02b2\3\2\2\2\u02b2"+
"\u00dc\3\2\2\2\u02b3\u02b4\t\t\2\2\u02b4\u02b5\3\2\2\2\u02b5\u02b6\bo"+
"\2\2\u02b6\u00de\3\2\2\2\f\2\u027a\u0282\u0289\u0290\u0296\u029e\u02a4"+
"\u02ab\u02b1\3\b\2\2";
public static final ATN _ATN =
new ATNDeserializer().deserialize(_serializedATN.toCharArray());
static {
_decisionToDFA = new DFA[_ATN.getNumberOfDecisions()];
for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) {
_decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i);
}
}
}

View File

@ -0,0 +1,181 @@
// Generated from com/khubla/pdp7parse/antlr4/pdp7.g4 by ANTLR 4.5
package com.khubla.pdp7parse.antlr4;
import org.antlr.v4.runtime.misc.NotNull;
import org.antlr.v4.runtime.tree.ParseTreeListener;
/**
* This interface defines a complete listener for a parse tree produced by
* {@link pdp7Parser}.
*/
public interface pdp7Listener extends ParseTreeListener {
/**
* Enter a parse tree produced by {@link pdp7Parser#prog}.
* @param ctx the parse tree
*/
void enterProg(pdp7Parser.ProgContext ctx);
/**
* Exit a parse tree produced by {@link pdp7Parser#prog}.
* @param ctx the parse tree
*/
void exitProg(pdp7Parser.ProgContext ctx);
/**
* Enter a parse tree produced by {@link pdp7Parser#line}.
* @param ctx the parse tree
*/
void enterLine(pdp7Parser.LineContext ctx);
/**
* Exit a parse tree produced by {@link pdp7Parser#line}.
* @param ctx the parse tree
*/
void exitLine(pdp7Parser.LineContext ctx);
/**
* Enter a parse tree produced by {@link pdp7Parser#declarations}.
* @param ctx the parse tree
*/
void enterDeclarations(pdp7Parser.DeclarationsContext ctx);
/**
* Exit a parse tree produced by {@link pdp7Parser#declarations}.
* @param ctx the parse tree
*/
void exitDeclarations(pdp7Parser.DeclarationsContext ctx);
/**
* Enter a parse tree produced by {@link pdp7Parser#declaration}.
* @param ctx the parse tree
*/
void enterDeclaration(pdp7Parser.DeclarationContext ctx);
/**
* Exit a parse tree produced by {@link pdp7Parser#declaration}.
* @param ctx the parse tree
*/
void exitDeclaration(pdp7Parser.DeclarationContext ctx);
/**
* Enter a parse tree produced by {@link pdp7Parser#instruction}.
* @param ctx the parse tree
*/
void enterInstruction(pdp7Parser.InstructionContext ctx);
/**
* Exit a parse tree produced by {@link pdp7Parser#instruction}.
* @param ctx the parse tree
*/
void exitInstruction(pdp7Parser.InstructionContext ctx);
/**
* Enter a parse tree produced by {@link pdp7Parser#argument}.
* @param ctx the parse tree
*/
void enterArgument(pdp7Parser.ArgumentContext ctx);
/**
* Exit a parse tree produced by {@link pdp7Parser#argument}.
* @param ctx the parse tree
*/
void exitArgument(pdp7Parser.ArgumentContext ctx);
/**
* Enter a parse tree produced by {@link pdp7Parser#assignment}.
* @param ctx the parse tree
*/
void enterAssignment(pdp7Parser.AssignmentContext ctx);
/**
* Exit a parse tree produced by {@link pdp7Parser#assignment}.
* @param ctx the parse tree
*/
void exitAssignment(pdp7Parser.AssignmentContext ctx);
/**
* Enter a parse tree produced by {@link pdp7Parser#expression}.
* @param ctx the parse tree
*/
void enterExpression(pdp7Parser.ExpressionContext ctx);
/**
* Exit a parse tree produced by {@link pdp7Parser#expression}.
* @param ctx the parse tree
*/
void exitExpression(pdp7Parser.ExpressionContext ctx);
/**
* Enter a parse tree produced by {@link pdp7Parser#multiplyingExpression}.
* @param ctx the parse tree
*/
void enterMultiplyingExpression(pdp7Parser.MultiplyingExpressionContext ctx);
/**
* Exit a parse tree produced by {@link pdp7Parser#multiplyingExpression}.
* @param ctx the parse tree
*/
void exitMultiplyingExpression(pdp7Parser.MultiplyingExpressionContext ctx);
/**
* Enter a parse tree produced by {@link pdp7Parser#atom}.
* @param ctx the parse tree
*/
void enterAtom(pdp7Parser.AtomContext ctx);
/**
* Exit a parse tree produced by {@link pdp7Parser#atom}.
* @param ctx the parse tree
*/
void exitAtom(pdp7Parser.AtomContext ctx);
/**
* Enter a parse tree produced by {@link pdp7Parser#string}.
* @param ctx the parse tree
*/
void enterString(pdp7Parser.StringContext ctx);
/**
* Exit a parse tree produced by {@link pdp7Parser#string}.
* @param ctx the parse tree
*/
void exitString(pdp7Parser.StringContext ctx);
/**
* Enter a parse tree produced by {@link pdp7Parser#signednumber}.
* @param ctx the parse tree
*/
void enterSignednumber(pdp7Parser.SignednumberContext ctx);
/**
* Exit a parse tree produced by {@link pdp7Parser#signednumber}.
* @param ctx the parse tree
*/
void exitSignednumber(pdp7Parser.SignednumberContext ctx);
/**
* Enter a parse tree produced by {@link pdp7Parser#eol}.
* @param ctx the parse tree
*/
void enterEol(pdp7Parser.EolContext ctx);
/**
* Exit a parse tree produced by {@link pdp7Parser#eol}.
* @param ctx the parse tree
*/
void exitEol(pdp7Parser.EolContext ctx);
/**
* Enter a parse tree produced by {@link pdp7Parser#comment}.
* @param ctx the parse tree
*/
void enterComment(pdp7Parser.CommentContext ctx);
/**
* Exit a parse tree produced by {@link pdp7Parser#comment}.
* @param ctx the parse tree
*/
void exitComment(pdp7Parser.CommentContext ctx);
/**
* Enter a parse tree produced by {@link pdp7Parser#label}.
* @param ctx the parse tree
*/
void enterLabel(pdp7Parser.LabelContext ctx);
/**
* Exit a parse tree produced by {@link pdp7Parser#label}.
* @param ctx the parse tree
*/
void exitLabel(pdp7Parser.LabelContext ctx);
/**
* Enter a parse tree produced by {@link pdp7Parser#variable}.
* @param ctx the parse tree
*/
void enterVariable(pdp7Parser.VariableContext ctx);
/**
* Exit a parse tree produced by {@link pdp7Parser#variable}.
* @param ctx the parse tree
*/
void exitVariable(pdp7Parser.VariableContext ctx);
/**
* Enter a parse tree produced by {@link pdp7Parser#opcode}.
* @param ctx the parse tree
*/
void enterOpcode(pdp7Parser.OpcodeContext ctx);
/**
* Exit a parse tree produced by {@link pdp7Parser#opcode}.
* @param ctx the parse tree
*/
void exitOpcode(pdp7Parser.OpcodeContext ctx);
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,210 @@
T__0=1
T__1=2
T__2=3
T__3=4
T__4=5
T__5=6
T__6=7
T__7=8
T__8=9
T__9=10
T__10=11
T__11=12
T__12=13
T__13=14
T__14=15
T__15=16
T__16=17
T__17=18
T__18=19
T__19=20
T__20=21
T__21=22
T__22=23
T__23=24
T__24=25
T__25=26
T__26=27
T__27=28
T__28=29
T__29=30
T__30=31
T__31=32
T__32=33
T__33=34
T__34=35
T__35=36
T__36=37
T__37=38
T__38=39
T__39=40
T__40=41
T__41=42
T__42=43
T__43=44
T__44=45
T__45=46
T__46=47
T__47=48
T__48=49
T__49=50
T__50=51
T__51=52
T__52=53
T__53=54
T__54=55
T__55=56
T__56=57
T__57=58
T__58=59
T__59=60
T__60=61
T__61=62
T__62=63
T__63=64
T__64=65
T__65=66
T__66=67
T__67=68
T__68=69
T__69=70
T__70=71
T__71=72
T__72=73
T__73=74
T__74=75
T__75=76
T__76=77
T__77=78
T__78=79
T__79=80
T__80=81
T__81=82
T__82=83
T__83=84
T__84=85
T__85=86
T__86=87
T__87=88
T__88=89
T__89=90
T__90=91
T__91=92
T__92=93
T__93=94
LOC=95
RELOC=96
PLUS=97
MINUS=98
TIMES=99
DIV=100
LABEL=101
IDENTIFIER=102
NUMERIC_LITERAL=103
DECIMAL=104
OCTAL=105
DECIMAL_MINUS=106
STRING=107
COMMENT=108
EOL=109
WS=110
';'=1
'='=2
'>'=3
'dac'=4
'jms'=5
'dzm'=6
'lac'=7
'xor'=8
'add'=9
'tad'=10
'xct'=11
'isz'=12
'and'=13
'sad'=14
'jmp'=15
'nop'=16
'law'=17
'cma'=18
'las'=19
'ral'=20
'rar'=21
'hlt'=22
'sma'=23
'sza'=24
'snl'=25
'skp'=26
'sna'=27
'szl'=28
'rtl'=29
'rtr'=30
'cil'=31
'rcl'=32
'rcr'=33
'cia'=34
'lrs'=35
'lrss'=36
'lls'=37
'llss'=38
'als'=39
'alss'=40
'mul'=41
'idiv'=42
'lacq'=43
'clq'=44
'omq'=45
'cmq'=46
'lmq'=47
'dscs'=48
'dslw'=49
'dslm'=50
'dsld'=51
'dsls'=52
'dssf'=53
'dsrs'=54
'iof'=55
'ion'=56
'caf'=57
'clon'=58
'clsf'=59
'clof'=60
'ksf'=61
'krb'=62
'tsf'=63
'tcf'=64
'tls'=65
'sck'=66
'cck'=67
'lck'=68
'rsf'=69
'rsa'=70
'rrb'=71
'psf'=72
'pcf'=73
'psa'=74
'cdf'=75
'rlpd'=76
'lda'=77
'wcga'=78
'raef'=79
'beg'=80
'spb'=81
'cpb'=82
'lpb'=83
'wbl'=84
'dprs'=85
'dpsf'=86
'dpcf'=87
'dprc'=88
'crsf'=89
'crrb'=90
'sys'=91
'czm'=92
'irss'=93
'dsm'=94
'.'=95
'..'=96
'+'=97
'-'=98
'*'=99
'/'=100

View File

@ -0,0 +1,210 @@
T__0=1
T__1=2
T__2=3
T__3=4
T__4=5
T__5=6
T__6=7
T__7=8
T__8=9
T__9=10
T__10=11
T__11=12
T__12=13
T__13=14
T__14=15
T__15=16
T__16=17
T__17=18
T__18=19
T__19=20
T__20=21
T__21=22
T__22=23
T__23=24
T__24=25
T__25=26
T__26=27
T__27=28
T__28=29
T__29=30
T__30=31
T__31=32
T__32=33
T__33=34
T__34=35
T__35=36
T__36=37
T__37=38
T__38=39
T__39=40
T__40=41
T__41=42
T__42=43
T__43=44
T__44=45
T__45=46
T__46=47
T__47=48
T__48=49
T__49=50
T__50=51
T__51=52
T__52=53
T__53=54
T__54=55
T__55=56
T__56=57
T__57=58
T__58=59
T__59=60
T__60=61
T__61=62
T__62=63
T__63=64
T__64=65
T__65=66
T__66=67
T__67=68
T__68=69
T__69=70
T__70=71
T__71=72
T__72=73
T__73=74
T__74=75
T__75=76
T__76=77
T__77=78
T__78=79
T__79=80
T__80=81
T__81=82
T__82=83
T__83=84
T__84=85
T__85=86
T__86=87
T__87=88
T__88=89
T__89=90
T__90=91
T__91=92
T__92=93
T__93=94
LOC=95
RELOC=96
PLUS=97
MINUS=98
TIMES=99
DIV=100
LABEL=101
IDENTIFIER=102
NUMERIC_LITERAL=103
DECIMAL=104
OCTAL=105
DECIMAL_MINUS=106
STRING=107
COMMENT=108
EOL=109
WS=110
';'=1
'='=2
'>'=3
'dac'=4
'jms'=5
'dzm'=6
'lac'=7
'xor'=8
'add'=9
'tad'=10
'xct'=11
'isz'=12
'and'=13
'sad'=14
'jmp'=15
'nop'=16
'law'=17
'cma'=18
'las'=19
'ral'=20
'rar'=21
'hlt'=22
'sma'=23
'sza'=24
'snl'=25
'skp'=26
'sna'=27
'szl'=28
'rtl'=29
'rtr'=30
'cil'=31
'rcl'=32
'rcr'=33
'cia'=34
'lrs'=35
'lrss'=36
'lls'=37
'llss'=38
'als'=39
'alss'=40
'mul'=41
'idiv'=42
'lacq'=43
'clq'=44
'omq'=45
'cmq'=46
'lmq'=47
'dscs'=48
'dslw'=49
'dslm'=50
'dsld'=51
'dsls'=52
'dssf'=53
'dsrs'=54
'iof'=55
'ion'=56
'caf'=57
'clon'=58
'clsf'=59
'clof'=60
'ksf'=61
'krb'=62
'tsf'=63
'tcf'=64
'tls'=65
'sck'=66
'cck'=67
'lck'=68
'rsf'=69
'rsa'=70
'rrb'=71
'psf'=72
'pcf'=73
'psa'=74
'cdf'=75
'rlpd'=76
'lda'=77
'wcga'=78
'raef'=79
'beg'=80
'spb'=81
'cpb'=82
'lpb'=83
'wbl'=84
'dprs'=85
'dpsf'=86
'dpcf'=87
'dprc'=88
'crsf'=89
'crrb'=90
'sys'=91
'czm'=92
'irss'=93
'dsm'=94
'.'=95
'..'=96
'+'=97
'-'=98
'*'=99
'/'=100

View File

@ -0,0 +1,35 @@
package com.khubla.pdp7parse;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Collection;
import org.apache.commons.io.FileUtils;
import org.junit.Assert;
import org.junit.Test;
import com.khubla.pdp7parse.antlr4.pdp7Parser.ProgContext;
public class BasicTests {
@Test
public void test1() {
String[] extensions = new String[] { "s" };
Collection<File> files = FileUtils.listFiles(new File("src/test/resources"), extensions, true);
for (File file : files) {
testFile(file);
}
}
private void testFile(File file) {
try {
System.out.println(file.getAbsolutePath());
InputStream is = new FileInputStream(file);
ProgContext progContext = PDP7Parser.parse(is, System.out);
Assert.assertNotNull(progContext);
} catch (Exception e) {
e.printStackTrace();
Assert.fail();
}
}
}

View File

@ -0,0 +1,151 @@
" cat: cat [arg1 arg2 ...]
" Load the pointer pointer in 017777 to see if we have any arguments
lac 017777 i
sad d4 " Skip if we have more than four argument words
jmp nofiles " Only four argument words, so no arguments
lac 017777 " Move five words past the argument word count
tad d1 " so that AC points at the first argument
tad d4 " and save the pointer in name
dac name
loop:
sys open; name:0; 0 " Open file, get fd back
spa
jmp badfile " Negative fd, exit with an error message
dac fi " Save file descriptor in fi
1:
jms getc " Get a character in AC
sad o4
jmp 1f " Break the loop when we get a ctrl-D
jms putc " Write the character on stdout
jmp 1b " and loop back
1:
lac fi " Close the file descriptor in fi
sys close
loop1:
-4
tad 017777 i " Subtract 4 from the count of argument words
dac 017777 i
sad d4 " Is the value 4, i.e. no args left?
jmp done " Yes, so exit
lac name " Still an argument, so move up
tad d4 " to the next filename argument
dac name
jmp loop " and loop back to cat this file
badfile:
lac name " Get the pointer to the filename
dac 1f " Store it in 1f below
lac d8 " Load fd 8 which is stderr
sys write; 1:0; 4 " Write the four words of the filename
lac d8
sys write; 1f; 2 " and then write " ?\n"
jmp loop1 " Now try doing the next argument
1: 040;077012 " String literal: " ?\n"
nofiles:
lac d8
sys write; 1f; 5 " Write "No files\n" to stderr
sys exit " and exit
1: <no>; 040; <fi>;<le>;<s 012
done:
lac noc " Is the number of characters left zero?
sna
sys exit " Yes, exit
and d1
sna cla
jmp 1f
jms putc " Store the character in the buffer
jmp done " and loop back
1:
lac noc " Get the number of characters in the buffer
rcr " Divide by two to convert to words
dac 1f " Save in the write's word count below
lac fo " Load fd 1, stdout
sys write; iopt+1; 1:.. " Write the leftover buffer and exit
sys exit
getc: 0
lac ipt " Load the pointer to the next word in the buffer
sad eipt
jmp 1f " We've reached the end of the buffer, so read more
dac 2f " Save the pointer
add o400000 " Flip the msb and save into ipt
dac ipt
ral " Move the msb into the link register
lac 2f i " Load the word from the buffer
szl " Skip if this is the second character in the word
lrss 9 " It's the first char, shift down the top character
and o177 " Keep the lowest 7 bits
sna
jmp getc+1 " Skip a NUL characters and read another one
jmp getc i " Return the character from the subroutine
1:
lac fi " Buffer is empty, read another 64 characters
sys read; iipt+1; 64
sna
jmp 1f " No characters were read in
tad iipt " Add the word count to the base of the buffer
dac eipt " and store in the end buffer pointer
lac iipt " Reset the ipt to the base of the buffer
dac ipt
jmp getc+1 " and loop back to get one character
1:
lac o4 " No character, return with ctrl-D
jmp getc i " return from subroutine
putc: 0
and o177 " Keep the lowest 7 bits and save into 2f+1
dac 2f+1
lac opt " Save the pointer to the empty buffer
dac 2f " position to 2f
add o400000 " Flip the msb and save back into opt
dac opt " This also has the effect of incrementing
" the opt pointer every second addition!
spa " If the bit was set, we already have one
jmp 1f " character at 2f+1. If no previous character,
lac 2f i " merge the old and new character together
xor 2f+1
jmp 3f " and go to the "save it in buffer" code
1:
lac 2f+1 " Move the character up into the top half
alss 9
3:
dac 2f i " Save the word into the buffer
isz noc " Add 1 to the char count, never skipping
lac noc " Have we reached 128 characters, 64 words?
sad d128
skp
jmp putc i " No, so return (more room still in the buffer)
lac fo " Load fd1 (i.e stdout)
sys write; iopt+1; 64 " and write out the 64 words in the buffer
lac iopt
dac opt " Set opt pointing back to base of buffer
dzm noc " Set the number of chars in the buffer to 0
jmp putc i " and return
2: 0;0 " Current input and output word pointers
ipt: 0 " Current input buffer base
eipt: 0 " Pointer to end of data read in input buffer
iipt: .+1; .=.+64 " 64 word input buffer and pointer to it
fi: 0 " Input file descriptor
opt: .+2 " Current output buffer base
iopt: .+1; .=.+64 " 64 word output buffer and pointer to it
noc: 0 " Number of output characters
fo: 1 " Output file descriptor, fd 1 is stdout
d1: 1 " Octal and decimal constants
o4:d4: 4
d8: 8
o400000: 0400000 " Msb toggle bit
o177: 0177 " ASCII mask
d128: 128 " 128 words in the output buffer

View File

@ -0,0 +1,76 @@
" chown
lac 017777 i
sad d4
jmp error
lac 017777
tad d4
dac 8
tad d1
dac name
dzm octal
dzm nochar
-8
dac c1
1:
lac nchar
dzm nchar
sza
jmp 2f
lac 8 i
lmq
and o177
dac nchar
lacq
lrss 9
2:
sad o40
jmp 3f
tad om60
lmq
lac octal
cll; als 3
omq
dac octal
3:
isz c1
jmp 1b
loop:
lac 017777 i
sad d8
sys exit
tad dm4
dac 017777 i
lac name
tad d4
dac name
lac octal
sys chowner; name:0
sma
jmp loop
lac name
dac 1f
lac d1
sys write; 1:0; 4
lac d1
sys write; 1f; 2
jmp loop
1:
040;077012
error:
lac d1
sys write; 1b+1; 1
sys exit
om60: -060
o40: 040
d1: 1
d8: 8
dm4: -4
d4: 4
o177: 0177
nchar: .=.+1
c1: .=.+1
octal: .=.+1

View File

@ -0,0 +1,501 @@
" ds
lac 017777 i
sad d8
skp
sys exit
lac 017777
tad d5
dac .+3
law 017
sys creat; ..
dac fo
law 017
sys creat; scrname
spa; jms error
dac fso
sys open; scrname; 0
spa; jms error
dac fsi
sys chdir; dd
spa; jms error
lac d1
sys write; pass1; 1
law fsobuf
dac fsopt
dzm nfiles
law fbuf
dac filp
dzm ndirs
law dbuf
dac dirp
dzm fsloc
sys open; dotdot; 0
spa; jms error
dac fd
jms readdir; dotdot
law statbuf
sys status; dotdot; dotdot
spa; jms error
lac statbuf+12 " i index
dac dirp i
isz dirp
-1
tad nfiles
cma
dac ddfiles
law fbuf
dac ddfilp
loop:
-1
tad ndirs
cma
dac c1
law dbuf
dac i1
1:
isz i1
lac i1 i
sad ddfilp i
jmp 2f
isz i1
isz c1
jmp 1b
lac ddfilp
tad i1
dac i1
lac i1 i
dac .+3
lac fsi
sys seek; ..; 0
lac fsi
sys read; scrname; 4
law statbuf
sys status; dotdot; scrname
spa; jms error
lac statbuf+0 " flags
and o20
sna
jmp 2f
sys open; scrname; 0
spa; jms error
dac fd
jms readdir; scrname
lac ddfilp i
dac dirp i
isz dirp
2:
isz ddfilp
isz ddfilp
isz ddfiles
jmp loop
" output phase
lac fso
sys write; fsobuf; 64
lac d1
sys write; pass2; 2
-500
dac c1
1:
law dbuf+2
dac i1
dzm fflg
law fbuf
dac i2
r1
tad nfiles
cma
dac c2
2:
lac c1
tad d501
sad i2 i
skp
jmp 3f
-1
tad i1
dac i3
iac i3 i
dac c3
law fbuf
dac i3
0:
lac i3 i
sad c3
jmp 0f
isz i3
isz i3
jmp 0b
0:
lac i3
tad d1
dac c3
lac c3 i
dac .+3
lac fsi
sys seek; ..; 0
lac fsi
sys read; scrname; 4
lac i2
tad d1
dac c3
lac c3 i
dac .+3
lac fsi
sys seek; ..; 0
lac fsi
sys read; dd; 4
lac fflg
sza
jmp 0f
lac nlinkt
sad nlinka
skp
jms fishy
dzm nlinka
law 012
jms putc
law statbuf
sys status; scrname; dd
spa; jms error
-1
tad statbuf+9
cma
dac nlinkt
-1
dac fflg
jms longout
law 012
jms putc
0:
isz nlinka
jms putname; scrname
jms putname; dd
law 012
jms putc
3:
isz i2
isz i2
lac i2
sad i1 i
skp
jmp .+3
isz i1
isz i1
isz c2
jmp 2b
isz c1
jmp 1b
lac nlinkt
sad nlinka
skp
jms fishy
sys chdir; system
jmp done
fishy: 0
jms asters
jms asters
law 012
jms putc
lac d1
sys write; 1f; 1
jmp fishy i
1: 052012
nlinka: 0
nlinkt: 0
asters: 0
-10
dac c
1:
law 052
jms putc
isz c
jmp 1b
jmp asters i
longout: 0
lac statbuf+12 " i
jms octal; -3
lac statbuf+0 " flags
jms octal; -2
lac statbuf+8 " uid
jms octal; -2
-1
tad statbuf+9 " nlinks
cma
jms octal; -2
lac statbuf+10
jms octal; -5
jmp longout i
readdir: 0
law 012
jms putc
law 012
jms putc
jms asters
lac readdir i
dac 5f
dac .+2
jms putname; ..
jms asters
law 012
jms putc
law 012
jms putc
isz readdir
isz ndirs
lac filp
dac dirp i
isz dirp
0:
jms copyz; buf; 64
lac fd
sys read; buf; 64
spa; jms error
sna
jmp 4f
-8
dac c1
law buf
dac i1
1:
lac i1 i
sna
jmp 3f
isz nfiles
dac filp i
isz filp
lac fsloc
dac filp i
tad d4
dac fsloc
isz filp
lac i1
tad d1
dac .+4
law statbuf
sys status; 5:..; ..
spa; jms error
jms longout
lac i1
tad d1
dac .+2
jms putname; ..
law 012
jms putc
lac i1
dac 8
lac 8 i
dac fsopt i
isz fsopt
lac 8 i
dac fsopt i
isz fsopt
lac 8 i
dac fsopt i
isz fsopt
lac 8 i
dac fsopt i
isz fsopt
law fsobuf+64
sad fsopt
skp
jmp 3f
lac fso
sys write; fsobuf; 64
law fsobuf
dac fsopt
3:
law 8
tad i1
dac i1
isz c1
jmp 1b
jmp 0b
4:
lac fd
sys close
jmp readdir i
putname: 0
-1
tad putname i
dac 8
-4
dac c
1:
lac 8 i
lrss 9
jms putc
llss 9
jms putc
isz c
jmp 1b
isz putname
jmp putname i
octal: 0
lmq
lac d5
tad octal i
cma
dac c
1:
llss 3
isz c
jmp 1b
lac octal i
dac c
1:
ecla llss 3
tad o60
jms putc
isz c
jmp 1b
law 040
jms putc
isz octal
jmp octal i
error: 0
-1
tad error
hlt
sys save
copyz: 0
-1
tad copyz i
dac 8
isz copyz
-1
tad copyz i
cma
dac 2f
isz copyz
1:
dzm 8 i
isz 2f
jmp 1b
jmp copyz i
2: 0
done:
lac noc
sna
sys exit
and d1
sna cla
jmp 1f
jms putc
jmp done
1:
lac noc
rcr
dac 1f
lac fo
sys write; obuf; 1;..
sys exit
putc: 0
and o177
dac 2f+1
lac opt
dac 2f
add o400000
dac opt
spa
jmp 1f
lac 2f i
xor 2f+1
jmp 3f
1:
lac 2f+1
alss 9
3:
dac 2f i
isz noc
lac noc
sad d128
skp
jmp putc i
lac fo
sys write; obuf; 64
lac iopt
dac opt
dzm noc
jmp putc i
2: 0;0
opt: obuf
iopt: obuf
noc: 0
fo: 1
d1: 1
o177: 0177
o400000: 0400000
d128: 128
d4: 4
d5: 5
d8: 8
o60: 060
o20: 020
d501: 501
dd:
<dd>; 040040; 040040; 040040
dotdot:
056056; 040040; 040040; 040040
system:
<sy>;<st>;<em>; 040040
scrname:
<*s>;<rc>;040040;040040
pass2:
<i
pass1:
<i 012
fso: .=.+1
fsi: .=.+1
fsloc: .=.+1
nfiles: .=.+1
fflg: .=.+1
buf: .=.+64
obuf: .=.+64
fd: .=.+1
filp: .=.+1
ddfilp: .=.+1
ddfiles: .=.+1
statbuf: .=.+13
c: .=.+1
i1: .=.+1
i2: .=.+1
i3: .=.+1
c1: .=.+1
c2: .=.+1
c3: .=.+1
ndirs: .=.+1
dirp: .=.+1
fsopt: .=.+1
fsobuf: .=.+64
dbuf: .=.+100
fbuf:

View File

@ -0,0 +1,26 @@
" dsksav
iof
hlt
dzm track
-640
dac c1
1:
lac track
jms dskrd1
lac track
jms dskwr0
lac track
tad d10
dac track
isz c1
jmp 1b
hlt
sys exit
track: 0
c1: 0
d10: 10

View File

@ -0,0 +1,519 @@
"** 08-rest.pdf page 21
"[handwritten page number top right of scan - 14]
" ed2
cs:
jsm getsc; tal
sad o40
jmp cs
sad o12
jmp error
dac delim
jms compile
lac tbufp
dac tal1
1:
jms getsc; tal
sad delim
jmp 1f
sad o12
jmp error
jms putsc; tal1
jmp 1b
1:
lac o12
jms putsc; tal1
jms newline
jms setdd
lac addr1
sad zerop
jmp error
1:
dac addr1
lac i addr1
jms execute
jmp 2f
lac addr1
dac dot
law line-1
dac 8
law nlist-1
dac 9
-64
dac c1
3:
lac i 8
dac i 9
isz c1
jmp 3b
-1
tad fchrno
dac linsiz
rcr
szl
xor o400000
tad linep
dac tal1 "???
lac tbufp
dac tal
3:
jms getsc; tal
sad o12
jmp 3f
jms putsc; tal1
isz linsiz "???
"** 08-rest.pdf page 22
"[handwritten page number top right of scan - 15]
jmp 3b
3:
-1
tad lcrhno
rcr
szl
xor o400000
tad nlistp
dac tal
3:
jms getsc; tal
jms putsc; tal1
isz linsiz
sad o12
skp
jmp 3b
jms addline
2:
lac addr1
sad addr2
jmp advanc
tad d1
jmp 1b
fsrch:
dac delim
jms compile
jms srcsav
lac dot
floop:
tad d1
dac addr
lac i addr
sza
jmp 1f
lac zerop
dac addr
jmp 2f
1:
jms execute
jmp 2f
jms srcres
jmp ad1
2:
lac addr
sad dot
jmp error
jmp floop
bsrch:
dac delim
jms compile
jms srcsav
lac dot
dad zerop
lac eofp
bloop:
tad dm1
dac addr
lac i addr
"** 08-rest.pdf page 23
"[handwritten page number top right of scan - 16]
sza
jmp 1f
lac eofp
dac addr
jmp 2f
1:
jms execute
jmp 2f
jms srcres
jmp ad1
2:
lac addr
sad dot
jmp error
jmp bloop
srcsav: 0
lac minflg
sza
jmp error
lac addr
sma
jmp error
law line-1
dac 8
law tbuf-1
dac 9
-64
dac c1
1:
lac i 8
dac i 9
isz c1
jmp 1b
jmp i srcsav
srcres: 0
law tbuf-1
dac 8
law line-1
dac 9
-64
dac c1
1:
lac i 8
dac i 9
isz c1
jmp 1b
jmp i srcres
compile: 0
law compbuf-1
dac 8
dzm prev
dzm compflg
cadvanc:
jms getsc; tal
sad delim
jmp cdone
dac compflg "???
"** 08-rest.pdf page 24
"[handwritten page number top right of scan - 17]
dzm lastre
sad o12
jmp error
"sad o133
"jmp chrcls
sad o136 "???
jmp beglin
sad o44
jmp endlin
"sad o52
"jmp clsure
dac 1f
jmp comp
1; jms matchar; 1: 0; 0
jmp cadvanc
cdone:
lac compflg
sna
jmp 1f
dac lastre
jms comp
1; jms found; 0
jmp i compile
1: "???
lac lastre
sna
jmp error
jmp i compile
chrcls:
jmp error
beglin: "???
jms comp
1; jms matbol; 0
dzm prev
jmp cadvanc
endlin: "???
jms comp
1; jms mateol; 0
dzm prev
jmp cadvanc
clsure:
lac prev
sna
jmp error
tad d1
dac 1f
jms comp
1; jms matclo; 1: 0; 0
dzm prev
jmp cadvanc
comp: 0 "???
-1
tad comp
dac 9
lac 8 "???
"** 08-rest.pdf page 25
"[handwritten page number top right of scan - 18]
dac prev
1: "???
lac i 9
sna
jmp i 9
dac i 8
jmp 1b
execute: 0
jms gline
lac linep
dac tal1
dzm charno
dzm fchrno
dzm lchrno
lac jmpclist
dac trvect
lac jmpnlist
dac trvect+1
lac jmpxchg
dac i trvect+1
jmp 1f
exchg: "???
lacq
sad o12
jmp i execute
lac jmpxchg
dac i 8
1: "???
lac trvect
lmq
lac trvect+1
dac trvect
lacq
dac trvect+1
tad dm1
dac 8
jms getsc; tal1
lmq
isz charno
jms compbuf
charno:
0
trvect:
0;0
matchar: 0 "???
-2
tad matchar
dac exret
lac i exret
dac exret
lacq
sad i matchar
skp
jmp 1f
lac matchar
adn o17777
tad jms1
dac i 8 "??? [unreadable page cutoff]
"** 08-rest.pdf page 26
"[handwritten page number top right of scan - 19]
lac i exret
dac i 8
1: "???
isz exret
jmp i exret
found: 0
-2
tad found
dac exret
lac i exret
dac exret
lac fchrno
sza
jmp 1f
isz execute
jmp 2f
1: "???
sad i exret
jmp 1f
cma
tad i exret
spa
jmp 2f
jmp 3f
1: "???
lac charno
cma
tad charno
spa
jmp 3f
2: "???
lac i exret
dac fchrno
lac charno
dac lchrno
3: "???
isz exret
jmp i exret
matbol: 0 "???
lac charno
sad d1
jmp 1f
lac matbol
jmp 2f
1: "???
lac matbol
jmp 3f
mateol: 0 "???
lacq
sad o12
jmp 1f
lac mateol
2: "???
tad dm2
dac exret
lac i exret
dac 9
"??? [line is cut off in scan, maybe lac i 8 or jmp i 9]
"** 08-rest.pdf page 27
"[handwritten page number top right of scan - 20]
1: "???
lac mateol
3: "???
tad dm3
dac 9
lac i 9
isz 9
dac i 9
jmp i 9
matclo: 0 "???
-2
tad matclo
dac exret
lac i exret
dac cloret
lac i cloret
dac 1f
dac 2f
lac i matclo
dac exret
jms i exret; 1: 0
isz matclo
jms i matclo; 2: 0
isz cloret
jmp i cloret
"??? the remainder of this scan had an unreadable first character
"??? I did the best I could to recreate the characters appropriately
o1: 1
o133: 0133
dm3: -3
o136: 0136
dm2: -2
o52: 052
o57: 057
o77: 077
o40: 040
o12: 012
d47: 47
d58: 58
dm48: -48
d10: 10
d8: 8
d48: o60: 060
d100000: 100000
o44: 044
o53: 053
o56: 056
o55: 055
o11: 011
o400000: 0400000
o17777: 017777
o144: 0144
dm1: -1
o56012: 056012
o777: 0777
o100: 0100
o43: 043
o777000: 0777000
o75: 075
o167: 0167
o161: 0161
"** 08-rest.pdf page 28
"[handwritten page number top right of scan - 21]
o160: 0160
o143: 0143
o141: 0141
o1777: 01777
d1024: 1024
o776000: 0776000
o162: 0162
o163: 0163
o73: 073
o54: 054
o17: 017
tname:
0145056;0164155;0160040;040040
tbufp: tbuf
linep: line
nlistp: nlist
fbufp: fbuf
dskbfp: dskbuf "[line crossed out - scan markup]
edskbfp: dskbuf+1024 "[line crossed out - scan markup]
lnodp: lnodes
linpm1: line-1
jmpclist: jmp clist
jmpnlist: jmp nlist
jmpxchg: jmp xchg
jms1: jms 1
tal: .=.+1
exret: .=.+1
cloret: .=.+1
delim: .=.+1
prev: .=.+1
compflg: .=.+1
tal1: .=.+1
c1: .=.+1
ital: .=.+1
otal: .=.+1
diskin: .=.+1
glint: .=.+1
c2: .=.+1
num: .=.+1
zermp: .=.+1
minflg: .=.+1
adrflg: .=.+1
dot: .=.+1
addr: .=.+1
addr1: .=.+1
addr2: .=.+1
eofp: .=.+1
zerop: .=.+1
dskadr: .=.+1
linsiz: .=.+1
tfi: .=.+1
fchrno: .=.+1
lchrno: .=.+1
lastre: .=.+1
bett1: .=.+1
bett2: .=.+1
wrflg: .=.+1
apt1: .=.+1
"[page cuts off one label]
"** 08-rest.pdf page 29
"[handwritten page number top right of scan - 22]
sfo: .=.+1
sctal: .=.+1
sctalp: .=.+1
char: .=.+1
fbuf: .=.+4 "not sure if this is fbuf, but
tbuf: .=.+64 "there is a write; tbuf; 64 call
line: .=.+64
nlist: .=.+50
"??? ?list: .=.+50, unable to determine label
compbuf: .=.+100
dskbuf: .=.+1 "[line crossed out - scan markup]
lnodes: .=.+1000

View File

@ -59,7 +59,7 @@ trace: 0
jmp stop
jmp trace i
itrace: 0
dtrace: 0
lac pc
dac 8
lac 8 i

View File

@ -8,7 +8,7 @@ start:
fetch:
lac pc i
imq
lmq
and o17777
dac addr
ecla lls 4
@ -79,7 +79,7 @@ bor:
jmp fetch
band:
lac t2 i
lac t1 i
and t2 i
dac t4 i
jmp fetch
@ -185,7 +185,7 @@ consop:
tad d1
dac sp i
isz sp
iac addr
lac addr
dac sp i
isz sp
jmp fetch
@ -206,13 +206,13 @@ mcall:
dac t2
-1
tad t2 i
imq
lmq
lac dp
dac t1 i
lac t1
dac dp
isz t1
iac pc
lac pc
dac t1 i
lacq
dac pc
@ -364,24 +364,24 @@ unaop:
jmp . i
uadr; umin; uind; unot
badr:
uadr:
lac t1
dac t3 i
jmp fetch
bmin:
umin:
-1
tad t1 i
cma
dac t3 i
jmp fetch
bind:
uind:
lac t1 i
dac t2 i
jmp fetch
bnot:
unot:
lac t1 i
sna cla
lac d1
@ -412,22 +412,22 @@ s = n+a
t = s+a
u = t+a
x = u+a
f = x+a
y = x+a
d1: 1
dm1: -1
dm2: -2
o17777: 017777
:1: 0
:2: 0
:3: 0
:4: 0
:ddr: 0
t1: 0
t2: 0
t3: 0
t4: 0
addr: 0
pc = 017
sp: stack
dp: stack
ip: stack
ap: stack
stack: 0

View File

@ -1,18 +1,18 @@
"** 05-1-4.pdf page 32
" as
jms init1 " initialize
jms init1 " initialize for pass 1
assm1:
lac eofflg
sza " saw EOF?
jmp assm2 " no.
lac passno
jmp assm2 " no.
lac passno " yes
sza " pass==0?
jmp finis " no, pass 2: done
jms init2 " pass 1: init for pass2
jms init2 " initialize for pass 2
assm2:
assm2: " main loop
jms gchar " get character
sad d4 " comma space or tab?
jmp assm1 " yes, ignore
@ -41,7 +41,7 @@ assm2:
assm3:
lac rand
sad d2
jmp assm4
jmp assm4 " yes
sza
jmp assm6
lac rator " fetch operator
@ -67,9 +67,9 @@ assm4:
lac rand+1
tad d4
dac lvrand
lac rator
sza
jmp assm5
lac rator " get operator
sza " ':'?
jmp assm5 " no
lac dot " load dot type
dac r " save as r type
lac dot+1 " get dot value
@ -171,13 +171,13 @@ finis:
sys close
-1
tad namsiz
cma
rcl
cma " get positive count of namelist entries
rcl " multiply by 6 to get words
dac char
rcl
tad char
dac 1f
lac o17
lac o17 " ?? creat mode bits??
sys creat; n.out " create "n.out"
dac bfi
sys write; namlst; 1: 0 " write name list
@ -197,16 +197,16 @@ process: 0
jmp proc4 " no, give "." error
sza " zero?
jmp proc1 " no
-1
tad cmflx+1 " '..' - 1
-1 " yes (".." type)
tad cmflx+1
cma
tad lvrand
tad lvrand " get "." - ".."
dac lvrand
proc1:
lac lvrand
spa
jmp proc4
spa " is relocated value positive?
jmp proc4 " no, give "." error
and o17700 " mask to block
sad bufadd " same block as buffer?
jmp proc2 " yes, same block
@ -224,25 +224,25 @@ proc1:
sys read; buf; 64
proc2:
lac lvrand
and o77 " get word within block
jms betwen; dm1; maxsto
dac maxsto
tad bufp
dac lvrand
lac r
sna
jmp proc3
sad d3
jmp proc5
lac lvrand " destination address
and o77 " word within block
jms betwen; dm1; maxsto " inside buffer?
dac maxsto " no, increment buffer size
tad bufp " add pointer to buffer
dac lvrand " save buffer pointer
lac r " get r type?
sna " non-zero ("." or label)?
jmp proc3 " no: zero (..)
sad d3 " three (user label)?
jmp proc5 " yes
lac cmflx+1 " get ".." value
tad r+1
tad r+1 " add to r value
dac r+1
proc3:
lac r+1
dac i lvrand
jmp i process
lac r+1 " get r value
dac i lvrand " save in buffer
jmp i process " return
proc4:
jms error; .>
@ -266,18 +266,18 @@ bufwr: 0 " write current buffer to a.out file
dac maxsto
jmp i bufwr
number: 0 " print decimal number?
dac 3f
number: 0 " print decimal number: append to buffer at index 8
dac 3f " save number
lac d1000
dac 2f
dac 2f " save divisor
1:
lac 3f
cll
idiv; 2: 0
dac 3f
lacq
tad o60
dac i 8
tad o60 " add ascii '0'
dac i 8 " save char
lac 2b
cll
idiv; 10
@ -288,17 +288,18 @@ number: 0 " print decimal number?
jmp i number
3: 0
" get character from buffer
" get character from buffer (two characters per word)
" call with:
" jms getsc; pointer_pointer
" where pointer_pointer contains a pointer to buffer
" where pointer_pointer refers to a pointer to buffer
" high bit in pointer indicates low char is next
getsc: 0
lac i getsc " get pointer pointer
dac sctalp " save
isz getsc " skip pointer pointer
lac i sctalp " fetch pointer
dac sctal " save
add o400000 " toggle high bit of pointer
add o400000 " toggle high bit, increment on wrap
dac i sctalp " save pointer back
ral " rotate high bit into link reg
lac i sctal " load word from buffer
@ -308,7 +309,7 @@ getsc: 0
jmp i getsc " return
" save characters: word after call is addr of pointer, -count pair
" high bit in pointer used to indicate high or low byte next?
" high bit in pointer used to indicate high/low
putsc: 0
and o177 " strip character to 7 bits
lmq " save in MQ
@ -318,7 +319,7 @@ putsc: 0
"** 05-1-4.pdf page 37
lac i sctalp " get pointer
dac sctal " save
add o400000 " toggle sign bit by adding -0
add o400000 " toggle pointer sign bit, increment on wrap
dac i sctalp " save pointer
sma cla " skip if minus & clear AC
jmp 1f " AC positive
@ -329,7 +330,7 @@ putsc: 0
1:
lac i sctal " load target word
omq " or in char from MQ
omq " or in low char from MQ
dac i sctal " save word back
lacq " restore character
jmp i putsc " return
@ -400,27 +401,27 @@ error: 0
jmp i error " return
1:
-1
tad mesp
dac 8
lac i error
dac i 8
lac o40
dac i 8
lac rator
sad d5
jmp 1f
lac savchr
sad o12
jmp 1f
lac lineno
tad mesp " get mes-1
dac 8 " save as index
lac i error " get error
dac i 8 " save in mess
lac o40 " get space
dac i 8 " save in mess
lac rator " get operator
sad d5 " word break (semi, newline)?
jmp 1f " yes
lac savchr " no, get saved char
sad o12 " newline?
jmp 1f " yes
lac lineno " get lineno
jmp 2f
1:
-1
tad lineno
tad lineno " get lineno -1
2:
jms number
lac o12
dac i 8
jms number " convert line number to ascii
lac o12 " get newline
dac i 8 " append to mess
-2
tad mesp
cma
@ -591,8 +592,8 @@ lqot: " left quote (<)
rqot: " right quote (>)
lac namc " get previous(?) char
1:
dac rand+1
lac d7
dac rand+1 " save value
lac d7 " return as literal
dac rator
jmp i gsymb
@ -770,20 +771,20 @@ lu2:
namep: name
gpair: 0
jms gsymb
jms gsymb " get a symbol
lac rator " get operator
sad d4 " space tab or comma?
jmp gpair+1 " yes, get another
jms betwen; dm1; d6 " anything but a digit?
jmp gp1 " no-- a digit
dzm rand
jms betwen; dm1; d6 " plus, minus, comma, semi?
jmp gp1 " no
dzm rand " clear "rand"
dzm rand+1
jmp i gpair
gp1: " here with digit
sad d7
lac d4
tad dm4
dac rand
jmp i gpair " return
gp1:
sad d7 " digit??
lac d4 " yes: switch to space??
tad dm4 " subtract 4??
dac rand " save as operand??
jms gsymb
lac rator
sad d4 " whitespace?
@ -867,13 +868,15 @@ grand: 0
dac rand+1
jmp i grand
" called with
" jms oper; argument
oper: 0
tad opsw
dac oper1
-1
tad i oper
dac 8
isz oper
tad i oper " pick up argument
dac 8 " store as index
isz oper " skip argument
lac r
sad d3
jmp oper2
@ -958,10 +961,10 @@ o77: 077
o74: 074
o76: 076
namsiz: -2
namlstp: namlst
fnamep: fakename
lactab: lac .+1 " character class table (8 unless noted)
namsiz: -2 " negative numberof namelist entries
namlstp: namlst " pointer to namelist
fnamep: fakename " pointer to fake namelist entry
lactab: lac .+1 " character (operator) class table (8 unless noted)
8;8;8;8;8;8;8;8
8;4;5;8;8;8;8;8 " TAB=4 NL=5
8;8;8;8;8;8;8;8
@ -979,44 +982,44 @@ lactab: lac .+1 " character class table (8 unless noted)
6;6;6;6;6;6;6;6
6;6;6;8;8;8;8;8
fbflg: .=.+1
tal: .=.+1
talc: .=.+1
tal1: .=.+1
tal1c: .=.+1
narg: .=.+1
lvrand: .=.+1
eofflg: .=.+1
namc: .=.+1
passno: .=.+1
char: .=.+1
savchr: .=.+1
comflg: .=.+1
rator: .=.+1
orator: .=.+1
rand: .=.+2
srand: .=.+2
r: .=.+2
name: .=.+4
buf: .=.+64
iobuf: .=.+64
fbx: .=.+10 " forward/backward pointers?
mes: .=.+20
iof: .=.+1
bfi: .=.+1
bfo: .=.+1
lineno: .=.+1
fbflg: .=.+1 " f/b label flag
tal: .=.+1 " iobuf pointer
talc: .=.+1 " -bytecount-1
tal1: .=.+1 " namebuf pointer
tal1c: .=.+1 " -bytecount-1
narg: .=.+1 " argc
lvrand: .=.+1 " numeric constant, word address
eofflg: .=.+1 " 0 on EOF??
namc: .=.+1 " saved char, temporary
passno: .=.+1 " 0=pass1, 1=pass2
char: .=.+1 " current character
savchr: .=.+1 " pushed back char
comflg: .=.+1 " comment flag
rator: .=.+1 " (opo)rator (char type)
orator: .=.+1 " ?? (op)orator
rand: .=.+2 " ?? (ope)rand (type/address pair)
srand: .=.+2 " ?? another operand
r: .=.+2 " ?? yet another??
name: .=.+4 " buffer for accumulating names
buf: .=.+64 " a.out output buffer
iobuf: .=.+64 " input buffer
fbx: .=.+10 " forward/backward counters
mes: .=.+20 " (error) message buffer
iof: .=.+1 " source file fd
bfi: .=.+1 " a.out input fd
bfo: .=.+1 " a.out output fd
lineno: .=.+1 " source file line number
fakename: .=.+6 " dummy entry returned by tlookup??
namlst:
.=.+4
dot: " dot type, value
.=.+6
cmflx: " dotdot type, value
" first four words of name list are symbol (space padded)
fakename: .=.+6 " dummy namelist entry returned by tlookup??
namlst: " symbol table
.=.+4 " dot name
dot: " dot type, value
.=.+6 " dot dot name
cmflx: " dotdot type, value
" namelist (symbol table) entries are 6 words.
" four words of symbol (space padded) name
" next word is type??
" 0: initial dotdot type
" 1: initial dot type
" 3: set by "lookup"
" last word is value??
" 1: initial dot type (reset on error)
" 3: set by "lookup" (user symbol)
" last word is value??

473
tools/as7
View File

@ -1,473 +0,0 @@
#!/usr/bin/perl
#
# Read in files of PDP-7 assembly code in Ken Thompon's as format
# and convert them into PDP-7 machine code
#
# (c) 2016 Warren Toomey, GPL3
# Tweaked by Phil Budne (line, expression parsing, "list", "ptr" formats)
#
use strict;
use warnings;
use Data::Dumper;
use Getopt::Long qw(GetOptions);
Getopt::Long::Configure qw(gnu_getopt);
### Global variables ###
my %Var; # Variables such as ., .., t
my %Label; # Labels that are defined once
my %Rlabel; # Relative labels, e.g. 1:, 2:
# with an array of locations for each label
my @Mem; # Actual PDP-7 memory locations
my @Mline; # Source lines associated with mem locations
my $origline; # The original current input line of code
my $line; # line being parsed
my $stage = 1; # Pass one or pass two
my $errors = 0; # set to non-zero on error
my $line_error = ' ';
my $file; # current file name
my $lineno; # current line number
## command line options
my $debug = 0; # Run in debug mode
my $format = 'a7out'; # output format
# keep this near the GetOptions call to make it easy to add documentation!
sub usage {
die("Usage: $0 [--debug] [--format=a7out|list|ptr ] file1.s [file2.s ...]\n")
}
### Main program ###
GetOptions(
'debug|d' => \$debug,
'format|f=s' => \$format,
) or usage();
usage() if ( @ARGV < 1 );
# start with the location counter at zero
# predefine syscall and opcodes as variables
%Var = (
'.' => 020,
'..' => 4096, # output base addr?
# as.s does not have an initial symbol table
# (except for the above), so there must have been a
# user "ops" file
save => 1, # saves core dump & user area!
getuid => 2,
open => 3,
read => 4,
write => 5,
creat => 6,
seek => 7,
tell => 8,
close => 9,
link => 10,
unlink => 11,
setuid => 12,
rename => 13,
exit => 14,
time => 15,
intrp => 16,
chdir => 17,
chmod => 18,
chown => 19,
# 20 removed
sysloc => 21, # return system addresses
# 22 removed
capt => 23, # capture display?
rele => 24, # release display?
status => 25, # "stat"
smes => 27,
rmes => 28,
fork => 29,
# List of instruction names and machine code values
# These come from https://raw.githubusercontent.com/simh/
sys => 0020000, # "cal i" instruction (trap indirect thru 020)
i => 0020000, # indirect bit
# memory reference instructions
dac => 0040000, # deposit AC
jms => 0100000, # jump to subroutine
dzm => 0140000, # deposit zero in memory
lac => 0200000, # load AC
xor => 0240000, # exclusive or
add => 0300000, # one's complement add
tad => 0340000, # two's complement add
xct => 0400000, # execute
isz => 0440000, # increment and skip if zero
and => 0500000, # AND with contents of Y
sad => 0540000, # skip if AC different from content of Y
jmp => 0600000, # jump to Y
# Type 177 Extended Arithmetic Element (EAE)
eae => 0640000, # base instruction (nop)
osc => 0640001, # OR SC into AC
omq => 0640002, # OR MQ into AC
cmq => 0640004, # Complement MQ
div => 0640323, # divide
norm => 0640444, # normalize, unsigned
lls => 0640600, # long left shift
als => 0640700, # AC shift
lrs => 0640500, # long right shift
lacs => 0641001, # load AC with SC
lacq => 0641002, # load AC with MQ
abs => 0644000, # absolute value
divs => 0644323, # divide, signed
clq => 0650000, # clear MQ
frdiv => 0650323, # fractional divide
lmq => 0652000, # load MQ from AC
mul => 0653122, # multiply
idiv => 0653323, # integer divide
idivs => 0657323, # integer divide, signed
frdivs => 0654323, # fractional divide, signed
muls => 0657122, # multiply, signed
norms => 0660444, # normalize, signed
gsm => 0664000, # get sign and magnitude
lrss => 0660500, # long right shift, signed
llss => 0660600, # long left shift, signed
alss => 0660700, # AC left shift, signed
# PLB: removed I/OT instructions: kernel uses sop.s
# Operate Instructions
# Group 1 (OPR 1) instructions
opr => 0740000, # base operate instruction (nop)
nop => 0740000,
cma => 0740001, # complement accumulator
cml => 0740002, # complement link
oas => 0740004, # inclusive or accumulator switches
ral => 0740010, # rotate (ac, link) left
rar => 0740020, # rotate (ac, link) right
hlt => 0740040, # HALT
xx => 0740040,
sma => 0740100, # skip on minus accumulator
sza => 0740200, # skip on zero accumulator
snl => 0740400, # skip on non-zero link
skp => 0741000, # unconditional skip
spa => 0741100, # skip on positive accumulator
sna => 0741200, # skip on negative accumulator
szl => 0741400, # skip on zero link
rtl => 0742010, # rotate two left (ral*2)
rtr => 0742020, # rotate two right (rar*2)
cll => 0744000, # clear link
stl => 0744002, # set link
rcl => 0744010, # clear link, rotate left
rcr => 0744020, # clear link, rotate right
cla => 0750000, # clear accumulator
clc => 0750001, # clear and complement acc
las => 0750004, # load acc from switches
glk => 0750010, # get link
# Group 2 operate
law => 0760000, # load accumulator with (instruction)
# lam => 0777777, # (load accumulator minus)
);
# Parse all the files
foreach my $file (@ARGV) {
parse_file($file);
}
# Now do it all again, pass two
$Var{'.'} = 020;
$stage = 2;
print("PASS 2\n") if ($debug);
foreach my $file (@ARGV) {
parse_file($file);
}
if ($format eq 'a7out') {
# print out the contents of memory
for my $i ( 0 .. $#Mem ) {
if ( defined( $Mem[$i] ) ) {
printf( "%06o: %06o\t%s\n", $i, $Mem[$i], $Mline[$i] || "" );
}
}
}
elsif ($format eq 'list') {
print "\n";
print "Labels:\n";
foreach my $key (sort keys %Label) {
printf("%-8.8s %#06o\n", $key, $Label{$key});
}
}
elsif ($format eq 'ptr') { # dump absolute memory in PTR binary
for my $loc ( 0 .. $#Mem ) {
my $m = $Mem[$loc] || 0;
printf("%c%c%c", ($m >> 12) & 077, ($m >> 6) & 077, $m & 077);
}
}
else {
die("unknown format $format");
}
# as.s writes a binary file named n.out, ours is ascii
open (my $NOUT, ">n.out") || die "n.out";
foreach my $key (sort keys %Label) {
printf $NOUT "%-8.8s %#06o\n", $key, $Label{$key};
}
close($NOUT);
exit($errors);
# report an assmebly error:
# sets error flag
# reports filename:lineno for emacs m-x compile
sub err {
$line_error = shift;
my $msg = shift;
$errors = 1; # exit status
if ($stage == 2) {
print STDERR "$file:$lineno: $msg\n";
print "$file:$lineno: $msg\n" if (! -t STDOUT && $format ne 'ptr');
}
return 0; # expression value
}
# Open and parse the given file
sub parse_file {
$file = shift;
open( my $IN, "<", $file ) || die("Cannot read $file: $!\n");
$lineno = 0;
while ( $line = <$IN> ) {
$lineno++;
chomp($line); # Lose the end of line
$origline = $line;
print "\t\t$line\n" if ($stage == 2 && $line ne '' && $format eq 'list');
parse_line();
}
close($IN);
}
# process a label and set its value to the location counter
# OK for symbolic label to be entered twice, so long as it's the same value
# (ie; both passes)
sub process_label {
my $label = shift;
my $loc = $Var{'.'};
print "process_label $label\n" if ($debug);
if ( $label =~ m{^\d+$} ) { # numeric (relative) label?
if ($stage == 1) {
push( @{ $Rlabel{$label} }, $loc );
printf( "Pushing %#o for label %s\n", $loc, $label ) if ($debug);
}
} # numeric label
else { # symbolic label
# error to have different values
if ( defined( $Label{$label} ) && $Label{$label} != $loc ) {
err('M', "Label $label multiply defined");
}
else {
$Label{$label} = $loc;
printf( "Set label %s to %#o\n", $label, $loc ) if ($debug);
}
}
}
sub eol {
return $line eq '' || $line =~ m{^"}; # empty or comment
}
# Blame Phil for this....
# parses global $line based on prefixes, nibbling of a bit at a time
# (: and ; can appear in char literals)
# handles multiple ';' separated words per line
# allows " in character literals (tho none appear in listings)
sub parse_line {
while (1) {
$line_error = ' '; # clear listing error indicator
return if (eol());
# Lose any leading whitespace
$line =~ s{^\s*}{};
print "parse_line: '$line'\n" if ($debug);
while ($line =~ s{^([a-z0-9\.]+):\s*}{}) { # labels
process_label($1);
}
return if (eol());
if ( $line =~ s{^(\S+)\s*=}{}) { # assignment
my $lhs = $1;
my $word = parse_expression();
printf( "Setting variable %s to 0%o\n", $lhs, $word ) if ($debug);
$Var{$lhs} = $word;
printf("\t%06o %s\n", $word, $line_error) if ($stage == 2 && $format eq 'list');
}
else { # bare expression (not assignment)
# Get its value on pass two and save to memory
# Also save the input line that altered memory
my $word = parse_expression();
if ( $stage == 2 ) {
my $location = $Var{'.'};
$Mem[$location] = $word;
$Mline[$location] = $origline;
$origline = '';
if ($format eq 'list' and defined($word)) {
printf( "%06o: %06o %s\n", $location, $word, $line_error);
}
}
# Move up to the next location in both passes
$Var{'.'}++;
} # expr
# eat trailing whitespace and ";", if any
$line =~ s{^\s*;?}{};
} # while
}
# Blame Phil for this bit too...
# Parse an expression off $line and return a PDP-7 word
# as a series of whitespace separated "syllables"
# ORed, added, or subtracted
sub parse_expression {
my $word = 0;
print "expression: '$line'\n" if ($debug);
while (1) {
my $syllable = 0;
my $op = '|';
$line =~ s{^\s+}{}; # as.s accepts ",' as whitespace too!
if ($line eq '' || $line =~ m{^[";]}) { # EOL ; and " terminate expr
printf("\tparse_expression => %#o\n", $word) if ($debug);
return $word;
}
print " '$line'\n" if ($debug);
if ($line =~ s{^-}{}) {
print "\tfound -\n" if ($debug);
$op = '-';
}
elsif ($line =~ s{^\+}{}) {
print "\tfound +\n" if ($debug);
$op = '+';
}
if ($line =~ s{^<(.)}{}) { # <char
print "\tfound <x\n" if ($debug);
$syllable = ord($1) << 9;
}
elsif ($line =~ s{^(.)>}{}) { # char>
print "\tfound x>\n" if ($debug);
$syllable = ord($1)
}
elsif ($line =~ s{^>(.)}{}) { # >char !!
print "\tfound >x\n" if ($debug);
$syllable = ord($1)
}
elsif ($line =~ s{^([a-z\.][a-z0-9\.]*)}{}) {
my $sym = $1;
print "\tsym: $sym\n" if ($debug);
if (defined($Var{$sym})) {
$syllable = $Var{$sym};
printf("\tvar: %s: %#o\n", $sym, $syllable) if ($debug);
}
elsif (defined($Label{$sym})) {
$syllable = $Label{$sym};
printf("\tlbl: %s: %#o\n", $sym, $syllable) if ($debug);
}
elsif ($stage == 2) {
err('U', "$sym not defined")
} # pass 2
} # symbol
elsif ( $line =~ s{^(\d+)([fb])}{} ) { # relative label
printf "\tfound relative: $1$2\n" if ($debug);
$syllable = find_relative_label( $1, $2 ) if ($stage == 2);
}
elsif ( $line =~ s{^(\d+)}{} ) { # constant
my $value = $1;
printf "\tfound constant: $value\n" if ($debug);
if ( $value =~ m{^0} ) {
$syllable = oct($value);
}
else {
$syllable = $value + 0;
}
$syllable &= 0777777;
}
else {
# From the BSD fortune file:
# Ken Thompson has an automobile which he helped design.
# Unlike most automobiles, it has neither speedometer,
# nor gas gauge, nor any of the numerous idiot lights
# which plague the modern driver. Rather, if the driver
# makes any mistake, a giant "?" lights up in the center
# of the dashboard. "The experienced driver",
# he says, "will usually know what's wrong.
err('?', "huh? '$line'");
$line = ''; # abort processing
return undef;
}
if ($op eq '+') {
$word += $syllable;
}
elsif ($op eq '-') {
$word -= $syllable;
}
else {
$word |= $syllable;
}
$word &= 0777777;
printf("\tsyllable: %#o word: %#o\n", $syllable, $word) if ($debug);
}
}
# Given a relative label number and a direction,
# return the location of this relative label or
# die if we don't have one
sub find_relative_label {
my ( $label, $direction ) = @_;
my $curlocation = $Var{'.'};
# Error check: no labels at all
if ( !defined( $Rlabel{$label} ) ) {
return err('U', "relative label $label never defined");
}
# Get the list of possible locations for this label
my $locarray = $Rlabel{$label};
# Error check: no locations
return err('U', "No relative labels") if ( @{$locarray} == 0 );
if ( $direction eq 'f' ) {
# Search forward for first location larger then the current one
foreach my $reflocation ( @{$locarray} ) {
printf("forward %#o %#o\n", $reflocation, $curlocation) if ($debug);
return ($reflocation) if ( $reflocation > $curlocation );
}
}
else {
# Search backwards for first location smaller than the current one
foreach my $reflocation ( sort( { $b <=> $a } @{$locarray} ) ) {
printf("backward %#o %#o\n", $reflocation, $curlocation) if ($debug);
return ($reflocation) if ( $reflocation < $curlocation );
}
}
return err('U', "undefined relative reference $label$direction");
}