s2asm --- .s to .asm conversion

s2asm --- .s to .asm conversion

Post by Earl Ch » Fri, 02 Nov 1990 04:10:00




Quote:> This posting contains a uuencoded compressed (12 bits) shar file (I did it this
> way):

In case there's some confusion ---

You will probably find that you will have to port Minix sed in order to use the
sed script. The Unix seds that I have tried it on either will not allow long
labels or have internal arrays that are too small to handle such large scripts.

Porting Minix sed should not prove too difficult. I just compiled mine under TC
and squinted as the warning messages flew past :-) The patches enclosed are
necessary to increase the sizes of the internal arrays so that Minix sed will
run the script. I suppose if you have the source to Unix sed, you could try
fixing the problems :-)

Earl
--
Earl Chew, Dept of Computer Science, Monash University, Australia 3168

----------------------------------------------------------------------

 
 
 

s2asm --- .s to .asm conversion

Post by Earl Ch » Fri, 02 Nov 1990 02:32:00


From article <1...@bruce.OZ>, by cec...@bruce.OZ (Earl Chew):

> Porting Minix sed should not prove too difficult. I just compiled mine under TC
> and squinted as the warning messages flew past :-) The patches enclosed are
> necessary to increase the sizes of the internal arrays so that Minix sed will
> run the script. I suppose if you have the source to Unix sed, you could try
> fixing the problems :-)

Oops... I spoke too soon. I believe that there are *many* problems with the old
Minix sed (NULL dereferencing and the like). Here is the version off the net
with the bigger poolsize and command array length. It was posted by Peter
Housel I think.

Earl

-------------------------------------------------------------------------------
#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#               "End of shell archive."
# Contents:  sed.c
# Wrapped by cechew@bruce on Fri Nov 17 12:32:07 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'sed.c' -a "${1}" != "-c" ; then
  echo shar: Will not clobber existing file \"'sed.c'\"
