Skip to content

Commit 7e76fbb

Browse files
committed
Split off libword.
1 parent d607af9 commit 7e76fbb

20 files changed

+222
-110
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ palx
1515
kldcp
1616
klfedr
1717
libfiles.a
18-
libwords.a
1918
scrmbl
2019
unscr
2120
tvpic

Makefile

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11

2-
CFLAGS = -g -W -Wall
2+
CFLAGS = -g -W -Wall -Ilibword
33

44
FILES = sblk-file.o pdump-file.o dmp-file.o raw-file.o exe-file.o \
55
mdl-file.o rim10-file.o fasl-file.o palx-file.o lda-file.o \
66
cross-file.o hex-file.o atari-file.o iml-file.o exb-file.o \
77
tenex-file.o csave-file.o hiseg-file.o
88

9-
WORDS = aa-word.o alto-word.o bin-word.o cadr-word.o core-word.o \
10-
data8-word.o dta-word.o its-word.o oct-word.o pt-word.o \
11-
sail-word.o tape-word.o
9+
LIBWORD = libword/libword.a
1210

1311
OBJS = pdp10-opc.o info.o dis.o symbols.o \
1412
timing.o timing_ka10.o timing_ki10.o memory.o weenix.o
@@ -21,96 +19,97 @@ UTILS = cat36 itsarc magdmp magfrm dskdmp dump \
2119
all: dis10 $(UTILS) check
2220

