39 Commits

Author SHA1 Message Date
David Given
3f09da5045 Rename branch.
--HG--
branch : dtrg-experimental-powerpc-branch
2015-06-18 23:39:26 +02:00
David Given
33b4873932 Readjust after merge to default.
--HG--
branch : dtrg-experimental-powerpc
2013-05-09 18:15:49 +01:00
David Given
d91a1dc1a6 Merge changes from branch: linux68k platform, linuxppc platform (partially
working), and miscellaneous changes to support these.
2013-05-09 18:14:16 +01:00
David Given
b9b808e01a Apply George Koehler's aelflod fix for generating non-EM_386 binaries.
Adjust platforms to use it. Fix some bugs in the linux386 platform.

--HG--
branch : dtrg-experimental-powerpc
2013-05-09 15:54:23 +01:00
David Given
99d7f513f2 Properly error out if something goes wrong rather than ploughing ahead
anyway.

--HG--
branch : dtrg-experimental-powerpc
2013-05-09 11:20:36 +01:00
David Given
bcfb3d802f Add pmfile for m68020 libend.
--HG--
branch : dtrg-experimental-powerpc
2013-05-09 00:58:35 +01:00
David Given
8e2d027c49 Add pmfile for m68020 libem.
--HG--
branch : dtrg-experimental-powerpc
2013-05-09 00:57:47 +01:00
David Given
8d0261473d Add missing linux68k platform and liblinux support library.
--HG--
branch : dtrg-experimental-powerpc
2013-05-09 00:56:10 +01:00
David Given
c93cb69959 Check in incomplete Linux PowerPC and M68K work.
--HG--
branch : dtrg-experimental-powerpc
2013-05-08 00:48:48 +01:00
George Koehler
c8fdcff960 Some fixes for aelflod and aslod.
Copy rhead() and rsect() from aslod to aelflod, so aelflod can work
for machine with 64-bit long.