else
echo shar: Extracting \"'sed.c'\" \(45843 characters\)
sed "s/^X//" >'sed.c' <<'END_OF_FILE'
X/* sed - stream editor         Author: Eric S. Raymond */
X
X/* This used to be three different files with the following makefile:
X * (Note the chmem).
X
XCFLAGS=        -F -T.
X
XOBJS=   sedcomp.s sedexec.s
X
Xsed:   $(OBJS)
X        cc -T. -o sed $(OBJS)
X       @chmem =13312 sed
X
X$(OBJS):       sed.h
X
X * If you want longer lines: increase MAXBUF.
X * If you want scripts with more text: increase POOLSIZE.
X * If you want more commands per script: increase MAXCMDS.
X */
X
X#include <stdio.h>
X#include <ctype.h>
X
X/*+++++++++++++++*/
X
X/* sed.h -- types and constants for the stream editor */
X
X/* data area sizes used by both modules */
X#define MAXBUF         4000    /* current line buffer size */
X#define MAXAPPENDS     20      /* maximum number of appends */
X#define MAXTAGS                9       /* tagged patterns are \1 to \9 */
X
X/* constants for compiled-command representation */
X#define EQCMD  0x01    /* = -- print current line number       */
X#define ACMD   0x02    /* a -- append text after current line  */
X#define BCMD   0x03    /* b -- branch to label                 */
X#define CCMD   0x04    /* c -- change current line             */
X#define DCMD   0x05    /* d -- delete all of pattern space             */
X#define CDCMD  0x06    /* D -- delete first line of pattern space      */
X#define GCMD   0x07    /* g -- copy hold space to pattern space        */
X#define CGCMD  0x08    /* G -- append hold space to pattern space      */
X#define HCMD   0x09    /* h -- copy pattern space to hold space        */
X#define CHCMD  0x0A    /* H -- append pattern space to hold space      */
X#define ICMD   0x0B    /* i -- insert text before current line         */
X#define LCMD   0x0C    /* l -- print pattern space in escaped form     */
X#define NCMD   0x0D    /* n -- get next line into pattern space        */
X#define CNCMD  0x0E    /* N -- append next line to pattern space       */
X#define PCMD   0x0F    /* p -- print pattern space to output           */
X#define CPCMD  0x10    /* P -- print first line of pattern space       */
X#define QCMD   0x11    /* q -- exit the stream editor                  */
X#define RCMD   0x12    /* r -- read in a file after current line       */
X#define SCMD   0x13    /* s -- regular-expression substitute           */
X#define TCMD   0x14    /* t -- branch on any substitute successful     */
X#define CTCMD  0x15    /* T -- branch on any substitute failed         */
X#define WCMD   0x16    /* w -- write pattern space to file             */
X#define CWCMD  0x17    /* W -- write first line of pattern space       */
X#define XCMD   0x18    /* x -- exhange pattern and hold spaces         */
X#define YCMD   0x19    /* y -- transliterate text                      */
X
Xstruct cmd_t                           /* compiled-command representation */
X{
X       char    *addr1;                 /* first address for command */
X       char    *addr2;                 /* second address for command */
X       union
X       {
X               char            *lhs;   /* s command lhs */
X               struct cmd_t    *link;  /* label link */
X       } u;
X       char    command;                /* command code */
X       char    *rhs;                   /* s command replacement string */
X       FILE    *fout;                  /* associated output file descriptor */
X       struct
X       {
X               char allbut  ;   /* was negation specified? */
X               char global  ;   /* was g postfix specified? */
X               char print   ;   /* was p postfix specified? */
X               char inrange ;   /* in an address range? */
X       } flags;
X};
Xtypedef struct cmd_t   sedcmd;         /* use this name for declarations */
X
X#define BAD    ((char *) -1)           /* guaranteed not a string ptr */
X
X
X/* address and regular expression compiled-form markers */
X#define STAR   1       /* marker for Kleene star */
X#define CCHR   2       /* non-newline character to be matched follows */
X#define CDOT   4       /* dot wild-card marker */
X#define CCL    6       /* character class follows */
X#define CNL    8       /* match line start */
X#define CDOL   10      /* match line end */
X#define CBRA   12      /* tagged pattern start marker */
X#define CKET   14      /* tagged pattern end marker */
X#define CBACK  16      /* backslash-digit pair marker */
X#define CLNUM  18      /* numeric-address index follows */
X#define CEND   20      /* symbol for end-of-source */
X#define CEOF   22      /* end-of-field mark */
X
X/* sed.h ends here */
X
X#define CMASK  0xFF    /* some char type should have been unsigned char? */
X
X/*+++++++++++++++*/
X
X/* sed - stream editor         Author: Eric S. Raymond */
X
X/*
X   The stream editor compiles its command input         (from files or -e options)
X   into an internal form using compile() then executes the compiled form using
X   execute(). Main() just initializes data structures, interprets command line
X   options, and calls compile() and execute() in appropriate sequence.
X  
X   The data structure produced by compile() is an array of compiled-command
X   structures (type sedcmd).  These contain several pointers into pool[], the
X   regular-expression and text-data pool, plus a command code and g & p flags.
X   In the special case that the command is a label the struct  will hold a ptr
X   into the labels array labels[] during most of the compile,  until resolve()
X   resolves references at the end.
X
X   The operation of execute() is described in its source module.
X*/
X
X/* #include <stdio.h>            /* uses getc, fprintf, fopen, fclose */
Xextern FILE *fopen();          /* should this be in stdio.h? */
X/* #include "sed.h"          /* command type struct and name defines */
X
X/* imported functions */
Xextern int strcmp();           /* test strings for equality */
Xextern void execute();         /* execute compiled command */
X
X/***** public stuff ******/
X
X#define MAXCMDS                500     /* maximum number of compiled commands */
X#define MAXLINES       256     /* max # numeric addresses to compile */
X
X/* main data areas */
Xchar   linebuf[MAXBUF+1];      /* current-line buffer */
Xsedcmd cmds[MAXCMDS+1];        /* hold compiled commands */
Xlong   linenum[MAXLINES];      /* numeric-addresses table */
X
X/* miscellaneous shared variables */
Xint    nflag;                  /* -n option flag */
Xint    eargc;                  /* scratch copy of argument count */
Xchar   **eargv;                /* scratch copy of argument list */
Xchar   bits[]          = {1,2,4,8,16,32,64,128};
X
X/***** module common stuff *****/
X
X#define POOLSIZE       20000   /* size of string-pool space */
X#define WFILES         10      /* max # w output files that can be compiled */
X#define RELIMIT                256     /* max chars in compiled RE */
X#define MAXDEPTH       20      /* maximum {}-nesting level */
X#define MAXLABS                50      /* max # of labels that can be handled */
X
X#define SKIPWS(pc)     while ((*pc==' ') || (*pc=='\t')) pc++
X#define ABORT(msg)     (fprintf(stderr, msg, linebuf), quit(2))
X#define IFEQ(x, v)     if (*x == v) x++ , /* do expression */
X
X/* error messages */
Xstatic char    AGMSG[] = "sed: garbled address %s\n";
Xstatic char    CGMSG[] = "sed: garbled command %s\n";
Xstatic char    TMTXT[] = "sed: too much text: %s\n";
Xstatic char    AD1NG[] = "sed: no addresses allowed for %s\n";
Xstatic char    AD2NG[] = "sed: only one address allowed for %s\n";
Xstatic char    TMCDS[] = "sed: too many commands, last was %s\n";
Xstatic char    COCFI[] = "sed: cannot open command-file %s\n";
Xstatic char    UFLAG[] = "sed: unknown flag %c\n";
Xstatic char    CCOFI[] = "sed: cannot create %s\n";
Xstatic char    ULABL[] = "sed: undefined label %s\n";
Xstatic char    TMLBR[] = "sed: too many {'s\n";
Xstatic char    FRENL[] = "sed: first RE must be non-null\n";
Xstatic char    NSCAX[] = "sed: no such command as %s\n";
Xstatic char    TMRBR[] = "sed: too many }'s\n";
Xstatic char    DLABL[] = "sed: duplicate label %s\n";
Xstatic char    TMLAB[] = "sed: too many labels: %s\n";
Xstatic char    TMWFI[] = "sed: too many w files\n";
Xstatic char    REITL[] = "sed: RE too long: %s\n";
Xstatic char    TMLNR[] = "sed: too many line numbers\n";
Xstatic char    TRAIL[] = "sed: command \"%s\" has trailing garbage\n";
X
Xtypedef struct                 /* represent a command label */
X{
X       char            *name;          /* the label name */
X       sedcmd          *last;          /* it's on the label search list */  
X       sedcmd          *address;       /* pointer to the cmd it labels */
X}
Xlabel;
X
X/* label handling */
Xstatic label   labels[MAXLABS];        /* here's the label table */
Xstatic label   *lab    = labels + 1;   /* pointer to current label */
Xstatic label   *lablst = labels;       /* header for search list */
X
X/* string pool for regular expressions, append text, etc. etc. */
Xstatic char    pool[POOLSIZE];                 /* the pool */
Xstatic char    *fp     = pool;                 /* current pool pointer */
Xstatic char    *poolend = pool + POOLSIZE;     /* pointer past pool end */
X
X/* compilation state */
Xstatic FILE    *cmdf   = NULL;         /* current command source */
Xstatic char    *cp     = linebuf;      /* compile pointer */
Xstatic sedcmd  *cmdp   = cmds;         /* current compiled-cmd ptr */
Xstatic char    *lastre = NULL;         /* old RE pointer */
Xstatic int     bdepth  = 0;            /* current {}-nesting level */
Xstatic int     bcount  = 0;            /* # tagged patterns in current RE */
X
X/* compilation flags */
Xstatic int     eflag;                  /* -e option flag */
Xstatic int     gflag;                  /* -g option flag */
X
X
Xmain(argc, argv)
X/* main sequence of the stream editor */
Xint    argc;
Xchar   *argv[];
X{
X       void compile(), resolve();
X
X       eargc   = argc;         /*
...

read more »

 
 
 

1. Inline asm {} vs. asm functions

Hi,

I'm encountering some weirdness, (or probably just my
misunderstanding), related to inline 68k assembly in CodeWarrior 8 for
PalmOS.  The following function appears to compile correctly:

asm void MyFunction(MyObject *obj)
{
    move.l obj, A0
    move.l D3,struct(MyObject.m_member)(A0);

However, doing the exact same thing inline does not compile:

void MyFunction(MyObject *obj)
{
    asm {
       move.l obj, A0
       move.l D3,struct(MyObject.m_member)(A0);
    }

It gives me the following compiler errors:

Error   : expression syntax error
File.cpp line 93     move.l D3,struct(MyObject.m_member)(A0);
Error   : unknown assembler instruction mnemonic
File.cpp line 93     move.l D3,struct(MyObject.m_member)(A0);
etc.

Is this syntax not allowed when using statement-level (inline) asm,
rather than function-level asm?  If not, is there an easy way to
access struct/class members as in the example above?  I'd prefer to
use statement-level asm.

thanks!
-- Chris

P.S. - I am new to 68k assembly, so please forgive me if this is
obvious.

2. replacing hard drive

3. REQ: Sourcecode for Z80 ASM in ASM

4. I can't install 2000 on my computer , please help

5. Translator: Motorola 68K ASM source to Intel X86 ASM source

6. CGI & Front Page

7. ACK (asm) to GNU (asm) code convertor

8. ZIP 2.04g on CP/M

9. Translator: Intel ASM -> GNU ASM ?

10. I need s2asm.sed for mcc-2.1.4

11. Wanted s2asm program

12. s2asm header files

13. s2asm --- dos2out bug