2321
clean:
24-
rm -f $(OBJS) $(WORDS) libfiles.a libwords.a
22+
cd libword; make clean
23+
rm -f $(OBJS) libfiles.a
2524
rm -f dis10 core
2625
rm -f $(UTILS)
2726
rm -f main.o dmp.o raw.o das.o crypt.o
2827
for f in $(UTILS); do rm -f $${f}.o; done
2928
rm -f out/*
3029
rm -f check
3130

32-
dis10: main.o $(OBJS) libfiles.a libwords.a
31+
dis10: main.o $(OBJS) libfiles.a $(LIBWORD)
3332
$(CC) $(CFLAGS) $^ -o $@
3433

3534
libfiles.a: file.o $(FILES)
3635
ar -crs $@ $^
3736

38-
libwords.a: word.o $(WORDS)
39-
ar -crs $@ $^
37+
$(LIBWORD):
38+
cd libword && make
4039

41-
cat36: cat36.o libwords.a
40+
cat36: cat36.o $(LIBWORD)
4241
$(CC) $(CFLAGS) $^ -o $@
4342

44-
dump: dump.c $(OBJS) libfiles.a libwords.a
43+
dump: dump.c $(OBJS) libfiles.a $(LIBWORD)
4544
$(CC) $(CFLAGS) $^ -o $@
4645

47-
dskdmp: dskdmp.c $(OBJS) libwords.a
46+
dskdmp: dskdmp.c $(OBJS) $(LIBWORD)
4847
$(CC) $(CFLAGS) $^ -o $@
4948

50-
macdmp: macdmp.c $(OBJS) libwords.a
49+
macdmp: macdmp.c $(OBJS) $(LIBWORD)
5150
$(CC) $(CFLAGS) $^ -o $@
5251

53-
tendmp: tendmp.o dec.o $(OBJS) libfiles.a libwords.a
52+
tendmp: tendmp.o dec.o $(OBJS) libfiles.a $(LIBWORD)
5453
$(CC) $(CFLAGS) $^ -o $@
5554

56-
magdmp: magdmp.c core-word.o $(OBJS) libwords.a
55+
magdmp: magdmp.c $(OBJS) $(LIBWORD)
5756
$(CC) $(CFLAGS) $^ -o $@
5857

59-
magfrm: magfrm.c core-word.o $(OBJS) libwords.a
58+
magfrm: magfrm.c $(OBJS) $(LIBWORD)
6059
$(CC) $(CFLAGS) $^ -o $@
6160

62-
ipak: ipak.o $(OBJS) libwords.a
61+
ipak: ipak.o $(OBJS) $(LIBWORD)
6362
$(CC) $(CFLAGS) $^ -o $@
6463

65-
itsarc: itsarc.o $(OBJS) libwords.a
64+
itsarc: itsarc.o $(OBJS) $(LIBWORD)
6665
$(CC) $(CFLAGS) $^ -o $@
6766

68-
macro-tapes: macro-tapes.o $(OBJS) libwords.a
67+
macro-tapes: macro-tapes.o $(OBJS) $(LIBWORD)
6968
$(CC) $(CFLAGS) $^ -o $@
7069

71-
tape-dir: tape-dir.o $(OBJS) libwords.a
70+
tape-dir: tape-dir.o $(OBJS) $(LIBWORD)
7271
$(CC) $(CFLAGS) $^ -o $@
7372

74-
tito: tito.o $(OBJS) libwords.a
73+
tito: tito.o $(OBJS) $(LIBWORD)
7574
$(CC) $(CFLAGS) $^ -o $@
7675

77-
dart: dart.o dec.o $(OBJS) libwords.a
76+
dart: dart.o dec.o $(OBJS) $(LIBWORD)
7877
$(CC) $(CFLAGS) $^ -o $@
7978

80-
dumper: dumper.o $(OBJS) libwords.a
79+
dumper: dumper.o $(OBJS) $(LIBWORD)
8180
$(CC) $(CFLAGS) $^ -o $@
8281

8382
mini-dumper: dumper
8483
ln -f $< $@
8584

86-
od10: od10.o $(OBJS) libwords.a
85+
od10: od10.o $(OBJS) $(LIBWORD)
8786
$(CC) $(CFLAGS) $^ -o $@
8887

89-
linum: linum.o $(OBJS) libwords.a
88+
linum: linum.o $(OBJS) $(LIBWORD)
9089
$(CC) $(CFLAGS) $^ -o $@
9190

92-
constantinople: constantinople.o $(OBJS) libfiles.a libwords.a
91+
constantinople: constantinople.o $(OBJS) libfiles.a $(LIBWORD)
9392
$(CC) $(CFLAGS) $^ -o $@
9493

95-
harscntopbm: harscntopbm.o libwords.a
94+
harscntopbm: harscntopbm.o $(LIBWORD)
9695
$(CC) $(CFLAGS) $^ -o $@
9796

98-
palx: palx.o $(OBJS) libwords.a
97+
palx: palx.o $(OBJS) $(LIBWORD)
9998
$(CC) $(CFLAGS) $^ -o $@
10099

101-
cross: cross.o $(OBJS) libwords.a
100+
cross: cross.o $(OBJS) $(LIBWORD)
102101
$(CC) $(CFLAGS) $^ -o $@
103102

104-
kldcp: kldcp.o $(OBJS) das.o libwords.a
103+
kldcp: kldcp.o $(OBJS) das.o $(LIBWORD)
105104
$(CC) $(CFLAGS) $^ -o $@
106105

107-
klfedr: klfedr.o $(OBJS) libwords.a
106+
klfedr: klfedr.o $(OBJS) $(LIBWORD)
108107
$(CC) $(CFLAGS) $^ -o $@
109108

110-
scrmbl: scrmbl.o crypt.o $(OBJS) libwords.a
109+
scrmbl: scrmbl.o crypt.o $(OBJS) $(LIBWORD)
111110
$(CC) $(CFLAGS) $^ -o $@
112111

113-
unscr: unscr.o crypt.o $(OBJS) libwords.a
112+
unscr: unscr.o crypt.o $(OBJS) $(LIBWORD)
114113
$(CC) $(CFLAGS) $^ -o $@
115114

116115
lodepng.c: lodepng/lodepng.cpp
@@ -121,13 +120,13 @@ lodepng.h: lodepng/lodepng.h
121120

122121
tvpic.o: tvpic.c lodepng.h
123122

124-
tvpic: tvpic.o lodepng.o $(OBJS) libwords.a
123+
tvpic: tvpic.o lodepng.o $(OBJS) $(LIBWORD)
125124
$(CC) $(CFLAGS) $^ -o $@
126125

127-
test/test_write: test/test_write.o $(OBJS) libwords.a
126+
test/test_write: test/test_write.o $(OBJS) $(LIBWORD)
128127
$(CC) $(CFLAGS) $^ -o $@
129128

130-
test/test_read: test/test_read.o $(OBJS) libwords.a
129+
test/test_read: test/test_read.o $(OBJS) $(LIBWORD)
131130
$(CC) $(CFLAGS) $^ -o $@
132131

133132
check: check.sh

dis.h

Lines changed: 1 addition & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <time.h>
2020
#include <stdio.h>
2121
#include <stdlib.h>
22+
#include <libword.h>
2223

2324
#define WORDMASK (0777777777777LL)
2425
#define SIGNBIT (0400000000000LL)
@@ -29,8 +30,6 @@
2930
/* DEC page size, in words */
3031
#define DEC_PAGESIZE 512
3132

