Compare commits
50 Commits
release-6-
...
dtrg-exper
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3f09da5045 | ||
|
|
33b4873932 | ||
|
|
d91a1dc1a6 | ||
|
|
b9b808e01a | ||
|
|
99d7f513f2 | ||
|
|
bcfb3d802f | ||
|
|
8e2d027c49 | ||
|
|
8d0261473d | ||
|
|
c93cb69959 | ||
|
|
c8fdcff960 | ||
|
|
dccecc5d45 | ||
|
|
0fc7fd5d33 | ||
|
|
4349d702fa | ||
|
|
2beb3646a7 | ||
|
|
7ef9b79c11 | ||
|
|
3dcc3bd1cf | ||
|
|
e7c79415b5 | ||
|
|
0131ca4d46 | ||
|
|
be234ea759 | ||
|
|
8bf34937f1 | ||
|
|
99eb12a282 | ||
|
|
96ea0a5903 | ||
|
|
800d4ae032 | ||
|
|
6ea172d0d9 | ||
|
|
1072a8797e | ||
|
|
2483e5723d | ||
|
|
58613009f8 | ||
|
|
b6dfaefeff | ||
|
|
eb0b730607 | ||
|
|
45ee287136 | ||
|
|
075cb488a3 | ||
|
|
a33473e0a5 | ||
|
|
7292b538bc | ||
|
|
a8ecb11013 | ||
|
|
085f346f8c | ||
|
|
c326f3c6a3 | ||
|
|
a0c67da261 | ||
|
|
293f34fa9b | ||
|
|
da6111328d | ||
|
|
7273130b4c | ||
|
|
9d2d5606ea | ||
|
|
5147166810 | ||
|
|
e537bcc321 | ||
|
|
5a872eed38 | ||
|
|
51b41f72f8 | ||
|
|
ee72886e54 | ||
|
|
2c54f8c742 | ||
|
|
481bcd8a8b | ||
|
|
fc44fe2185 | ||
|
|
4dd1ff6d80 |
9
.hgtags
Normal file
9
.hgtags
Normal 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
|
||||
5
CHANGES
5
CHANGES
@@ -2,6 +2,11 @@
|
||||
# $State$
|
||||
# $Revision$
|
||||
|
||||
6.0pre4
|
||||
|
||||
Fixed some minor bit-rotting issues that were preventing compilation on
|
||||
modern Linux systems.
|
||||
|
||||
6.0pre3
|
||||
|
||||
Added the cpm platform. Made some optimisations to the i80 code generator,
|
||||
|
||||
16
README
16
README
@@ -1,12 +1,8 @@
|
||||
# $Source$
|
||||
# $State$
|
||||
# $Revision$
|
||||
|
||||
THE AMSTERDAM COMPILER KIT V6.0pre3
|
||||
THE AMSTERDAM COMPILER KIT V6.0pre4
|
||||
===================================
|
||||
|
||||
© 1987-2005 Vrije Universiteit, Amsterdam
|
||||
2007-04-29
|
||||
2010-08-08
|
||||
|
||||
|
||||
INTRODUCTION
|
||||
@@ -17,7 +13,7 @@ front end compilers for a number of different languages, code generators,
|
||||
support libraries, and all the tools necessary to go from source code to
|
||||
executable on any of the platforms it supports.
|
||||
|
||||
This is an early prerelease of the upcoming version 6.0 release. Not a
|
||||
This is an early prerelease of the apocryphal version 6.0 release. Not a
|
||||
lot is supported, the build mechanism needs work, and a lot of things are
|
||||
probably broken. However, what's there should be sufficient to get things
|
||||
done and to evaluate how the full 6.0 release should work.
|
||||
@@ -167,4 +163,8 @@ Please enjoy.
|
||||
|
||||
David Given (dtrg on Sourceforge)
|
||||
dg@cowlark.com
|
||||
2007-04-29
|
||||
2010-08-08
|
||||
|
||||
# $Source$
|
||||
# $State$
|
||||
# $Revision$
|
||||
|
||||
@@ -21,7 +21,7 @@ PREFIX = "/usr/local"
|
||||
-- ======================================================================= --
|
||||
|
||||
-- FIXME: the following two variables must be set to their Minix variants
|
||||
-- due to hard-coded references in the descr files. Don't c
|
||||
-- due to hard-coded references in the descr files.
|
||||
|
||||
-- Name of the platform-independent library directory; 'share' on modern
|
||||
-- systems, 'lib' on Minix-like systems.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 */
|
||||
|
||||
5
h/out.h
5
h/out.h
@@ -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. */
|
||||
|
||||
@@ -1,79 +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".
|
||||
*/
|
||||
|
||||
/*
|
||||
* Basic system types and major/minor device constructing/busting macros.
|
||||
*/
|
||||
|
||||
#if !defined(_SYS_TYPES_H)
|
||||
#define _SYS_TYPES_H
|
||||
|
||||
#ifdef __STDC__
|
||||
#if !defined(_SIZE_T)
|
||||
#define _SIZE_T
|
||||
typedef unsigned int size_t; /* type returned by sizeof */
|
||||
#endif /* _SIZE_T */
|
||||
|
||||
#if !defined(_TIME_T)
|
||||
#define _TIME_T
|
||||
typedef unsigned long time_t;
|
||||
#endif /* TIME_T */
|
||||
#endif
|
||||
|
||||
#if !defined(_POSIX_SOURCE)
|
||||
|
||||
/* major part of a device */
|
||||
#define major(x) ((int)(((unsigned)(x)>>8)&0377))
|
||||
|
||||
/* minor part of a device */
|
||||
#define minor(x) ((int)((x)&0377))
|
||||
|
||||
/* make a device number */
|
||||
#define makedev(x,y) ((dev_t)(((x)<<8) | (y)))
|
||||
|
||||
typedef unsigned char u_char;
|
||||
typedef unsigned short u_short;
|
||||
typedef unsigned int u_int;
|
||||
typedef unsigned long u_long;
|
||||
|
||||
typedef struct _physadr { int r[1]; } *physadr;
|
||||
typedef long daddr_t;
|
||||
typedef char * caddr_t;
|
||||
#if defined(__BSD4_2)
|
||||
typedef u_long ino_t;
|
||||
#else
|
||||
typedef u_short ino_t;
|
||||
#endif
|
||||
typedef long swblk_t;
|
||||
|
||||
#include <sys/stdtypes.h>
|
||||
|
||||
typedef long label_t[14];
|
||||
typedef short dev_t;
|
||||
typedef long off_t;
|
||||
|
||||
/* system V compatibility: */
|
||||
typedef unsigned int uint;
|
||||
typedef unsigned short ushort;
|
||||
typedef unsigned char uchar_t;
|
||||
typedef short cnt_t;
|
||||
typedef long paddr_t;
|
||||
typedef long key_t;
|
||||
|
||||
#else /* _POSIX_SOURCE */
|
||||
#if defined(_MINIX)
|
||||
typedef unsigned short dev_t; /* hold (major|minor) device pair */
|
||||
typedef unsigned char gid_t; /* group id */
|
||||
typedef unsigned short ino_t; /* i-node number */
|
||||
typedef unsigned short mode_t; /* mode number within an i-node */
|
||||
typedef unsigned char nlink_t; /* number-of-links field within an i-node */
|
||||
typedef long off_t; /* offsets within a file */
|
||||
typedef int pid_t; /* type for pids (must be signed) */
|
||||
typedef unsigned short uid_t; /* user id */
|
||||
#endif /* _MINIX */
|
||||
#endif /* _POSIX_SOURCE */
|
||||
|
||||
#endif /* _SYS_TYPES_H */
|
||||
@@ -1,79 +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".
|
||||
*/
|
||||
|
||||
/*
|
||||
* Basic system types and major/minor device constructing/busting macros.
|
||||
*/
|
||||
|
||||
#if !defined(_SYS_TYPES_H)
|
||||
#define _SYS_TYPES_H
|
||||
|
||||
#ifdef __STDC__
|
||||
#if !defined(_SIZE_T)
|
||||
#define _SIZE_T
|
||||
typedef unsigned int size_t; /* type returned by sizeof */
|
||||
#endif /* _SIZE_T */
|
||||
|
||||
#if !defined(_TIME_T)
|
||||
#define _TIME_T
|
||||
typedef unsigned long time_t;
|
||||
#endif /* TIME_T */
|
||||
#endif
|
||||
|
||||
#if !defined(_POSIX_SOURCE)
|
||||
|
||||
/* major part of a device */
|
||||
#define major(x) ((int)(((unsigned)(x)>>8)&0377))
|
||||
|
||||
/* minor part of a device */
|
||||
#define minor(x) ((int)((x)&0377))
|
||||
|
||||
/* make a device number */
|
||||
#define makedev(x,y) ((dev_t)(((x)<<8) | (y)))
|
||||
|
||||
typedef unsigned char u_char;
|
||||
typedef unsigned short u_short;
|
||||
typedef unsigned int u_int;
|
||||
typedef unsigned long u_long;
|
||||
|
||||
typedef struct _physadr { int r[1]; } *physadr;
|
||||
typedef long daddr_t;
|
||||
typedef char * caddr_t;
|
||||
#if defined(__BSD4_2)
|
||||
typedef u_long ino_t;
|
||||
#else
|
||||
typedef u_short ino_t;
|
||||
#endif
|
||||
typedef long swblk_t;
|
||||
|
||||
#include <sys/stdtypes.h>
|
||||
|
||||
typedef long label_t[14];
|
||||
typedef short dev_t;
|
||||
typedef long off_t;
|
||||
|
||||
/* system V compatibility: */
|
||||
typedef unsigned int uint;
|
||||
typedef unsigned short ushort;
|
||||
typedef unsigned char uchar_t;
|
||||
typedef short cnt_t;
|
||||
typedef long paddr_t;
|
||||
typedef long key_t;
|
||||
|
||||
#else /* _POSIX_SOURCE */
|
||||
#if defined(_MINIX)
|
||||
typedef unsigned short dev_t; /* hold (major|minor) device pair */
|
||||
typedef unsigned char gid_t; /* group id */
|
||||
typedef unsigned short ino_t; /* i-node number */
|
||||
typedef unsigned short mode_t; /* mode number within an i-node */
|
||||
typedef unsigned char nlink_t; /* number-of-links field within an i-node */
|
||||
typedef long off_t; /* offsets within a file */
|
||||
typedef int pid_t; /* type for pids (must be signed) */
|
||||
typedef unsigned short uid_t; /* user id */
|
||||
#endif /* _MINIX */
|
||||
#endif /* _POSIX_SOURCE */
|
||||
|
||||
#endif /* _SYS_TYPES_H */
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ local libc = acklibrary {
|
||||
"%U%/isascii.c",
|
||||
},
|
||||
command = {
|
||||
"cd %out[1]:dirname% && %in[1]%"
|
||||
"cd %out[1]:dirname% && sh %in[1]%"
|
||||
},
|
||||
|
||||
file (d.."ctype/genfiles")
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
38
mach/m68020/libem/pmfile
Normal 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"),
|
||||
}
|
||||
@@ -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:
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <em_abs.h>
|
||||
|
||||
char *
|
||||
_trpstr(d)
|
||||
{
|
||||
|
||||
@@ -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
16
mach/m68020/libend/pmfile
Normal 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"),
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
@@ -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].
|
||||
@@ -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
|
||||
@@ -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 == ®sav[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 == ®sav[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 < ®sav[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 */
|
||||
};
|
||||
@@ -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
|
||||
6942
mach/m68k2/ncg/table
6942
mach/m68k2/ncg/table
File diff suppressed because it is too large
Load Diff
@@ -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].
|
||||
@@ -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
|
||||
@@ -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 == ®sav[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 == ®sav[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 < ®sav[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 */
|
||||
};
|
||||
@@ -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
|
||||
6942
mach/m68k4/ncg/table
6942
mach/m68k4/ncg/table
File diff suppressed because it is too large
Load Diff
@@ -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].
|
||||
@@ -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
|
||||
@@ -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 == ®sav[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 == ®sav[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 < ®sav[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 */
|
||||
};
|
||||
@@ -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
|
||||
6942
mach/moon3/ncg/table
6942
mach/moon3/ncg/table
File diff suppressed because it is too large
Load Diff
6
mach/powerpc/as/.distr
Normal file
6
mach/powerpc/as/.distr
Normal file
@@ -0,0 +1,6 @@
|
||||
mach0.c
|
||||
mach1.c
|
||||
mach2.c
|
||||
mach3.c
|
||||
mach4.c
|
||||
mach5.c
|
||||
31
mach/powerpc/as/mach0.c
Normal file
31
mach/powerpc/as/mach0.c
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* $Source$
|
||||
* $State$
|
||||
*/
|
||||
|
||||
#define THREE_PASS /* branch and offset optimization */
|
||||
#define BYTES_REVERSED /* high order byte has lowest address */
|
||||
#define WORDS_REVERSED /* high order word has lowest address */
|
||||
#define LISTING /* enable listing facilities */
|
||||
#define RELOCATION /* generate relocatable code */
|
||||
#define DEBUG 0
|
||||
|
||||
#undef valu_t
|
||||
#define valu_t long
|
||||
|
||||
#undef ADDR_T
|
||||
#define ADDR_T long
|
||||
|
||||
#undef word_t
|
||||
#define word_t long
|
||||
|
||||
#undef ALIGNWORD
|
||||
#define ALIGNWORD 4
|
||||
|
||||
#undef ALIGNSECT
|
||||
#define ALIGNSECT 4
|
||||
|
||||
#undef VALWIDTH
|
||||
#define VALWIDTH 8
|
||||
|
||||
#define FIXUPFLAGS (RELBR | RELWR)
|
||||
5
mach/powerpc/as/mach1.c
Normal file
5
mach/powerpc/as/mach1.c
Normal file
@@ -0,0 +1,5 @@
|
||||
/*
|
||||
* $Source$
|
||||
* $State$
|
||||
*/
|
||||
|
||||
89
mach/powerpc/as/mach2.c
Normal file
89
mach/powerpc/as/mach2.c
Normal file
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* $Source$
|
||||
* $State$
|
||||
*/
|
||||
|
||||
%token <y_word> GPR
|
||||
%token <y_word> SPR
|
||||
%token <y_word> FPR
|
||||
%token <y_word> CR
|
||||
%token <y_word> C
|
||||
|
||||
%token <y_word> OP
|
||||
%token <y_word> OP_BF
|
||||
%token <y_word> OP_BF_BFA
|
||||
%token <y_word> OP_BF_FRA_FRB
|
||||
%token <y_word> OP_BF_L_RA_RB
|
||||
%token <y_word> OP_BF_L_RA_SI
|
||||
%token <y_word> OP_BF_L_RA_UI
|
||||
%token <y_word> OP_BF_U_C
|
||||
%token <y_word> OP_BO_BI_BDA
|
||||
%token <y_word> OP_BO_BI_BDL
|
||||
%token <y_word> OP_BO_BI_BH
|
||||
%token <y_word> OP_BT_C
|
||||
%token <y_word> OP_BT_BA_BB
|
||||
%token <y_word> OP_FLM_FRB_C
|
||||
%token <y_word> OP_FRS_RA_D
|
||||
%token <y_word> OP_FRS_RA_RB
|
||||
%token <y_word> OP_FRT_C
|
||||
%token <y_word> OP_FRT_FRA_FRB_C
|
||||
%token <y_word> OP_FRT_FRA_FRC_FRB_C
|
||||
%token <y_word> OP_FRT_FRA_FRC_C
|
||||
%token <y_word> OP_FRT_FRB_C
|
||||
%token <y_word> OP_FRT_RA_D
|
||||
%token <y_word> OP_FRT_RA_RB
|
||||
%token <y_word> OP_L
|
||||
%token <y_word> OP_LEV
|
||||
%token <y_word> OP_LIA
|
||||
%token <y_word> OP_LIL
|
||||
%token <y_word> OP_L_RB
|
||||
%token <y_word> OP_RA_RB
|
||||
%token <y_word> OP_RB
|
||||
%token <y_word> OP_RS
|
||||
%token <y_word> OP_RS_FXM
|
||||
%token <y_word> OP_RS_L
|
||||
%token <y_word> OP_RS_RA
|
||||
%token <y_word> OP_RS_RA_C
|
||||
%token <y_word> OP_RS_RA_D
|
||||
%token <y_word> OP_RS_RA_DS
|
||||
%token <y_word> OP_RS_RA_NB
|
||||
%token <y_word> OP_RS_RA_RB
|
||||
%token <y_word> OP_RS_RA_RB_C
|
||||
%token <y_word> OP_RS_RA_RB_MB5_ME5_C
|
||||
%token <y_word> OP_RS_RA_RB_MB6_C
|
||||
%token <y_word> OP_RS_RA_RB_ME6_C
|
||||
%token <y_word> OP_RS_RA_SH_MB5_ME5_C
|
||||
%token <y_word> OP_RS_RA_SH_MB6_SH_C
|
||||
%token <y_word> OP_RS_RA_SH_ME6_SH_C
|
||||
%token <y_word> OP_RS_RA_SH5_C
|
||||
%token <y_word> OP_RS_RA_SH6_C
|
||||
%token <y_word> OP_RS_RA_UI
|
||||
%token <y_word> OP_RS_RA_UI_CC
|
||||
%token <y_word> OP_RS_RB
|
||||
%token <y_word> OP_RS_SPR
|
||||
%token <y_word> OP_RS_SR
|
||||
%token <y_word> OP_RT
|
||||
%token <y_word> OP_RT_FXM
|
||||
%token <y_word> OP_RT_RA_C
|
||||
%token <y_word> OP_RT_RA_D
|
||||
%token <y_word> OP_RT_RA_DS
|
||||
%token <y_word> OP_RT_RA_NB
|
||||
%token <y_word> OP_RT_RA_RB
|
||||
%token <y_word> OP_RT_RA_RB_C
|
||||
%token <y_word> OP_RT_RA_SI
|
||||
%token <y_word> OP_RT_RA_SI_addic
|
||||
%token <y_word> OP_RT_RB
|
||||
%token <y_word> OP_RT_SPR
|
||||
%token <y_word> OP_RT_SR
|
||||
%token <y_word> OP_RT_TBR
|
||||
%token <y_word> OP_TH_RA_RB
|
||||
%token <y_word> OP_TO_RA_RB
|
||||
%token <y_word> OP_TO_RA_SI
|
||||
|
||||
%token <y_word> OP_la
|
||||
|
||||
/* Other token types */
|
||||
|
||||
%type <y_word> c
|
||||
%type <y_word> e16 u8 u7 u6 u5 u4 u2 u1
|
||||
%type <y_word> nb ds bda bdl lia lil
|
||||
358
mach/powerpc/as/mach3.c
Normal file
358
mach/powerpc/as/mach3.c
Normal file
@@ -0,0 +1,358 @@
|
||||
/*
|
||||
* $Source$
|
||||
* $State$
|
||||
*/
|
||||
|
||||
/* Integer registers */
|
||||
|
||||
0, GPR, 0, "r0",
|
||||
0, GPR, 1, "r1",
|
||||
0, GPR, 1, "sp",
|
||||
0, GPR, 2, "r2",
|
||||
0, GPR, 2, "fp",
|
||||
0, GPR, 3, "r3",
|
||||
0, GPR, 4, "r4",
|
||||
0, GPR, 5, "r5",
|
||||
0, GPR, 6, "r6",
|
||||
0, GPR, 7, "r7",
|
||||
0, GPR, 8, "r8",
|
||||
0, GPR, 9, "r9",
|
||||
0, GPR, 10, "r10",
|
||||
0, GPR, 11, "r11",
|
||||
0, GPR, 12, "r12",
|
||||
0, GPR, 13, "r13",
|
||||
0, GPR, 14, "r14",
|
||||
0, GPR, 15, "r15",
|
||||
0, GPR, 16, "r16",
|
||||
0, GPR, 17, "r17",
|
||||
0, GPR, 18, "r18",
|
||||
0, GPR, 19, "r19",
|
||||
0, GPR, 20, "r20",
|
||||
0, GPR, 21, "r21",
|
||||
0, GPR, 22, "r22",
|
||||
0, GPR, 23, "r23",
|
||||
0, GPR, 24, "r24",
|
||||
0, GPR, 25, "r25",
|
||||
0, GPR, 26, "r26",
|
||||
0, GPR, 27, "r27",
|
||||
0, GPR, 28, "r28",
|
||||
0, GPR, 29, "r29",
|
||||
0, GPR, 30, "r30",
|
||||
0, GPR, 31, "r31",
|
||||
|
||||
/* Floating-point registers */
|
||||
|
||||
0, FPR, 0, "f0",
|
||||
0, FPR, 1, "f1",
|
||||
0, FPR, 2, "f2",
|
||||
0, FPR, 3, "f3",
|
||||
0, FPR, 4, "f4",
|
||||
0, FPR, 5, "f5",
|
||||
0, FPR, 6, "f6",
|
||||
0, FPR, 7, "f7",
|
||||
0, FPR, 8, "f8",
|
||||
0, FPR, 9, "f9",
|
||||
0, FPR, 10, "f10",
|
||||
0, FPR, 11, "f11",
|
||||
0, FPR, 12, "f12",
|
||||
0, FPR, 13, "f13",
|
||||
0, FPR, 14, "f14",
|
||||
0, FPR, 15, "f15",
|
||||
0, FPR, 16, "f16",
|
||||
0, FPR, 17, "f17",
|
||||
0, FPR, 18, "f18",
|
||||
0, FPR, 19, "f19",
|
||||
0, FPR, 20, "f20",
|
||||
0, FPR, 21, "f21",
|
||||
0, FPR, 22, "f22",
|
||||
0, FPR, 23, "f23",
|
||||
0, FPR, 24, "f24",
|
||||
0, FPR, 25, "f25",
|
||||
0, FPR, 26, "f26",
|
||||
0, FPR, 27, "f27",
|
||||
0, FPR, 28, "f28",
|
||||
0, FPR, 29, "f29",
|
||||
0, FPR, 30, "f30",
|
||||
0, FPR, 31, "f31",
|
||||
|
||||
/* Special registers */
|
||||
|
||||
0, SPR, 32, "xer",
|
||||
0, SPR, 256, "lr",
|
||||
0, SPR, 288, "ctr",
|
||||
|
||||
/* Condition registers */
|
||||
|
||||
0, CR, 0, "cr0",
|
||||
0, CR, 1, "cr1",
|
||||
0, CR, 2, "cr2",
|
||||
0, CR, 3, "cr3",
|
||||
0, CR, 4, "cr4",
|
||||
0, CR, 5, "cr5",
|
||||
0, CR, 6, "cr6",
|
||||
0, CR, 7, "cr7",
|
||||
|
||||
/* Condition code flag */
|
||||
|
||||
0, C, 0, ".",
|
||||
|
||||
/* Special instructions */
|
||||
|
||||
0, OP_la, 0, "la",
|
||||
|
||||
/* Branch processor instructions (page 20) */
|
||||
|
||||
0, OP_LIL, 18<<26 | 0<<1 | 0<<0, "b",
|
||||
0, OP_LIA, 18<<26 | 1<<1 | 0<<0, "ba",
|
||||
0, OP_LIL, 18<<26 | 0<<1 | 1<<0, "bl",
|
||||
0, OP_LIA, 18<<26 | 1<<1 | 1<<0, "bla",
|
||||
0, OP_BO_BI_BDL, 16<<26 | 0<<1 | 0<<0, "bc",
|
||||
0, OP_BO_BI_BDA, 16<<26 | 1<<1 | 0<<0, "bca",
|
||||
0, OP_BO_BI_BDL, 16<<26 | 0<<1 | 1<<0, "bcl",
|
||||
0, OP_BO_BI_BDA, 16<<26 | 1<<1 | 1<<0, "bcla",
|
||||
0, OP_BO_BI_BH, 19<<26 | 16<<1 | 0<<0, "bclr",
|
||||
0, OP_BO_BI_BH, 19<<26 | 16<<1 | 1<<0, "bclrl",
|
||||
0, OP_BO_BI_BH, 19<<26 | 528<<1 | 0<<0, "bcctr",
|
||||
0, OP_BO_BI_BH, 19<<26 | 528<<1 | 1<<0, "bcctrl",
|
||||
0, OP_LEV, 17<<26 | 1<<1, "sc",
|
||||
0, OP_BT_BA_BB, 19<<26 | 257<<1, "crand",
|
||||
0, OP_BT_BA_BB, 19<<26 | 449<<1, "cror",
|
||||
0, OP_BT_BA_BB, 19<<26 | 193<<1, "crxor",
|
||||
0, OP_BT_BA_BB, 19<<26 | 225<<1, "crnand",
|
||||
0, OP_BT_BA_BB, 19<<26 | 33<<1, "crnor",
|
||||
0, OP_BT_BA_BB, 19<<26 | 289<<1, "crneqv",
|
||||
0, OP_BT_BA_BB, 19<<26 | 129<<1, "crandc",
|
||||
0, OP_BT_BA_BB, 19<<26 | 417<<1, "crorc",
|
||||
0, OP_BF_BFA, 19<<26 | 0<<1, "mcrf",
|
||||
|
||||
/* Fixed point instructions (page 29) */
|
||||
|
||||
0, OP_RT_RA_D, 34<<26, "lbz",
|
||||
0, OP_RT_RA_RB, 31<<26 | 87<<1, "lbzx",
|
||||
0, OP_RT_RA_D, 35<<26, "lbzu",
|
||||
0, OP_RT_RA_RB, 31<<26 | 119<<1, "lbzux",
|
||||
0, OP_RT_RA_D, 40<<26, "lhz",
|
||||
0, OP_RT_RA_RB, 31<<26 | 279<<1, "lhzx",
|
||||
0, OP_RT_RA_D, 41<<26, "lhzu",
|
||||
0, OP_RT_RA_RB, 31<<26 | 311<<1, "lhzux",
|
||||
0, OP_RT_RA_D, 42<<26, "lha",
|
||||
0, OP_RT_RA_RB, 31<<26 | 343<<1, "lhax",
|
||||
0, OP_RT_RA_D, 43<<26, "lhau",
|
||||
0, OP_RT_RA_RB, 31<<26 | 375<<1, "lhaux",
|
||||
0, OP_RT_RA_D, 32<<26, "lwz",
|
||||
0, OP_RT_RA_RB, 31<<26 | 23<<1, "lwzx",
|
||||
0, OP_RT_RA_D, 33<<26, "lwzu",
|
||||
0, OP_RT_RA_RB, 31<<26 | 55<<1, "lwzux",
|
||||
0, OP_RT_RA_DS, 58<<26 | 2<<0, "lwa",
|
||||
0, OP_RT_RA_RB, 31<<26 | 341<<1, "lwax",
|
||||
0, OP_RT_RA_RB, 31<<26 | 363<<1, "lwaux",
|
||||
0, OP_RT_RA_DS, 58<<26, "ld",
|
||||
0, OP_RT_RA_RB, 31<<26 | 21<<1, "ldx",
|
||||
0, OP_RT_RA_DS, 58<<26 | 1<<0, "ldu",
|
||||
0, OP_RT_RA_RB, 31<<26 | 53<<1, "ldux",
|
||||
|
||||
0, OP_RS_RA_D, 38<<26, "stb",
|
||||
0, OP_RS_RA_RB, 31<<26 | 215<<1, "stbx",
|
||||
0, OP_RS_RA_D, 39<<26, "stbu",
|
||||
0, OP_RS_RA_RB, 31<<26 | 247<<1, "stbux",
|
||||
0, OP_RS_RA_D, 44<<26, "sth",
|
||||
0, OP_RS_RA_RB, 31<<26 | 407<<1, "sthx",
|
||||
0, OP_RS_RA_D, 45<<26, "sthu",
|
||||
0, OP_RS_RA_RB, 31<<26 | 439<<1, "sthux",
|
||||
0, OP_RS_RA_D, 36<<26, "stw",
|
||||
0, OP_RS_RA_RB, 31<<26 | 151<<1, "stwx",
|
||||
0, OP_RS_RA_D, 37<<26, "stwu",
|
||||
0, OP_RS_RA_RB, 31<<26 | 183<<1, "stwux",
|
||||
0, OP_RS_RA_DS, 62<<26, "std",
|
||||
0, OP_RS_RA_RB, 31<<26 | 149<<1, "stdx",
|
||||
0, OP_RS_RA_DS, 62<<26 | 1<<0, "stdu",
|
||||
0, OP_RS_RA_RB, 31<<26 | 181<<1, "stdux",
|
||||
|
||||
/* page 42 */
|
||||
0, OP_RT_RA_RB, 31<<26 | 790<<1, "lhbrx",
|
||||
0, OP_RT_RA_RB, 31<<26 | 534<<1, "lwbrx",
|
||||
0, OP_RS_RA_RB, 31<<26 | 918<<1, "sthbrx",
|
||||
0, OP_RS_RA_RB, 31<<26 | 662<<1, "stwbrx",
|
||||
|
||||
/* page 44 */
|
||||
0, OP_RT_RA_D, 46<<26, "lmw",
|
||||
0, OP_RS_RA_D, 47<<26, "stmw",
|
||||
|
||||
/* page 45 */
|
||||
0, OP_RT_RA_NB, 31<<26 | 597<<1, "lswi",
|
||||
0, OP_RT_RA_RB, 31<<26 | 533<<1, "lswx",
|
||||
0, OP_RS_RA_NB, 31<<26 | 725<<1, "stswi",
|
||||
0, OP_RS_RA_RB, 31<<26 | 661<<1, "stswx",
|
||||
|
||||
/* page 49 */
|
||||
0, OP_RT_RA_SI, 14<<26, "addi",
|
||||
0, OP_RT_RA_SI, 15<<26, "addis",
|
||||
0, OP_RT_RA_RB_C, 31<<26 | 0<<10 | 266<<1, "add",
|
||||
0, OP_RT_RA_RB_C, 31<<26 | 1<<10 | 266<<1, "addo",
|
||||
0, OP_RT_RA_RB_C, 31<<26 | 0<<10 | 40<<1, "subf",
|
||||
0, OP_RT_RA_RB_C, 31<<26 | 1<<10 | 40<<1, "subfo",
|
||||
0, OP_RT_RA_SI_addic, 12<<26, "addic", /* special case C */
|
||||
0, OP_RT_RA_SI, 8<<26, "subfic",
|
||||
0, OP_RT_RA_RB_C, 31<<26 | 0<<10 | 138<<1, "adde",
|
||||
0, OP_RT_RA_RB_C, 31<<26 | 1<<10 | 138<<1, "addeo",
|
||||
0, OP_RT_RA_RB_C, 31<<26 | 0<<10 | 136<<1, "subfe",
|
||||
0, OP_RT_RA_RB_C, 31<<26 | 1<<10 | 136<<1, "subfeo",
|
||||
0, OP_RT_RA_C, 31<<26 | 0<<10 | 234<<1, "addme",
|
||||
0, OP_RT_RA_C, 31<<26 | 1<<10 | 234<<1, "addmeo",
|
||||
0, OP_RT_RA_C, 31<<26 | 0<<10 | 232<<1, "subfme",
|
||||
0, OP_RT_RA_C, 31<<26 | 1<<10 | 232<<1, "subfmeo",
|
||||
0, OP_RT_RA_C, 31<<26 | 0<<10 | 202<<1, "addze",
|
||||
0, OP_RT_RA_C, 31<<26 | 1<<10 | 202<<1, "addzeo",
|
||||
0, OP_RT_RA_C, 31<<26 | 0<<10 | 200<<1, "subfze",
|
||||
0, OP_RT_RA_C, 31<<26 | 1<<10 | 200<<1, "subfzeo",
|
||||
0, OP_RT_RA_C, 31<<26 | 0<<10 | 104<<1, "neg",
|
||||
0, OP_RT_RA_C, 31<<26 | 1<<10 | 104<<1, "nego",
|
||||
|
||||
/* page 54 */
|
||||
0, OP_RT_RA_SI, 7<<26, "mulli",
|
||||
0, OP_RT_RA_RB_C, 31<<26 | 0<<10 | 233<<1, "mulld",
|
||||
0, OP_RT_RA_RB_C, 31<<26 | 1<<10 | 233<<1, "mulldo",
|
||||
0, OP_RT_RA_RB_C, 31<<26 | 0<<10 | 235<<1, "mullw",
|
||||
0, OP_RT_RA_RB_C, 31<<26 | 1<<10 | 235<<1, "mullwo",
|
||||
0, OP_RT_RA_RB_C, 31<<26 | 73<<1, "mulhd",
|
||||
0, OP_RT_RA_RB_C, 31<<26 | 75<<1, "mulhw",
|
||||
0, OP_RT_RA_RB_C, 31<<26 | 9<<1, "mulhdu",
|
||||
0, OP_RT_RA_RB_C, 31<<26 | 11<<1, "mulhwu",
|
||||
|
||||
/* page 56 */
|
||||
0, OP_RT_RA_RB_C, 31<<26 | 0<<10 | 489<<1, "divd",
|
||||
0, OP_RT_RA_RB_C, 31<<26 | 1<<10 | 489<<1, "divdo",
|
||||
0, OP_RT_RA_RB_C, 31<<26 | 0<<10 | 491<<1, "divw",
|
||||
0, OP_RT_RA_RB_C, 31<<26 | 1<<10 | 491<<1, "divwo",
|
||||
0, OP_RT_RA_RB_C, 31<<26 | 0<<10 | 457<<1, "divdu",
|
||||
0, OP_RT_RA_RB_C, 31<<26 | 1<<10 | 457<<1, "divduo",
|
||||
0, OP_RT_RA_RB_C, 31<<26 | 0<<10 | 459<<1, "divwu",
|
||||
0, OP_RT_RA_RB_C, 31<<26 | 1<<10 | 459<<1, "divwuo",
|
||||
|
||||
/* page 58 */
|
||||
0, OP_BF_L_RA_SI, 11<<26, "cmpi",
|
||||
0, OP_BF_L_RA_RB, 31<<26 | 0<<1, "cmp",
|
||||
0, OP_BF_L_RA_UI, 10<<26, "cmpli",
|
||||
0, OP_BF_L_RA_RB, 31<<26 | 32<<1, "cmpl",
|
||||
|
||||
/* page 60 */
|
||||
0, OP_TO_RA_SI, 2<<26, "tdi",
|
||||
0, OP_TO_RA_SI, 3<<26, "twi",
|
||||
0, OP_TO_RA_RB, 31<<26 | 68<<1, "td",
|
||||
0, OP_TO_RA_RB, 31<<26 | 4<<1, "tw",
|
||||
|
||||
/* page 62 */
|
||||
0, OP_RS_RA_UI_CC, 28<<26, "andi", /* C compulsory */
|
||||
0, OP_RS_RA_UI_CC, 29<<26, "andis", /* C compulsory */
|
||||
0, OP_RS_RA_UI, 24<<26, "ori",
|
||||
0, OP_RS_RA_UI, 25<<26, "oris",
|
||||
0, OP_RS_RA_UI, 26<<26, "xori",
|
||||
0, OP_RS_RA_UI, 27<<26, "xoris",
|
||||
0, OP_RS_RA_RB_C, 31<<26 | 28<<1, "and",
|
||||
0, OP_RS_RA_RB_C, 31<<26 | 444<<1, "or",
|
||||
0, OP_RS_RA_RB_C, 31<<26 | 316<<1, "xor",
|
||||
0, OP_RS_RA_RB_C, 31<<26 | 476<<1, "nand",
|
||||
0, OP_RS_RA_RB_C, 31<<26 | 124<<1, "nor",
|
||||
0, OP_RS_RA_RB_C, 31<<26 | 284<<1, "eqv",
|
||||
0, OP_RS_RA_RB_C, 31<<26 | 60<<1, "andc",
|
||||
0, OP_RS_RA_RB_C, 31<<26 | 412<<1, "orc",
|
||||
0, OP_RS_RA_C, 31<<26 | 954<<1, "extsb",
|
||||
0, OP_RS_RA_C, 31<<26 | 922<<1, "extsh",
|
||||
0, OP_RS_RA_C, 31<<26 | 986<<1, "extsw",
|
||||
0, OP_RS_RA_C, 31<<26 | 58<<1, "cntlzd",
|
||||
0, OP_RS_RA_C, 31<<26 | 26<<1, "cntlzw",
|
||||
|
||||
/* page 69 */
|
||||
0, OP_RS_RA_SH_MB6_SH_C, 30<<26 | 0<<2, "rldicl",
|
||||
0, OP_RS_RA_SH_ME6_SH_C, 30<<26 | 1<<2, "rldicr",
|
||||
0, OP_RS_RA_SH_MB6_SH_C, 30<<26 | 2<<2, "rldic",
|
||||
0, OP_RS_RA_SH_MB5_ME5_C, 21<<26, "rlwinm",
|
||||
0, OP_RS_RA_RB_MB6_C, 30<<26 | 8<<1, "rldcl",
|
||||
0, OP_RS_RA_RB_ME6_C, 30<<26 | 9<<1, "rldcr",
|
||||
0, OP_RS_RA_RB_MB5_ME5_C, 23<<26, "rlwnm",
|
||||
0, OP_RS_RA_SH_MB6_SH_C, 30<<26 | 3<<2, "rldimi",
|
||||
0, OP_RS_RA_SH_MB5_ME5_C, 20<<26, "rlwimi",
|
||||
|
||||
/* page 74 */
|
||||
0, OP_RS_RA_RB_C, 31<<26 | 27<<1, "sld",
|
||||
0, OP_RS_RA_RB_C, 31<<26 | 24<<1, "slw",
|
||||
0, OP_RS_RA_RB_C, 31<<26 | 539<<1, "srd",
|
||||
0, OP_RS_RA_RB_C, 31<<26 | 536<<1, "srw",
|
||||
0, OP_RS_RA_SH6_C, 31<<26 | 413<<2, "sradi",
|
||||
0, OP_RS_RA_SH5_C, 31<<26 | 824<<1, "srawi",
|
||||
0, OP_RS_RA_RB_C, 31<<26 | 794<<1, "srad",
|
||||
0, OP_RS_RA_RB_C, 31<<26 | 792<<1, "sraw",
|
||||
|
||||
/* page 78 */
|
||||
0, OP_RS_SPR, 31<<26 | 467<<1, "mtspr",
|
||||
0, OP_RT_SPR, 31<<26 | 339<<1, "mfspr",
|
||||
0, OP_RS_FXM, 31<<26 | 0<<21 | 144<<1, "mtcrf",
|
||||
0, OP_RT, 31<<26 | 0<<21 | 19<<1, "mfcr",
|
||||
|
||||
/* Floating point instructions (page 83) */
|
||||
|
||||
0, OP_FRT_RA_D, 48<<26, "lfs",
|
||||
0, OP_FRT_RA_RB, 31<<26 | 535<<1, "lfsx",
|
||||
0, OP_FRT_RA_D, 49<<26, "lfsu",
|
||||
0, OP_FRT_RA_RB, 31<<26 | 567<<1, "lfsux",
|
||||
0, OP_FRT_RA_D, 50<<26, "lfd",
|
||||
0, OP_FRT_RA_RB, 31<<26 | 599<<1, "lfdx",
|
||||
0, OP_FRT_RA_D, 51<<26, "lfdu",
|
||||
0, OP_FRT_RA_RB, 31<<26 | 631<<1, "lfdux",
|
||||
0, OP_FRS_RA_D, 52<<26, "stfs",
|
||||
0, OP_FRS_RA_RB, 31<<26 | 663<<1, "stfsx",
|
||||
0, OP_FRS_RA_D, 53<<26, "stfsu",
|
||||
0, OP_FRS_RA_RB, 31<<26 | 695<<1, "stfsux",
|
||||
0, OP_FRS_RA_D, 54<<26, "stfd",
|
||||
0, OP_FRS_RA_RB, 31<<26 | 727<<1, "stfdx",
|
||||
0, OP_FRS_RA_D, 55<<26, "stfdu",
|
||||
0, OP_FRS_RA_RB, 31<<26 | 759<<1, "stfdux",
|
||||
0, OP_FRS_RA_RB, 31<<26 | 983<<1, "stfiwx",
|
||||
|
||||
0, OP_FRT_FRB_C, 63<<26 | 72<<1, "fmr",
|
||||
0, OP_FRT_FRB_C, 63<<26 | 40<<1, "fneg",
|
||||
0, OP_FRT_FRB_C, 63<<26 | 264<<1, "fabs",
|
||||
0, OP_FRT_FRB_C, 63<<26 | 136<<1, "fnabs",
|
||||
|
||||
0, OP_FRT_FRA_FRB_C, 63<<26 | 21<<1, "fadd",
|
||||
0, OP_FRT_FRA_FRB_C, 59<<26 | 21<<1, "fadds",
|
||||
0, OP_FRT_FRA_FRB_C, 63<<26 | 20<<1, "fsub",
|
||||
0, OP_FRT_FRA_FRB_C, 59<<26 | 20<<1, "fsubs",
|
||||
0, OP_FRT_FRA_FRC_C, 63<<26 | 25<<1, "fmul",
|
||||
0, OP_FRT_FRA_FRC_C, 59<<26 | 25<<1, "fmuls",
|
||||
0, OP_FRT_FRA_FRB_C, 63<<26 | 18<<1, "fdiv",
|
||||
0, OP_FRT_FRA_FRB_C, 59<<26 | 18<<1, "fdivs",
|
||||
|
||||
0, OP_FRT_FRA_FRC_FRB_C, 63<<26 | 29<<1, "fmadd",
|
||||
0, OP_FRT_FRA_FRC_FRB_C, 59<<26 | 29<<1, "fmadds",
|
||||
0, OP_FRT_FRA_FRC_FRB_C, 63<<26 | 28<<1, "fmsub",
|
||||
0, OP_FRT_FRA_FRC_FRB_C, 59<<26 | 28<<1, "fmsubs",
|
||||
0, OP_FRT_FRA_FRC_FRB_C, 63<<26 | 31<<1, "fnmadd",
|
||||
0, OP_FRT_FRA_FRC_FRB_C, 59<<26 | 31<<1, "fnmadds",
|
||||
0, OP_FRT_FRA_FRC_FRB_C, 63<<26 | 30<<1, "fnmsub",
|
||||
0, OP_FRT_FRA_FRC_FRB_C, 59<<26 | 30<<1, "fnmsubs",
|
||||
|
||||
0, OP_FRT_FRB_C, 63<<26 | 12<<1, "frsp",
|
||||
0, OP_FRT_FRB_C, 63<<26 | 814<<1, "fctid",
|
||||
0, OP_FRT_FRB_C, 63<<26 | 815<<1, "fctidz",
|
||||
0, OP_FRT_FRB_C, 63<<26 | 14<<1, "fctiw",
|
||||
0, OP_FRT_FRB_C, 63<<26 | 15<<1, "fctiwz",
|
||||
0, OP_FRT_FRB_C, 63<<26 | 846<<1, "fcfid",
|
||||
|
||||
0, OP_BF_FRA_FRB, 63<<26 | 0<<1, "fcmpu",
|
||||
0, OP_BF_FRA_FRB, 63<<26 | 32<<1, "fcmpo",
|
||||
|
||||
0, OP_FRT_C, 63<<26 | 583<<1, "mffs",
|
||||
0, OP_BF_BFA, 63<<26 | 64<<1, "mcrfs",
|
||||
0, OP_BF_U_C, 63<<26 | 134<<1, "mtfsfi",
|
||||
0, OP_FLM_FRB_C, 63<<26 | 711<<1, "mtfsf",
|
||||
0, OP_BT_C, 63<<26 | 70<<1, "mtfsb0",
|
||||
0, OP_BT_C, 63<<26 | 38<<1, "mtfsb1",
|
||||
|
||||
0, OP_FRT_FRB_C, 63<<26 | 22<<1, "fsqrt",
|
||||
0, OP_FRT_FRB_C, 59<<26 | 22<<1, "fsqrts",
|
||||
0, OP_FRT_FRB_C, 59<<26 | 24<<1, "fres",
|
||||
0, OP_FRT_FRB_C, 63<<26 | 26<<1, "frsqrte",
|
||||
0, OP_FRT_FRA_FRC_FRB_C, 63<<26 | 23<<1, "fsel",
|
||||
|
||||
/* page 98 */
|
||||
236
mach/powerpc/as/mach4.c
Normal file
236
mach/powerpc/as/mach4.c
Normal file
@@ -0,0 +1,236 @@
|
||||
/*
|
||||
* $Source$
|
||||
* $State$
|
||||
*/
|
||||
|
||||
operation
|
||||
: OP_BF_BFA CR ',' CR { emit4($1 | ($2<<23) | ($4<<18)); }
|
||||
| OP_BF_FRA_FRB CR ',' FPR ',' FPR { emit4($1 | ($2<<23) | ($4<<16) | ($6<<11)); }
|
||||
| OP_BF_L_RA_RB CR ',' u1 ',' GPR ',' GPR { emit4($1 | ($2<<23) | ($4<<21) | ($6<<16) | ($8<<11)); }
|
||||
| OP_BF_L_RA_SI CR ',' u1 ',' GPR ',' e16 { emit4($1 | ($2<<23) | ($4<<21) | ($6<<16) | $8); }
|
||||
| OP_BF_L_RA_UI CR ',' u1 ',' GPR ',' e16 { emit4($1 | ($2<<23) | ($4<<21) | ($6<<16) | $8); }
|
||||
| OP_BF_U_C c CR ',' u4 { emit4($1 | $2 | ($3<<23) | ($5<<12)); }
|
||||
| OP_BO_BI_BDA u5 ',' u5 ',' bda { emit4($1 | ($2<<21) | ($4<<16) | $6); }
|
||||
| OP_BO_BI_BDL u5 ',' u5 ',' bdl { emit4($1 | ($2<<21) | ($4<<16) | $6); }
|
||||
| OP_BO_BI_BH u5 ',' u5 ',' u2 { emit4($1 | ($2<<21) | ($4<<16) | ($6<<11)); }
|
||||
| OP_BT_BA_BB u5 ',' u5 ',' u5 { emit4($1 | ($2<<21) | ($4<<16) | ($6<<11)); }
|
||||
| OP_BT_C c u5 { emit4($1 | $2 | ($3<<21)); }
|
||||
| OP_FLM_FRB_C c u8 ',' FPR { emit4($1 | $2 | ($3<<17) | ($5<<11)); }
|
||||
| OP_FRS_RA_D FPR ',' e16 '(' GPR ')' { emit4($1 | ($2<<21) | ($6<<16) | $4); }
|
||||
| OP_FRS_RA_RB FPR ',' GPR ',' GPR { emit4($1 | ($2<<21) | ($4<<16) | ($6<<11)); }
|
||||
| OP_FRT_FRA_FRB_C c FPR ',' FPR ',' FPR { emit4($1 | $2 | ($3<<21) | ($5<<16) | ($7<<11)); }
|
||||
| OP_FRT_FRA_FRC_FRB_C c FPR ',' FPR ',' FPR ',' FPR { emit4($1 | $2 | ($3<<21) | ($5<<16) | ($9<<11) | ($7<<6)); }
|
||||
| OP_FRT_FRA_FRC_C c FPR ',' FPR ',' FPR { emit4($1 | $2 | ($3<<21) | ($5<<16) | ($7<<6)); }
|
||||
| OP_FRT_FRB_C c FPR ',' FPR { emit4($1 | $2 | ($3<<21) | ($5<<11)); }
|
||||
| OP_FRT_RA_D FPR ',' e16 '(' GPR ')' { emit4($1 | ($2<<21) | ($6<<16) | $4); }
|
||||
| OP_FRT_RA_RB FPR ',' GPR ',' GPR { emit4($1 | ($2<<21) | ($4<<16) | ($6<<11)); }
|
||||
| OP_FRT_C c FPR { emit4($1 | $2 | ($3<<21)); }
|
||||
| OP_RT GPR { emit4($1 | ($2<<21)); }
|
||||
| OP_RT_RA_C c GPR ',' GPR { emit4($1 | $2 | ($3<<21) | ($5<<16)); }
|
||||
| OP_RT_RA_D GPR ',' e16 '(' GPR ')' { emit4($1 | ($2<<21) | ($6<<16) | $4); }
|
||||
| OP_RT_RA_DS GPR ',' ds '(' GPR ')' { emit4($1 | ($2<<21) | ($6<<16) | $4); }
|
||||
| OP_RT_RA_NB GPR ',' GPR ',' nb { emit4($1 | ($2<<21) | ($4<<16) | ($6<<11)); }
|
||||
| OP_RT_RA_RB GPR ',' GPR ',' GPR { emit4($1 | ($2<<21) | ($4<<16) | ($6<<11)); }
|
||||
| OP_RT_RA_RB_C c GPR ',' GPR ',' GPR { emit4($1 | $2 | ($3<<21) | ($5<<16) | ($7<<11)); }
|
||||
| OP_RT_RA_SI GPR ',' GPR ',' e16 { emit4($1 | ($2<<21) | ($4<<16) | $6); }
|
||||
| OP_RT_RA_SI_addic c GPR ',' GPR ',' e16 { emit4($1 | ($2<<26) | ($3<<21) | ($5<<16) | $7); }
|
||||
| OP_RT_SPR GPR ',' SPR { emit4($1 | ($2<<21) | ($4<<11)); }
|
||||
| OP_RS_FXM u7 ',' GPR { emit4($1 | ($4<<21) | ($2<<12)); }
|
||||
| OP_RS_RA_C c GPR ',' GPR { emit4($1 | $2 | ($5<<21) | ($3<<16)); }
|
||||
| OP_RS_RA_D GPR ',' e16 '(' GPR ')' { emit4($1 | ($2<<21) | ($6<<16) | $4); }
|
||||
| OP_RS_RA_DS GPR ',' ds '(' GPR ')' { emit4($1 | ($2<<21) | ($6<<16) | $4); }
|
||||
| OP_RS_RA_NB GPR ',' GPR ',' nb { emit4($1 | ($2<<21) | ($4<<16) | ($6<<11)); }
|
||||
| OP_RS_RA_UI GPR ',' GPR ',' e16 { emit4($1 | ($4<<21) | ($2<<16) | $6); }
|
||||
| OP_RS_RA_UI_CC C GPR ',' GPR ',' e16 { emit4($1 | ($5<<21) | ($3<<16) | $7); }
|
||||
| OP_RS_RA_RB GPR ',' GPR ',' GPR { emit4($1 | ($2<<21) | ($4<<16) | ($6<<11)); }
|
||||
| OP_RS_RA_RB_C c GPR ',' GPR ',' GPR { emit4($1 | $2 | ($5<<21) | ($3<<16) | ($7<<11)); }
|
||||
| OP_RS_RA_RB_MB5_ME5_C c GPR ',' GPR ',' GPR ',' u5 ',' u5 { emit4($1 | $2 | ($5<<21) | ($3<<16) | ($7<<11) | ($9<<6) | ($11<<1)); }
|
||||
| OP_RS_RA_RB_MB6_C c GPR ',' GPR ',' GPR ',' u6 { emit4($1 | $2 | ($5<<21) | ($3<<16) | ($7<<11) | (($9&0x1F)<<6) | (($9&0x20)>>0)); }
|
||||
| OP_RS_RA_RB_ME6_C c GPR ',' GPR ',' GPR ',' u6 { emit4($1 | $2 | ($5<<21) | ($3<<16) | ($7<<11) | (($9&0x1F)<<6) | (($9&0x20)>>0)); }
|
||||
| OP_RS_RA_SH_MB5_ME5_C c GPR ',' GPR ',' u5 ',' u5 ',' u5 { emit4($1 | $2 | ($5<<21) | ($3<<16) | ($7<<11) | ($9<<6) | ($11<<1)); }
|
||||
| OP_RS_RA_SH_MB6_SH_C c GPR ',' GPR ',' u6 ',' u6 { emit4($1 | $2 | ($5<<21) | ($3<<16) | (($7&0x1F)<<11) | ($9<<6) | (($7&0x20)>>4)); }
|
||||
| OP_RS_RA_SH_ME6_SH_C c GPR ',' GPR ',' u6 ',' u6 { emit4($1 | $2 | ($5<<21) | ($3<<16) | (($7&0x1F)<<11) | ($9<<6) | (($7&0x20)>>4)); }
|
||||
| OP_RS_RA_SH5_C c GPR ',' GPR ',' u5 { emit4($1 | $2 | ($5<<21) | ($3<<16) | ($7<<11)); }
|
||||
| OP_RS_RA_SH6_C c GPR ',' GPR ',' u6 { emit4($1 | $2 | ($5<<21) | ($3<<16) | (($7&0x1F)<<11) | (($7&0x20)>>4)); }
|
||||
| OP_RS_SPR SPR ',' GPR { emit4($1 | ($4<<21) | ($2<<11)); }
|
||||
| OP_TO_RA_RB u5 ',' GPR ',' GPR { emit4($1 | ($2<<21) | ($4<<16) | ($6<<11)); }
|
||||
| OP_TO_RA_SI u5 ',' GPR ',' e16 { emit4($1 | ($2<<21) | ($4<<16) | $6); }
|
||||
| OP_LEV u7 { emit4($1 | ($2<<5)); }
|
||||
| OP_LIA lia { emit4($1 | $2); }
|
||||
| OP_LIL lil { emit4($1 | $2); }
|
||||
;
|
||||
|
||||
c
|
||||
: /* nothing */ { $$ = 0; }
|
||||
| C { $$ = 1; }
|
||||
;
|
||||
|
||||
e16
|
||||
: '<' expr
|
||||
{
|
||||
DOTVAL += 2;
|
||||
newrelo($2.typ, RELOH2 | FIXUPFLAGS);
|
||||
DOTVAL -= 2;
|
||||
$$ = ($2.val >> 16) & 0xFFFF;
|
||||
}
|
||||
| '>' expr
|
||||
{
|
||||
DOTVAL += 2;
|
||||
newrelo($2.typ, RELO2 | FIXUPFLAGS);
|
||||
DOTVAL -= 2;
|
||||
$$ = $2.val & 0xFFFF;
|
||||
}
|
||||
| expr
|
||||
{
|
||||
DOTVAL += 2;
|
||||
newrelo($1.typ, RELO2 | FIXUPFLAGS);
|
||||
DOTVAL -= 2;
|
||||
$$ = $1.val & 0xFFFF;
|
||||
}
|
||||
;
|
||||
|
||||
u8
|
||||
: absexp
|
||||
{
|
||||
if (($1 < 0) || ($1 > 0xFF))
|
||||
serror("8-bit unsigned value out of range");
|
||||
$$ = $1;
|
||||
}
|
||||
;
|
||||
|
||||
u7
|
||||
: absexp
|
||||
{
|
||||
if (($1 < 0) || ($1 > 0x7F))
|
||||
serror("7-bit unsigned value out of range");
|
||||
$$ = $1;
|
||||
}
|
||||
;
|
||||
|
||||
u6
|
||||
: absexp
|
||||
{
|
||||
if (($1 < 0) || ($1 > 0x3F))
|
||||
serror("6-bit unsigned value out of range");
|
||||
$$ = $1;
|
||||
}
|
||||
;
|
||||
|
||||
u5
|
||||
: absexp
|
||||
{
|
||||
if (($1 < 0) || ($1 > 0x1F))
|
||||
serror("5-bit unsigned value out of range");
|
||||
$$ = $1;
|
||||
}
|
||||
;
|
||||
|
||||
u4
|
||||
: absexp
|
||||
{
|
||||
if (($1 < 0) || ($1 > 0xF))
|
||||
serror("4-bit unsigned value out of range");
|
||||
$$ = $1;
|
||||
}
|
||||
;
|
||||
|
||||
u1
|
||||
: absexp
|
||||
{
|
||||
if (($1 < 0) || ($1 > 1))
|
||||
serror("1-bit unsigned value out of range");
|
||||
$$ = $1;
|
||||
}
|
||||
;
|
||||
|
||||
u2
|
||||
: absexp
|
||||
{
|
||||
if (($1 < 0) || ($1 > 0x3))
|
||||
serror("2-bit unsigned value out of range");
|
||||
$$ = $1;
|
||||
}
|
||||
;
|
||||
|
||||
ds
|
||||
: e16
|
||||
{
|
||||
if ($1 & 3)
|
||||
serror("value must be 4-aligned");
|
||||
$$ = $1;
|
||||
}
|
||||
;
|
||||
|
||||
nb
|
||||
: absexp
|
||||
{
|
||||
if (($1 < 1) || ($1 > 32))
|
||||
serror("register count must be in the range 1..32");
|
||||
|
||||
if ($1 == 32)
|
||||
$$ = 0;
|
||||
else
|
||||
$$ = $1;
|
||||
}
|
||||
;
|
||||
|
||||
bdl
|
||||
: expr
|
||||
{
|
||||
int dist = $1.val - DOTVAL;
|
||||
fit(fitx(dist, 25));
|
||||
|
||||
if (dist & 0x3)
|
||||
serror("jump targets must be 4-aligned");
|
||||
|
||||
DOTVAL += 2;
|
||||
newrelo($1.typ, RELO2 | RELPC | FIXUPFLAGS);
|
||||
DOTVAL -= 2;
|
||||
$$ = dist & 0xFFFD;
|
||||
}
|
||||
;
|
||||
|
||||
bda
|
||||
: expr
|
||||
{
|
||||
int target = $1.val;
|
||||
fit(fitx(target, 16));
|
||||
|
||||
if (target & 0x3)
|
||||
serror("jump targets must be 4-aligned");
|
||||
|
||||
DOTVAL += 2;
|
||||
newrelo($1.typ, RELO2 | FIXUPFLAGS);
|
||||
DOTVAL -= 2;
|
||||
$$ = target & 0xFFFD;
|
||||
}
|
||||
;
|
||||
|
||||
lil
|
||||
: expr
|
||||
{
|
||||
int dist = $1.val - DOTVAL;
|
||||
fit(fitx(dist, 26));
|
||||
|
||||
if (dist & 0x3)
|
||||
serror("jump targets must be 4-aligned");
|
||||
|
||||
newrelo($1.typ, RELOPPC | RELPC | FIXUPFLAGS);
|
||||
$$ = dist & 0x03FFFFFD;
|
||||
}
|
||||
;
|
||||
|
||||
lia
|
||||
: expr
|
||||
{
|
||||
int target = $1.val;
|
||||
fit(fitx(target, 26));
|
||||
|
||||
if (target & 0x3)
|
||||
serror("jump targets must be 4-aligned");
|
||||
|
||||
newrelo($1.typ, RELOPPC | FIXUPFLAGS);
|
||||
$$ = target & 0x03FFFFFD;
|
||||
}
|
||||
;
|
||||
|
||||
5
mach/powerpc/as/mach5.c
Normal file
5
mach/powerpc/as/mach5.c
Normal file
@@ -0,0 +1,5 @@
|
||||
/*
|
||||
* $Source$
|
||||
* $State$
|
||||
*/
|
||||
|
||||
2
mach/powerpc/libem/.distr
Normal file
2
mach/powerpc/libem/.distr
Normal file
@@ -0,0 +1,2 @@
|
||||
LIST
|
||||
libem_s.a
|
||||
35
mach/powerpc/libem/aar4.s
Normal file
35
mach/powerpc/libem/aar4.s
Normal file
@@ -0,0 +1,35 @@
|
||||
#
|
||||
! $Source$
|
||||
! $State$
|
||||
! $Revision$
|
||||
|
||||
#include "powerpc.h"
|
||||
|
||||
.sect .text
|
||||
|
||||
! Index into a bounds-checked array.
|
||||
!
|
||||
! On entry:
|
||||
! r3 = ptr to descriptor
|
||||
! r4 = index
|
||||
! r5 = address of array
|
||||
|
||||
.define .aar4
|
||||
.aar4:
|
||||
addis r0, r0, <.trap_earray
|
||||
ori r0, r0, >.trap_earray
|
||||
mtspr ctr, r0 ! load CTR with trap address
|
||||
|
||||
lwz r0, 0(r3)
|
||||
subf. r4, r0, r4 ! adjust range
|
||||
bcctr IFTRUE, LT, 0 ! check lower bound
|
||||
|
||||
lwz r0, 4(r3)
|
||||
cmpl cr0, 0, r4, r3
|
||||
bcctr IFFALSE, LT, 0 ! check upper bound
|
||||
|
||||
lwz r0, 8(r3)
|
||||
mullw r4, r4, r0 ! scale index
|
||||
add r3, r4, r5 ! calculate element address
|
||||
|
||||
bclr ALWAYS, 0, 0
|
||||
20
mach/powerpc/libem/cfi8.s
Normal file
20
mach/powerpc/libem/cfi8.s
Normal file
@@ -0,0 +1,20 @@
|
||||
#
|
||||
! $Source$
|
||||
! $State$
|
||||
! $Revision$
|
||||
|
||||
#include "powerpc.h"
|
||||
|
||||
.sect .text
|
||||
|
||||
! Converts a 64-bit double into a 32-bit integer.
|
||||
!
|
||||
! Stack: ( double -- int )
|
||||
|
||||
.define .cfi8
|
||||
.cfi8:
|
||||
lfd f0, 0(sp)
|
||||
fctiwz f0, f0
|
||||
stfd f0, 0(sp)
|
||||
addi sp, sp, 4
|
||||
bclr ALWAYS, 0, 0 ! ...and return
|
||||
44
mach/powerpc/libem/cfu8.s
Normal file
44
mach/powerpc/libem/cfu8.s
Normal file
@@ -0,0 +1,44 @@
|
||||
#
|
||||
! $Source$
|
||||
! $State$
|
||||
! $Revision$
|
||||
|
||||
#include "powerpc.h"
|
||||
|
||||
.sect .text
|
||||
|
||||
! Converts a 64-bit double into a 32-bit unsigned integer.
|
||||
!
|
||||
! Stack: ( double -- uint )
|
||||
|
||||
.define .cfu8
|
||||
.cfu8:
|
||||
la(r3, .fd_00000000)
|
||||
lfd f0, 0(r3) ! f0 = 0.0
|
||||
|
||||
lfd f1, 0(sp) ! value to be converted
|
||||
|
||||
la(r3, .fd_FFFFFFFF)
|
||||
lfd f3, 0(r3) ! f3 = 0xFFFFFFFF
|
||||
|
||||
la(r3, .fd_80000000)
|
||||
lfd f4, 0(r3) ! f4 = 0x80000000
|
||||
|
||||
fsel f2, f1, f1, f0
|
||||
fsub f5, f3, f1
|
||||
fsel f2, f5, f2, f3
|
||||
fsub f5, f2, f4
|
||||
fcmpu cr0, f2, f4
|
||||
fsel f2, f5, f5, f2
|
||||
fctiwz f2, f2
|
||||
|
||||
stfd f2, 0(sp)
|
||||
addi sp, sp, 4
|
||||
|
||||
bclr IFTRUE, LT, 0
|
||||
|
||||
lwz r3, 0(sp)
|
||||
xoris r3, r3, 0x8000
|
||||
stw r3, 0(sp)
|
||||
|
||||
bclr ALWAYS, 0, 0
|
||||
37
mach/powerpc/libem/cif8.s
Normal file
37
mach/powerpc/libem/cif8.s
Normal file
@@ -0,0 +1,37 @@
|
||||
#
|
||||
! $Source$
|
||||
! $State$
|
||||
! $Revision$
|
||||
|
||||
#include "powerpc.h"
|
||||
|
||||
.sect .text
|
||||
|
||||
! Converts a 32-bit integer into a 64-bit double.
|
||||
!
|
||||
! Stack: ( int -- double )
|
||||
|
||||
.define .cif8
|
||||
.cif8:
|
||||
addi sp, sp, -4 ! make space for the double
|
||||
|
||||
lwz r3, 4(sp)
|
||||
xoris r3, r3, 0x8000
|
||||
stw r3, 4(sp) ! flip sign of integer value
|
||||
|
||||
addis r3, r0, 0x4330
|
||||
stw r3, 0(sp) ! set high word to construct a double
|
||||
|
||||
lfd f0, 0(sp) ! load value
|
||||
|
||||
la (r3, pivot)
|
||||
lfd f1, 0(r3) ! load pivot value
|
||||
fsub f0, f0, f1 ! adjust
|
||||
|
||||
stfd f0, 0(sp) ! save value again...
|
||||
bclr ALWAYS, 0, 0 ! ...and return
|
||||
|
||||
.sect .rom
|
||||
pivot:
|
||||
.data4 0x43300000
|
||||
.data4 0x80000000
|
||||
44
mach/powerpc/libem/csa.s
Normal file
44
mach/powerpc/libem/csa.s
Normal file
@@ -0,0 +1,44 @@
|
||||
#
|
||||
! $Source$
|
||||
! $State$
|
||||
! $Revision$
|
||||
|
||||
#include "powerpc.h"
|
||||
|
||||
.sect .text
|
||||
|
||||
! this is not a subroutine, but just a
|
||||
! piece of code that computes the jump-
|
||||
! address and jumps to it.
|
||||
! traps if resulting address is zero
|
||||
!
|
||||
! On entry: r3 = address of CSA table
|
||||
! r4 = value
|
||||
|
||||
.define .csa
|
||||
.csa:
|
||||
lwz r5, 0(r3) ! load default
|
||||
mtspr ctr, r5
|
||||
|
||||
lwz r5, 4(r3) ! fetch lower bound
|
||||
subf. r4, r5, r4 ! adjust value
|
||||
bcctr IFTRUE, LT, 0 ! jump to default if out of range
|
||||
|
||||
lwz r5, 8(r3) ! fetch range
|
||||
cmp cr0, 0, r4, r5
|
||||
bcctr IFTRUE, GT, 0 ! jump to default if out of range
|
||||
|
||||
addi r3, r3, 12 ! skip header
|
||||
rlwinm r4, r4, 2, 0, 31-2 ! scale value (<<2)
|
||||
b 1f
|
||||
1:
|
||||
lwzx r5, r3, r4 ! load target
|
||||
b 1f
|
||||
1:
|
||||
mtspr ctr, r5
|
||||
|
||||
or. r5, r5, r5 ! test it
|
||||
b 1f
|
||||
1:
|
||||
bcctr IFFALSE, EQ, 0 ! jump to target if non-zero
|
||||
b .trap_ecase ! otherwise trap
|
||||
39
mach/powerpc/libem/csb.s
Normal file
39
mach/powerpc/libem/csb.s
Normal file
@@ -0,0 +1,39 @@
|
||||
#
|
||||
! $Source$
|
||||
! $State$
|
||||
! $Revision$
|
||||
|
||||
#include "powerpc.h"
|
||||
|
||||
.sect .text
|
||||
|
||||
! this is not a subroutine, but just a
|
||||
! piece of code that computes the jump-
|
||||
! address and jumps to it.
|
||||
! traps if resulting address is zero
|
||||
!
|
||||
! On entry: r3 = address of CSB table
|
||||
! r4 = value
|
||||
|
||||
.define .csb
|
||||
.csb:
|
||||
lwz r5, 0(r3) ! load default
|
||||
mtspr ctr, r5
|
||||
|
||||
lwz r6, 4(r3) ! fetch count
|
||||
|
||||
1:
|
||||
or. r6, r6, r6 ! test count
|
||||
bcctr IFTRUE, EQ, 0 ! exit if zero
|
||||
addi r6, r6, -1 ! otherwise decrement
|
||||
|
||||
lwzu r7, 8(r3) ! fetch target index, increment pointer
|
||||
cmp cr0, 0, r4, r7 ! compare with value
|
||||
bc IFFALSE, EQ, 1b ! if not equal, go again
|
||||
|
||||
lwz r7, 4(r3) ! fetch target address
|
||||
mtspr ctr, r7
|
||||
|
||||
or. r7, r7, r7 ! test it
|
||||
bcctr IFFALSE, EQ, 0 ! jump to target if non-zero
|
||||
b .trap_ecase ! otherwise trap
|
||||
33
mach/powerpc/libem/cuf8.s
Normal file
33
mach/powerpc/libem/cuf8.s
Normal file
@@ -0,0 +1,33 @@
|
||||
#
|
||||
! $Source$
|
||||
! $State$
|
||||
! $Revision$
|
||||
|
||||
#include "powerpc.h"
|
||||
|
||||
.sect .text
|
||||
|
||||
! Converts a 32-bit unsigned integer into a 64-bit double.
|
||||
!
|
||||
! Stack: ( uint -- double )
|
||||
|
||||
.define .cuf8
|
||||
.cuf8:
|
||||
addi sp, sp, -4 ! make space for the double
|
||||
|
||||
addis r3, r0, 0x4330
|
||||
stw r3, 0(sp) ! set high word to construct a double
|
||||
|
||||
lfd f0, 0(sp) ! load value
|
||||
|
||||
la (r3, pivot)
|
||||
lfd f1, 0(r3) ! load pivot value
|
||||
fsub f0, f0, f1 ! adjust
|
||||
|
||||
stfd f0, 0(sp) ! save value again...
|
||||
bclr ALWAYS, 0, 0 ! ...and return
|
||||
|
||||
.sect .rom
|
||||
pivot:
|
||||
.data4 0x43300000
|
||||
.data4 0x00000000
|
||||
17
mach/powerpc/libem/fd_00000000.s
Normal file
17
mach/powerpc/libem/fd_00000000.s
Normal file
@@ -0,0 +1,17 @@
|
||||
#
|
||||
! $Source$
|
||||
! $State$
|
||||
! $Revision$
|
||||
|
||||
#include "powerpc.h"
|
||||
|
||||
.sect .rom
|
||||
|
||||
! Contains a handy double-precision zero. (Also works as a single-precision
|
||||
! zero.)
|
||||
|
||||
.define .fd_00000000, .fs_00000000
|
||||
.fd_00000000:
|
||||
.fs_00000000:
|
||||
.data4 0x00000000
|
||||
.data4 0x00000000
|
||||
15
mach/powerpc/libem/fd_80000000.s
Normal file
15
mach/powerpc/libem/fd_80000000.s
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
! $Source$
|
||||
! $State$
|
||||
! $Revision$
|
||||
|
||||
#include "powerpc.h"
|
||||
|
||||
.sect .rom
|
||||
|
||||
! Contains a handy double-precision 0x80000000.
|
||||
|
||||
.define .fd_80000000
|
||||
.fd_80000000:
|
||||
!float 2.147483648e+9 sz 8
|
||||
.data1 0101,0340,00,00,00,00,00,00
|
||||
15
mach/powerpc/libem/fd_FFFFFFFF.s
Normal file
15
mach/powerpc/libem/fd_FFFFFFFF.s
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
! $Source$
|
||||
! $State$
|
||||
! $Revision$
|
||||
|
||||
#include "powerpc.h"
|
||||
|
||||
.sect .rom
|
||||
|
||||
! Contains a handy double-precision 0xFFFFFFFF.
|
||||
|
||||
.define .fd_FFFFFFFF
|
||||
.fd_FFFFFFFF:
|
||||
!float 4.294967295e+9 sz 8
|
||||
.data1 0101,0357,0377,0377,0377,0340,00,00
|
||||
46
mach/powerpc/libem/fef8.c
Normal file
46
mach/powerpc/libem/fef8.c
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* $Source$
|
||||
* $State$
|
||||
* $Revision$
|
||||
*/
|
||||
|
||||
/* no headers allowed! */
|
||||
|
||||
/* Given a double, calculates the mantissa and exponent.
|
||||
*
|
||||
* This function is intended to be called internally by the code generator,
|
||||
* so the calling convention is odd.
|
||||
*/
|
||||
|
||||
int __fef8(double* fp)
|
||||
{
|
||||
double f = *fp;
|
||||
int exponent, sign;
|
||||
|
||||
if (f == 0.0)
|
||||
return 0;
|
||||
|
||||
if (f < 0.0)
|
||||
{
|
||||
sign = -1;
|
||||
f = -f;
|
||||
}
|
||||
else
|
||||
sign = 0;
|
||||
|
||||
exponent = 0;
|
||||
while (f >= 1.0)
|
||||
{
|
||||
f /= 2.0;
|
||||
exponent++;
|
||||
}
|
||||
|
||||
while (f < 0.5)
|
||||
{
|
||||
f *= 2.0;
|
||||
exponent--;
|
||||
}
|
||||
|
||||
*fp = (sign) ? -f : f;
|
||||
return exponent;
|
||||
}
|
||||
38
mach/powerpc/libem/fif8.s
Normal file
38
mach/powerpc/libem/fif8.s
Normal file
@@ -0,0 +1,38 @@
|
||||
#
|
||||
! $Source$
|
||||
! $State$
|
||||
! $Revision$
|
||||
|
||||
#include "powerpc.h"
|
||||
|
||||
.sect .text
|
||||
|
||||
! Multiplies two floats, and returns the fraction and integer.
|
||||
|
||||
.define .fif8
|
||||
.fif8:
|
||||
lfd f0, 8(sp)
|
||||
lfd f1, 0(sp)
|
||||
fmul f0, f0, f1
|
||||
fabs f1, f0 ! f0 = result
|
||||
|
||||
! The following chunk does f1 = floor(f1). See page 158 of the book.
|
||||
|
||||
mtfsfi cr7, 3 ! set rounding mode to -inf.
|
||||
mtfsb0 23
|
||||
fctid f2, f1
|
||||
fcfid f2, f2
|
||||
mcrfs cr7, cr5
|
||||
bc IFFALSE, 31, toobig
|
||||
fmr f1, f2
|
||||
toobig:
|
||||
|
||||
fabs f2, f1 ! f2 = fabs(f1)
|
||||
fsub f2, f2, f1
|
||||
stfd f2, 8(sp)
|
||||
|
||||
fneg f2, f1
|
||||
fsel f2, f0, f1, f2
|
||||
stfd f2, 0(sp)
|
||||
|
||||
bclr ALWAYS, 0, 0
|
||||
54
mach/powerpc/libem/los.s
Normal file
54
mach/powerpc/libem/los.s
Normal file
@@ -0,0 +1,54 @@
|
||||
#
|
||||
! $Source$
|
||||
! $State$
|
||||
! $Revision$
|
||||
|
||||
#include "powerpc.h"
|
||||
|
||||
.sect .text
|
||||
|
||||
! Loads a variable-sized structure onto the stack.
|
||||
!
|
||||
! r3 = size
|
||||
! r4 = address
|
||||
|
||||
.define .los
|
||||
.los:
|
||||
! These sizes are handled specially.
|
||||
|
||||
cmpi cr0, 0, r3, 1
|
||||
bc IFFALSE, GT, size1
|
||||
|
||||
cmpi cr0, 0, r3, 2
|
||||
bc IFFALSE, GT, size2
|
||||
|
||||
cmpi cr0, 0, r3, 4
|
||||
bc IFFALSE, GT, size4
|
||||
|
||||
! Variable-sized structure.
|
||||
|
||||
addi r3, r3, 3
|
||||
andi. r3, r3, ~3 ! align size
|
||||
|
||||
add r4, r4, r3 ! adjust address to top of block
|
||||
|
||||
srawi r3, r3, 2 ! convert size to the number of words
|
||||
mtspr ctr, r3
|
||||
|
||||
1:
|
||||
lwzu r5, -4(r4)
|
||||
stwu r5, -4(sp)
|
||||
bc DNZ, 0, 1b ! decrement CTR, jump if non-zero
|
||||
bclr ALWAYS, 0, 0
|
||||
|
||||
size1:
|
||||
lbz r3, 0(r4)
|
||||
b 1f
|
||||
size2:
|
||||
lhz r3, 0(r4)
|
||||
b 1f
|
||||
size4:
|
||||
lwz r3, 0(r4)
|
||||
1:
|
||||
stwu r3, -4(sp)
|
||||
bclr ALWAYS, 0, 0
|
||||
30
mach/powerpc/libem/pmfile
Normal file
30
mach/powerpc/libem/pmfile
Normal file
@@ -0,0 +1,30 @@
|
||||
-- $Source$
|
||||
-- $State$
|
||||
-- $Revision$
|
||||
|
||||
local d = ROOTDIR.."mach/powerpc/libem/"
|
||||
|
||||
libem_powerpc = acklibrary {
|
||||
outputs = {"%U%/libem-%PLATFORM%.a"},
|
||||
|
||||
ACKINCLUDES = {PARENT, d},
|
||||
|
||||
ackfile (d.."ret.s"),
|
||||
ackfile (d.."tge.s"),
|
||||
ackfile (d.."csa.s"),
|
||||
ackfile (d.."csb.s"),
|
||||
ackfile (d.."los.s"),
|
||||
ackfile (d.."sts.s"),
|
||||
ackfile (d.."aar4.s"),
|
||||
ackfile (d.."fef8.c"),
|
||||
ackfile (d.."fif8.s"),
|
||||
ackfile (d.."cif8.s"),
|
||||
ackfile (d.."cuf8.s"),
|
||||
ackfile (d.."cfi8.s"),
|
||||
ackfile (d.."cfu8.s"),
|
||||
ackfile (d.."fd_00000000.s"),
|
||||
ackfile (d.."fd_80000000.s"),
|
||||
ackfile (d.."fd_FFFFFFFF.s"),
|
||||
|
||||
install = pm.install("%BINDIR%lib/%PLATFORM%/libem.a"),
|
||||
}
|
||||
23
mach/powerpc/libem/powerpc.h
Normal file
23
mach/powerpc/libem/powerpc.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#
|
||||
! $Source$
|
||||
! $State$
|
||||
! $Revision$
|
||||
|
||||
! Declare segments (the order is important).
|
||||
|
||||
.sect .text
|
||||
.sect .rom
|
||||
.sect .data
|
||||
.sect .bss
|
||||
|
||||
#define IFFALSE 4
|
||||
#define IFTRUE 12
|
||||
#define ALWAYS 20
|
||||
#define DNZ 16
|
||||
|
||||
#define LT 0
|
||||
#define GT 1
|
||||
#define EQ 2
|
||||
#define OV 3
|
||||
|
||||
#define la(reg, val) addis reg, r0, <val; ori reg, reg, >val
|
||||
19
mach/powerpc/libem/ret.s
Normal file
19
mach/powerpc/libem/ret.s
Normal file
@@ -0,0 +1,19 @@
|
||||
#
|
||||
! $Source$
|
||||
! $State$
|
||||
! $Revision$
|
||||
|
||||
#include "powerpc.h"
|
||||
|
||||
.sect .text
|
||||
|
||||
! Standard boilerplate for returning from functions.
|
||||
|
||||
.define .ret
|
||||
.ret:
|
||||
lwz r0, 4(fp)
|
||||
mtspr lr, r0
|
||||
lwz r0, 0(fp) ! our stack frame becomes invalid as soon as...
|
||||
addi sp, fp, 8 ! ...we change sp
|
||||
or fp, r0, r0
|
||||
bclr ALWAYS, 0, 0
|
||||
57
mach/powerpc/libem/sts.s
Normal file
57
mach/powerpc/libem/sts.s
Normal file
@@ -0,0 +1,57 @@
|
||||
#
|
||||
! $Source$
|
||||
! $State$
|
||||
! $Revision$
|
||||
|
||||
#include "powerpc.h"
|
||||
|
||||
.sect .text
|
||||
|
||||
! Stores a variable-sized structure from the stack.
|
||||
!
|
||||
! r3 = size
|
||||
! r4 = address
|
||||
|
||||
.define .sts
|
||||
.sts:
|
||||
! These sizes are handled specially.
|
||||
|
||||
lwz r5, 0(sp)
|
||||
|
||||
cmpi cr0, 0, r3, 1
|
||||
bc IFFALSE, GT, size1
|
||||
|
||||
cmpi cr0, 0, r3, 2
|
||||
bc IFFALSE, GT, size2
|
||||
|
||||
cmpi cr0, 0, r3, 4
|
||||
bc IFFALSE, GT, size4
|
||||
|
||||
! Variable-sized structure.
|
||||
|
||||
addi r3, r3, 3
|
||||
andi. r3, r3, ~3 ! align size
|
||||
|
||||
srawi r3, r3, 2 ! convert size to the number of words
|
||||
mtspr ctr, r3
|
||||
|
||||
1:
|
||||
lwz r5, 0(sp)
|
||||
addi sp, sp, 4
|
||||
stw r5, 0(r4)
|
||||
addi r4, r4, 4
|
||||
|
||||
bc DNZ, 0, 1b ! decrement CTR, jump if non-zero
|
||||
bclr ALWAYS, 0, 0
|
||||
|
||||
size1:
|
||||
stb r5, 0(r4)
|
||||
b 1f
|
||||
size2:
|
||||
sth r5, 0(r4)
|
||||
b 1f
|
||||
size4:
|
||||
stw r5, 0(r4)
|
||||
1:
|
||||
addi sp, sp, 4
|
||||
bclr ALWAYS, 0, 0
|
||||
46
mach/powerpc/libem/tge.s
Normal file
46
mach/powerpc/libem/tge.s
Normal file
@@ -0,0 +1,46 @@
|
||||
#
|
||||
! $Source$
|
||||
! $State$
|
||||
! $Revision$
|
||||
|
||||
#include "powerpc.h"
|
||||
|
||||
.sect .rom
|
||||
|
||||
! Lookup table for tge.
|
||||
|
||||
.define .teq_table
|
||||
.teq_table:
|
||||
.data4 1 ! . .
|
||||
.data4 0 ! . G
|
||||
.data4 0 ! L .
|
||||
|
||||
.define .tne_table
|
||||
.tne_table:
|
||||
.data4 0 ! . .
|
||||
.data4 1 ! . G
|
||||
.data4 1 ! L .
|
||||
|
||||
.define .tgt_table
|
||||
.tgt_table:
|
||||
.data4 0 ! . .
|
||||
.data4 1 ! . G
|
||||
.data4 0 ! L .
|
||||
|
||||
.define .tge_table
|
||||
.tge_table:
|
||||
.data4 1 ! . .
|
||||
.data4 1 ! . G
|
||||
.data4 0 ! L .
|
||||
|
||||
.define .tlt_table
|
||||
.tlt_table:
|
||||
.data4 0 ! . .
|
||||
.data4 0 ! . G
|
||||
.data4 1 ! L .
|
||||
|
||||
.define .tle_table
|
||||
.tle_table:
|
||||
.data4 1 ! . .
|
||||
.data4 0 ! . G
|
||||
.data4 1 ! L .
|
||||
5
mach/powerpc/libend/.distr
Normal file
5
mach/powerpc/libend/.distr
Normal file
@@ -0,0 +1,5 @@
|
||||
pmfile
|
||||
edata.s
|
||||
em_end.s
|
||||
end.s
|
||||
etext.s
|
||||
5
mach/powerpc/libend/LIST
Normal file
5
mach/powerpc/libend/LIST
Normal file
@@ -0,0 +1,5 @@
|
||||
end_s.a
|
||||
edata.s
|
||||
em_end.s
|
||||
end.s
|
||||
etext.s
|
||||
9
mach/powerpc/libend/edata.s
Normal file
9
mach/powerpc/libend/edata.s
Normal file
@@ -0,0 +1,9 @@
|
||||
.sect .text
|
||||
.sect .rom
|
||||
.sect .data
|
||||
.sect .bss
|
||||
.define _edata
|
||||
.sect .data
|
||||
.align 4
|
||||
.sect .data
|
||||
_edata:
|
||||
24
mach/powerpc/libend/em_end.s
Normal file
24
mach/powerpc/libend/em_end.s
Normal file
@@ -0,0 +1,24 @@
|
||||
! $Source$
|
||||
! $State$
|
||||
! $Revision$
|
||||
|
||||
.sect .text
|
||||
.sect .rom
|
||||
.sect .data
|
||||
.sect .bss
|
||||
.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:
|
||||
7
mach/powerpc/libend/end.s
Normal file
7
mach/powerpc/libend/end.s
Normal file
@@ -0,0 +1,7 @@
|
||||
.sect .text
|
||||
.sect .rom
|
||||
.sect .data
|
||||
.sect .bss
|
||||
.define _end
|
||||
.sect .end ! only for declaration of _end, __end and endbss.
|
||||
_end:
|
||||
9
mach/powerpc/libend/etext.s
Normal file
9
mach/powerpc/libend/etext.s
Normal file
@@ -0,0 +1,9 @@
|
||||
.sect .text
|
||||
.sect .rom
|
||||
.sect .data
|
||||
.sect .bss
|
||||
.define _etext
|
||||
.sect .text
|
||||
.align 4
|
||||
.sect .text
|
||||
_etext:
|
||||
16
mach/powerpc/libend/pmfile
Normal file
16
mach/powerpc/libend/pmfile
Normal file
@@ -0,0 +1,16 @@
|
||||
-- $Source$
|
||||
-- $State$
|
||||
-- $Revision$
|
||||
|
||||
local d = ROOTDIR.."mach/powerpc/libend/"
|
||||
|
||||
libend_powerpc = 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"),
|
||||
}
|
||||
3
mach/powerpc/ncg/.distr
Normal file
3
mach/powerpc/ncg/.distr
Normal file
@@ -0,0 +1,3 @@
|
||||
mach.c
|
||||
mach.h
|
||||
table
|
||||
209
mach/powerpc/ncg/mach.c
Normal file
209
mach/powerpc/ncg/mach.c
Normal file
@@ -0,0 +1,209 @@
|
||||
/*
|
||||
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
||||
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
|
||||
#ifndef NORCSID
|
||||
static char rcsid[]= "$Id$" ;
|
||||
#endif
|
||||
|
||||
int framesize;
|
||||
|
||||
/*
|
||||
* machine dependent back end routines for the Zilog Z80.
|
||||
*/
|
||||
|
||||
con_part(int sz, word w)
|
||||
{
|
||||
while (part_size % sz)
|
||||
part_size++;
|
||||
if (part_size == TEM_WSIZE)
|
||||
part_flush();
|
||||
if (sz == 1) {
|
||||
w &= 0xFF;
|
||||
w <<= 8*(3-part_size);
|
||||
part_word |= w;
|
||||
} else if (sz == 2) {
|
||||
w &= 0xFFFF;
|
||||
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(word sz)
|
||||
{
|
||||
|
||||
if (argval != 4)
|
||||
fatal("bad icon/ucon size");
|
||||
fprintf(codefile,".data4 %s\n", str);
|
||||
}
|
||||
|
||||
#define CODE_GENERATOR
|
||||
#define IEEEFLOAT
|
||||
#define FL_MSL_AT_LOW_ADDRESS 1
|
||||
#define FL_MSW_AT_LOW_ADDRESS 1
|
||||
#define FL_MSB_AT_LOW_ADDRESS 1
|
||||
#include <con_float>
|
||||
|
||||
prolog(full nlocals)
|
||||
{
|
||||
int ss = nlocals + 8;
|
||||
fprintf(codefile, "addi sp, sp, %d\n", -ss);
|
||||
fprintf(codefile, "stw fp, %d(sp)\n", nlocals);
|
||||
fprintf(codefile, "mfspr r0, lr\n"
|
||||
"stw r0, %d(sp)\n", nlocals+4);
|
||||
fprintf(codefile, "addi fp, sp, %d\n", nlocals);
|
||||
|
||||
framesize = nlocals;
|
||||
}
|
||||
|
||||
mes(word type)
|
||||
{
|
||||
int argt ;
|
||||
|
||||
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 ;
|
||||
}
|
||||
}
|
||||
default :
|
||||
while ( getarg(any_ptyp) != sp_cend ) ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
|
||||
char *segname[] = {
|
||||
".sect .text",
|
||||
".sect .data",
|
||||
".sect .rom",
|
||||
".sect .bss"
|
||||
};
|
||||
|
||||
#ifdef REGVARS
|
||||
|
||||
static int savedregsi[32];
|
||||
static int numsaved;
|
||||
|
||||
/* Initialise regvar system for one function. */
|
||||
|
||||
i_regsave()
|
||||
{
|
||||
int i;
|
||||
|
||||
fprintf(codefile, "! i_regsave()\n");
|
||||
for (i=0; i<32; i++)
|
||||
savedregsi[i] = INT_MAX;
|
||||
numsaved = 0;
|
||||
}
|
||||
|
||||
/* Mark a register as being saved. */
|
||||
|
||||
regsave(const char* regname, full offset, int size)
|
||||
{
|
||||
int regnum = atoi(regname+1);
|
||||
savedregsi[regnum] = offset;
|
||||
numsaved++;
|
||||
|
||||
fprintf(codefile, "! %d is saved in %s\n", offset, regname);
|
||||
#if 0
|
||||
fprintf(codefile, "stwu %s, -4(sp)\n", regname);
|
||||
if (offset >= 0)
|
||||
fprintf(codefile, "lwz %s, %d(fp)\n", regname, offset);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Finish saving ragisters. */
|
||||
|
||||
void saveloadregs(const char* ops, const char* opm)
|
||||
{
|
||||
int offset = -(framesize + numsaved*4);
|
||||
int reg = 32;
|
||||
|
||||
/* Check for the possibility of a multiple. */
|
||||
|
||||
do
|
||||
{
|
||||
reg--;
|
||||
}
|
||||
while ((reg > 0) && (savedregsi[reg] != INT_MAX));
|
||||
if (reg < 31)
|
||||
{
|
||||
fprintf(codefile, "%s r%d, %d(fp)\n", opm, reg+1, offset);
|
||||
offset += (31-reg)*4;
|
||||
}
|
||||
|
||||
/* Saved everything else singly. */
|
||||
|
||||
while (reg > 0)
|
||||
{
|
||||
if (savedregsi[reg] != INT_MAX)
|
||||
{
|
||||
fprintf(codefile, "%s r%d, %d(fp)\n", ops, reg, offset);
|
||||
offset += 4;
|
||||
}
|
||||
reg--;
|
||||
}
|
||||
}
|
||||
|
||||
f_regsave()
|
||||
{
|
||||
int i;
|
||||
fprintf(codefile, "! f_regsave()\n");
|
||||
fprintf(codefile, "addi sp, sp, %d\n", -numsaved*4);
|
||||
|
||||
saveloadregs("stw", "stmw");
|
||||
|
||||
for (i=0; i<32; i++)
|
||||
if ((savedregsi[i] != INT_MAX) && (savedregsi[i] > 0))
|
||||
fprintf(codefile, "lwz r%d, %d(fp)\n", i, savedregsi[i]);
|
||||
}
|
||||
|
||||
/* Restore all saved registers. */
|
||||
|
||||
regreturn()
|
||||
{
|
||||
fprintf(codefile, "! regreturn()\n");
|
||||
saveloadregs("lwz", "lmw");
|
||||
}
|
||||
|
||||
/* Calculate the score of a given register. */
|
||||
|
||||
int regscore(full offset, int size, int type, int frequency, int totype)
|
||||
{
|
||||
int score;
|
||||
|
||||
fprintf(codefile, "! regscore(%ld, %d, %d, %d, %d)\n", offset, size, type, frequency, totype);
|
||||
|
||||
if (size != 4)
|
||||
return -1;
|
||||
|
||||
/* Per use: 6 bytes (on average)
|
||||
* Overhead in prologue: 4 bytes, plus 4 if a parameter
|
||||
* Overhead in epilogue: 0 bytes
|
||||
*/
|
||||
|
||||
score = frequency*6 - 4 - ((offset>=0) ? 4 : 0);
|
||||
fprintf(codefile, "! local at offset %d has regvar score %d\n", offset, score);
|
||||
return score;
|
||||
}
|
||||
|
||||
#endif
|
||||
30
mach/powerpc/ncg/mach.h
Normal file
30
mach/powerpc/ncg/mach.h
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
||||
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
||||
*/
|
||||
/* $Id$ */
|
||||
#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,%u\n",l,x);
|
||||
|
||||
#define cst_fmt "%d"
|
||||
#define off_fmt "%d"
|
||||
#define ilb_fmt "I%x_%x"
|
||||
#define dlb_fmt "_%d"
|
||||
#define hol_fmt "hol%d"
|
||||
|
||||
#define hol_off "%ld+hol%d"
|
||||
|
||||
#define con_cst(x) fprintf(codefile,".data4\t%ld\n",x)
|
||||
#define con_ilb(x) fprintf(codefile,".data4\t%s\n",x)
|
||||
#define con_dlb(x) fprintf(codefile,".data4\t%s\n",x)
|
||||
|
||||
#define fmt_id(sf, st) sprintf(st,"_%s",sf)
|
||||
|
||||
#define modhead ".sect .text; .sect .rom; .sect .data; .sect .bss\n"
|
||||
|
||||
#define BSS_INIT 0
|
||||
2160
mach/powerpc/ncg/table
Normal file
2160
mach/powerpc/ncg/table
Normal file
File diff suppressed because it is too large
Load Diff
23
mach/powerpc/pmfile
Normal file
23
mach/powerpc/pmfile
Normal file
@@ -0,0 +1,23 @@
|
||||
-- $Source$
|
||||
-- $State$
|
||||
|
||||
local d = ROOTDIR.."mach/powerpc/"
|
||||
|
||||
include (d.."libem/pmfile")
|
||||
include (d.."libend/pmfile")
|
||||
|
||||
mach_powerpc = group {
|
||||
ARCH = "powerpc",
|
||||
|
||||
proto_as,
|
||||
proto_ncg { ARCHDIR = "powerpc" },
|
||||
proto_top,
|
||||
-- ego_descr,
|
||||
}
|
||||
|
||||
support_powerpc = group {
|
||||
OPTIMISATION = "-O",
|
||||
|
||||
libem_powerpc,
|
||||
libend_powerpc,
|
||||
}
|
||||
1
mach/powerpc/top/.distr
Normal file
1
mach/powerpc/top/.distr
Normal file
@@ -0,0 +1 @@
|
||||
table
|
||||
20
mach/powerpc/top/table
Normal file
20
mach/powerpc/top/table
Normal file
@@ -0,0 +1,20 @@
|
||||
|
||||
/* 68020 desciptor table for ACK target optimizer */
|
||||
|
||||
MAXOP 3;
|
||||
|
||||
%%;
|
||||
|
||||
P, Q, R { TRUE };
|
||||
X, Y, Z { TRUE };
|
||||
|
||||
%%;
|
||||
|
||||
/* Whitespace is significant here! */
|
||||
|
||||
addi X, X, 0 -> ;
|
||||
addis X, X, 0 -> ;
|
||||
|
||||
or X, Y, Z : or. X, X, X -> or. X, Y, Z ;
|
||||
|
||||
%%;
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
*/
|
||||
/* $Id$ */
|
||||
|
||||
#undef NDEBUG
|
||||
#ifndef NDEBUG
|
||||
#define assert(x) if(!(x)) badassertion("x",__FILE__,__LINE__)
|
||||
#else
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
static char rcsid[] = "$Id$";
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "assert.h"
|
||||
#include "equiv.h"
|
||||
#include "param.h"
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -60,8 +60,6 @@ long con();
|
||||
#define get8() getc(emfile)
|
||||
|
||||
FILE *emfile;
|
||||
extern FILE *codefile;
|
||||
extern FILE *freopen();
|
||||
|
||||
int nextispseu,savetab1;
|
||||
int opcode;
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
static char rcsid[] = "$Id$";
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "assert.h"
|
||||
#include "param.h"
|
||||
#include "tables.h"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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%")
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
static char rcsid[] = "$Id$";
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "assert.h"
|
||||
#include "param.h"
|
||||
#include "tables.h"
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "assert.h"
|
||||
#include "param.h"
|
||||
#include "tables.h"
|
||||
|
||||
@@ -3,6 +3,7 @@ static char rcsid[] = "$Id$";
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "assert.h"
|
||||
#include "param.h"
|
||||
#include "tables.h"
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
static char rcsid[] = "$Id$";
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "assert.h"
|
||||
#include "param.h"
|
||||
#include "tables.h"
|
||||
|
||||
@@ -562,6 +562,8 @@ instr_p read_instr()
|
||||
return ip;
|
||||
}
|
||||
c = getc(inp);
|
||||
if (c == EOF)
|
||||
break;
|
||||
}
|
||||
ungetc(c,inp);
|
||||
*p = '\0';
|
||||
|
||||
@@ -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"); }
|
||||
1
mach/z80/top/.distr
Normal file
1
mach/z80/top/.distr
Normal file
@@ -0,0 +1 @@
|
||||
table
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user