mirror of
https://github.com/open-simh/simtools.git
synced 2026-01-26 20:21:45 +00:00
Add RT11 macro libraries.
Hopefully they won't open as RSX ones, because then they still won't work. Can't test this now.
This commit is contained in:
2
Makefile
2
Makefile
@@ -9,7 +9,7 @@ CFLAGS ?= -O -ggdb -std=gnu99 $(WARNS)
|
|||||||
MACRO11_SRCS = macro11.c \
|
MACRO11_SRCS = macro11.c \
|
||||||
assemble.c assemble_globals.c assemble_aux.c \
|
assemble.c assemble_globals.c assemble_aux.c \
|
||||||
extree.c listing.c macros.c parse.c rept_irpc.c symbols.c \
|
extree.c listing.c macros.c parse.c rept_irpc.c symbols.c \
|
||||||
mlb-rsx.c object.c stream2.c util.c rad50.c
|
mlb2.c mlb-rsx.c mlb-rt11.c object.c stream2.c util.c rad50.c
|
||||||
|
|
||||||
MACRO11_OBJS = $(MACRO11_SRCS:.c=.o)
|
MACRO11_OBJS = $(MACRO11_SRCS:.c=.o)
|
||||||
|
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ static void print_help(
|
|||||||
printf("-h print this help\n");
|
printf("-h print this help\n");
|
||||||
printf("-l gives the listing file name (.LST)\n");
|
printf("-l gives the listing file name (.LST)\n");
|
||||||
printf(" -l - enables listing to stdout.\n");
|
printf(" -l - enables listing to stdout.\n");
|
||||||
printf("-m load RT-11 compatible macro library from which\n");
|
printf("-m load RSX-11 or RT-11 compatible macro library from which\n");
|
||||||
printf(" .MCALLed macros can be found.\n");
|
printf(" .MCALLed macros can be found.\n");
|
||||||
printf(" Multiple allowed.\n");
|
printf(" Multiple allowed.\n");
|
||||||
printf("-o gives the object file name (.OBJ)\n");
|
printf("-o gives the object file name (.OBJ)\n");
|
||||||
|
|||||||
@@ -48,6 +48,24 @@ DAMAGE.
|
|||||||
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
|
static MLB *mlb_rt11_open(
|
||||||
|
char *name,
|
||||||
|
int allow_object_library);
|
||||||
|
static BUFFER *mlb_rt11_entry(
|
||||||
|
MLB *mlb,
|
||||||
|
char *name);
|
||||||
|
static void mlb_rt11_close(
|
||||||
|
MLB *mlb);
|
||||||
|
static void mlb_rt11_extract(
|
||||||
|
MLB *mlb);
|
||||||
|
|
||||||
|
struct mlb_vtbl mlb_rt11_vtbl = {
|
||||||
|
mlb_rt11_open,
|
||||||
|
mlb_rt11_entry,
|
||||||
|
mlb_rt11_extract,
|
||||||
|
mlb_rt11_close,
|
||||||
|
};
|
||||||
|
|
||||||
#define WORD(cp) ((*(cp) & 0xff) + ((*((cp)+1) & 0xff) << 8))
|
#define WORD(cp) ((*(cp) & 0xff) + ((*((cp)+1) & 0xff) << 8))
|
||||||
|
|
||||||
/* BYTEPOS calculates the byte position within the macro libray file.
|
/* BYTEPOS calculates the byte position within the macro libray file.
|
||||||
@@ -84,11 +102,13 @@ static void trim(
|
|||||||
*cp = 0;
|
*cp = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* mlb_open opens a file which is given to be a macro library. */
|
/* mlb_rt11_open opens a file which is given to be a macro library. */
|
||||||
/* Returns NULL on failure. */
|
/* Returns NULL on failure. */
|
||||||
|
|
||||||
MLB *mlb_open(
|
static
|
||||||
char *name)
|
MLB *mlb_rt11_open(
|
||||||
|
char *name,
|
||||||
|
int allow_object_library)
|
||||||
{
|
{
|
||||||
MLB *mlb = memcheck(malloc(sizeof(MLB)));
|
MLB *mlb = memcheck(malloc(sizeof(MLB)));
|
||||||
char *buff;
|
char *buff;
|
||||||
@@ -97,24 +117,26 @@ MLB *mlb_open(
|
|||||||
unsigned start_block;
|
unsigned start_block;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
(void)allow_object_library; /* This parameter is not supported */
|
||||||
|
mlb->vtbl = &mlb_rt11_vtbl;
|
||||||
mlb->directory = NULL;
|
mlb->directory = NULL;
|
||||||
|
|
||||||
mlb->fp = fopen(name, "rb");
|
mlb->fp = fopen(name, "rb");
|
||||||
if (mlb->fp == NULL) {
|
if (mlb->fp == NULL) {
|
||||||
mlb_close(mlb);
|
mlb_rt11_close(mlb);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
buff = memcheck(malloc(044)); /* Size of MLB library header */
|
buff = memcheck(malloc(044)); /* Size of MLB library header */
|
||||||
|
|
||||||
if (fread(buff, 1, 044, mlb->fp) < 044) {
|
if (fread(buff, 1, 044, mlb->fp) < 044) {
|
||||||
mlb_close(mlb);
|
mlb_rt11_close(mlb);
|
||||||
free(buff);
|
free(buff);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (WORD(buff) != 01001) { /* Is this really a macro library? */
|
if (WORD(buff) != 01001) { /* Is this really a macro library? */
|
||||||
mlb_close(mlb); /* Nope. */
|
mlb_rt11_close(mlb); /* Nope. */
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,7 +154,7 @@ MLB *mlb_open(
|
|||||||
|
|
||||||
/* Read the disk directory */
|
/* Read the disk directory */
|
||||||
if (fread(buff, entsize, nr_entries, mlb->fp) < nr_entries) {
|
if (fread(buff, entsize, nr_entries, mlb->fp) < nr_entries) {
|
||||||
mlb_close(mlb); /* Sorry, read error. */
|
mlb_rt11_close(mlb); /* Sorry, read error. */
|
||||||
free(buff);
|
free(buff);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -214,8 +236,9 @@ MLB *mlb_open(
|
|||||||
return mlb;
|
return mlb;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* mlb_close discards MLB and closes the file. */
|
/* mlb_rt11_close discards MLB and closes the file. */
|
||||||
void mlb_close(
|
static
|
||||||
|
void mlb_rt11_close(
|
||||||
MLB *mlb)
|
MLB *mlb)
|
||||||
{
|
{
|
||||||
if (mlb) {
|
if (mlb) {
|
||||||
@@ -234,10 +257,11 @@ void mlb_close(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* mlb_entry returns a BUFFER containing the specified entry from the
|
/* mlb_rt11_entry returns a BUFFER containing the specified entry from the
|
||||||
macro library, or NULL if not found. */
|
macro library, or NULL if not found. */
|
||||||
|
|
||||||
BUFFER *mlb_entry(
|
static
|
||||||
|
BUFFER *mlb_rt11_entry(
|
||||||
MLB *mlb,
|
MLB *mlb,
|
||||||
char *name)
|
char *name)
|
||||||
{
|
{
|
||||||
@@ -278,7 +302,7 @@ BUFFER *mlb_entry(
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* mlb_extract - walk thru a macro library and store its contents
|
/* mlb_rt11_extract - walk thru a macro library and store its contents
|
||||||
into files in the current directory.
|
into files in the current directory.
|
||||||
|
|
||||||
See, I had decided not to bother writing macro library maintenance
|
See, I had decided not to bother writing macro library maintenance
|
||||||
@@ -288,7 +312,8 @@ BUFFER *mlb_entry(
|
|||||||
in the file system from thence forward.
|
in the file system from thence forward.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void mlb_extract(
|
static
|
||||||
|
void mlb_rt11_extract(
|
||||||
MLB *mlb)
|
MLB *mlb)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
14
mlb.h
14
mlb.h
@@ -46,13 +46,24 @@ typedef struct mlbent {
|
|||||||
int length;
|
int length;
|
||||||
} MLBENT;
|
} MLBENT;
|
||||||
|
|
||||||
|
struct mlb_vtbl;
|
||||||
|
|
||||||
typedef struct mlb {
|
typedef struct mlb {
|
||||||
|
struct mlb_vtbl *vtbl;
|
||||||
|
char *name;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
MLBENT *directory;
|
MLBENT *directory;
|
||||||
int nentries;
|
int nentries;
|
||||||
int is_objlib; /* is really an object library */
|
int is_objlib; /* is really an object library */
|
||||||
} MLB;
|
} MLB;
|
||||||
|
|
||||||
|
typedef struct mlb_vtbl {
|
||||||
|
MLB *(*mlb_open)(char *name, int allow_object_library);
|
||||||
|
BUFFER *(*mlb_entry)(MLB *mlb, char *name);
|
||||||
|
void (*mlb_extract)(MLB *mlb);
|
||||||
|
void (*mlb_close)(MLB *mlb);
|
||||||
|
} MLB_VTBL;
|
||||||
|
|
||||||
extern MLB *mlb_open(
|
extern MLB *mlb_open(
|
||||||
char *name,
|
char *name,
|
||||||
int allow_object_library);
|
int allow_object_library);
|
||||||
@@ -64,4 +75,7 @@ extern void mlb_close(
|
|||||||
extern void mlb_extract(
|
extern void mlb_extract(
|
||||||
MLB *mlb);
|
MLB *mlb);
|
||||||
|
|
||||||
|
extern struct mlb_vtbl mlb_rsx_vtbl;
|
||||||
|
extern struct mlb_vtbl mlb_rt11_vtbl;
|
||||||
|
|
||||||
#endif /* MLB_H */
|
#endif /* MLB_H */
|
||||||
|
|||||||
4
mlb2.c
4
mlb2.c
@@ -1,9 +1,11 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include "util.h"
|
||||||
#include "mlb.h"
|
#include "mlb.h"
|
||||||
|
|
||||||
MLB_VTBL *mlb_vtbls[] = {
|
MLB_VTBL *mlb_vtbls[] = {
|
||||||
&mlb_rsx_vtbl,
|
&mlb_rsx_vtbl,
|
||||||
|
&mlb_rt11_vtbl,
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -18,7 +20,7 @@ MLB *mlb_open(
|
|||||||
for (i = 0; (vtbl = mlb_vtbls[i]); i++) {
|
for (i = 0; (vtbl = mlb_vtbls[i]); i++) {
|
||||||
mlb = vtbl->mlb_open(name, allow_object_library);
|
mlb = vtbl->mlb_open(name, allow_object_library);
|
||||||
if (mlb != NULL) {
|
if (mlb != NULL) {
|
||||||
mlb->name = strdup(name);
|
mlb->name = memcheck(strdup(name));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user