32-
typedef long long word_t;
33-
3433
#define JRST ((word_t)(0254000000000LL))
3534
#define JRST_1 (JRST + 1)
3635
#define JUMPA ((word_t)(0324000000000LL))
@@ -46,23 +45,8 @@ struct file_format {
4645
void (*write) (FILE *f, struct pdp10_memory *memory);
4746
};
4847

49-
struct word_format {
50-
const char *name;
51-
word_t (*get_word) (FILE *);
52-
void (*rewind_word) (FILE *); /* NULL means just rewind (f) */
53-
void (*seek_word) (FILE *, int); /* NULL means rewind and go forward. */
54-
void (*write_word) (FILE *, word_t);
55-
void (*flush_word) (FILE *); /* NULL means do nothing */
56-
};
57-
5848
enum { SYMBOLS_NONE, SYMBOLS_DDT, SYMBOLS_ALL };
5949

60-
enum {
61-
START_FILE = 1LL << 36,
62-
START_RECORD = 1LL << 37,
63-
START_TAPE = 1LL << 38
64-
};
65-
6650
extern struct file_format *input_file_format;
6751
extern struct file_format *output_file_format;
6852
extern struct file_format atari_file_format;
@@ -87,51 +71,10 @@ extern struct file_format sblk_file_format;
8771
extern struct file_format shr_file_format;
8872
extern struct file_format tenex_file_format;
8973

