mirror of
https://github.com/aap/pdp6.git
synced 2026-02-27 09:19:45 +00:00
been working on a new assmbler and a linker
This commit is contained in:
22
mem
22
mem
@@ -577,36 +577,38 @@
|
||||
0
|
||||
777700001000
|
||||
200740001101
|
||||
260740001122
|
||||
260740001130
|
||||
201000001142
|
||||
260740001114
|
||||
260740001123
|
||||
260740001131
|
||||
201000000012
|
||||
260740001130
|
||||
260740001131
|
||||
201000000141
|
||||
260740001130
|
||||
260740001131
|
||||
254200000000
|
||||
200200000000
|
||||
200004000000
|
||||
254200000000
|
||||
350000000004
|
||||
336000000000
|
||||
263740000000
|
||||
260740001130
|
||||
254000001113
|
||||
260740001131
|
||||
254000001115
|
||||
712240000000
|
||||
606000000040
|
||||
254000001122
|
||||
254000001123
|
||||
712040000000
|
||||
620000000200
|
||||
263740000000
|
||||
712240000001
|
||||
602040000020
|
||||
254000001130
|
||||
254000001131
|
||||
435000000200
|
||||
712140000000
|
||||
302000000212
|
||||
263740000000
|
||||
201000000015
|
||||
254000001130
|
||||
254000001131
|
||||
141
|
||||
142
|
||||
143
|
||||
0
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
P=17
|
||||
TTY=120
|
||||
|
||||
TAC=1
|
||||
TAC1=2
|
||||
|
||||
PDLLEN=100
|
||||
|
||||
@@ -15,6 +16,8 @@ SP: -PDLLEN,,PDL-1
|
||||
|
||||
START:
|
||||
MOVE P,SP
|
||||
MOVEI 0,STR
|
||||
PUSHJ P,PUTSTR
|
||||
PUSHJ P,GETCH
|
||||
PUSHJ P,PUTCHR
|
||||
MOVEI 0,"\n
|
||||
@@ -27,7 +30,6 @@ PUTSTR:
|
||||
MOVE 4,0 # save str pointer to AC4
|
||||
PLOOP:
|
||||
MOVE 0,(4) # load char
|
||||
JRST 4,
|
||||
AOS 4 # advance to next
|
||||
SKIPN 0 # check for end of string
|
||||
POPJ P,
|
||||
@@ -57,3 +59,4 @@ STR:
|
||||
"a
|
||||
"b
|
||||
"c
|
||||
0
|
||||
|
||||
1410
tools/as6.c
Normal file
1410
tools/as6.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -3,34 +3,10 @@
|
||||
#include <stdint.h>
|
||||
#include <assert.h>
|
||||
#include "pdp6common.h"
|
||||
#include "pdp6bin.h"
|
||||
#include "../args.h"
|
||||
|
||||
word fw(hword l, hword r) { return ((word)l << 18) | (word)r; }
|
||||
word point(word pos, word sz, hword p){ return (pos<<30)|(sz<<24)|p; }
|
||||
hword left(word w) { return (w >> 18) & 0777777; }
|
||||
hword right(word w) { return w & 0777777; }
|
||||
|
||||
/* just a subset here */
|
||||
enum ItemType
|
||||
{
|
||||
Nothing = 0,
|
||||
Code = 1,
|
||||
Symbols = 2,
|
||||
Entry = 4,
|
||||
End = 5,
|
||||
Name = 6,
|
||||
Start = 7,
|
||||
};
|
||||
|
||||
enum SymType
|
||||
{
|
||||
SymName = 000,
|
||||
SymGlobal = 004,
|
||||
SymLocal = 010,
|
||||
SymBlock = 014,
|
||||
SymGlobalH = 044, /* hidden
|
||||
SymLocalH = 050, */
|
||||
SymUndef = 060,
|
||||
};
|
||||
char *argv0;
|
||||
|
||||
enum
|
||||
{
|
||||
@@ -56,6 +32,9 @@ hword rel, loc;
|
||||
|
||||
int error;
|
||||
|
||||
char **files;
|
||||
int nfiles;
|
||||
|
||||
/*
|
||||
* debugging helpers
|
||||
*/
|
||||
@@ -332,7 +311,6 @@ void
|
||||
handlesym(void)
|
||||
{
|
||||
int i;
|
||||
word w1, w2;
|
||||
|
||||
while(itemsz){
|
||||
readblock(2);
|
||||
@@ -351,11 +329,27 @@ skipitem(void)
|
||||
readblock(0);
|
||||
}
|
||||
|
||||
void
|
||||
save(const char *filename)
|
||||
{
|
||||
FILE *out;
|
||||
out = mustopen(filename, "wb");
|
||||
fclose(out);
|
||||
}
|
||||
|
||||
void
|
||||
usage(void)
|
||||
{
|
||||
fprintf(stderr, "usage: %s\n", argv0);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
word w;
|
||||
hword i, type;
|
||||
hword type;
|
||||
int i;
|
||||
void (*typesw[8])(void) = {
|
||||
skipitem,
|
||||
handlecode,
|
||||
@@ -367,22 +361,36 @@ main()
|
||||
handlestart,
|
||||
};
|
||||
|
||||
// rel = 01000;
|
||||
in = mustopen("test.rel", "rb");
|
||||
while(w = getword(in), w != ~0){
|
||||
type = left(w);
|
||||
itemsz = right(w);
|
||||
typesw[type]();
|
||||
ARGBEGIN{
|
||||
case 'r':
|
||||
rel = strtol(EARGF(usage()), NULL, 8);
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
}ARGEND;
|
||||
|
||||
nfiles = argc;
|
||||
files = argv;
|
||||
|
||||
for(i = 0; i < nfiles; i++){
|
||||
in = mustopen(files[i], "rb");
|
||||
while(w = getword(in), w != ~0){
|
||||
type = left(w);
|
||||
itemsz = right(w);
|
||||
typesw[type]();
|
||||
}
|
||||
fclose(in);
|
||||
}
|
||||
fclose(in);
|
||||
|
||||
checkundef();
|
||||
if(error)
|
||||
return 1;
|
||||
|
||||
disasmrange(findsym(rad50(0, "LINKSR"))[1],
|
||||
findsym(rad50(0, "LINEP"))[1]);
|
||||
disasmrange(0600+rel, 0603+rel);
|
||||
// disasmrange(findsym(rad50(0, "LINKSR"))[1],
|
||||
// findsym(rad50(0, "LINEP"))[1]);
|
||||
// disasmrange(0600+rel, 0603+rel);
|
||||
|
||||
save("a.dump");
|
||||
|
||||
return 0;
|
||||
}
|
||||
22
tools/pdp6bin.h
Normal file
22
tools/pdp6bin.h
Normal file
@@ -0,0 +1,22 @@
|
||||
/* just a subset here */
|
||||
enum ItemType
|
||||
{
|
||||
Nothing = 0,
|
||||
Code = 1,
|
||||
Symbols = 2,
|
||||
Entry = 4,
|
||||
End = 5,
|
||||
Name = 6,
|
||||
Start = 7,
|
||||
};
|
||||
|
||||
enum SymType
|
||||
{
|
||||
SymName = 000,
|
||||
SymGlobal = 004,
|
||||
SymLocal = 010,
|
||||
SymBlock = 014,
|
||||
SymGlobalH = 044, /* hidden
|
||||
SymLocalH = 050, */
|
||||
SymUndef = 060,
|
||||
};
|
||||
@@ -1,7 +1,16 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <ctype.h>
|
||||
#include "pdp6common.h"
|
||||
|
||||
word fw(hword l, hword r) { return ((word)l << 18) | (word)r; }
|
||||
word point(word pos, word sz, hword p) { return (pos<<30)|(sz<<24)|p; }
|
||||
hword left(word w) { return (w >> 18) & 0777777; }
|
||||
hword right(word w) { return w & 0777777; }
|
||||
word negw(word w) { return (~w + 1) & 0777777777777; }
|
||||
int isneg(word w) { return !!(w & 0400000000); }
|
||||
|
||||
/* map ascii to radix50/squoze, also map lower to upper case */
|
||||
char
|
||||
ascii2rad(char c)
|
||||
@@ -27,18 +36,26 @@ ascii2rad(char c)
|
||||
return tab[c&0177];
|
||||
}
|
||||
|
||||
static char rad50tab[] = {
|
||||
' ', '0', '1', '2', '3', '4', '5', '6',
|
||||
'7', '8', '9', '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', '.', '$', '%',
|
||||
0
|
||||
};
|
||||
|
||||
/* map radix50/squoze to ascii */
|
||||
char
|
||||
rad2ascii(char c)
|
||||
{
|
||||
static char tab[] = {
|
||||
' ', '0', '1', '2', '3', '4', '5', '6',
|
||||
'7', '8', '9', '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', '.', '$', '%'
|
||||
};
|
||||
return tab[c%050];
|
||||
return rad50tab[c%050];
|
||||
}
|
||||
|
||||
int
|
||||
israd50(char c)
|
||||
{
|
||||
return strchr(rad50tab, toupper(c)) != NULL;
|
||||
}
|
||||
|
||||
/* convert ascii string + code to radix50 */
|
||||
@@ -105,22 +122,31 @@ ascii2sixbit(char c)
|
||||
return tab[c&0177];
|
||||
}
|
||||
|
||||
static char sixbittab[] = {
|
||||
' ', '!', '"', '#', '$', '%', '&', '\'',
|
||||
'(', ')', '*', '+', ',', '-', '.', '/',
|
||||
'0', '1', '2', '3', '4', '5', '6', '7',
|
||||
'8', '9', ':', ';', '<', '=', '>', '?',
|
||||
'@', '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', '[', '\\', ']', '^', '_',
|
||||
0
|
||||
|
||||
};
|
||||
|
||||
|
||||
/* map sixbit to ascii */
|
||||
char
|
||||
sixbit2ascii(char c)
|
||||
{
|
||||
static char tab[] = {
|
||||
' ', '!', '"', '#', '$', '%', '&', '\'',
|
||||
'(', ')', '*', '+', ',', '-', '.', '/',
|
||||
'0', '1', '2', '3', '4', '5', '6', '7',
|
||||
'8', '9', ':', ';', '<', '=', '>', '?',
|
||||
'@', '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', '[', '\\', ']', '^', '_'
|
||||
|
||||
};
|
||||
return tab[c&077];
|
||||
return sixbittab[c&077];
|
||||
}
|
||||
|
||||
int
|
||||
issixbit(char c)
|
||||
{
|
||||
return strchr(sixbittab, toupper(c)) != NULL;
|
||||
}
|
||||
|
||||
/* convert ascii string to sixbit */
|
||||
@@ -1,12 +1,21 @@
|
||||
typedef uint64_t word;
|
||||
typedef uint32_t hword;
|
||||
|
||||
word fw(hword l, hword r);
|
||||
word point(word pos, word sz, hword p);
|
||||
hword left(word w);
|
||||
hword right(word w);
|
||||
word negw(word w);
|
||||
int isneg(word w);
|
||||
|
||||
char ascii2rad(char c);
|
||||
char rad2ascii(char c);
|
||||
int israd50(char c);
|
||||
word rad50(int n, const char *s);
|
||||
int unrad50(word r, char *s);
|
||||
char ascii2sixbit(char c);
|
||||
char sixbit2ascii(char c);
|
||||
int issixbit(char c);
|
||||
word sixbit(const char *s);
|
||||
void unsixbit(word sx, char *s);
|
||||
char *disasm(word w);
|
||||
181
tools/rel.c
Normal file
181
tools/rel.c
Normal file
@@ -0,0 +1,181 @@
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include "pdp6common.h"
|
||||
|
||||
word fw(hword l, hword r) { return ((word)l << 18) | (word)r; }
|
||||
hword left(word w) { return (w >> 18) & 0777777; }
|
||||
hword right(word w) { return w & 0777777; }
|
||||
|
||||
word item[01000000];
|
||||
int itemp;
|
||||
|
||||
FILE *infp;
|
||||
int type;
|
||||
|
||||
int peekc;
|
||||
int ch(void){
|
||||
int c;
|
||||
if(peekc){
|
||||
c = peekc;
|
||||
peekc = 0;
|
||||
return c;
|
||||
}
|
||||
tail:
|
||||
c = getc(infp);
|
||||
if(c == ';'){
|
||||
while(c = getc(infp), c != '\n')
|
||||
if(c == EOF) return c;
|
||||
goto tail;
|
||||
}
|
||||
if(c == '\t' || c == '\n')
|
||||
c = ' ';
|
||||
return c;
|
||||
}
|
||||
int chsp(void){
|
||||
int c;
|
||||
while(c = ch(), c == ' ');
|
||||
return c;
|
||||
}
|
||||
int peek(void) { return peekc = ch(); }
|
||||
int peeksp(void) { return peekc = chsp(); }
|
||||
int isoct(int c) { return c >= '0' && c <= '7'; }
|
||||
word num(void){
|
||||
word w;
|
||||
int c;
|
||||
|
||||
w = 0;
|
||||
while(c = ch(), c != EOF){
|
||||
if(!isoct(c)){
|
||||
peekc = c;
|
||||
break;
|
||||
}
|
||||
w = (w<<3) | c-'0';
|
||||
}
|
||||
return w;
|
||||
}
|
||||
void dumpitem(void){
|
||||
word head;
|
||||
int type, sz;
|
||||
int p;
|
||||
int i;
|
||||
|
||||
type = left(item[0]);
|
||||
sz = right(item[0]);
|
||||
printf("%06o %06o\n", type, sz);
|
||||
p = 1;
|
||||
while(sz){
|
||||
head = item[p++];
|
||||
i = 18;
|
||||
while(sz && i--){
|
||||
printf(" %06o%c%06o%c\n",
|
||||
left(item[p]),
|
||||
head & 0400000000000 ? '\'' : ' ',
|
||||
right(item[p]),
|
||||
head & 0200000000000 ? '\'' : ' ');
|
||||
head <<= 2;
|
||||
p++;
|
||||
sz--;
|
||||
}
|
||||
}
|
||||
}
|
||||
void type0(void)
|
||||
{
|
||||
int c;
|
||||
while(c = chsp(), c != EOF){
|
||||
switch(c){
|
||||
case ':':
|
||||
type = num();
|
||||
printf("TYPE %o\n", type);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
void type1(void)
|
||||
{
|
||||
int c;
|
||||
word bits;
|
||||
hword l, r;
|
||||
word head;
|
||||
word block[18];
|
||||
int n;
|
||||
int sz;
|
||||
int i;
|
||||
|
||||
sz = 0;
|
||||
itemp = 0;
|
||||
item[itemp++] = 0;
|
||||
|
||||
n = 0;
|
||||
head = 0;
|
||||
while(c = chsp(), c != EOF){
|
||||
switch(c){
|
||||
case ':':
|
||||
type = num();
|
||||
printf("TYPE %o\n", type);
|
||||
goto out;
|
||||
case '0': case '1': case '2': case '3':
|
||||
case '4': case '5': case '6': case '7':
|
||||
peekc = c;
|
||||
bits = 0;
|
||||
l = num();
|
||||
if(peeksp() == '\''){
|
||||
bits |= 2;
|
||||
chsp();
|
||||
}
|
||||
while(c = ch(), !isoct(c));
|
||||
peekc = c;
|
||||
r = num();
|
||||
if(peeksp() == '\''){
|
||||
bits |= 1;
|
||||
chsp();
|
||||
}
|
||||
block[n++] = fw(l, r);
|
||||
head = head<<2 | bits;
|
||||
/* write out one block */
|
||||
if(n == 18){
|
||||
item[itemp++] = head;
|
||||
for(i = 0; i < 18; i++){
|
||||
item[itemp++] = block[i];
|
||||
sz++;
|
||||
}
|
||||
n = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
out:
|
||||
/* write incomplete block */
|
||||
if(n){
|
||||
head <<= (18-n)*2;
|
||||
item[itemp++] = head;
|
||||
for(i = 0; i < n; i++){
|
||||
item[itemp++] = block[i];
|
||||
sz++;
|
||||
}
|
||||
|
||||
}
|
||||
/* write item header */
|
||||
item[0] = fw(01, sz);
|
||||
dumpitem();
|
||||
}
|
||||
int main(){
|
||||
int c;
|
||||
word n;
|
||||
|
||||
infp = stdin;
|
||||
type = 0;
|
||||
while(peek() != EOF)
|
||||
switch(type){
|
||||
case 0:
|
||||
type0();
|
||||
break;
|
||||
case 1:
|
||||
type1();
|
||||
break;
|
||||
default:
|
||||
goto out;
|
||||
}
|
||||
out:
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,33 +1,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include "pdp6common.h"
|
||||
|
||||
word fw(hword l, hword r) { return ((word)l << 18) | (word)r; }
|
||||
hword left(word w) { return (w >> 18) & 0777777; }
|
||||
hword right(word w) { return w & 0777777; }
|
||||
|
||||
/* just a subset here */
|
||||
enum ItemType
|
||||
{
|
||||
Nothing = 0,
|
||||
Code = 1,
|
||||
Symbols = 2,
|
||||
Entry = 4,
|
||||
End = 5,
|
||||
Name = 6,
|
||||
Start = 7,
|
||||
};
|
||||
|
||||
enum SymType
|
||||
{
|
||||
SymName = 000,
|
||||
SymGlobal = 004,
|
||||
SymLocal = 010,
|
||||
SymBlock = 014,
|
||||
SymGlobalH = 044, /* hidden
|
||||
SymLocalH = 050, */
|
||||
SymUndef = 060,
|
||||
};
|
||||
#include "pdp6bin.h"
|
||||
|
||||
word item[01000000];
|
||||
hword itemp, headp;
|
||||
Reference in New Issue
Block a user