In aelflod, fix ELF header so file(1) no longer reports "corrupted
section header size".
2013-04-24 19:57:23 -04:00
David Given
dccecc5d45 Back out erroneous change. 2012-12-14 11:56:21 +00:00
George Koehler
0fc7fd5d33 Prevent segfault when trying to print an error message.
Use <stdarg.h> to pass arguments correctly, as ack/util/util.c
already uses <stdarg.h> the same way.
2012-10-24 13:44:50 -04:00
David Given
4349d702fa Change from using platform-specific types to stdint platform-independent types
when reading the structure header.
2012-09-27 11:32:40 +01:00
David Given
2beb3646a7 Change to use stdint's implementation independent types rather than short and
long (which vary depending on whether you're on a 64-bit system or not).
2012-09-27 10:54:41 +01:00
George Koehler
7ef9b79c11 Merge deletion of many undead files. 2012-09-23 15:31:16 -04:00
George Koehler
3dcc3bd1cf Allow pc86 bootloader to boot from more floppy drives.
When the bootloader probes the drive geometry, the BIOS can clobber the
es register.  If this happens, the bootloader loads the program to the
wrong address, and jumps off the code.  This happens with an emulated
floppy drive in Bochs or QEMU, but not with an emulated hard disk.
2012-09-23 14:43:22 -04:00
George Koehler
e7c79415b5 Prevent division by zero in aslod.
rhead() and rsect() had assumed sizeof(long) == 4, but OpenBSD/amd64
has sizeof(long) == 8.  The problem revealed itself when sect->os_lign
became zero, and align() divided by zero.
2012-09-21 22:51:12 -04:00
George Koehler
0131ca4d46 Delete 689 undead files.
These files "magically reappeared" after the conversion from CVS to
Mercurial.  The old CVS repository deleted these files but did not
record *when* it deleted these files.  The conversion resurrected these
files because they have no history of deletion.  These files were
probably deleted before year 1995.  The CVS repository begins to record
deletions around 1995.

These files may still appear in older revisions of this Mercurial
repository, when they should already be deleted.  There is no way to fix
this, because the CVS repository provides no dates of deletion.

See http://sourceforge.net/mailarchive/message.php?msg_id=29823032
2012-09-20 22:26:32 -04:00
George Koehler
be234ea759 *Again* fix fit16i() for systems with 64-bit long.
I already did this in abebf1586c06, but I edited the wrong file.  Then
in edddc6b7cd17, I deleted that file.

By fixing fit16i(), I can now compile ACK for OpenBSD/amd64.
2012-09-19 23:39:51 -04:00
George Koehler
8bf34937f1 Delete old and unused files from modules/src/em_code 2012-09-17 16:04:55 -04:00
George Koehler
99eb12a282 Fix fit16i() for systems with 64-bit long.
(long)0xFFFF8000 had expanded to 0x00000000FFFF8000.
With (long)(-0x8000), the compiler now extends the negative sign.
2012-09-16 19:57:07 -04:00
George Koehler
96ea0a5903 Fix more functions in util/ack for 64-bit hosts.
This continues the fix from changeset aabde0589450.  We must use
va_list to forward the arguments, because some of the arguments might
be 64-bit pointers.  A pointer does not fit in an int.
2012-09-07 16:28:10 -04:00
George Koehler
800d4ae032 Fix cemcom.ansi for 64-bit hosts.
Hosts with sizeof(arith) == sizeof(long) == 8 need to set full_mask[1]
through full_mask[8].  Because MAXSIZE == 8, we only had full_mask[0]
through full_mask[7].  This fix declares arith full_mask[MAXSIZE + 1]
and prevents a fatal error: "array full_mask too small for this machine"
2012-09-07 15:53:13 -04:00
David Given
6ea172d0d9 Fix a 64-bitness issue (removed some untyped K&R C code that assumed ints
and pointers were the same size).
2012-02-27 22:36:36 +00:00
Ceriel Jacobs
1072a8797e Added atol() that ignores overflow, so that unsigned long constants are dealt with properly 2011-06-15 11:13:48 +02:00
Ceriel Jacobs
2483e5723d Fixed CFU 2011-06-15 10:56:58 +02:00
cjhjacobs
58613009f8 Fixed bug reported on tack-devel mailing list on 20-3-2011 2011-05-18 19:19:19 +02:00
David Given
b6dfaefeff Removed file that the CVS conversion procedure left in (when it shouldn't have). 2011-03-20 20:47:10 +00:00
cvs2hg
eb0b730607 convert CVS tags 2011-02-11 00:51:45 +00:00
dtrg
45ee287136 Replaced dis and new with modern implementations donated by erik@backerud.se. 2010-10-02 21:52:29 +00:00
dtrg
075cb488a3 Call the correct kill() and getpid() syscalls rather than _kill() and _getpid(). 2010-10-02 21:51:40 +00:00
dtrg
a33473e0a5 Now call creat() and open() instead of _creat() and _open(). 2010-09-27 20:47:32 +00:00
dtrg
7292b538bc Added support for remove() and unlink(). 2010-09-27 20:44:49 +00:00
dtrg
a8ecb11013 Fixed very old bug where Streams.GetStreamPosition would return the wrong position --- thanks to Jan Verhoeven for finding this. 2010-09-01 19:55:15 +00:00
dtrg
085f346f8c Fixed definitions of O_* flags. 2010-08-20 19:27:09 +00:00
dtrg
c326f3c6a3 Remove references to using-machine-name-for-compiler, as we don't do that any more. 2010-08-09 22:47:33 +00:00
dtrg
a0c67da261 Changed to actually work. (On modern Linux systems the old version just
crashes. On old Linux systems it apparently only worked by accident.)
2010-08-06 17:06:31 +00:00
dtrg
293f34fa9b Flush stdout before prompting the user for input. 2010-08-06 17:02:16 +00:00
dtrg
da6111328d Flush output stream before waiting for user input. 2010-08-05 22:23:34 +00:00
123 changed files with 1966 additions and 23394 deletions

9
.hgtags Normal file
View File

@@ -0,0 +1,9 @@
5a0daa6017c4aa5ae23b870e97eb7431021762bc distr2
15b742c4c278c27029eca0e41f16463bc076de6e distr3
a0686e2ca8d6780ce37b8267b865f60e9317a340 llgen-1-0
d96cd06672c368e8aaa584fead379ce1d343acad oct-1
bf69b3579e8545ecfc03f5e2550586e3c479270d release-6-0-pre-4
e880082b57f12a7df1c33a2da2c7424d6368f185 dist2
fe535e3e8bc859d4a4e4a186f42670f9e588a5aa release-5-6
90102c21c4480102634c6a482d0dd55f2d9ca00f release-6-0-pre-3
ddc0de0e5e7d91b1dcd7c05602c9c2a6adf8d312 release-6-0-pre-1

View File

@@ -6,13 +6,22 @@
MODULE HiLo;
FROM InOut IMPORT WriteInt, WriteLn, WriteString, ReadString, ReadInt;
FROM random IMPORT Uniform;
FROM Streams IMPORT FlushStream, OutputStream, StreamResult;
VAR
buffer : ARRAY [0..32] OF CHAR;
PROCEDURE flush;
VAR
strus : StreamResult;
BEGIN
FlushStream(OutputStream, strus);
END flush;
PROCEDURE reads;
BEGIN
WriteString("> ");
flush;
ReadString(buffer);
END reads;
@@ -31,8 +40,8 @@ BEGIN
finished := FALSE;
WHILE NOT finished DO
WriteLn;
WriteString("> ");
flush;
ReadInt(guess);
IF guess = Number THEN

View File

@@ -199,6 +199,13 @@ string sG2; /* Used to pass string results */
FILE *stream;
bool bFlag = FALSE; /* Prevent multiple file opens */
void
reads(char* buffer)
{
fflush(stdout);
gets(buffer);
}
/* Main Program */
int
@@ -228,7 +235,7 @@ intro(void)
printf("\nDo you need instructions (y/n): ");
gets(sTemp);
reads(sTemp);
if (sTemp[0] == 'y' || sTemp[0] == 'Y')
showfile("startrek.doc");
@@ -271,7 +278,7 @@ new_game(void)
printf("Command? ");
gets(sTemp);
reads(sTemp);
printf("\n");
if (! strncmp(sTemp, "nav", 3))
@@ -516,7 +523,7 @@ course_control(void)
printf("Course (0-9): ");
gets(sTemp);
reads(sTemp);
printf("\n");
@@ -537,7 +544,7 @@ course_control(void)
printf("Warp Factor (0-%s): ", sX);
gets(sTemp);
reads(sTemp);
printf("\n");
@@ -916,7 +923,7 @@ phaser_control(void)
printf("Number of units to fire: ");
gets(sTemp);
reads(sTemp);
printf("\n");
@@ -1002,7 +1009,7 @@ photon_torpedoes(void)
printf("Course (0-9): ");
gets(sTemp);
reads(sTemp);
printf("\n");
@@ -1214,7 +1221,7 @@ sheild_control(void)
printf("Input number of units to shields: ");
gets(sTemp);
reads(sTemp);
printf("\n");
@@ -1254,7 +1261,7 @@ library_computer(void)
printf("Computer active and awating command: ");
gets(sTemp);
reads(sTemp);
printf("\n");
if (! strncmp(sTemp, "0", 1))
@@ -1406,19 +1413,19 @@ dirdist_calc(void)
(int)s1, (int)s2);
printf("Please enter initial X coordinate: ");
gets(sTemp);
reads(sTemp);
c1 = atoi(sTemp);
printf("Please enter initial Y coordinate: ");
gets(sTemp);
reads(sTemp);
a = atoi(sTemp);
printf("Please enter final X coordinate: ");
gets(sTemp);
reads(sTemp);
w1 = atoi(sTemp);
printf("Please enter final Y coordinate: ");
gets(sTemp);
reads(sTemp);
x = atoi(sTemp);
compute_vector();
@@ -1589,7 +1596,7 @@ end_of_game(void)
printf("If there is a volunteer, let him step forward and");
printf(" enter 'aye': ");
gets(sTemp);
reads(sTemp);
printf("\n");
if (! strncmp(sTemp, "aye", 3))
@@ -1921,6 +1928,7 @@ closefile(void)
int
getline(char *s)
{
fflush(stdout);
if (fgets(s, MAXCOL, stream) == NULL)
return(0);
else

View File

@@ -39,6 +39,7 @@
#define DO_TOSTACK 23
#define DO_KILLREG 24
#define DO_LABDEF 25
#define DO_STACKADJUST 26
#ifndef MAXATT
#define MAXATT TOKENSIZE
@@ -133,6 +134,7 @@ typedef struct exprnode *node_p;
#define EX_ISROM 44
#define EX_TOPELTSIZE 45
#define EX_FALLTHROUGH 46
#define EX_STACKOFFSET 47
typedef struct { /* to stack coercions */

View File

@@ -61,7 +61,10 @@ struct outname {
#define RELSZ 0x07 /* relocation length */
#define RELO1 1 /* 1 byte */
#define RELO2 2 /* 2 bytes */
#define RELO4 4 /* 4 bytes */
#define RELO4 3 /* 4 bytes */
#define RELOPPC 4 /* PowerPC 26-bit address */
#define RELOH2 5 /* write top 2 bytes of 4 byte word */
#define RELPC 0x08 /* pc relative */
#define RELBR 0x10 /* High order byte lowest address. */
#define RELWR 0x20 /* High order word lowest address. */

View File

@@ -20,7 +20,7 @@
#include "sizes.h"
extern char options[];
extern arith full_mask[/*MAXSIZE*/]; /* cstoper.c */
extern arith full_mask[/*MAXSIZE + 1*/]; /* cstoper.c */
char *symbol2str();
ch3mon(oper, expp)

View File

@@ -16,7 +16,8 @@
#include "Lpars.h"
#include "assert.h"
arith full_mask[MAXSIZE];/* full_mask[1] == 0XFF, full_mask[2] == 0XFFFF, .. */
/* full_mask[1] == 0XFF, full_mask[2] == 0XFFFF, .. */
arith full_mask[MAXSIZE + 1];
#ifndef NOCROSS
arith max_int; /* maximum integer on target machine */
arith max_unsigned; /* maximum unsigned on target machine */
@@ -247,7 +248,7 @@ init_cst()
while (!(bt < 0)) {
bt = (bt << 8) + 0377, i++;
if (i == MAXSIZE)
if (i > MAXSIZE)
fatal("array full_mask too small for this machine");
full_mask[i] = bt;
}

View File

@@ -9,13 +9,10 @@
#endif
#include <signal.h>
int _kill(int pid, int sig);
int _getpid(void);
int
raise(int sig)
{
if (sig < 0 || sig > _NSIG)
return -1;
return _kill(_getpid(), sig);
return kill(getpid(), sig);
}

View File

@@ -340,7 +340,7 @@ IMPLEMENTATION MODULE Streams;
RETURN;
END;
IF s^.mode = reading THEN
position := position + LONG(s^.maxcnt - s^.cnt + 1);
position := position - LONG(s^.maxcnt - s^.cnt + 1);
END;
END GetPosition;

View File

@@ -1,3 +1,15 @@
/*
* File: - dis.c
*
* dispose() built in standard procedure in Pascal (6.6.5.3)
*
* Re-implementation of storage allocator for Ack Pascal compiler
* under Linux, and other UNIX-like systems.
*
* Written by Erik Backerud, 2010-10-01
*
* Original copyright and author info below:
*/
/* $Id$ */
/*
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
@@ -23,65 +35,67 @@
#define assert() /* nothing */
/*
* use circular list of free blocks from low to high addresses
* _highp points to free block with highest address
* use a singly linked list of free blocks.
*/
struct adm {
struct adm *next;
int size;
};
extern struct adm *_lastp;
extern struct adm *_highp;
extern _trp();
struct adm *freep = 0; /* first element on free list */
static int merge(p1,p2) struct adm *p1,*p2; {
struct adm *p;
extern void _trp(int);
p = (struct adm *)((char *)p1 + p1->size);
if (p > p2)
/*
* Dispose
* Called with two arguments:
* n the size of the block to be freed, in bytes,
* pp address of pointer to data.
*/
void
_dis(int n, struct adm **pp)
{
struct adm *block; /* the block of data being freed (inc. header) */
struct adm *p, *q;
if (*pp == 0) {
_trp(EFREE);
}
block = *pp - 1;
if (freep == 0) {
freep = block;
block->next = 0;
} else {
q = 0; /* trail one behind */
for (p = freep; p < block; p = p->next) {
if (p == 0) { /* We reached the end of the free list. */
break;
}
q = p;
/* check if block is contained in the free block p */
if (p+p->size > block) {
_trp(EFREE);
if (p != p2)
return(0);
p1->size += p2->size;
p1->next = p2->next;
return(1);
}
_dis(n,pp) int n; struct adm **pp; {
struct adm *p1,*p2;
/*
* NOTE: dispose only objects whose size is a multiple of sizeof(*pp).
* this is always true for objects allocated by _new()
*/
n = ((n+sizeof(*p1)-1) / sizeof(*p1)) * sizeof(*p1);
if (n == 0)
return;
if ((p1= *pp) == (struct adm *) 0)
_trp(EFREE);
p1->size = n;
if ((p2 = _highp) == 0) /*p1 is the only free block*/
p1->next = p1;
else {
if (p2 > p1) {
/*search for the preceding free block*/
if (_lastp < p1) /*reduce search*/
p2 = _lastp;
while (p2->next < p1)
p2 = p2->next;
}
/* if p2 preceeds p1 in the circular list,
* try to merge them */
p1->next = p2->next; p2->next = p1;
if (p2 <= p1 && merge(p2,p1))
p1 = p2;
p2 = p1->next;
/* p1 preceeds p2 in the circular list */
if (p2 > p1) merge(p1,p2);
}
}
if (p1 >= p1->next)
_highp = p1;
_lastp = p1;
*pp = (struct adm *) 0;
}
if (p == block) { /* this block already freed */
_trp(EFREE);
}
if (q == 0) { /* block is first */
freep = block;
block->next = p;
} else {
q->next = block;
}
block->next = p;
/* merge with successor on free list? */
if (block + block->size == p) {
block->size = block->size + p->size;
block->next = p->next;
}
/* merge with preceding block on free list? */
if (q != 0 && q+q->size == block) {
q->size = q->size + block->size;
q->next = block->next;
}
}
} /* _dis */

View File

@@ -1,3 +1,15 @@
/*
* File: - new.c
*
* new() built in standard procedure in Pascal (6.6.5.3)
*
* Re-implementation of storage allocator for Ack Pascal compiler
* under Linux, and other UNIX-like systems.
*
* Written by Erik Backerud, 2010-10-01
*
* Original copyright and author info below:
*/
/* $Id$ */
/*
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
@@ -17,53 +29,92 @@
*/
/* Author: J.W. Stevenson */
extern _sav();
extern _rst();
#include <em_abs.h>
#include <pc_err.h>
#define assert(x) /* nothing */
#define UNDEF 0x8000
#define NALLOC (1024) /* request this many units from OS */
/*
* use a singly linked list of free blocks.
*/
struct adm {
struct adm *next;
int size;
};
struct adm *_lastp = 0;
struct adm *_highp = 0;
extern struct adm *freep;
_new(n,pp) int n; struct adm **pp; {
struct adm *p,*q;
int *ptmp;
extern void _trp(int); /* called on error */
n = ((n+sizeof(*p)-1) / sizeof(*p)) * sizeof(*p);
if ((p = _lastp) != 0)
do {
q = p->next;
if (q->size >= n) {
assert(q->size%sizeof(adm) == 0);
if ((q->size -= n) == 0) {
if (p == q)
p = 0;
else
p->next = q->next;
if (q == _highp)
_highp = p;
}
_lastp = p;
p = (struct adm *)((char *)q + q->size);
q = (struct adm *)((char *)p + n);
goto initialize;
}
p = q;
} while (p != _lastp);
/*no free block big enough*/
_sav(&p);
q = (struct adm *)((char *)p + n);
_rst(&q);
initialize:
*pp = p;
ptmp = (int *)p;
while (ptmp < (int *)q)
*ptmp++ = UNDEF;
}
extern void _dis(int, struct adm **);
/*
* Helper function to request 'nu' units of memory from the OS.
* A storage unit is sizeof(struct adm). Typically 8 bytes
* on a 32-bit machine like i386 etc.
*/
static struct adm *
morecore(unsigned nu)
{
char *cp, *sbrk(int);
struct adm *up;
if (nu < NALLOC)
nu = NALLOC;
cp = sbrk(nu * sizeof(struct adm));
if (cp == (char *) -1) /* no space at all */
return 0;
up = (struct adm*) cp;
up->size = nu;
up = up + 1;
_dis((nu - 1) * sizeof(struct adm), &up);
return freep;
} /* morecore */
/*
* Dispose
* Called with two arguments:
* n the size of the block to be freed, in bytes,
* pp address of pointer to data.
*/
void
_new(int n, struct adm **pp)
{
int nunits; /* the unit of storage is sizeof(struct adm) */
struct adm *p,*q;
/* round up size of request */
nunits = (n + sizeof(struct adm) - 1) / sizeof(struct adm) + 1;
q = 0;
for (p = freep; ; p = p->next) {
if (p == 0) {
p = morecore(nunits);
if (p == 0)
_trp(EHEAP);
q = 0;
}
if (p->size >= nunits) {
if (p->size == nunits) { /* exact fit */
if (q == 0) { /* first element on free list. */
freep = p->next;
} else {
q->next = p->next;
}
} else { /* allocate tail end */
q = p;
q->size = q->size - nunits;
p = q + q->size;
p->next = 0;
p->size = nunits;
}
break;
}
q = p;
}
*pp = p + 1;
} /* _new */

View File

@@ -87,10 +87,10 @@ static int initfl(descr,sz,f) int descr; int sz; struct file *f; {
f->fname = _pargv[i];
_cls(f);
if ((descr & WRBIT) == 0) {
if ((f->ufd = _open(f->fname,0)) < 0)
if ((f->ufd = open(f->fname,0)) < 0)
_trp(ERESET);
} else {
if ((f->ufd = _creat(f->fname,0644)) < 0)
if ((f->ufd = creat(f->fname,0644)) < 0)
_trp(EREWR);
}
}

View File

@@ -18,12 +18,12 @@
/* Author: J.W. Stevenson */
#include <unistd.h>
#include <pc_file.h>
#include <pc_err.h>
extern _cls();
extern _trp();
extern int _creat();
/* procedure pcreat(var f:text; s:string); */
@@ -36,6 +36,6 @@ pcreat(f,s) struct file *f; char *s; {
f->size = 1;
f->count = PC_BUFLEN;
f->buflen = PC_BUFLEN;
if ((f->ufd = _creat(s,0644)) < 0)
if ((f->ufd = creat(s,0644)) < 0)
_trp(EREWR);
}

View File

@@ -14,8 +14,8 @@ del = 0177
.sect .text
.diagnos:
movem.l d0/d1/d2/a0, -(sp)
move.l (.lino), -(sp)
move.l (.filn), d2
move.l (hol0), -(sp)
move.l (hol0+4), d2
beq 1f
move.l d2, a0
move.l #40, d0

View File

@@ -9,7 +9,7 @@
move.l (.limhp),-(sp)
move.l (.reghp),-(sp)
pea (12, sp)
move.l (.lino),-(sp)
move.l (hol0),-(sp)
pea (fmt)
jsr (.diagnos)
lea (20, sp), sp

38
mach/m68020/libem/pmfile Normal file
View File

@@ -0,0 +1,38 @@
-- $Source: /cvsroot/tack/Ack/mach/i386/libem/pmfile,v $
-- $State: Exp $
-- $Revision: 1.1 $
local d = ROOTDIR.."mach/m68020/libem/"
libem_m68020 = acklibrary {
outputs = {"%U%/libem-%PLATFORM%.a"},
ACKINCLUDES = {PARENT, ROOTDIR.."h"},
ackfile (d.."fp68881.s"),
ackfile (d.."aar.s"),
ackfile (d.."lar.s"),
ackfile (d.."sar.s"),
ackfile (d.."csa.s"),
ackfile (d.."csb.s"),
ackfile (d.."shp.s"),
ackfile (d.."set.s"),
ackfile (d.."inn.s"),
ackfile (d.."fat.s"),
ackfile (d.."trp.s"),
ackfile (d.."trpstr.c"),
ackfile (d.."mon.s"),
ackfile (d.."nop.s"),
ackfile (d.."dia.s"),
ackfile (d.."cii.s"),
ackfile (d.."cuu.s"),
ackfile (d.."cmi.s"),
ackfile (d.."cms.s"),
ackfile (d.."cmu.s"),
ackfile (d.."cvf.s"),
ackfile (d.."exg.s"),
ackfile (d.."los.s"),
ackfile (d.."sts.s"),
install = pm.install("%BINDIR%lib/%PLATFORM%/libem.a"),
}

View File

@@ -15,7 +15,7 @@ fmt: .asciz "%s\n"
move.l d0, (12, sp)
cmp.l #16, d0
bcc 1f
move.l (.trpim), d1
move.l (.ignmask), d1
btst d0, d1
bne 3f
1:

View File

@@ -1,4 +1,5 @@
#include <em_abs.h>
char *
_trpstr(d)
{

View File

@@ -1,22 +1,24 @@
! $Source: /cvsroot/tack/Ack/mach/i386/libend/em_end.s,v $
! $State: Exp $
! $Revision: 1.2 $
.sect .text
.sect .rom
.sect .data
.sect .bss
.define endtext,enddata,endbss,__end
.sect .text
.align 4
.sect .rom
.align 4
.sect .data
.align 4
.sect .bss
.align 4
.sect .end ! only for declaration of _end, __end and endbss.
.define endtext, endrom, enddata, endbss, __end
.sect .text
.align 4
endtext:
.sect .rom
.align 4
endrom:
.sect .data
.align 4
enddata:
.sect .end
.align 4
__end:
endbss:

16
mach/m68020/libend/pmfile Normal file
View File

@@ -0,0 +1,16 @@
-- $Source: /cvsroot/tack/Ack/mach/i386/libend/pmfile,v $
-- $State: Exp $
-- $Revision: 1.1 $
local d = ROOTDIR.."mach/m68020/libend/"
libend_m68020 = acklibrary {
outputs = {"%U%/libend-%PLATFORM%.a"},
ackfile (d.."edata.s"),
ackfile (d.."em_end.s"),
ackfile (d.."end.s"),
ackfile (d.."etext.s"),
install = pm.install("%BINDIR%lib/%PLATFORM%/libend.a"),
}

View File

@@ -5840,7 +5840,7 @@ with any_int STACK
jsr {absolute4, ".exg"}
pat fil
gen move_l {ext_addr, $1}, {absolute4, ".filn"}
gen move_l {ext_addr, $1}, {absolute4, "hol0+4"}
pat gto
with STACK
@@ -5854,15 +5854,15 @@ with STACK
jmp {indirect4, %a}
#endif
pat lim yields {absolute_int, ".trpim"}
pat lim yields {absolute_int, ".ignmask"}
pat lin
kills posextern
gen move_i {const, $1}, {absolute_int, ".lino"}
gen move_i {const, $1}, {absolute_int, "hol0"}
pat lni
kills posextern
gen add_i {const, 1}, {absolute_int, ".lino"}
gen add_i {const, 1}, {absolute_int, "hol0"}
pat lor $1==0 yields lb
@@ -5955,7 +5955,7 @@ with any4
pat sim
with any_int
kills posextern
gen move_i %1, {absolute_int, ".trpim"}
gen move_i %1, {absolute_int, ".ignmask"}
pat str $1==0
with any4 STACK

View File

@@ -6,4 +6,4 @@
#define WORD_SIZE 4 /* should be 2 or 4 */
#define TBL68020 1 /* should be TBL68020 or TBL68000 */
/* #define TBL68881 1 /* use floating point processor */
#define TBL68881 1 /* use floating point processor */

View File

@@ -3,6 +3,9 @@
local d = ROOTDIR.."mach/m68020/"
include (d.."libem/pmfile")
include (d.."libend/pmfile")
mach_m68020 = group {
ARCH = "m68020",
@@ -10,20 +13,11 @@ mach_m68020 = group {
proto_ncg { ARCHDIR = "m68020" },
proto_top,
ego_descr,
install = {
pm.install("%ROOTDIR%/lib/%ARCH%/descr", "%BINDIR%%PLATIND%/%ARCH%/descr"),
}
}
-- Revision history
-- $Log$
-- Revision 1.3 2006-07-22 12:31:19 dtrg
-- Added support for the top target peephole optimiser.
--
-- Revision 1.2 2006/07/22 00:52:01 dtrg
-- Added support for the ego global optimisation suite.
--
-- Revision 1.1 2006/07/20 23:18:18 dtrg
-- First version in CVS.
--
support_m68020 = group {
OPTIMISATION = "-O6",
libem_m68020,
libend_m68020,
}

View File

@@ -1,11 +0,0 @@
The file 'table' in this directory contains a back end table for the
MC68020 processor as well as one for the MC68000. Both tables use 2 or 4 bytes
for words and 4 bytes for pointers. The table must be preprocessed first
by the C preprocessor.
The file "whichone.h" specifies which code generator is generated:
it #defines either TBL68000 or TBL86020, and it defines WORD_SIZE to either
2 or 4.
The m68k4(TBL68000) cg can very well be used for the MC68010 processor,
for it makes rather efficient use of the 68010 loop mode.
The mach.[ch] files are also suitable for both the m68020 and the m68k[24].

View File

@@ -1,144 +0,0 @@
#if WORD_SIZE==2
#define LLP ldl
#define LEP lde
#define LFP ldf /* load offsetted pointer */
#define SLP sdl
#define SEP sde
#define SFP sdf /* store offsetted pointer */
#define ABS_off_int ABS_off2
#define ABS_indoff_int ABS_indoff2
#define ABSIND_off_int ABSIND_off2
#define INDOFF_off_int INDOFF_off2
#define OFF_off_int OFF_off2
#define OFF_indoff_int OFF_indoff2
#define abs_index_int abs_index2
#define absolute_int absolute2
#define any_int any2
#define conreg_int conreg2
#define data_int data2
#define datalt_int datalt2
#define dreg_int dreg2
#define imm_cmp_int imm_cmp2
#define immediate_int immediate2
#define indirect_int indirect2
#define index_off_int index_off2
#define offsetted_int offsetted2
#define post_inc_int post_inc2
#define pre_dec_int pre_dec2
#define store_int any2
#define test_set_int test_set2
#define add_i add_w
#define ADD_I "add.w"
#define and_i and_w
#define AND_I "and.w"
#define asl_i asl_w
#define ASL_I "asl.w"
#define asr_i asr_w
#define ASR_I "asr.w"
#define clr_i clr_w
#define CLR_I "clr.w"
#define cmp_i cmp_w
#define cmp2_i cmp2_w
#define DEC "sub.w #1,"
#define DIVS_I "divs.w"
#define DIVU_I "divu.w"
#define eor_i eor_w
#define EOR_I "eor.w"
#define INC "add.w #1,"
#define lsr_i lsr_w
#define LSR_I "lsr.w"
#define move_i move_w
#define MOVE_I "move.w"
#define muls_i muls_w
#define MULS_I "muls.w"
#define mulu_i mulu_w
#define MULU_I "mulu.w"
#define neg_i neg_w
#define NEG_I "neg.w"
#define not_i not_w
#define NOT_I "not.w"
#define or_i or_w
#define OR_I "or.w"
#define rol_i rol_w
#define ROL_I "rol.w"
#define ror_i ror_w
#define ROR_I "ror.w"
#define sub_i sub_w
#define SUB_I "sub.w"
#define tst_i tst_w
#else
#define LLP lol
#define LEP loe
#define LFP lof /* load offsetted pointer */
#define SLP stl
#define SEP ste
#define SFP stf /* store offsetted pointer */
#define ABS_off_int ABS_off4
#define ABS_indoff_int ABS_indoff4
#define ABSIND_off_int ABSIND_off4
#define INDOFF_off_int INDOFF_off4
#define OFF_off_int OFF_off4
#define OFF_indoff_int OFF_indoff4
#define abs_index_int abs_index4
#define absolute_int absolute4
#define any_int any4
#define conreg_int conreg4
#define data_int data4
#define datalt_int datalt4
#define dreg_int dreg4
#define imm_cmp_int imm_cmp4
#define immediate_int immediate4
#define indirect_int indirect4
#define index_off_int index_off4
#define offsetted_int offsetted4
#define post_inc_int post_inc4
#define pre_dec_int pre_dec4
#define store_int store4
#define test_set_int test_set4
#define add_i add_l
#define ADD_I "add.l"
#define and_i and_l
#define AND_I "and.l"
#define asl_i asl_l
#define ASL_I "asl.l"
#define asr_i asr_l
#define ASR_I "asr.l"
#define clr_i clr_l
#define CLR_I "clr.l"
#define cmp_i cmp_l
#define cmp2_i cmp2_l
#define DEC "sub.l #1,"
#define DIVS_I "divs.l"
#define DIVU_I "divu.l"
#define eor_i eor_l
#define EOR_I "eor.l"
#define INC "add.l #1,"
#define lsr_i lsr_l
#define LSR_I "lsr.l"
#define move_i move_l
#define MOVE_I "move.l"
#define muls_i muls_l
#define MULS_I "muls.l"
#define mulu_i mulu_l
#define MULU_I "mulu.l"
#define neg_i neg_l
#define NEG_I "neg.l"
#define not_i not_l
#define NOT_I "not.l"
#define or_i or_l
#define OR_I "or.l"
#define rol_i rol_l
#define ROL_I "rol.l"
#define ror_i ror_l
#define ROR_I "ror.l"
#define sub_i sub_l
#define SUB_I "sub.l"
#define tst_i tst_l
#endif

View File

@@ -1,288 +0,0 @@
/* $Id$ */
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*
*/
/*
* machine dependent back end routines for the Motorola 68000, 68010 or 68020
*/
#include <whichone.h>
#if TBL68020
#define SYNTAX_68020 1
#endif
#include <stb.h>
con_part(sz,w) register sz; word w; {
while (part_size % sz)
part_size++;
if (part_size == TEM_WSIZE)
part_flush();
if (sz == 1) {
w &= 0xFF;
#if WORD_SIZE==4
w <<= 8*(3-part_size);
part_word |= w;
} else if (sz == 2) {
w &= 0xFFFF;
#endif
if (part_size == 0) {
/* Shift 8 for m68k2, 16 otherwise */
w <<= 4 * TEM_WSIZE;
}
part_word |= w;
} else {
assert(sz == TEM_WSIZE);
part_word = w;
}
part_size += sz;
}
con_mult(sz) word sz; {
if (sz != 4)
fatal("bad icon/ucon size");
fprintf(codefile,".data4 %s\n",str);
}
#define IEEEFLOAT
#define CODE_GENERATOR
#define FL_MSL_AT_LOW_ADDRESS 1
#define FL_MSW_AT_LOW_ADDRESS 1
#define FL_MSB_AT_LOW_ADDRESS 1
#include <con_float>
regscore(off,size,typ,score,totyp)
long off;
{
if (score == 0) return -1;
switch(typ) {
case reg_float:
return -1;
case reg_pointer:
if (size != 4 || totyp != reg_pointer) return -1;
score += (score >> 1);
break;
case reg_loop:
score += 5;
/* fall through .. */
case reg_any:
if (size != TEM_WSIZE || totyp == reg_pointer) return -1;
break;
}
if (off >= 0) {
/* parameters must be initialised with an instruction
* like "move.l 4(a6),d0", which costs 2 words.
*/
score -= 2;
}
score--; /* save/restore */
return score;
}
struct regsav_t {
char *rs_reg; /* e.g. "a3" or "d5" */
long rs_off; /* offset of variable */
int rs_size; /* 2 or 4 bytes */
} regsav[9];
int regnr;
i_regsave()
{
regnr = 0;
}
full nlocals;
regreturn()
{
register struct regsav_t *p;
if (regnr > 1) {
#ifdef SYNTAX_68020
fprintf(codefile,"movem.l (-%ld,a6),", nlocals);
#else
fprintf(codefile,"movem.l -%ld(a6),", nlocals);
#endif
for (p = regsav; ;) {
fputs(p->rs_reg, codefile);
if (++p == &regsav[regnr]) break;
putc('/',codefile);
}
putc('\n',codefile);
} else if (regnr == 1) {
p = regsav;
#ifdef SYNTAX_68020
fprintf(codefile,"move.l (-%ld,a6),%s\n",nlocals, p->rs_reg);
#else
fprintf(codefile,"move.l -%ld(a6),%s\n",nlocals, p->rs_reg);
#endif
}
fputs("unlk a6\nrts\n", codefile);
}
f_regsave()
{
register struct regsav_t *p;
nlocals += regnr*4;
#ifdef TBL68020
fprintf(codefile,"link\ta6,#-%ld\n",nlocals);
#else
if (nlocals > 32768) {
fprintf(codefile, "move.l a6,-(sp)\nmove.l sp,a6\nsub #%ld,sp\n", nlocals);
}
else fprintf(codefile,"link\ta6,#-%ld\n",nlocals);
#endif
#ifndef NOSTACKTEST
fprintf(codefile, "tst.b %s\n",
#ifdef SYNTAX_68020
"(-40, sp)"
#else
"-40(sp)"
#endif
);
#endif
if (regnr > 1) {
fputs("movem.l ", codefile);
for (p = regsav; ;) {
fputs(p->rs_reg, codefile);
if (++p == &regsav[regnr]) break;
putc('/',codefile);
}
fputs(",(sp)\n", codefile);
} else if (regnr == 1) {
p = regsav;
fprintf(codefile,"move.l %s,(sp)\n",p->rs_reg);
}
/* initialise register-parameters */
for (p = regsav; p < &regsav[regnr]; p++) {
if (p->rs_off >= 0) {
#ifdef SYNTAX_68020
fprintf(codefile,"move.%c (%ld,a6),%s\n",
#else
fprintf(codefile,"move.%c %ld(a6),%s\n",
#endif
(p->rs_size == 4 ? 'l' : 'w'),
p->rs_off,
p->rs_reg);
}
}
}
regsave(s,off,size)
char *s;
long off;
{
assert (regnr < 9);
regsav[regnr].rs_reg = s;
regsav[regnr].rs_off = off;
regsav[regnr++].rs_size = size;
fprintf(codefile, "!Local %ld into %s\n",off,s);
}
prolog(n) full n; {
nlocals = n;
}
#ifdef MACH_OPTIONS
static int gdb_flag = 0;
mach_option(s)
char *s;
{
if (! strcmp(s, "-gdb")) {
gdb_flag = 1;
}
else {
error("Unknown flag %s", s);
}
}
#endif /* MACH_OPTIONS */
mes(type) word type ; {
int argt, a1, a2 ;
switch ( (int)type ) {
case ms_ext :
for (;;) {
switch ( argt=getarg(
ptyp(sp_cend)|ptyp(sp_pnam)|sym_ptyp) ) {
case sp_cend :
return ;
default:
strarg(argt) ;
fprintf(codefile,".define %s\n",argstr) ;
break ;
}
}
case ms_stb:
argt = getarg(str_ptyp | cst_ptyp);
if (argt == sp_cstx)
fputs(".symb \"\", ", codefile);
else {
fprintf(codefile, ".symb \"%s\", ", str);
argt = getarg(cst_ptyp);
}
a1 = argval;
argt = getarg(cst_ptyp);
a2 = argval;
argt = getarg(cst_ptyp|nof_ptyp|sof_ptyp|ilb_ptyp|pro_ptyp);
#ifdef MACH_OPTIONS
if (gdb_flag) {
if (a1 == N_PSYM) {
/* Change offset from AB into offset from
the frame pointer.
*/
argval += 8;
}
}
#endif
fprintf(codefile, "%s, 0x%x, %d\n", strarg(argt), a1, a2);
argt = getarg(end_ptyp);
break;
case ms_std:
argt = getarg(str_ptyp | cst_ptyp);
if (argt == sp_cstx)
str[0] = '\0';
else {
argt = getarg(cst_ptyp);
}
swtxt();
if (argval == N_SLINE
#ifdef MACH_OPTIONS
&& ! gdb_flag
#endif
) {
#ifdef SYNTAX_68020
fputs("jsr (___u_LiB)\n", codefile);
#else
fputs("jsr ___u_LiB\n", codefile);
#endif
cleanregs(); /* debugger might change variables */
}
fprintf(codefile, ".symd \"%s\", 0x%x,", str, (int) argval);
argt = getarg(cst_ptyp);
fprintf(codefile, "%d\n", (int) argval);
argt = getarg(end_ptyp);
break;
default :
while ( getarg(any_ptyp) != sp_cend ) ;
break ;
}
}
char *segname[] = {
".sect .text", /* SEGTXT */
".sect .data", /* SEGCON */
".sect .rom", /* SEGROM */
".sect .bss" /* SEGBSS */
};

View File

@@ -1,49 +0,0 @@
/* $Id$ */
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#include <whichone.h>
#ifndef TBL68020
#ifndef TBL68000
Something is very wrong here. You must specify the machine: either
TBL68000 or TBL68020, in the file whichone.h, then REMOVE tables.c
and then run "make" again
#endif
#endif
#if WORD_SIZE!=2 && WORD_SIZE!=4
You must specify the appropriate word size, then REMOVE tables.c
#endif
#define ex_ap(y) fprintf(codefile,".extern %s\n",y)
#define in_ap(y) /* nothing */
#define newilb(x) fprintf(codefile,"%s:\n",x)
#define newdlb(x) fprintf(codefile,"%s:\n",x)
#define dlbdlb(x,y) fprintf(codefile,"%s = %s\n",x,y)
#define newlbss(l,x) fprintf(codefile,".comm %s,%ld\n",l,x);
#define pop_fmt "(sp)+"
#define cst_fmt "%ld"
#define off_fmt "%ld"
#define ilb_fmt "I%x_%x"
#define dlb_fmt "I_%d"
#define hol_fmt "hol%d"
#define hol_off "%ld+hol%d"
#if WORD_SIZE==2
#define con_cst(x) fprintf(codefile,".data2\t%ld\n",x)
#else
#define con_cst(x) fprintf(codefile,".data4\t%ld\n",x)
#endif
#define con_ilb(x) fprintf(codefile,".data4\t%s\n",x)
#define con_dlb(x) fprintf(codefile,".data4\t%s\n",x)
#define modhead ".sect .text\n.sect .rom\n.sect .data\n.sect .bss\n"
#define fmt_id(sf,st) sprintf(st,"_%s",sf)
#define BSS_INIT 0
#define MACH_OPTIONS

File diff suppressed because it is too large Load Diff

View File

@@ -1,11 +0,0 @@
The file 'table' in this directory contains a back end table for the
MC68020 processor as well as one for the MC68000. Both tables use 2 or 4 bytes
for words and 4 bytes for pointers. The table must be preprocessed first
by the C preprocessor.
The file "whichone.h" specifies which code generator is generated:
it #defines either TBL68000 or TBL86020, and it defines WORD_SIZE to either
2 or 4.
The m68k4(TBL68000) cg can very well be used for the MC68010 processor,
for it makes rather efficient use of the 68010 loop mode.
The mach.[ch] files are also suitable for both the m68020 and the m68k[24].

View File

@@ -1,144 +0,0 @@
#if WORD_SIZE==2
#define LLP ldl
#define LEP lde
#define LFP ldf /* load offsetted pointer */
#define SLP sdl
#define SEP sde
#define SFP sdf /* store offsetted pointer */
#define ABS_off_int ABS_off2
#define ABS_indoff_int ABS_indoff2
#define ABSIND_off_int ABSIND_off2
#define INDOFF_off_int INDOFF_off2
#define OFF_off_int OFF_off2
#define OFF_indoff_int OFF_indoff2
#define abs_index_int abs_index2
#define absolute_int absolute2
#define any_int any2
#define conreg_int conreg2
#define data_int data2
#define datalt_int datalt2
#define dreg_int dreg2
#define imm_cmp_int imm_cmp2
#define immediate_int immediate2
#define indirect_int indirect2
#define index_off_int index_off2
#define offsetted_int offsetted2
#define post_inc_int post_inc2
#define pre_dec_int pre_dec2
#define store_int any2
#define test_set_int test_set2
#define add_i add_w
#define ADD_I "add.w"
#define and_i and_w
#define AND_I "and.w"
#define asl_i asl_w
#define ASL_I "asl.w"
#define asr_i asr_w
#define ASR_I "asr.w"
#define clr_i clr_w
#define CLR_I "clr.w"
#define cmp_i cmp_w
#define cmp2_i cmp2_w
#define DEC "sub.w #1,"
#define DIVS_I "divs.w"
#define DIVU_I "divu.w"
#define eor_i eor_w
#define EOR_I "eor.w"
#define INC "add.w #1,"
#define lsr_i lsr_w
#define LSR_I "lsr.w"
#define move_i move_w
#define MOVE_I "move.w"
#define muls_i muls_w
#define MULS_I "muls.w"
#define mulu_i mulu_w
#define MULU_I "mulu.w"
#define neg_i neg_w
#define NEG_I "neg.w"
#define not_i not_w
#define NOT_I "not.w"
#define or_i or_w
#define OR_I "or.w"
#define rol_i rol_w
#define ROL_I "rol.w"
#define ror_i ror_w
#define ROR_I "ror.w"
#define sub_i sub_w
#define SUB_I "sub.w"
#define tst_i tst_w
#else
#define LLP lol
#define LEP loe
#define LFP lof /* load offsetted pointer */
#define SLP stl
#define SEP ste
#define SFP stf /* store offsetted pointer */
#define ABS_off_int ABS_off4
#define ABS_indoff_int ABS_indoff4
#define ABSIND_off_int ABSIND_off4
#define INDOFF_off_int INDOFF_off4
#define OFF_off_int OFF_off4
#define OFF_indoff_int OFF_indoff4
#define abs_index_int abs_index4
#define absolute_int absolute4
#define any_int any4
#define conreg_int conreg4
#define data_int data4
#define datalt_int datalt4
#define dreg_int dreg4
#define imm_cmp_int imm_cmp4
#define immediate_int immediate4
#define indirect_int indirect4
#define index_off_int index_off4
#define offsetted_int offsetted4
#define post_inc_int post_inc4
#define pre_dec_int pre_dec4
#define store_int store4
#define test_set_int test_set4
#define add_i add_l
#define ADD_I "add.l"
#define and_i and_l
#define AND_I "and.l"
#define asl_i asl_l
#define ASL_I "asl.l"
#define asr_i asr_l
#define ASR_I "asr.l"
#define clr_i clr_l
#define CLR_I "clr.l"
#define cmp_i cmp_l
#define cmp2_i cmp2_l
#define DEC "sub.l #1,"
#define DIVS_I "divs.l"
#define DIVU_I "divu.l"
#define eor_i eor_l
#define EOR_I "eor.l"
#define INC "add.l #1,"
#define lsr_i lsr_l
#define LSR_I "lsr.l"
#define move_i move_l
#define MOVE_I "move.l"
#define muls_i muls_l
#define MULS_I "muls.l"
#define mulu_i mulu_l
#define MULU_I "mulu.l"
#define neg_i neg_l
#define NEG_I "neg.l"
#define not_i not_l
#define NOT_I "not.l"
#define or_i or_l
#define OR_I "or.l"
#define rol_i rol_l
#define ROL_I "rol.l"
#define ror_i ror_l
#define ROR_I "ror.l"
#define sub_i sub_l
#define SUB_I "sub.l"
#define tst_i tst_l
#endif

View File

@@ -1,288 +0,0 @@
/* $Id$ */
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*
*/
/*
* machine dependent back end routines for the Motorola 68000, 68010 or 68020
*/
#include <whichone.h>
#if TBL68020
#define SYNTAX_68020 1
#endif
#include <stb.h>
con_part(sz,w) register sz; word w; {
while (part_size % sz)
part_size++;
if (part_size == TEM_WSIZE)
part_flush();
if (sz == 1) {
w &= 0xFF;
#if WORD_SIZE==4
w <<= 8*(3-part_size);
part_word |= w;
} else if (sz == 2) {
w &= 0xFFFF;
#endif
if (part_size == 0) {
/* Shift 8 for m68k2, 16 otherwise */
w <<= 4 * TEM_WSIZE;
}
part_word |= w;
} else {
assert(sz == TEM_WSIZE);
part_word = w;
}
part_size += sz;
}
con_mult(sz) word sz; {
if (sz != 4)
fatal("bad icon/ucon size");
fprintf(codefile,".data4 %s\n",str);
}
#define IEEEFLOAT
#define CODE_GENERATOR
#define FL_MSL_AT_LOW_ADDRESS 1
#define FL_MSW_AT_LOW_ADDRESS 1
#define FL_MSB_AT_LOW_ADDRESS 1
#include <con_float>
regscore(off,size,typ,score,totyp)
long off;
{
if (score == 0) return -1;
switch(typ) {
case reg_float:
return -1;
case reg_pointer:
if (size != 4 || totyp != reg_pointer) return -1;
score += (score >> 1);
break;
case reg_loop:
score += 5;
/* fall through .. */
case reg_any:
if (size != TEM_WSIZE || totyp == reg_pointer) return -1;
break;
}
if (off >= 0) {
/* parameters must be initialised with an instruction
* like "move.l 4(a6),d0", which costs 2 words.
*/
score -= 2;
}
score--; /* save/restore */
return score;
}
struct regsav_t {
char *rs_reg; /* e.g. "a3" or "d5" */
long rs_off; /* offset of variable */
int rs_size; /* 2 or 4 bytes */
} regsav[9];
int regnr;
i_regsave()
{
regnr = 0;
}
full nlocals;
regreturn()
{
register struct regsav_t *p;
if (regnr > 1) {
#ifdef SYNTAX_68020
fprintf(codefile,"movem.l (-%ld,a6),", nlocals);
#else
fprintf(codefile,"movem.l -%ld(a6),", nlocals);
#endif
for (p = regsav; ;) {
fputs(p->rs_reg, codefile);
if (++p == &regsav[regnr]) break;
putc('/',codefile);
}
putc('\n',codefile);
} else if (regnr == 1) {
p = regsav;
#ifdef SYNTAX_68020
fprintf(codefile,"move.l (-%ld,a6),%s\n",nlocals, p->rs_reg);
#else
fprintf(codefile,"move.l -%ld(a6),%s\n",nlocals, p->rs_reg);
#endif
}
fputs("unlk a6\nrts\n", codefile);
}
f_regsave()
{
register struct regsav_t *p;
nlocals += regnr*4;
#ifdef TBL68020
fprintf(codefile,"link\ta6,#-%ld\n",nlocals);
#else
if (nlocals > 32768) {
fprintf(codefile, "move.l a6,-(sp)\nmove.l sp,a6\nsub #%ld,sp\n", nlocals);
}
else fprintf(codefile,"link\ta6,#-%ld\n",nlocals);
#endif
#ifndef NOSTACKTEST
fprintf(codefile, "tst.b %s\n",
#ifdef SYNTAX_68020
"(-40, sp)"
#else
"-40(sp)"
#endif
);
#endif
if (regnr > 1) {
fputs("movem.l ", codefile);
for (p = regsav; ;) {
fputs(p->rs_reg, codefile);
if (++p == &regsav[regnr]) break;
putc('/',codefile);
}
fputs(",(sp)\n", codefile);
} else if (regnr == 1) {
p = regsav;
fprintf(codefile,"move.l %s,(sp)\n",p->rs_reg);
}
/* initialise register-parameters */
for (p = regsav; p < &regsav[regnr]; p++) {
if (p->rs_off >= 0) {
#ifdef SYNTAX_68020
fprintf(codefile,"move.%c (%ld,a6),%s\n",
#else
fprintf(codefile,"move.%c %ld(a6),%s\n",
#endif
(p->rs_size == 4 ? 'l' : 'w'),
p->rs_off,
p->rs_reg);
}
}
}
regsave(s,off,size)
char *s;
long off;
{
assert (regnr < 9);
regsav[regnr].rs_reg = s;
regsav[regnr].rs_off = off;
regsav[regnr++].rs_size = size;
fprintf(codefile, "!Local %ld into %s\n",off,s);
}
prolog(n) full n; {
nlocals = n;
}
#ifdef MACH_OPTIONS
static int gdb_flag = 0;
mach_option(s)
char *s;
{
if (! strcmp(s, "-gdb")) {
gdb_flag = 1;
}
else {
error("Unknown flag %s", s);
}
}
#endif /* MACH_OPTIONS */
mes(type) word type ; {
int argt, a1, a2 ;
switch ( (int)type ) {
case ms_ext :
for (;;) {
switch ( argt=getarg(
ptyp(sp_cend)|ptyp(sp_pnam)|sym_ptyp) ) {
case sp_cend :
return ;
default:
strarg(argt) ;
fprintf(codefile,".define %s\n",argstr) ;
break ;
}
}
case ms_stb:
argt = getarg(str_ptyp | cst_ptyp);
if (argt == sp_cstx)
fputs(".symb \"\", ", codefile);
else {
fprintf(codefile, ".symb \"%s\", ", str);
argt = getarg(cst_ptyp);
}
a1 = argval;
argt = getarg(cst_ptyp);
a2 = argval;
argt = getarg(cst_ptyp|nof_ptyp|sof_ptyp|ilb_ptyp|pro_ptyp);
#ifdef MACH_OPTIONS
if (gdb_flag) {
if (a1 == N_PSYM) {
/* Change offset from AB into offset from
the frame pointer.
*/
argval += 8;
}
}
#endif
fprintf(codefile, "%s, 0x%x, %d\n", strarg(argt), a1, a2);
argt = getarg(end_ptyp);
break;
case ms_std:
argt = getarg(str_ptyp | cst_ptyp);
if (argt == sp_cstx)
str[0] = '\0';
else {
argt = getarg(cst_ptyp);
}
swtxt();
if (argval == N_SLINE
#ifdef MACH_OPTIONS
&& ! gdb_flag
#endif
) {
#ifdef SYNTAX_68020
fputs("jsr (___u_LiB)\n", codefile);
#else
fputs("jsr ___u_LiB\n", codefile);
#endif
cleanregs(); /* debugger might change variables */
}
fprintf(codefile, ".symd \"%s\", 0x%x,", str, (int) argval);
argt = getarg(cst_ptyp);
fprintf(codefile, "%d\n", (int) argval);
argt = getarg(end_ptyp);
break;
default :
while ( getarg(any_ptyp) != sp_cend ) ;
break ;
}
}
char *segname[] = {
".sect .text", /* SEGTXT */
".sect .data", /* SEGCON */
".sect .rom", /* SEGROM */
".sect .bss" /* SEGBSS */
};

View File

@@ -1,49 +0,0 @@
/* $Id$ */
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#include <whichone.h>
#ifndef TBL68020
#ifndef TBL68000
Something is very wrong here. You must specify the machine: either
TBL68000 or TBL68020, in the file whichone.h, then REMOVE tables.c
and then run "make" again
#endif
#endif
#if WORD_SIZE!=2 && WORD_SIZE!=4
You must specify the appropriate word size, then REMOVE tables.c
#endif
#define ex_ap(y) fprintf(codefile,".extern %s\n",y)
#define in_ap(y) /* nothing */
#define newilb(x) fprintf(codefile,"%s:\n",x)
#define newdlb(x) fprintf(codefile,"%s:\n",x)
#define dlbdlb(x,y) fprintf(codefile,"%s = %s\n",x,y)
#define newlbss(l,x) fprintf(codefile,".comm %s,%ld\n",l,x);
#define pop_fmt "(sp)+"
#define cst_fmt "%ld"
#define off_fmt "%ld"
#define ilb_fmt "I%x_%x"
#define dlb_fmt "I_%d"
#define hol_fmt "hol%d"
#define hol_off "%ld+hol%d"
#if WORD_SIZE==2
#define con_cst(x) fprintf(codefile,".data2\t%ld\n",x)
#else
#define con_cst(x) fprintf(codefile,".data4\t%ld\n",x)
#endif
#define con_ilb(x) fprintf(codefile,".data4\t%s\n",x)
#define con_dlb(x) fprintf(codefile,".data4\t%s\n",x)
#define modhead ".sect .text\n.sect .rom\n.sect .data\n.sect .bss\n"
#define fmt_id(sf,st) sprintf(st,"_%s",sf)
#define BSS_INIT 0
#define MACH_OPTIONS

File diff suppressed because it is too large Load Diff

View File

@@ -1,11 +0,0 @@
The file 'table' in this directory contains a back end table for the
MC68020 processor as well as one for the MC68000. Both tables use 2 or 4 bytes
for words and 4 bytes for pointers. The table must be preprocessed first
by the C preprocessor.
The file "whichone.h" specifies which code generator is generated:
it #defines either TBL68000 or TBL86020, and it defines WORD_SIZE to either
2 or 4.
The m68k4(TBL68000) cg can very well be used for the MC68010 processor,
for it makes rather efficient use of the 68010 loop mode.
The mach.[ch] files are also suitable for both the m68020 and the m68k[24].

View File

@@ -1,144 +0,0 @@
#if WORD_SIZE==2
#define LLP ldl
#define LEP lde
#define LFP ldf /* load offsetted pointer */
#define SLP sdl
#define SEP sde
#define SFP sdf /* store offsetted pointer */
#define ABS_off_int ABS_off2
#define ABS_indoff_int ABS_indoff2
#define ABSIND_off_int ABSIND_off2
#define INDOFF_off_int INDOFF_off2
#define OFF_off_int OFF_off2
#define OFF_indoff_int OFF_indoff2
#define abs_index_int abs_index2
#define absolute_int absolute2
#define any_int any2
#define conreg_int conreg2
#define data_int data2
#define datalt_int datalt2
#define dreg_int dreg2
#define imm_cmp_int imm_cmp2
#define immediate_int immediate2
#define indirect_int indirect2
#define index_off_int index_off2
#define offsetted_int offsetted2
#define post_inc_int post_inc2
#define pre_dec_int pre_dec2
#define store_int any2
#define test_set_int test_set2
#define add_i add_w
#define ADD_I "add.w"
#define and_i and_w
#define AND_I "and.w"
#define asl_i asl_w
#define ASL_I "asl.w"
#define asr_i asr_w
#define ASR_I "asr.w"
#define clr_i clr_w
#define CLR_I "clr.w"
#define cmp_i cmp_w
#define cmp2_i cmp2_w
#define DEC "sub.w #1,"
#define DIVS_I "divs.w"
#define DIVU_I "divu.w"
#define eor_i eor_w
#define EOR_I "eor.w"
#define INC "add.w #1,"
#define lsr_i lsr_w
#define LSR_I "lsr.w"
#define move_i move_w
#define MOVE_I "move.w"
#define muls_i muls_w
#define MULS_I "muls.w"
#define mulu_i mulu_w
#define MULU_I "mulu.w"
#define neg_i neg_w
#define NEG_I "neg.w"
#define not_i not_w
#define NOT_I "not.w"
#define or_i or_w
#define OR_I "or.w"
#define rol_i rol_w
#define ROL_I "rol.w"
#define ror_i ror_w
#define ROR_I "ror.w"
#define sub_i sub_w
#define SUB_I "sub.w"
#define tst_i tst_w
#else
#define LLP lol
#define LEP loe
#define LFP lof /* load offsetted pointer */
#define SLP stl
#define SEP ste
#define SFP stf /* store offsetted pointer */
#define ABS_off_int ABS_off4
#define ABS_indoff_int ABS_indoff4
#define ABSIND_off_int ABSIND_off4
#define INDOFF_off_int INDOFF_off4
#define OFF_off_int OFF_off4
#define OFF_indoff_int OFF_indoff4
#define abs_index_int abs_index4
#define absolute_int absolute4
#define any_int any4
#define conreg_int conreg4
#define data_int data4
#define datalt_int datalt4
#define dreg_int dreg4
#define imm_cmp_int imm_cmp4
#define immediate_int immediate4
#define indirect_int indirect4
#define index_off_int index_off4
#define offsetted_int offsetted4
#define post_inc_int post_inc4
#define pre_dec_int pre_dec4
#define store_int store4
#define test_set_int test_set4
#define add_i add_l
#define ADD_I "add.l"
#define and_i and_l
#define AND_I "and.l"
#define asl_i asl_l
#define ASL_I "asl.l"
#define asr_i asr_l
#define ASR_I "asr.l"
#define clr_i clr_l
#define CLR_I "clr.l"
#define cmp_i cmp_l
#define cmp2_i cmp2_l
#define DEC "sub.l #1,"
#define DIVS_I "divs.l"
#define DIVU_I "divu.l"
#define eor_i eor_l
#define EOR_I "eor.l"
#define INC "add.l #1,"
#define lsr_i lsr_l
#define LSR_I "lsr.l"
#define move_i move_l
#define MOVE_I "move.l"
#define muls_i muls_l
#define MULS_I "muls.l"
#define mulu_i mulu_l
#define MULU_I "mulu.l"
#define neg_i neg_l
#define NEG_I "neg.l"
#define not_i not_l
#define NOT_I "not.l"
#define or_i or_l
#define OR_I "or.l"
#define rol_i rol_l
#define ROL_I "rol.l"
#define ror_i ror_l
#define ROR_I "ror.l"
#define sub_i sub_l
#define SUB_I "sub.l"
#define tst_i tst_l
#endif

View File

@@ -1,288 +0,0 @@
/* $Id$ */
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*
*/
/*
* machine dependent back end routines for the Motorola 68000, 68010 or 68020
*/
#include <whichone.h>
#if TBL68020
#define SYNTAX_68020 1
#endif
#include <stb.h>
con_part(sz,w) register sz; word w; {
while (part_size % sz)
part_size++;
if (part_size == TEM_WSIZE)
part_flush();
if (sz == 1) {
w &= 0xFF;
#if WORD_SIZE==4
w <<= 8*(3-part_size);
part_word |= w;
} else if (sz == 2) {
w &= 0xFFFF;
#endif
if (part_size == 0) {
/* Shift 8 for m68k2, 16 otherwise */
w <<= 4 * TEM_WSIZE;
}
part_word |= w;
} else {
assert(sz == TEM_WSIZE);
part_word = w;
}
part_size += sz;
}
con_mult(sz) word sz; {
if (sz != 4)
fatal("bad icon/ucon size");
fprintf(codefile,".data4 %s\n",str);
}
#define IEEEFLOAT
#define CODE_GENERATOR
#define FL_MSL_AT_LOW_ADDRESS 1
#define FL_MSW_AT_LOW_ADDRESS 1
#define FL_MSB_AT_LOW_ADDRESS 1
#include <con_float>
regscore(off,size,typ,score,totyp)
long off;
{
if (score == 0) return -1;
switch(typ) {
case reg_float:
return -1;
case reg_pointer:
if (size != 4 || totyp != reg_pointer) return -1;
score += (score >> 1);
break;
case reg_loop:
score += 5;
/* fall through .. */
case reg_any:
if (size != TEM_WSIZE || totyp == reg_pointer) return -1;
break;
}
if (off >= 0) {
/* parameters must be initialised with an instruction
* like "move.l 4(a6),d0", which costs 2 words.
*/
score -= 2;
}
score--; /* save/restore */
return score;
}
struct regsav_t {
char *rs_reg; /* e.g. "a3" or "d5" */
long rs_off; /* offset of variable */
int rs_size; /* 2 or 4 bytes */
} regsav[9];
int regnr;
i_regsave()
{
regnr = 0;
}
full nlocals;
regreturn()
{
register struct regsav_t *p;
if (regnr > 1) {
#ifdef SYNTAX_68020
fprintf(codefile,"movem.l (-%ld,a6),", nlocals);
#else
fprintf(codefile,"movem.l -%ld(a6),", nlocals);
#endif
for (p = regsav; ;) {
fputs(p->rs_reg, codefile);
if (++p == &regsav[regnr]) break;
putc('/',codefile);
}
putc('\n',codefile);
} else if (regnr == 1) {
p = regsav;
#ifdef SYNTAX_68020
fprintf(codefile,"move.l (-%ld,a6),%s\n",nlocals, p->rs_reg);
#else
fprintf(codefile,"move.l -%ld(a6),%s\n",nlocals, p->rs_reg);
#endif
}
fputs("unlk a6\nrts\n", codefile);
}
f_regsave()
{
register struct regsav_t *p;
nlocals += regnr*4;
#ifdef TBL68020
fprintf(codefile,"link\ta6,#-%ld\n",nlocals);
#else
if (nlocals > 32768) {
fprintf(codefile, "move.l a6,-(sp)\nmove.l sp,a6\nsub #%ld,sp\n", nlocals);
}
else fprintf(codefile,"link\ta6,#-%ld\n",nlocals);
#endif
#ifndef NOSTACKTEST
fprintf(codefile, "tst.b %s\n",
#ifdef SYNTAX_68020
"(-40, sp)"
#else
"-40(sp)"
#endif
);
#endif
if (regnr > 1) {
fputs("movem.l ", codefile);
for (p = regsav; ;) {
fputs(p->rs_reg, codefile);
if (++p == &regsav[regnr]) break;
putc('/',codefile);
}
fputs(",(sp)\n", codefile);
} else if (regnr == 1) {
p = regsav;
fprintf(codefile,"move.l %s,(sp)\n",p->rs_reg);
}
/* initialise register-parameters */
for (p = regsav; p < &regsav[regnr]; p++) {
if (p->rs_off >= 0) {
#ifdef SYNTAX_68020
fprintf(codefile,"move.%c (%ld,a6),%s\n",
#else
fprintf(codefile,"move.%c %ld(a6),%s\n",
#endif
(p->rs_size == 4 ? 'l' : 'w'),
p->rs_off,
p->rs_reg);
}
}
}
regsave(s,off,size)
char *s;
long off;
{
assert (regnr < 9);
regsav[regnr].rs_reg = s;
regsav[regnr].rs_off = off;
regsav[regnr++].rs_size = size;
fprintf(codefile, "!Local %ld into %s\n",off,s);
}
prolog(n) full n; {
nlocals = n;
}
#ifdef MACH_OPTIONS
static int gdb_flag = 0;
mach_option(s)
char *s;
{
if (! strcmp(s, "-gdb")) {
gdb_flag = 1;
}
else {
error("Unknown flag %s", s);
}
}
#endif /* MACH_OPTIONS */
mes(type) word type ; {
int argt, a1, a2 ;
switch ( (int)type ) {
case ms_ext :
for (;;) {
switch ( argt=getarg(
ptyp(sp_cend)|ptyp(sp_pnam)|sym_ptyp) ) {
case sp_cend :
return ;
default:
strarg(argt) ;
fprintf(codefile,".define %s\n",argstr) ;
break ;
}
}
case ms_stb:
argt = getarg(str_ptyp | cst_ptyp);
if (argt == sp_cstx)
fputs(".symb \"\", ", codefile);
else {
fprintf(codefile, ".symb \"%s\", ", str);
argt = getarg(cst_ptyp);
}
a1 = argval;
argt = getarg(cst_ptyp);
a2 = argval;
argt = getarg(cst_ptyp|nof_ptyp|sof_ptyp|ilb_ptyp|pro_ptyp);
#ifdef MACH_OPTIONS
if (gdb_flag) {
if (a1 == N_PSYM) {
/* Change offset from AB into offset from
the frame pointer.
*/
argval += 8;
}
}
#endif
fprintf(codefile, "%s, 0x%x, %d\n", strarg(argt), a1, a2);
argt = getarg(end_ptyp);
break;
case ms_std:
argt = getarg(str_ptyp | cst_ptyp);
if (argt == sp_cstx)
str[0] = '\0';
else {
argt = getarg(cst_ptyp);
}
swtxt();
if (argval == N_SLINE
#ifdef MACH_OPTIONS
&& ! gdb_flag
#endif
) {
#ifdef SYNTAX_68020
fputs("jsr (___u_LiB)\n", codefile);
#else
fputs("jsr ___u_LiB\n", codefile);
#endif
cleanregs(); /* debugger might change variables */
}
fprintf(codefile, ".symd \"%s\", 0x%x,", str, (int) argval);
argt = getarg(cst_ptyp);
fprintf(codefile, "%d\n", (int) argval);
argt = getarg(end_ptyp);
break;
default :
while ( getarg(any_ptyp) != sp_cend ) ;
break ;
}
}
char *segname[] = {
".sect .text", /* SEGTXT */
".sect .data", /* SEGCON */
".sect .rom", /* SEGROM */
".sect .bss" /* SEGBSS */
};

View File

@@ -1,49 +0,0 @@
/* $Id$ */
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#include <whichone.h>
#ifndef TBL68020
#ifndef TBL68000
Something is very wrong here. You must specify the machine: either
TBL68000 or TBL68020, in the file whichone.h, then REMOVE tables.c
and then run "make" again
#endif
#endif
#if WORD_SIZE!=2 && WORD_SIZE!=4
You must specify the appropriate word size, then REMOVE tables.c
#endif
#define ex_ap(y) fprintf(codefile,".extern %s\n",y)
#define in_ap(y) /* nothing */
#define newilb(x) fprintf(codefile,"%s:\n",x)
#define newdlb(x) fprintf(codefile,"%s:\n",x)
#define dlbdlb(x,y) fprintf(codefile,"%s = %s\n",x,y)
#define newlbss(l,x) fprintf(codefile,".comm %s,%ld\n",l,x);
#define pop_fmt "(sp)+"
#define cst_fmt "%ld"
#define off_fmt "%ld"
#define ilb_fmt "I%x_%x"
#define dlb_fmt "I_%d"
#define hol_fmt "hol%d"
#define hol_off "%ld+hol%d"
#if WORD_SIZE==2
#define con_cst(x) fprintf(codefile,".data2\t%ld\n",x)
#else
#define con_cst(x) fprintf(codefile,".data4\t%ld\n",x)
#endif
#define con_ilb(x) fprintf(codefile,".data4\t%s\n",x)
#define con_dlb(x) fprintf(codefile,".data4\t%s\n",x)
#define modhead ".sect .text\n.sect .rom\n.sect .data\n.sect .bss\n"
#define fmt_id(sf,st) sprintf(st,"_%s",sf)
#define BSS_INIT 0
#define MACH_OPTIONS

File diff suppressed because it is too large Load Diff

View File

@@ -53,12 +53,12 @@ PROPERTIES
GPR24 GPR25 GPR26 GPR27 GPR28 GPR29 GPR30 GPR31
CR0 CR1
FPR0 FPR1 FPR2 FPR3 FPR4 FPR5 FPR6 FPR7
FPR8 FPR9 FPR10 FPR11 FPR12 FPR13 FPR14 FPR15
FPR16 FPR17 FPR18 FPR19 FPR20 FPR21 FPR22 FPR23
FPR24 FPR25 FPR26 FPR27 FPR28 FPR29 FPR30 FPR31
REGISTERS
/* Reverse order to encourage ncg to allocate them from r31 down */
@@ -95,7 +95,7 @@ REGISTERS
FP("fp") : GPR, GPRFP.
SP("sp") : GPR, GPRSP.
R0("r0") : GPR, GPR0.
F31("f31") : FPR, FREG, FPR31.
F30("f30") : FPR, FREG, FPR30.
F29("f29") : FPR, FREG, FPR29.
@@ -1996,7 +1996,7 @@ PATTERNS
/* All very cheap and nasty --- this needs to be properly integrated into
* the code generator. ncg doesn't like having separate FPU registers. */
/* Single-precision */
pat zrf $1==INT32 /* Push zero */
@@ -2158,4 +2158,3 @@ PATTERNS
gen
bl {LABEL, ".fif8"}

View File

@@ -41,7 +41,7 @@
#define GENLAB "I" /* compiler generated labels */
#define valu_t short /* type of expression values */
#define valu_t long /* type of expression values */
#define ADDR_T unsigned short /* type of dot */
#define word_t short /* type of keyword value */
/*
@@ -113,6 +113,7 @@ _include <signal.h>
#define lowb(z) ((int)(z) & 0xFF)
#define loww(z) ((int)(z) & 0xFFFF)
#define fitx(x, d) ((((x) + (1<<(d-1))) & ~((int)(1<<(d))-1)) == 0)
#define fitb(x) ((((x) + 0x80) & ~((int)0xFF)) == 0)
#define fitw(x) ((((x) + 0x8000L) & ~0xFFFFL) == 0)

View File

@@ -4,6 +4,7 @@
*/
/* $Id$ */
#undef NDEBUG
#ifndef NDEBUG
#define assert(x) if(!(x)) badassertion("x",__FILE__,__LINE__)
#else

View File

@@ -2,6 +2,8 @@
static char rcsid[] = "$Id$";
#endif
#include <stdlib.h>
#include <stdio.h>
#include "assert.h"
#include "param.h"
#include "tables.h"
@@ -778,7 +780,10 @@ normalfailed: if (stackpad!=tokpatlen) {
compute(&enodes[nodeno], &result);
assert(result.e_typ!=EV_INT && result.e_typ!=EV_ADDR);
if (result.e_typ==EV_REG)
erasereg(result.e_v.e_reg);
{
int regno = result.e_v.e_reg;
erasereg(regno);
}
break;
}
case DO_TOKREPLACE: {
@@ -904,6 +909,23 @@ normalfailed: if (stackpad!=tokpatlen) {
break;
}
#endif
#ifdef USE_NOFRAMEPOINTER
case DO_STACKADJUST: {
result_t result;
int nodeno;
DEBUG("STACKADJUST");
/* The offset is an expression, which we need to evaluate. */
getint(nodeno,codep);
compute(&enodes[nodeno], &result);
assert(result.e_typ==EV_INT);
if (toplevel)
stackoffset += result.e_v.e_con;
break;
}
#endif
}
}

View File

@@ -2,6 +2,8 @@
static char rcsid[] = "$Id$";
#endif
#include <stdlib.h>
#include <stdio.h>
#include "assert.h"
#include "equiv.h"
#include "param.h"

View File

@@ -20,6 +20,9 @@ extern rl_p curreglist; /* side effect of findcoerc() */
#ifndef NDEBUG
extern int Debug; /* on/off debug printout */
#endif
#ifdef USE_NOFRAMEPOINTER
extern int stackoffset; /* offset from localbase to sp */
#endif
/*
* Next descriptions are external declarations for tables created
@@ -52,3 +55,6 @@ extern struct reginfo **reglist[]; /* lists of registers per property */
extern int nregvar[]; /* # of register variables per type */
extern int *rvnumbers[]; /* lists of numbers */
#endif
extern FILE *codefile;
extern FILE *freopen();

View File

@@ -60,8 +60,6 @@ long con();
#define get8() getc(emfile)
FILE *emfile;
extern FILE *codefile;
extern FILE *freopen();
int nextispseu,savetab1;
int opcode;

View File

@@ -2,6 +2,8 @@
static char rcsid[] = "$Id$";
#endif
#include <stdlib.h>
#include <stdio.h>
#include "assert.h"
#include "param.h"
#include "tables.h"

View File

@@ -2,6 +2,8 @@
static char rcsid[] = "$Id$";
#endif
#include <stdlib.h>
#include <stdio.h>
#include <em_spec.h>
#include <em_flag.h>
#include "assert.h"

View File

@@ -1,5 +1,5 @@
-- $Source$
-- $State$
-- $Source: /cvsroot/tack/Ack/mach/proto/ncg/pmfile,v $
-- $State: Exp $
local d = ROOTDIR.."mach/proto/ncg/"
@@ -18,6 +18,8 @@ local cfile_with_tables = cfile {
proto_ncg = cprogram {
class = "proto_ncg",
exename = "ncg",
CINCLUDES = {
PARENT,
"mach/%PLATFORM%/ncg",
@@ -50,6 +52,6 @@ proto_ncg = cprogram {
lib_em_data,
lib_flt_arith,
outputs = {"%U%/%PLATFORM%-ncg"},
install = pm.install("%BINDIR%%PLATDEP%/%PLATFORM%/ncg")
outputs = {"%U%/%PLATFORM%-%exename%"},
install = pm.install("%BINDIR%%PLATDEP%/%PLATFORM%/%exename%")
}

View File

@@ -2,6 +2,8 @@
static char rcsid[] = "$Id$";
#endif
#include <stdlib.h>
#include <stdio.h>
#include "assert.h"
#include "param.h"
#include "tables.h"

View File

@@ -1,3 +1,5 @@
#include <stdlib.h>
#include <stdio.h>
#include "assert.h"
#include "param.h"
#include "tables.h"

View File

@@ -3,6 +3,7 @@ static char rcsid[] = "$Id$";
#endif
#include <stdlib.h>
#include <stdio.h>
#include "assert.h"
#include "param.h"
#include "tables.h"

View File

@@ -2,6 +2,8 @@
static char rcsid[] = "$Id$";
#endif
#include <stdlib.h>
#include <stdio.h>
#include "assert.h"
#include "param.h"
#include "tables.h"

View File

@@ -1,624 +0,0 @@
/* $Id$ */
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*
*/
/*
* Convert ACK a.out file to SUN3 object format.
*/
#include <stdio.h>
#include <out.h>
#include <assert.h>
long lseek();
#if __STDC__
#include <stdlib.h>
#else
char *calloc(), *malloc();
#endif
#define OMAGIC 0407 /* old-fashioned */
#define NMAGIC 0410 /* text write protexted */
#define ZMAGIC 0413 /* demand paging */
struct bhdr {
short machtype;
short magic;
long tsize;
long dsize;
long bsize;
long ssize;
long entry;
long rtsize;
long rdsize;
};
struct machrelo {
long address;
long relodata;
};
#define setpcrel(X,f) (X |= (f<<7))
#define setsymbolnum(X,n) (X = (X & 0377) | ((long)n << 8))
#define setextern(X,f) (X |= (f << 4))
#define setlength(X,l) (X = (X & ~0x60)|((long) l << 5))
struct sym {
long name;
char type;
char other;
short desc;
long value;
};
#define N_UNDF 0
#define N_ABS 02
#define N_TEXT 04
#define N_DATA 06
#define N_BSS 010
#define N_EXT 01
#define N_FN 0x1f
/*
* Header and section table of new format object file.
*/
struct outhead outhead;
struct outsect outsect[S_MAX];
char *output_file;
int outputfile_created;
long magic;
int rom_in_data;
char *program ;
char flag ;
/* Output file definitions and such */
struct bhdr bh;
#define ENTRY 0x02000
#define TOT_HDRSIZE (sizeof(struct bhdr))
#define TEXTSG 0
#define ROMSG 1
#define DATASG 2
#define BSSSG 3
#define LSECT BSSSG+1
#define NSECT LSECT+1
int output;
int unresolved;
long textsize ;
long datasize ;
long bsssize;
long align(a,b)
long a,b;
{
a += b - 1;
return a - a % b;
}
int
follows(pa, pb)
register struct outsect *pa, *pb;
{
/* return 1 if pa follows pb */
return pa->os_base == align(pb->os_base+pb->os_size, pa->os_lign);
}
main(argc, argv)
int argc;
char *argv[];
{
register int nsect;
program= argv[0] ;
if ( argc>1 && argv[1][0]=='-' ) {
flag=argv[1][1] ;
if (flag == 'u') unresolved++;
argc-- ; argv++ ;
}
switch (argc) {
case 3: if ((output = creat(argv[2], 0644)) < 0 ||
(close(output), output = open(argv[2],2)) < 0)
fatal("Can't write %s.\n", argv[2]);
output_file = argv[2];
outputfile_created = 1;
if (! rd_open(argv[1]))
fatal("Can't read %s.\n", argv[1]);
break;
default:fatal("Usage: %s [-u] <ACK object> <Sun object>.\n", program);
}
rd_ohead(&outhead);
if (BADMAGIC(outhead))
fatal("Not an ack object file.\n");
if (outhead.oh_flags & HF_LINK) {
if (! unresolved) {
fprintf(stderr,"Warning: contains unresolved references.\n");
}
unresolved++;
}
else if (outhead.oh_nrelo > 0 && !unresolved)
fprintf(stderr, "Warning: relocation information present.\n");
if ( outhead.oh_nsect!=LSECT && outhead.oh_nsect!=NSECT )
fatal("Input file must have %d sections, not %ld\n",
NSECT,outhead.oh_nsect) ;
rd_sect(outsect, outhead.oh_nsect);
/* A few checks */
if ( outsect[BSSSG].os_flen != 0 )
fatal("bss space contains initialized data\n") ;
if ( !unresolved && ! follows(&outsect[BSSSG], &outsect[DATASG]))
fatal("bss segment must follow data segment\n") ;
if ( outsect[ROMSG].os_lign == 0x20000 ) {
/* 410/413 file with ROMSG in data space */
rom_in_data = 1;
magic= NMAGIC ;
textsize= outsect[TEXTSG].os_size ;
datasize= outsect[BSSSG].os_base - outsect[ROMSG].os_base ;
if (! follows(&outsect[DATASG], &outsect[ROMSG]))
fatal("data segment must follow rom\n") ;
outsect[ROMSG].os_size = outsect[DATASG].os_base - outsect[ROMSG].os_base;
outsect[DATASG].os_size = outsect[BSSSG].os_base - outsect[DATASG].os_base;
} else
if ( outsect[DATASG].os_lign == 0x20000 ) {
/* 410/413 file with ROMSG in instruction space */
rom_in_data = 0;
magic= NMAGIC ;
textsize= (outsect[ROMSG].os_base - outsect[TEXTSG].os_base) +
outsect[ROMSG].os_size ;
if (! follows(&outsect[ROMSG],&outsect[TEXTSG]))
fatal("rom segment must follow text\n") ;
outsect[TEXTSG].os_size = outsect[ROMSG].os_base - outsect[TEXTSG].os_base;
outsect[DATASG].os_size = outsect[BSSSG].os_base - outsect[DATASG].os_base;
datasize= outsect[DATASG].os_size ;
} else {
/* Plain 407 file */
rom_in_data = 0;
magic= OMAGIC ;
if (!unresolved) {
textsize= (outsect[DATASG].os_base - outsect[TEXTSG].os_base);
if (! follows(&outsect[ROMSG],&outsect[TEXTSG]))
fatal("rom segment must follow text\n") ;
if (! follows(&outsect[DATASG],&outsect[ROMSG]))
fatal("data segment must follow rom\n") ;
outsect[TEXTSG].os_size = outsect[ROMSG].os_base - outsect[TEXTSG].os_base;
outsect[ROMSG].os_size = outsect[DATASG].os_base - outsect[ROMSG].os_base;
outsect[DATASG].os_size = outsect[BSSSG].os_base - outsect[DATASG].os_base;
}
else {
textsize = outsect[TEXTSG].os_size+outsect[ROMSG].os_size;
}
datasize = outsect[DATASG].os_size;
}
if (outsect[TEXTSG].os_base == TOT_HDRSIZE+ENTRY) {
if (magic != NMAGIC) {
fatal("illegal alignments.\n");
}
magic = ZMAGIC;
textsize = (textsize + TOT_HDRSIZE + (0x2000 - 1)) & ~(0x2000 - 1);
datasize = (datasize + (0x2000 - 1)) & ~(0x2000 - 1);
}
bsssize = outsect[BSSSG].os_size;
if ( outhead.oh_nsect==NSECT ) {
if (! follows(&outsect[LSECT],&outsect[BSSSG]))
fatal("end segment must follow bss\n") ;
if ( outsect[LSECT].os_size != 0 )
fatal("end segment must be empty\n") ;
}
if (magic != OMAGIC && unresolved) {
fatal("unresolved references with wrong magic number\n");
}
if ((magic == ZMAGIC && outsect[TEXTSG].os_base != TOT_HDRSIZE+ENTRY) ||
(magic != ZMAGIC && !unresolved && outsect[TEXTSG].os_base != ENTRY)) {
fatal("Illegal entry point.\n");
}
bh.magic = magic;
bh.machtype = MACH;
bh.tsize = textsize;
bh.bsize = bsssize;
bh.dsize = datasize;
bh.rtsize = 0;
bh.rdsize = 0;
if (magic == ZMAGIC) bh.entry = TOT_HDRSIZE+ENTRY;
else if (!unresolved) bh.entry = ENTRY;
else bh.entry = 0;
/* Action at last */
lseek(output,(long) TOT_HDRSIZE,0);
emits(&outsect[TEXTSG]) ;
if (rom_in_data && magic == ZMAGIC) {
lseek(output,textsize,0);
}
emits(&outsect[ROMSG]) ;
if (!rom_in_data && magic == ZMAGIC) {
lseek(output,textsize,0);
}
emits(&outsect[DATASG]) ;
if (magic == ZMAGIC) {
lseek(output,textsize + datasize,0);
}
if (unresolved) emit_relo();
emit_symtab();
bh.ssize = outhead.oh_nname * sizeof(struct sym);
lseek(output,0L,0);
cvshort(&(bh.machtype));
cvshort(&(bh.magic));
cvlong(&(bh.tsize));
cvlong(&(bh.dsize));
cvlong(&(bh.bsize));
cvlong(&(bh.ssize));
cvlong(&(bh.entry));
cvlong(&(bh.rtsize));
cvlong(&(bh.rdsize));
writef(&bh, 1, (long) TOT_HDRSIZE);
if ( outputfile_created && !unresolved ) chmod(argv[2],0755);
return 0;
}
writef(addr,sz,cnt)
char *addr;
long cnt;
{
cnt *= sz;
while (cnt) {
int i = cnt >= 0x4000 ? 0x4000 : cnt;
cnt -= i;
if (write(output, addr, i) < i) {
fatal("write error\n");
}
addr += i;
}
}
/*
* Transfer the emitted byted from one file to another.
*/
emits(section) struct outsect *section ; {
char *p;
long sz = section->os_flen;
rd_outsect(section - outsect);
while (sz) {
unsigned int i = (sz >= 0x4000 ? 0x4000 : sz);
if (!(p = malloc(i))) {
fatal("No memory.\n");
}
rd_emit(p, i);
if (write(output, p, i) < i) {
fatal("write error.\n");
}
free(p);
sz -= i;
}
sz = section->os_size - section->os_flen;
if (sz) {
if (!(p = calloc(0x4000, 1))) {
fatal("No memory.\n");
}
while (sz) {
unsigned int i = (sz >= 0x4000 ? 0x4000 : sz);
if (write(output, p, i) < i) {
fatal("write error.\n");
}
sz -= i;
}
free(p);
}
}
struct outname *ACKnames;
emit_relo()
{
struct outrelo *ACKrelo;
struct machrelo *MACHtrelo,*MACHdrelo;
register struct outrelo *ap;
register struct machrelo *mtp, *mdp;
unsigned int cnt = outhead.oh_nrelo;
ACKrelo = (struct outrelo *) calloc(cnt, sizeof(struct outrelo));
MACHtrelo = (struct machrelo *) calloc(cnt, sizeof(struct machrelo));
MACHdrelo = (struct machrelo *) calloc(cnt, sizeof(struct machrelo));
ACKnames = (struct outname *) calloc(outhead.oh_nname, sizeof(struct outname));
if (!(ap = ACKrelo) || !(mtp = MACHtrelo) || !(mdp = MACHdrelo) ||
!ACKnames) {
fatal("No memory.\n");
}
rd_relo(ACKrelo, cnt);
rd_name(ACKnames, outhead.oh_nname);
while (cnt-- != 0) {
register struct machrelo *mp;
if (ap->or_sect - S_MIN <= ROMSG) mp = mtp++;
else mp = mdp++;
setlength(mp->relodata,(ap->or_type&RELSZ) >> 1);
setpcrel(mp->relodata,(ap->or_type&RELPC != 0));
mp->address = ap->or_addr;
if (ap->or_sect == ROMSG+S_MIN) {
mp->address += outsect[TEXTSG].os_size;
}
if (ap->or_nami < outhead.oh_nname) {
if (ACKnames[ap->or_nami].on_type & S_EXT) {
setsymbolnum(mp->relodata, ap->or_nami);
setextern(mp->relodata,1);
}
else {
patch(ap, &ACKnames[ap->or_nami], mp);
}
}
else {
setsymbolnum(mp->relodata, N_ABS);
}
cvlong(&(mp->address));
cvlong(&(mp->relodata));
ap++;
}
bh.rtsize = (char *) mtp - (char *) MACHtrelo;
bh.rdsize = (char *) mdp - (char *) MACHdrelo;
writef(MACHtrelo, 1, bh.rtsize);
writef(MACHdrelo, 1, bh.rdsize);
free(ACKrelo);
free(MACHtrelo);
free(MACHdrelo);
}
long
get(sz)
{
char buf[10];
long l = 0;
register char *p = buf;
read(output,buf,sz);
while (sz--) {
l = (l << 8) | (*p++ & 0377);
}
return l;
}
put(l,sz)
long l;
{
char buf[10];
register char *p = buf;
*p++ = l >> 24;
*p++ = l >> 16;
*p++ = l >> 8;
*p++ = l;
p -= sz;
if (write(output, p, sz) < sz) {
fatal("write error.\n");
}
}
patch(ap, an, mp)
register struct outrelo *ap;
register struct outname *an;
register struct machrelo *mp;
{
int whichsect = (an->on_type & S_TYP) - S_MIN;
long correction = 0;
long where = TOT_HDRSIZE+ap->or_addr;
long X;
long here;
int sz;
if (!(an->on_type & S_SCT)) {
fprintf(stderr,"funny on_type %x\n", an->on_type);
}
switch(whichsect) {
case TEXTSG:
setsymbolnum(mp->relodata,N_TEXT);
return;
case DATASG:
correction = outsect[ROMSG].os_size + outsect[TEXTSG].os_size;
setsymbolnum(mp->relodata,N_DATA);
break;
case ROMSG:
correction = outsect[TEXTSG].os_size;
setsymbolnum(mp->relodata,N_TEXT);
break;
case BSSSG:
correction = outsect[ROMSG].os_size + outsect[TEXTSG].os_size+
outsect[DATASG].os_size;
setsymbolnum(mp->relodata,N_BSS);
break;
default:
assert(0);
}
switch(ap->or_sect - S_MIN) {
case DATASG:
where += outsect[ROMSG].os_size;
case ROMSG:
where += outsect[TEXTSG].os_size;
case TEXTSG:
break;
default:
assert(0);
}
here = lseek(output, 0L, 1);
lseek(output, where, 0);
sz = ap->or_type & RELSZ;
X = get(sz) + correction;
lseek(output, where, 0);
put(X,sz);
lseek(output, here, 0);
}
cvlong(l)
long *l;
{
long x = *l;
char *p = (char *) l;
*p++ = x >> 24;
*p++ = x >> 16;
*p++ = x >> 8;
*p = x;
}
cvshort(s)
short *s;
{
short x = *s;
char *p = (char *) s;
*p++ = x >> 8;
*p = x;
}
int
is_rest_local(A, i)
register int i;
register struct outname *A;
{
while (i--) {
if (A->on_type & S_EXT) return 0;
A++;
}
return 1;
}
emit_symtab()
{
register unsigned short i = outhead.oh_nname;
register struct outname *A;
struct sym *MACHnames;
register struct sym *M;
char *chars;
long offX = OFF_CHAR(outhead) - 4;
if (!(A = ACKnames)) {
if (!(A = (struct outname *)
calloc(i, sizeof(struct outname)))) {
fatal("No memory.\n");
}
rd_name(A, outhead.oh_nname);
}
if (!(M = (struct sym *) calloc(i, sizeof(struct sym)))) {
fatal("No memory.\n");
}
MACHnames = M;
ACKnames = A;
for (; i; i--, A++) {
M->value = A->on_valu;
M->desc = A->on_desc;
if ((A->on_type & S_SCT) ||
(A->on_type & S_ETC) == S_FIL) {
static int rest_local;
if (! unresolved || rest_local || (rest_local = is_rest_local(A, i))) {
outhead.oh_nname--;
continue;
}
}
if (A->on_type & S_STB) {
M->type = A->on_type >> 8;
}
else if (A->on_type & S_COM) {
M->type = N_UNDF | N_EXT;
}
else switch(A->on_type & S_TYP) {
case S_UND:
switch(A->on_type & S_ETC) {
default:
M->type = N_UNDF;
break;
case S_MOD:
M->type = N_FN;
break;
case S_LIN:
M->type = N_ABS;
break;
}
break;
case S_ABS:
M->type = N_ABS;
break;
case S_MIN + TEXTSG:
M->type = N_TEXT;
break;
case S_MIN + ROMSG:
if (unresolved) {
M->value += outsect[TEXTSG].os_size;
}
M->type = (rom_in_data ? N_DATA : N_TEXT);
break;
case S_MIN + DATASG:
if (unresolved) {
M->value += outsect[TEXTSG].os_size +
outsect[ROMSG].os_size;
}
M->type = N_DATA;
break;
case S_MIN + BSSSG:
if (unresolved) {
M->value += outsect[TEXTSG].os_size +
outsect[ROMSG].os_size +
outsect[DATASG].os_size;
}
M->type = N_BSS;
break;
case S_MIN + LSECT:
M->type = N_BSS;
break;
default:
fprintf(stderr,"warning: unknown s_type: %d\n",
A->on_type & S_TYP);
}
if (A->on_type & S_EXT) M->type |= N_EXT;
M->name = A->on_foff;
M++;
}
M = MACHnames;
for (i = outhead.oh_nname; i; i--, M++) {
if (M->name) {
M->name -= offX;
}
else M->name = outhead.oh_nchar + 3; /* pointer to nullbyte */
cvlong(&(M->name));
cvlong(&(M->value));
cvshort(&(M->desc));
}
writef(MACHnames, sizeof(struct sym), (long) outhead.oh_nname);
free(MACHnames);
free(ACKnames);
if ((unsigned) outhead.oh_nchar != outhead.oh_nchar ||
!( chars = malloc((unsigned) outhead.oh_nchar))) {
fatal("No memory\n.");
}
put(outhead.oh_nchar+4,4);
rd_string(chars,outhead.oh_nchar);
writef(chars, 1, outhead.oh_nchar);
free(chars);
}
/* VARARGS1 */
fatal(s, a1, a2)
char *s;
{
fprintf(stderr,"%s: ",program) ;
fprintf(stderr, s, a1, a2);
if (outputfile_created)
unlink(output_file);
exit(-1);
}
rd_fatal() { fatal("read error.\n"); }

View File

@@ -353,7 +353,7 @@ C_magic()
}
/*** the compact code generating routines ***/
#define fit16i(x) ((x) >= (long)0xFFFF8000 && (x) <= (long)0x00007FFF)
#define fit16i(x) ((x) >= (long)(-0x8000) && (x) <= (long)0x7FFF)
#define fit8u(x) ((x) <= 0xFF) /* x is already unsigned */
void

View File

@@ -1,6 +1,6 @@
/* $Source$
* $State$
* $Revision$
/* $Source: /cvsroot/tack/Ack/plat/linux386/libsys/_exit.c,v $
* $State: Exp $
* $Revision: 1.1 $
*/
#include <stdlib.h>

View File

@@ -1,7 +1,7 @@
#
! $Source$
! $State$
! $Revision$
! $Source: /cvsroot/tack/Ack/plat/linux386/libsys/_hol0.s,v $
! $State: Exp $
! $Revision: 1.1 $
! Declare segments (the order is important).

View File

@@ -1,6 +1,6 @@
/* $Source$
* $State$
* $Revision$
/* $Source: /cvsroot/tack/Ack/plat/linux386/libsys/brk.c,v $
* $State: Exp $
* $Revision: 1.1 $
*/
#include <stdlib.h>

View File

@@ -1,6 +1,6 @@
/* $Source$
* $State$
* $Revision$
/* $Source: /cvsroot/tack/Ack/plat/linux386/libsys/close.c,v $
* $State: Exp $
* $Revision: 1.1 $
*/
#include <stdlib.h>

View File

@@ -1,6 +1,6 @@
/* $Source$
* $State$
* $Revision$
/* $Source: /cvsroot/tack/Ack/plat/linux386/libsys/creat.c,v $
* $State: Exp $
* $Revision: 1.1 $
*/
#include <stdlib.h>

View File

@@ -1,7 +1,7 @@
#
! $Source$
! $State$
! $Revision$
! $Source: /cvsroot/tack/Ack/plat/linux386/libsys/errno.s,v $
! $State: Exp $
! $Revision: 1.1 $
! Declare segments (the order is important).

View File

@@ -1,6 +1,6 @@
/* $Source$
* $State$
* $Revision$
/* $Source: /cvsroot/tack/Ack/plat/linux386/libsys/getpid.c,v $
* $State: Exp $
* $Revision: 1.1 $
*/
#include <stdlib.h>

View File

@@ -1,6 +1,6 @@
/* $Source$
* $State$
* $Revision$
/* $Source: /cvsroot/tack/Ack/plat/linux386/libsys/gettimeofday.c,v $
* $State: Exp $
* $Revision: 1.1 $
*/
#include <stdlib.h>

View File

@@ -0,0 +1,13 @@
/* $Source: /cvsroot/tack/Ack/plat/linux386/libsys/isatty.c,v $
* $State: Exp $
* $Revision: 1.1 $
*/
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
int isatty(int fd)
{
return 0;
}

View File

@@ -1,6 +1,6 @@
/* $Source$
* $State$
* $Revision$
/* $Source: /cvsroot/tack/Ack/plat/linux386/libsys/kill.c,v $
* $State: Exp $
* $Revision: 1.1 $
*/
#include <stdlib.h>

View File

@@ -1,6 +1,6 @@
/* $Source$
* $State$
* $Revision$
/* $Source: /cvsroot/tack/Ack/plat/linux386/libsys/libsys.h,v $
* $State: Exp $
* $Revision: 1.1 $
*/
#ifndef LIBSYS_H

View File

@@ -1,6 +1,6 @@
/* $Source$
* $State$
* $Revision$
/* $Source: /cvsroot/tack/Ack/plat/linux386/libsys/lseek.c,v $
* $State: Exp $
* $Revision: 1.1 $
*/
#include <stdlib.h>

View File

@@ -1,6 +1,6 @@
/* $Source$
* $State$
* $Revision$
/* $Source: /cvsroot/tack/Ack/plat/linux386/libsys/open.c,v $
* $State: Exp $
* $Revision: 1.1 $
*/
#include <stdlib.h>

View File

@@ -0,0 +1,29 @@
-- $Source: /cvsroot/tack/Ack/plat/linux386/libsys/pmfile,v $
-- $State: Exp $
-- $Revision: 1.1 $
local d = ROOTDIR.."plat/linux/liblinux/"
liblinux = acklibrary {
ACKINCLUDES = {"%BINDIR%include"},
ackfile (d.."errno.s"),
ackfile (d.."_hol0.s"),
ackfile (d.."brk.c"),
ackfile (d.."close.c"),
ackfile (d.."creat.c"),
ackfile (d.."getpid.c"),
ackfile (d.."gettimeofday.c"),
ackfile (d.."_exit.c"),
ackfile (d.."isatty.c"),
ackfile (d.."kill.c"),
ackfile (d.."lseek.c"),
ackfile (d.."open.c"),
ackfile (d.."read.c"),
ackfile (d.."sbrk.c"),
ackfile (d.."signal.c"),
ackfile (d.."write.c"),
install = pm.install("%BINDIR%lib/%PLATFORM%/liblinux.a"),
}

View File

@@ -1,6 +1,6 @@
/* $Source$
* $State$
* $Revision$
/* $Source: /cvsroot/tack/Ack/plat/linux386/libsys/read.c,v $
* $State: Exp $
* $Revision: 1.1 $
*/
#include <stdlib.h>

View File

@@ -1,9 +1,10 @@
/* $Source$
* $State$
* $Revision$
/* $Source: /cvsroot/tack/Ack/plat/linux386/libsys/sbrk.c,v $
* $State: Exp $
* $Revision: 1.1 $
*/
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include "libsys.h"
@@ -17,7 +18,7 @@ void* sbrk(intptr_t increment)
{
char* old;
char* new;
if (increment == 0)
return current;

View File

@@ -1,6 +1,6 @@
/* $Source$
* $State$
* $Revision$
/* $Source: /cvsroot/tack/Ack/plat/linux386/libsys/signal.c,v $
* $State: Exp $
* $Revision: 1.1 $
*/
#include <stdlib.h>

View File

@@ -1,6 +1,6 @@
/* $Source$
* $State$
* $Revision$
/* $Source: /cvsroot/tack/Ack/plat/linux386/libsys/syscalls.h,v $
* $State: Exp $
* $Revision: 1.1 $
*/
#ifndef SYSCALLS_H

View File

@@ -1,6 +1,6 @@
/* $Source$
* $State$
* $Revision$
/* $Source: /cvsroot/tack/Ack/plat/linux386/libsys/write.c,v $
* $State: Exp $
* $Revision: 1.1 $
*/
#include <stdlib.h>

View File

@@ -59,7 +59,9 @@ name led
(.ocm:{TAIL}={PLATFORMDIR}/liboccam.a) \
(.ocm.b.mod.c.p:{TAIL}={PLATFORMDIR}/libc.a) \
{FLOATS?} \
(.e:{TAIL}={PLATFORMDIR}/libem.a \
(.e:{TAIL}={PLATFORMDIR}/liblinux.a \
{PLATFORMDIR}/libem.a \
{PLATFORMDIR}/liblinux.a \
{PLATFORMDIR}/libsys.a \
{PLATFORMDIR}/libend.a)
linker

View File

@@ -43,9 +43,9 @@ enum
O_WRONLY = 1,
O_RDWR = 2,
O_CREAT = 0x10,
O_TRUNC = 0x20,
O_APPEND = 0x40
O_CREAT = 0x40,
O_TRUNC = 0x200,
O_APPEND = 0x400
};
extern int open(const char* path, int access, ...);
@@ -55,6 +55,8 @@ extern int read(int fd, void* buffer, size_t count);
extern int write(int fd, void* buffer, size_t count);
extern off_t lseek(int fildes, off_t offset, int whence);
extern int fcntl(int fd, int op, ...);
extern int unlink(const char* path);
extern int remove(const char* path);
/* Special variables */

View File

@@ -3,8 +3,6 @@
! $State$
! $Revision$
#include "syscalls.h"
! Declare segments (the order is important).
.sect .text

View File

@@ -1,13 +0,0 @@
/* $Source$
* $State$
* $Revision$
*/
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
int isatty(int fd)
{
return 0;
}

View File

@@ -1,31 +1,13 @@
-- $Source$
-- $State$
-- $Revision$
-- $Source: /cvsroot/tack/Ack/plat/linux386/libsys/pmfile,v $
-- $State: Exp $
-- $Revision: 1.1 $
local d = ROOTDIR.."plat/linux386/libsys/"
libsys_linux386 = acklibrary {
ACKBUILDFLAGS = {PARENT, "-ansi"},
ACKINCLUDES = {"%BINDIR%include"},
ackfile (d.."errno.s"),
ackfile (d.."_hol0.s"),
ackfile (d.."_syscall.s"),
ackfile (d.."brk.c"),
ackfile (d.."close.c"),
ackfile (d.."creat.c"),
ackfile (d.."getpid.c"),
ackfile (d.."gettimeofday.c"),
ackfile (d.."_exit.c"),
ackfile (d.."isatty.c"),
ackfile (d.."kill.c"),
ackfile (d.."lseek.c"),
ackfile (d.."open.c"),
ackfile (d.."read.c"),
ackfile (d.."sbrk.c"),
ackfile (d.."signal.c"),
ackfile (d.."write.c"),
install = pm.install("%BINDIR%lib/%PLATFORM%/libsys.a"),
}

View File

@@ -5,6 +5,7 @@
local d = ROOTDIR.."plat/linux386/"
include (d.."libsys/pmfile")
include "plat/linux/liblinux/pmfile"
local bootsector = ackfile {
file (d.."boot.s"),
@@ -41,6 +42,7 @@ platform_linux386 = group {
-- Build the PC standalone syscall library.
liblinux,
libsys_linux386,
bootsector,
}

26
plat/linux68k/.distr Normal file
View File

@@ -0,0 +1,26 @@
descr
boot.s
pmfile
README
include/ack/config.h
include/unistd.h
libsys/pmfile
libsys/_exit.c
libsys/_hol0.s
libsys/_syscall.s
libsys/brk.c
libsys/close.c
libsys/creat.c
libsys/errno.s
libsys/getpid.c
libsys/gettimeofday.c
libsys/isatty.c
libsys/kill.c
libsys/libsys.h
libsys/lseek.c
libsys/open.c
libsys/read.c
libsys/sbrk.c
libsys/signal.c
libsys/syscalls.h
libsys/write.c

42
plat/linux68k/README Normal file
View File

@@ -0,0 +1,42 @@
# $Source: /cvsroot/tack/Ack/plat/linux386/README,v $
# $State: Exp $
# $Revision: 1.2 $
The linux386 platform
=====================
linux386 is an i386-based BSP that produces Linux ELF executables.
This port only implements a very limited number of system calls; basically,
just enough to make the demo apps run. Adding more is easy, but there are some
subtleties that require more thought. The port should be considered only in
proof-of-concept stage right now.
Important note: you *can't* link access ELF shared libraries from these
executables. In other words, you have to all your work from inside ACK.
IEEE floating point is available, but requires an FPU.
The executables are generated with aelfslod and are extremely simple; there's
one rwx ELF section which contains all the application's code and data. This
is not optimal, but it does work.
Bugs
====
isatty() is a stub and always returns 0.
Example command line
====================
ack -mlinux386 -O -o linux386.exe examples/paranoia.c
The file linux386.exe can then be run on a i386 Linux machine (or on an
emulation thereof).
David Given
dg@cowlark.com

87
plat/linux68k/boot.s Normal file
View File

@@ -0,0 +1,87 @@
#
! $Source: /cvsroot/tack/Ack/plat/linux386/boot.s,v $
! $State: Exp $
! $Revision: 1.3 $
! Declare segments (the order is important).
.sect .text
.sect .rom
.sect .data
.sect .bss
.sect .text
begtext:
! This code is placed at the beginning of the ELF executable and is the
! first thing that runs.
!
! On entry, the stack looks like this:
!
! sp+.. NULL
! sp+8+(4*argc) env (X quads)
! sp+4+(4*argc) NULL
! sp+4 argv (argc quads)
! sp argc
!
! The ACK actually expects:
!
! sp+8 argc
! sp+4 argv
! sp env
move.l (0, sp), d0 ! d0 = argc
move.l (4, sp), d1 ! d1 = argv
move.l d0, d2
asl.l #2, d2
move.l (sp, d2), d2
add.l #12, d2 ! d2 = environ
move.l d2, -(sp) ! environ
move.l d0, -(sp) ! argc
move.l d1, -(sp) ! argv
pea (0) ! dummy, representing the return address
jmp (__m_a_i_n)
#if 0
mov eax, (esp) ! eax = argc
lea ebx, 4(esp) ! ebx = argv
lea ecx, (esp)(eax*4)
add ecx, 12 ! environ
push ecx ! environ
push ebx ! argc
push eax ! argv
push eax ! dummy, representing the return argument
xor ebp, ebp
#endif
! This provides an emergency exit routine used by EM.
.define EXIT
.extern EXIT
EXIT:
pea (1)
jmp (__exit)
! This is used by the trap routine for diagnostics.
.define WRITE
.extern WRITE
WRITE:
jmp (_write)
! Define symbols at the beginning of our various segments, so that we can find
! them. (Except .text, which has already been done.)
.sect .data; begdata:
.sect .rom; begrom:
.sect .bss; begbss:
! Some magic data. All EM systems need these.
.define .trppc, .ignmask, _errno
.comm .trppc, 4
.comm .ignmask, 4
.comm _errno, 4

74
plat/linux68k/descr Normal file
View File

@@ -0,0 +1,74 @@
# $Source: /cvsroot/tack/Ack/plat/linux386/descr,v $
# $State: Exp $
# $Revision: 1.1 $
var w=4
var p=4
var s=2
var l=4
var f=4
var d=8
var ARCH=m68020
var PLATFORM=linux68k
var PLATFORMDIR={EM}/lib/{PLATFORM}
var CPP_F=-D__unix -D__mc68020 -D__m68k -D__mc68000 -D__M68020
var ALIGN=-a0:4 -a1:4 -a2:4 -a3:4 -b0:0x08000054
var C_LIB={PLATFORMDIR}/libc-ansi.a
# bitfields reversed for compatibility with (g)cc.
var CC_ALIGN=-Vr
var OLD_C_LIB={C_LIB}
var MACHOPT_F=-ml10
# Override the setting in fe so that files compiled for linux68k can see
# the platform-specific headers.
var C_INCLUDES=-I{PLATFORMDIR}/include -I{EM}/include/ansi
name be
from .m.g
to .s
program {EM}/lib.bin/{PLATFORM}/ncg
mapflag -gdb GF=-gdb
args {GF?} <
stdout
need .e
end
name as
from .s.so
to .o
program {EM}/lib.bin/{PLATFORM}/as
args - -o > <
prep cond
end
name led
from .o.a
to .out
program {EM}/lib.bin/em_led
mapflag -l* LNAME={PLATFORMDIR}/lib*
mapflag -fp FLOATS={EM}/{LIB}fp
args {ALIGN} {SEPID?} \
(.e:{HEAD}={PLATFORMDIR}/boot.o) \
({RTS}:.ocm.b={PLATFORMDIR}/c-ansi.o) \
({RTS}:.c={PLATFORMDIR}/c-ansi.o) \
({RTS}:.mod={PLATFORMDIR}/modula2.o) \
({RTS}:.p={PLATFORMDIR}/pascal.o) \
-o > < \
(.p:{TAIL}={PLATFORMDIR}/libpascal.a) \
(.b:{TAIL}={PLATFORMDIR}/libbasic.a) \
(.mod:{TAIL}={PLATFORMDIR}/libmodula2.a) \
(.ocm:{TAIL}={PLATFORMDIR}/liboccam.a) \
(.ocm.b.mod.c.p:{TAIL}={PLATFORMDIR}/libc.a) \
{FLOATS?} \
(.e:{TAIL}={PLATFORMDIR}/libem.a \
{PLATFORMDIR}/liblinux.a \
{PLATFORMDIR}/libsys.a \
{PLATFORMDIR}/libend.a)
linker
end
name cv
from .out
to .exe
program {EM}/bin/aelflod
args -m4 -b < >
outfile linux68k.exe
end

View File

@@ -0,0 +1,14 @@
/* $Source: /cvsroot/tack/Ack/plat/linux386/include/ack/config.h,v $
* $State: Exp $
* $Revision: 1.1 $
*/
#ifndef _ACK_CONFIG_H
#define _ACK_CONFIG_H
/* We're providing a time() system call rather than wanting a wrapper around
* gettimeofday() in the libc. */
/* #define ACKCONF_TIME_IS_A_SYSCALL */
#endif

View File

@@ -0,0 +1,76 @@
/* $Source: /cvsroot/tack/Ack/plat/linux386/include/sys/ioctl.h,v $
* $State: Exp $
* $Revision: 1.1 $
*/
#ifndef _SYS_IOCTL_H
#define _SYS_IOCTL_H
/* These are copied from the ioctl_list(2) man page. */
/* <include/asm-i386/socket.h> */
#define FIOSETOWN 0x00008901
#define SIOCSPGRP 0x00008902
#define FIOGETOWN 0x00008903
#define SIOCGPGRP 0x00008904
#define SIOCATMARK 0x00008905
#define SIOCGSTAMP 0x00008906
/* <include/asm-i386/termios.h> */
#define TCGETS 0x00005401
#define TCSETS 0x00005402
#define TCSETSW 0x00005403
#define TCSETSF 0x00005404
#define TCGETA 0x00005405
#define TCSETA 0x00005406
#define TCSETAW 0x00005407
#define TCSETAF 0x00005408
#define TCSBRK 0x00005409
#define TCXONC 0x0000540A
#define TCFLSH 0x0000540B
#define TIOCEXCL 0x0000540C
#define TIOCNXCL 0x0000540D
#define TIOCSCTTY 0x0000540E
#define TIOCGPGRP 0x0000540F
#define TIOCSPGRP 0x00005410
#define TIOCOUTQ 0x00005411
#define TIOCSTI 0x00005412
#define TIOCGWINSZ 0x00005413
#define TIOCSWINSZ 0x00005414
#define TIOCMGET 0x00005415
#define TIOCMBIS 0x00005416
#define TIOCMBIC 0x00005417
#define TIOCMSET 0x00005418
#define TIOCGSOFTCAR 0x00005419
#define TIOCSSOFTCAR 0x0000541A
#define FIONREAD 0x0000541B
#define TIOCINQ 0x0000541B
#define TIOCLINUX 0x0000541C
#define TIOCCONS 0x0000541D
#define TIOCGSERIAL 0x0000541E
#define TIOCSSERIAL 0x0000541F
#define TIOCPKT 0x00005420
#define FIONBIO 0x00005421
#define TIOCNOTTY 0x00005422
#define TIOCSETD 0x00005423
#define TIOCGETD 0x00005424
#define TCSBRKP 0x00005425
#define TIOCTTYGSTRUCT 0x00005426
#define FIONCLEX 0x00005450
#define FIOCLEX 0x00005451
#define FIOASYNC 0x00005452
#define TIOCSERCONFIG 0x00005453
#define TIOCSERGWILD 0x00005454
#define TIOCSERSWILD 0x00005455
#define TIOCGLCKTRMIOS 0x00005456
#define TIOCSLCKTRMIOS 0x00005457
#define TIOCSERGSTRUCT 0x00005458
#define TIOCSERGETLSR 0x00005459
#define TIOCSERGETMULTI 0x0000545A
#define TIOCSERSETMULTI 0x0000545B
#endif

View File

@@ -0,0 +1,123 @@
/*
* unistd.h - standard system calls
*/
/* $Id$ */
#ifndef _UNISTD_H
#define _UNISTD_H
#include <stddef.h>
#include <time.h>
/* Types */
typedef int pid_t;
typedef int mode_t;
typedef long suseconds_t;
/* Time handling. */
struct timeval
{
time_t tv_sec;
suseconds_t tv_usec;
};
struct timezone
{
int tz_minuteswest;
int tz_dsttime;
}; /* obsolete, unused */
extern int gettimeofday(struct timeval* tv, struct timezone* tz);
extern int settimeofday(const struct timeval* tv, const struct timezone* tz);
/* File access. */
enum
{
O_ACCMODE = 0x3,
O_RDONLY = 0,
O_WRONLY = 1,
O_RDWR = 2,
O_CREAT = 0x10,
O_TRUNC = 0x20,
O_APPEND = 0x40
};
extern int open(const char* path, int access, ...);
extern int creat(const char* path, mode_t mode);
extern int close(int d);
extern int read(int fd, void* buffer, size_t count);
extern int write(int fd, void* buffer, size_t count);
extern off_t lseek(int fildes, off_t offset, int whence);
extern int fcntl(int fd, int op, ...);
/* Special variables */
extern char** environ;
/* Implemented system calls */
extern void _exit(int);
extern pid_t getpid(void);
extern int brk(void* ptr);
extern void* sbrk(intptr_t increment);
extern int isatty(int d);
/* Signal handling */
typedef int sig_atomic_t;
#define SIG_ERR ((sighandler_t) -1) /* Error return. */
#define SIG_DFL ((sighandler_t) 0) /* Default action. */
#define SIG_IGN ((sighandler_t) 1) /* Ignore signal. */
#define SIGHUP 1 /* Hangup (POSIX). */
#define SIGINT 2 /* Interrupt (ANSI). */
#define SIGQUIT 3 /* Quit (POSIX). */
#define SIGILL 4 /* Illegal instruction (ANSI). */
#define SIGTRAP 5 /* Trace trap (POSIX). */
#define SIGABRT 6 /* Abort (ANSI). */
#define SIGIOT 6 /* IOT trap (4.2 BSD). */
#define SIGBUS 7 /* BUS error (4.2 BSD). */
#define SIGFPE 8 /* Floating-point exception (ANSI). */
#define SIGKILL 9 /* Kill, unblockable (POSIX). */
#define SIGUSR1 10 /* User-defined signal 1 (POSIX). */
#define SIGSEGV 11 /* Segmentation violation (ANSI). */
#define SIGUSR2 12 /* User-defined signal 2 (POSIX). */
#define SIGPIPE 13 /* Broken pipe (POSIX). */
#define SIGALRM 14 /* Alarm clock (POSIX). */
#define SIGTERM 15 /* Termination (ANSI). */
#define SIGSTKFLT 16 /* Stack fault. */
#define SIGCLD SIGCHLD /* Same as SIGCHLD (System V). */
#define SIGCHLD 17 /* Child status has changed (POSIX). */
#define SIGCONT 18 /* Continue (POSIX). */
#define SIGSTOP 19 /* Stop, unblockable (POSIX). */
#define SIGTSTP 20 /* Keyboard stop (POSIX). */
#define SIGTTIN 21 /* Background read from tty (POSIX). */
#define SIGTTOU 22 /* Background write to tty (POSIX). */
#define SIGURG 23 /* Urgent condition on socket (4.2 BSD). */
#define SIGXCPU 24 /* CPU limit exceeded (4.2 BSD). */
#define SIGXFSZ 25 /* File size limit exceeded (4.2 BSD). */
#define SIGVTALRM 26 /* Virtual alarm clock (4.2 BSD). */
#define SIGPROF 27 /* Profiling alarm clock (4.2 BSD). */
#define SIGWINCH 28 /* Window size change (4.3 BSD, Sun). */
#define SIGPOLL SIGIO /* Pollable event occurred (System V). */
#define SIGIO 29 /* I/O now possible (4.2 BSD). */
#define SIGPWR 30 /* Power failure restart (System V). */
#define SIGSYS 31 /* Bad system call. */
#define SIGUNUSED 31
#define _NSIG 32 /* Biggest signal number + 1
(not including real-time signals). */
typedef void (*sighandler_t)(int);
extern sighandler_t signal(int signum, sighandler_t handler);
extern int raise(int signum);
#endif

View File

@@ -0,0 +1,45 @@
#
! $Source: /cvsroot/tack/Ack/plat/linux386/libsys/_syscall.s,v $
! $State: Exp $
! $Revision: 1.1 $
! Declare segments (the order is important).
.sect .text
.sect .rom
.sect .data
.sect .bss
.sect .text
EINVAL = 22
! Perform a Linux system call.
.define __syscall
__syscall:
move.l (4, sp), d0
move.l (8, sp), d1
move.l (12, sp), d2
move.l (16, sp), d3
trap #0
tst.l d0
bmi 1f
rts
1:
neg.l d0
! It just so happens that errnos 1-34 are the same in Linux as in ACK.
cmp.l #1, d0
blt 2f
cmp.l #34, d0
bgt 2f
move.l d0, (_errno)
3:
move.l #-1, d0
rts
2:
move.l #EINVAL, (_errno)
bra 3b

View File

@@ -0,0 +1,13 @@
-- $Source: /cvsroot/tack/Ack/plat/linux386/libsys/pmfile,v $
-- $State: Exp $
-- $Revision: 1.1 $
local d = ROOTDIR.."plat/linux68k/libsys/"
libsys_linux68k = acklibrary {
ACKINCLUDES = {"%BINDIR%include"},
ackfile (d.."_syscall.s"),
install = pm.install("%BINDIR%lib/%PLATFORM%/libsys.a"),
}

48
plat/linux68k/pmfile Normal file
View File

@@ -0,0 +1,48 @@
-- $Source: /cvsroot/tack/Ack/plat/linux386/pmfile,v $
-- $State: Exp $
-- $Revision: 1.3 $
local d = ROOTDIR.."plat/linux68k/"
include (d.."libsys/pmfile")
include "plat/linux/liblinux/pmfile"
local bootsector = ackfile {
file (d.."boot.s"),
install = pm.install("%BINDIR%lib/%PLATFORM%/boot.o"),
}
local descr = group {
install = pm.install(d.."descr", "%BINDIR%%PLATIND%/%PLATFORM%/descr")
}
local headers = group {
install = {
pm.install(d.."include/ack/config.h", "%BINDIR%%PLATIND%/%PLATFORM%/include/ack/config.h"),
pm.install(d.."include/unistd.h", "%BINDIR%%PLATIND%/%PLATFORM%/include/unistd.h"),
}
}
platform_linux68k = group {
ARCH = "m68020",
PLATFORM = "linux68k",
OPTIMISATION = "-O6",
-- Ensure the descr and headers are installed first because we'll need it
-- to build the libraries.
descr,
headers,
-- Build the back-end support.
mach_m68020,
support_m68020,
lang_runtimes,
-- Build the PC standalone syscall library.
liblinux,
libsys_linux68k,
bootsector,
}

26
plat/linuxppc/.distr Normal file
View File

@@ -0,0 +1,26 @@
descr
boot.s
pmfile
README
include/ack/config.h
include/unistd.h
libsys/pmfile
libsys/_exit.c
libsys/_hol0.s
libsys/_syscall.s
libsys/brk.c
libsys/close.c
libsys/creat.c
libsys/errno.s
libsys/getpid.c
libsys/gettimeofday.c
libsys/isatty.c
libsys/kill.c
libsys/libsys.h
libsys/lseek.c
libsys/open.c
libsys/read.c
libsys/sbrk.c
libsys/signal.c
libsys/syscalls.h
libsys/write.c

42
plat/linuxppc/README Normal file
View File

@@ -0,0 +1,42 @@
# $Source: /cvsroot/tack/Ack/plat/linux386/README,v $
# $State: Exp $
# $Revision: 1.2 $
The linux386 platform
=====================
linux386 is an i386-based BSP that produces Linux ELF executables.
This port only implements a very limited number of system calls; basically,
just enough to make the demo apps run. Adding more is easy, but there are some
subtleties that require more thought. The port should be considered only in
proof-of-concept stage right now.
Important note: you *can't* link access ELF shared libraries from these
executables. In other words, you have to all your work from inside ACK.
IEEE floating point is available, but requires an FPU.
The executables are generated with aelfslod and are extremely simple; there's
one rwx ELF section which contains all the application's code and data. This
is not optimal, but it does work.
Bugs
====
isatty() is a stub and always returns 0.
Example command line
====================
ack -mlinux386 -O -o linux386.exe examples/paranoia.c
The file linux386.exe can then be run on a i386 Linux machine (or on an
emulation thereof).
David Given
dg@cowlark.com

56
plat/linuxppc/boot.s Normal file
View File

@@ -0,0 +1,56 @@
#
! $Source: /cvsroot/tack/Ack/plat/linux386/boot.s,v $
! $State: Exp $
! $Revision: 1.3 $
! Declare segments (the order is important).
.sect .text
.sect .rom
.sect .data
.sect .bss
.sect .text
begtext:
! This code is placed at the beginning of the ELF executable and is the
! first thing that runs.
!
! On entry, the stack looks like this:
!
! sp+... NULL
! sp+8+(4*argc) env (X quads)
! sp+4+(4*argc) NULL
! sp+4 argv (argc quads)
! sp argc
!
! The ACK actually expects:
!
! sp+8 argc
! sp+4 ptr to argv
! sp ptr to env
lwz r3, 0(sp) ! r3 = argc
addi r4, sp, 4 ! r4 = argv
rlwinm r5, r3, 32-2, 2, 31 ! shift left 2 bits
add r5, r5, r4
addi r5, r5, 8 ! r5 = env
stwu r5, -4(sp)
stwu r4, -4(sp)
stwu r3, -4(sp)
b __m_a_i_n
! Some magic data. All EM systems need these.
.define _errno
.comm _errno, 4 ! Posix errno storage
.define .trppc, .ignmask
.comm .trppc, 4 ! ptr to user trap handler
.comm .ignmask, 4 ! user trap ignore mask
.define .linenumber, .filename
.comm .linenumber, 4 ! current linenumber (used for debugging)
.comm .filename, 4 ! ptr to current filename (used for debugging)

81
plat/linuxppc/descr Normal file
View File

@@ -0,0 +1,81 @@
# $Source: /cvsroot/tack/Ack/plat/linux386/descr,v $
# $State: Exp $
# $Revision: 1.1 $
var w=4
var p=4
var s=2
var l=4
var f=4
var d=8
var ARCH=powerpc
var PLATFORM=linuxppc
var PLATFORMDIR={EM}/lib/{PLATFORM}
var CPP_F=-D__unix -D__POWERPC
var ALIGN=-a0:4 -a1:4 -a2:4 -a3:4 -b0:0x80000054
var C_LIB={PLATFORMDIR}/libc-ansi.a
# bitfields reversed for compatibility with (g)cc.
var CC_ALIGN=-Vr
var OLD_C_LIB={C_LIB}
var MACHOPT_F=
# Override the setting in fe so that files compiled for linuxppc can see
# the platform-specific headers.
var C_INCLUDES=-I{PLATFORMDIR}/include -I{EM}/include/ansi
name be
from .m.g
to .s
program {EM}/lib.bin/{PLATFORM}/ncg
mapflag -gdb GF=-gdb
args {GF?} <
stdout
need .e
end
name asopt
from .s
to .so
program {EM}/lib.bin/{PLATFORM}/top
args
optimizer
stdin
stdout
end
name as
from .s.so
to .o
program {EM}/lib.bin/{PLATFORM}/as
args - -o > <
prep cond
end
name led
from .o.a
to .out
program {EM}/lib.bin/em_led
mapflag -l* LNAME={PLATFORMDIR}/lib*
mapflag -fp FLOATS={EM}/{LIB}fp
args {ALIGN} {SEPID?} \
{PLATFORMDIR}/boot.o \
({RTS}:.ocm.b.c={PLATFORMDIR}/c-ansi.o) \
({RTS}:.mod={PLATFORMDIR}/modula2.o) \
({RTS}:.p={PLATFORMDIR}/pascal.o) \
-o > < \
(.p:{TAIL}={PLATFORMDIR}/libpascal.a) \
(.b:{TAIL}={PLATFORMDIR}/libbasic.a) \
(.mod:{TAIL}={PLATFORMDIR}/libmodula2.a) \
(.ocm:{TAIL}={PLATFORMDIR}/liboccam.a) \
(.ocm.b.mod.c.p:{TAIL}={PLATFORMDIR}/libc.a) \
{PLATFORMDIR}/liblinux.a \
{PLATFORMDIR}/libem.a \
{PLATFORMDIR}/libsys.a \
{PLATFORMDIR}/libend.a
linker
end
name cv
from .out
to .exe
program {EM}/bin/aelflod
args -m20 -b < >
outfile linuxppc.exe
end

View File

@@ -0,0 +1,18 @@
/* $Source: /cvsroot/tack/Ack/plat/linux386/include/ack/config.h,v $
* $State: Exp $
* $Revision: 1.1 $
*/
#ifndef _ACK_CONFIG_H
#define _ACK_CONFIG_H
/* We're providing a time() system call rather than wanting a wrapper around
* gettimeofday() in the libc. */
/* #define ACKCONF_TIME_IS_A_SYSCALL */
/* We don't support floating point right now. */
/* #define ACKCONF_NO_STDIO_FLOAT */
#endif

View File

@@ -0,0 +1,76 @@
/* $Source: /cvsroot/tack/Ack/plat/linux386/include/sys/ioctl.h,v $
* $State: Exp $
* $Revision: 1.1 $
*/
#ifndef _SYS_IOCTL_H
#define _SYS_IOCTL_H
/* These are copied from the ioctl_list(2) man page. */
/* <include/asm-i386/socket.h> */
#define FIOSETOWN 0x00008901
#define SIOCSPGRP 0x00008902
#define FIOGETOWN 0x00008903
#define SIOCGPGRP 0x00008904
#define SIOCATMARK 0x00008905
#define SIOCGSTAMP 0x00008906
/* <include/asm-i386/termios.h> */
#define TCGETS 0x00005401
#define TCSETS 0x00005402
#define TCSETSW 0x00005403
#define TCSETSF 0x00005404
#define TCGETA 0x00005405
#define TCSETA 0x00005406
#define TCSETAW 0x00005407
#define TCSETAF 0x00005408
#define TCSBRK 0x00005409
#define TCXONC 0x0000540A
#define TCFLSH 0x0000540B
#define TIOCEXCL 0x0000540C
#define TIOCNXCL 0x0000540D
#define TIOCSCTTY 0x0000540E
#define TIOCGPGRP 0x0000540F
#define TIOCSPGRP 0x00005410
#define TIOCOUTQ 0x00005411
#define TIOCSTI 0x00005412
#define TIOCGWINSZ 0x00005413
#define TIOCSWINSZ 0x00005414
#define TIOCMGET 0x00005415
#define TIOCMBIS 0x00005416
#define TIOCMBIC 0x00005417
#define TIOCMSET 0x00005418
#define TIOCGSOFTCAR 0x00005419
#define TIOCSSOFTCAR 0x0000541A
#define FIONREAD 0x0000541B
#define TIOCINQ 0x0000541B
#define TIOCLINUX 0x0000541C
#define TIOCCONS 0x0000541D
#define TIOCGSERIAL 0x0000541E
#define TIOCSSERIAL 0x0000541F
#define TIOCPKT 0x00005420
#define FIONBIO 0x00005421
#define TIOCNOTTY 0x00005422
#define TIOCSETD 0x00005423
#define TIOCGETD 0x00005424
#define TCSBRKP 0x00005425
#define TIOCTTYGSTRUCT 0x00005426
#define FIONCLEX 0x00005450
#define FIOCLEX 0x00005451
#define FIOASYNC 0x00005452
#define TIOCSERCONFIG 0x00005453
#define TIOCSERGWILD 0x00005454
#define TIOCSERSWILD 0x00005455
#define TIOCGLCKTRMIOS 0x00005456
#define TIOCSLCKTRMIOS 0x00005457
#define TIOCSERGSTRUCT 0x00005458
#define TIOCSERGETLSR 0x00005459
#define TIOCSERGETMULTI 0x0000545A
#define TIOCSERSETMULTI 0x0000545B
#endif

View File

@@ -0,0 +1,123 @@
/*
* unistd.h - standard system calls
*/
/* $Id$ */
#ifndef _UNISTD_H
#define _UNISTD_H
#include <stddef.h>
#include <time.h>
/* Types */
typedef int pid_t;
typedef int mode_t;
typedef long suseconds_t;
/* Time handling. */
struct timeval
{
time_t tv_sec;
suseconds_t tv_usec;
};
struct timezone
{
int tz_minuteswest;
int tz_dsttime;
}; /* obsolete, unused */
extern int gettimeofday(struct timeval* tv, struct timezone* tz);
extern int settimeofday(const struct timeval* tv, const struct timezone* tz);
/* File access. */
enum
{
O_ACCMODE = 0x3,
O_RDONLY = 0,
O_WRONLY = 1,
O_RDWR = 2,
O_CREAT = 0x10,
O_TRUNC = 0x20,
O_APPEND = 0x40
};
extern int open(const char* path, int access, ...);
extern int creat(const char* path, mode_t mode);
extern int close(int d);
extern int read(int fd, void* buffer, size_t count);
extern int write(int fd, void* buffer, size_t count);
extern off_t lseek(int fildes, off_t offset, int whence);
extern int fcntl(int fd, int op, ...);
/* Special variables */
extern char** environ;
/* Implemented system calls */
extern void _exit(int);
extern pid_t getpid(void);
extern int brk(void* ptr);
extern void* sbrk(intptr_t increment);
extern int isatty(int d);
/* Signal handling */
typedef int sig_atomic_t;
#define SIG_ERR ((sighandler_t) -1) /* Error return. */
#define SIG_DFL ((sighandler_t) 0) /* Default action. */
#define SIG_IGN ((sighandler_t) 1) /* Ignore signal. */
#define SIGHUP 1 /* Hangup (POSIX). */
#define SIGINT 2 /* Interrupt (ANSI). */
#define SIGQUIT 3 /* Quit (POSIX). */
#define SIGILL 4 /* Illegal instruction (ANSI). */
#define SIGTRAP 5 /* Trace trap (POSIX). */
#define SIGABRT 6 /* Abort (ANSI). */
#define SIGIOT 6 /* IOT trap (4.2 BSD). */
#define SIGBUS 7 /* BUS error (4.2 BSD). */
#define SIGFPE 8 /* Floating-point exception (ANSI). */
#define SIGKILL 9 /* Kill, unblockable (POSIX). */
#define SIGUSR1 10 /* User-defined signal 1 (POSIX). */
#define SIGSEGV 11 /* Segmentation violation (ANSI). */
#define SIGUSR2 12 /* User-defined signal 2 (POSIX). */
#define SIGPIPE 13 /* Broken pipe (POSIX). */
#define SIGALRM 14 /* Alarm clock (POSIX). */
#define SIGTERM 15 /* Termination (ANSI). */
#define SIGSTKFLT 16 /* Stack fault. */
#define SIGCLD SIGCHLD /* Same as SIGCHLD (System V). */
#define SIGCHLD 17 /* Child status has changed (POSIX). */
#define SIGCONT 18 /* Continue (POSIX). */
#define SIGSTOP 19 /* Stop, unblockable (POSIX). */
#define SIGTSTP 20 /* Keyboard stop (POSIX). */
#define SIGTTIN 21 /* Background read from tty (POSIX). */
#define SIGTTOU 22 /* Background write to tty (POSIX). */
#define SIGURG 23 /* Urgent condition on socket (4.2 BSD). */
#define SIGXCPU 24 /* CPU limit exceeded (4.2 BSD). */
#define SIGXFSZ 25 /* File size limit exceeded (4.2 BSD). */
#define SIGVTALRM 26 /* Virtual alarm clock (4.2 BSD). */
#define SIGPROF 27 /* Profiling alarm clock (4.2 BSD). */
#define SIGWINCH 28 /* Window size change (4.3 BSD, Sun). */
#define SIGPOLL SIGIO /* Pollable event occurred (System V). */
#define SIGIO 29 /* I/O now possible (4.2 BSD). */
#define SIGPWR 30 /* Power failure restart (System V). */
#define SIGSYS 31 /* Bad system call. */
#define SIGUNUSED 31
#define _NSIG 32 /* Biggest signal number + 1
(not including real-time signals). */
typedef void (*sighandler_t)(int);
extern sighandler_t signal(int signum, sighandler_t handler);
extern int raise(int signum);
#endif

View File

@@ -0,0 +1,53 @@
#
! $Source: /cvsroot/tack/Ack/plat/linux386/libsys/_syscall.s,v $
! $State: Exp $
! $Revision: 1.1 $
! Declare segments (the order is important).
.sect .text
.sect .rom
.sect .data
.sect .bss
.sect .text
EINVAL = 22
#define IFFALSE 4
#define IFTRUE 12
#define ALWAYS 20
#define LT 0
#define GT 1
#define EQ 2
#define OV 3
! Perform a Linux system call.
.define __syscall
__syscall:
lwz r0, 0(sp)
lwz r3, 4(sp)
lwz r4, 8(sp)
lwz r5, 12(sp)
sc 0
bclr IFFALSE, OV, 0
! On error, r3 contains the errno.
! It just so happens that errnos 1-34 are the same in Linux as in ACK.
cmpi cr0, 0, r3, 1
bc IFTRUE, LT, 2f
cmpi cr0, 0, r3, 34
bc IFTRUE, GT, 2f
3:
addis r4, r0, <_errno
ori r4, r4, >_errno
stw r3, 0(r4)
addi r3, r0, -1
bclr ALWAYS, 0, 0
2:
addi r3, r0, EINVAL
b 3b

View File

@@ -0,0 +1,14 @@
-- $Source: /cvsroot/tack/Ack/plat/linux386/libsys/pmfile,v $
-- $State: Exp $
-- $Revision: 1.1 $
local d = ROOTDIR.."plat/linuxppc/libsys/"
libsys_linuxppc = acklibrary {
ACKINCLUDES = {"%BINDIR%include"},
ackfile (d.."_syscall.s"),
ackfile (d.."trap.s"),
install = pm.install("%BINDIR%lib/%PLATFORM%/libsys.a"),
}

108
plat/linuxppc/libsys/trap.s Normal file
View File

@@ -0,0 +1,108 @@
#
! $Source: /cvsroot/tack/Ack/plat/linux386/libsys/_syscall.s,v $
! $State: Exp $
! $Revision: 1.1 $
! Declare segments (the order is important).
.sect .text
.sect .rom
.sect .data
.sect .bss
.sect .text
#define IFFALSE 4
#define IFTRUE 12
#define ALWAYS 20
#define LT 0
#define GT 1
#define EQ 2
#define OV 3
EARRAY = 0
ERANGE = 1
ESET = 2
EIOVFL = 3
EFOVFL = 4
EFUNFL = 5
EIDIVZ = 6
EFDIVZ = 7
EIUND = 8
EFUND = 9
ECONV = 10
ESTACK = 16
EHEAP = 17
EILLINS = 18
EODDZ = 19
ECASE = 20
EMEMFLT = 21
EBADPTR = 22
EBADPC = 23
EBADLAE = 24
EBADMON = 25
EBADLIN = 26
EBADGTO = 27
EUNIMPL = 63 ! unimplemented em-instruction called
! EM trap handling.
.define .trap_ecase
.trap_ecase:
addi r3, r0, ECASE
b .trap
.define .trap_earray
.trap_earray:
addi r3, r0, EARRAY
b .trap
.define .trap
.trap:
cmpi cr0, 0, r3, 15 ! traps >15 can't be ignored
bc IFTRUE, LT, 1f
addi r4, r0, 1
rlwnm r4, r4, r3, 0, 31 ! calculate trap bit
addis r5, r0, <.ignmask
ori r5, r5, >.ignmask
lwz r5, 0(r5) ! load ignore mask
and. r4, r4, r5 ! compare
bclr IFFALSE, EQ, 0 ! return if non-zero
1:
addis r4, r0, <.trppc
ori r4, r4, >.trppc
lwz r5, 0(r4) ! load user trap routine
or. r5, r5, r5 ! test
bc IFTRUE, EQ, fatal ! if no user trap routine, bail out
addi r0, r0, 0
stw r0, 0(r4) ! reset trap routine
mfspr r0, lr
stwu r0, -4(sp) ! save old lr
stwu r3, -4(sp)
mtspr ctr, r5
bcctrl ALWAYS, 0, 0 ! call trap routine
lwz r0, 4(sp) ! load old lr again
addi sp, sp, 8 ! retract over stack usage
bclr ALWAYS, 0, 0 ! return
fatal:
addi r3, r0, 1
addis r4, r0, <message
ori r4, r4, >message
addi r5, r0, 6
addi r0, r0, 4 ! write()
sc 0
addi r0, r0, 1 ! exit()
sc 0
.sect .rom
message:
.ascii "TRAP!\n"

48
plat/linuxppc/pmfile Normal file
View File

@@ -0,0 +1,48 @@
-- $Source: /cvsroot/tack/Ack/plat/linux386/pmfile,v $
-- $State: Exp $
-- $Revision: 1.3 $
local d = ROOTDIR.."plat/linuxppc/"
include (d.."libsys/pmfile")
include "plat/linux/liblinux/pmfile"
local bootsector = ackfile {
file (d.."boot.s"),
install = pm.install("%BINDIR%lib/%PLATFORM%/boot.o"),
}
local descr = group {
install = pm.install(d.."descr", "%BINDIR%%PLATIND%/%PLATFORM%/descr")
}
local headers = group {
install = {
pm.install(d.."include/ack/config.h", "%BINDIR%%PLATIND%/%PLATFORM%/include/ack/config.h"),
pm.install(d.."include/unistd.h", "%BINDIR%%PLATIND%/%PLATFORM%/include/unistd.h"),
}
}
platform_linuxppc = group {
ARCH = "powerpc",
PLATFORM = "linuxppc",
OPTIMISATION = "-O",
-- Ensure the descr and headers are installed first because we'll need it
-- to build the libraries.
descr,
headers,
-- Build the back-end support.
mach_powerpc,
support_powerpc,
lang_runtimes,
-- Build the PC standalone syscall library.
liblinux,
libsys_linuxppc,
bootsector,
}

Some files were not shown because too many files have changed in this diff Show More