90-
extern struct word_format *input_word_format;
91-
extern struct word_format *output_word_format;
92-
extern struct word_format aa_word_format;
93-
extern struct word_format alto_word_format;
94-
extern struct word_format bin_word_format;
95-
extern struct word_format cadr_word_format;
96-
extern struct word_format core_word_format;
97-
extern struct word_format data8_word_format;
98-
extern struct word_format dta_word_format;
99-
extern struct word_format its_word_format;
100-
extern struct word_format oct_word_format;
101-
extern struct word_format pt_word_format;
102-
extern struct word_format sail_word_format;
103-
extern struct word_format tape_word_format;
104-
extern struct word_format tape7_word_format;
105-
10674
extern void usage_file_format (void);
10775
extern int parse_input_file_format (const char *);
10876
extern int parse_output_file_format (const char *);
10977
extern void guess_input_file_format (FILE *);
110-
extern void usage_word_format (void);
111-
extern int parse_input_word_format (const char *);
112-
extern int parse_output_word_format (const char *);
113-
extern word_t get_word (FILE *f);
114-
extern word_t get_checksummed_word (FILE *f);
115-
extern void reset_checksum (word_t);
116-
extern void check_checksum (word_t);
117-
extern void rewind_word (FILE *f);
118-
extern void seek_word (FILE *f, int position);
119-
extern void by_five_octets (FILE *f, int position);
120-
extern void by_eight_octets (FILE *f, int position);
121-
extern void write_word (FILE *, word_t);
122-
extern void flush_word (FILE *);
123-
extern void (*tape_hook) (int code);
124-
extern int get_7track_record (FILE *f, word_t **buffer);
125-
extern int get_9track_record (FILE *f, word_t **buffer);
126-
extern void write_7track_record (FILE *f, word_t *buffer, int);
127-
extern void write_9track_record (FILE *f, word_t *buffer, int);
128-
extern void write_tape_mark (FILE *f);
129-
extern void write_tape_eof (FILE *f);
130-
extern void write_tape_eot (FILE *f);
131-
extern void write_tape_gap (FILE *f, unsigned code);
132-
extern void write_tape_error (FILE *f, unsigned code);
133-
extern word_t get_core_word (FILE *f);
134-
extern void write_core_word (FILE *f, word_t word);
13578
extern void read_raw_at (FILE *f, struct pdp10_memory *memory,
13679
int address);
13780
extern void write_raw_at (FILE *f, struct pdp10_memory *memory,

libword/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*~
2+
*.o
3+
libword.a

libword/Makefile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
CFLAGS = -g -W -Wall
2+
3+
OBJS = aa-word.o alto-word.o bin-word.o cadr-word.o core-word.o \
4+
data8-word.o dta-word.o its-word.o oct-word.o pt-word.o \
5+
sail-word.o tape-word.o
6+
7+
all: libword.a
8+
9+
clean:
10+
rm -f libword.a *.o
11+
12+
libword.a: word.o $(OBJS)
13+
$(AR) -crs $@ $^
14+

libword/README.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# LIBWORD
2+
3+
A library for reading and writing binary words.
4+
5+
### API
6+
7+
**Basic word input/output.**
8+
9+
- `word_t`
10+
Type for storing a word.
11+
12+
- `word_t read_word (FILE *file);`
13+
Read one `word` from the `file`.
14+
15+
- `void write_word (FILE *file, word_t word);`
16+
Write one `word` to the `file`.
17+
18+
- `void rewind_word (FILE *file);`
19+
Rewind the `file` to the beginning.
20+
21+
- `void seek_word (FILE *file, long long position);`
22+
Seek to word number `position` in the `file`.
23+
24+
- `void flush_word (FILE *file);`
25+
Prepare output `file` to be closed.
26+
27+
**Selecting a word format.**
28+
29+
- `word usage_word_format (void);`
30+
Print a summary of valid word formats.
31+
32+
- `int parse_input_word_format (const char *string);`
33+
Parse a `string` and set the input word format.
34+
Return 0 on success, or -1 on error.
35+
36+
- `int parse_output_word_format (const char *string);`
37+
Parse a `string` and set the output word format.
38+
Return 0 on success, or -1 on error.
39+
40+
Word formats are:
41+
42+
- `ascii` - PDP-10 ANSI ASCII.
43+
- `alto` - PDP-10 words stored in an Alto file system.
44+
- `bin` - PDP-10 densely packed words.
45+
- `cadr` - 32-bit CADR Lisp machine words stored left aligned in 36-bit words.
46+
- `core` - PDP-10 core dump.
47+
- `data8` - PDP-10 words stored little-endian in eight octets.
48+
- `dta` - 36-bit DECtape image.
49+
- `its` - ITS evacuate format.
50+
- `oct` - 36-bit octal numbers as ASCII text.
51+
- `pt` - 36-bit words in a paper tape image.
52+
- `sail` - Saildart.org text files.
53+
- `tape` - SIMH 9-track tape image.
54+
- `tape7` - SIMH 7-track tape image.
55+
56+
**Tape structured data.**
57+
58+
A `word_t` can have the bits `START_TAPE`, `START_FILE`, or
59+
`START_RECORD` set. On input, this means a structure boundary was
60+
encountered before the word. On output, mark such a boundary before
61+
the word.
62+
63+
More complicated media events are supported by a hook which receives
64+
a SIMH tape image code with the most significant bit set.
65+
66+
- `void (*tape_hook) (int code);`

aa-word.c renamed to libword/aa-word.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
#include <stdio.h>
2828

29-
#include "dis.h"
29+
#include "libword.h"
3030

3131
static inline int
3232
get_byte (FILE *f)

alto-word.c renamed to libword/alto-word.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
#include <stdio.h>
1717

18-
#include "dis.h"
18+
#include "libword.h"
1919

2020
static int
2121
get_byte (FILE *f)

bin-word.c renamed to libword/bin-word.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@
1414
along with this program. If not, see <http://www.gnu.org/licenses/>. */
1515

1616
#include <stdio.h>
17+
#include <stdlib.h>
18+
#include "libword.h"
1719

18-
#include "dis.h"
20+
#define WORDMASK (0777777777777LL)
21+
#define SIGNBIT (0400000000000LL)
1922

2023
static int leftover_input, have_leftover_input = 0;
2124
static int leftover_output, have_leftover_output = 0;

cadr-word.c renamed to libword/cadr-word.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
along with this program. If not, see <http://www.gnu.org/licenses/>. */
1515

1616
#include <stdio.h>
17-
#include "dis.h"
17+
#include "libword.h"
1818

1919
/* Data files for CADR Lisp machines were apparently stored as 32 bits
2020
left aligned in a 36-bit word. The 32-bit word is in PDP-11 endian

0 commit comments

Comments
 (0)