🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: mod.computers.masscomp
1 messages
1 total messages Started by masscomp-request Mon, 09 Mar 1987 18:49
asmprt - print intermixed C and generated assembly
#102
Author: masscomp-request
Date: Mon, 09 Mar 1987 18:49
164 lines
4049 bytes
[I could not get this to work with RTU 3.1 and the C compiler version 1.1
on the MC5700, MC5400, MC5500-PEP. Perhaps it will  be useful to someone,
though. -- sob]

#!/bin/sh
echo 'Start of pack.out, part 01 of 01:'
echo 'x - Makefile'
sed 's/^X//' > Makefile << '/'
Xasmprt:	exp.i asmprt.o
X	cc asmprt.o -o asmprt -lPW
Xexp.i:	exp
X	regcmp exp
Xasmprt.o:	asmprt.c
X	cc -c asmprt.c
Xclean:
X	rm -f asmprt exp.i asmprt.o
/
echo 'x - asmprt.1'
sed 's/^X//' > asmprt.1 << '/'
X.TH ASMPRT
X.SH NAME
Xasmprt - printout C program with generated assembler code intermixed
X.SH SYNOPSIS
Xasmprt filename
X.SH DESCRIPTION
Xasmprt prints out a C program along with it's generated assembly
Xlanguage code.  Input can be either a ".s" file as produced by
X"cc -S" or a listing file as produced by "cc -S" followed by "as -s".
XOutput is to stdout.
X.BUGS
XOnly works with Masscomp's C Compiler.  Only tested with MC5500 under
XRTU-3.0a and RTU-3.1a.
X.SH AUTHOR
XBruce Karsh
/
echo 'x - asmprt.c'
sed 's/^X//' > asmprt.c << '/'
X#include "exp.i"
X#include <stdio.h>
X
X/*
X** amsprt - print out intermixed C and Assembler code.
X*/
X
Xint cline,oldcline;
Xchar cname[100],oldcname[100];
XFILE *sfile,*cfile;
X
Xmain(argc,argv)
Xint argc;
Xchar *argv[];
X{
Xcfile=NULL; cname[0]=0; oldcname[0]=0;
X
X/* Parse args */
X
Xif(argc != 2)
X  {
X  fputs("Usage asmprt filename\n",stderr);
X  exit(1);
X  }
X
X/* Open the .s file. */
X
Xsfile = fopen(argv[1],"r");
Xif(sfile == NULL)
X  {
X  fputs("Can't open file ",stderr); fputs(argv[1],stderr); fputs("\n",stderr);
X  exit(2);
X  }
X
Xfor(;;)
X  {
X
X  /* Copy the .s file to standard output until a position comment
X     appears in the .s file. */
X
X  if(0==copytillposition())exit(0);
X
X  /* If the position comment changes the name of the .c file,
X     open the new file, and close the old file. */
X
X  if(strcmp(oldcname,cname)!=0)
X    {
X    strcpy(oldcname,cname);
X    if(cfile != NULL)
X      fclose(cfile);
X    cfile=fopen(cname,"r");
X    if(sfile == NULL)
X      {
X      fputs("Can't open file ",stderr); fputs(cname,stderr); fputs("\n",stderr);
X      exit(3);
X      }
X    oldcline=1;
X    }
X  copyfile(oldcline,cline);
X  oldcline=cline+1;
X  }
X}
X/*------------------------------------------*/
Xcopytillposition()
X{
Xchar line[100];
Xfor(;;)
X  {
X  if(fgets(line,80,sfile)==NULL)return(0);
X  fputs(line,stdout);
X  if(testpos(line))break;
X  }
Xreturn(1);
X}
Xcopyfile(start,end)
Xint start,end;
X{
Xint i;
Xchar line[100];
Xfor(i=start;i<=end;i++)
X  {
X  if(fgets(line,80,cfile)==NULL)return(0);
X  fputs(line,stdout);
X  }
Xreturn(1);
X}
Xtestpos(line)
Xchar line[];
X{
Xchar linenum[80],file[80];
Xif(regex(Rlineandfile,line,linenum,file,0))
X  {
X  strcpy(cname,file);
X  cline=atoi(linenum);
X  return(1);
X  }
Xelse if(regex(Rline,line,linenum,0))
X  {
X  cline=atoi(linenum);
X  return(1);
X  }
Xelse if(regex(xRlineandfile,line,linenum,file,0))
X  {
X  strcpy(cname,file);
X  cline=atoi(linenum);
X  return(1);
X  }
Xelse if(regex(xRline,line,linenum,0))
X  {
X  cline=atoi(linenum);
X  return(1);
X  }
Xelse
X  {
X  return(0);
X  }
X}
/
echo 'x - exp'
sed 's/^X//' > exp << '/'
XRlineandfile "					| *([^ ]*)$0 *\"([^ ]*)$1\""
XRline "					| *([^ ]*)$0"
XxRlineandfile "				    					| *([^ ]*)$0 *\"([^ ]*)$1\""
XxRline "				    					| *([^ ]*)$0"
/
echo 'Part 01 of pack.out complete.'
exit
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads