Replied: Wed, 09 Feb 1994 10:04:22 -0600
Replied: "kjetilja@stud.cs.uit.no (Kjetil Jacobsen) "
Return-Path: kjetilja@stud.cs.uit.no
Received: from cs.wisc.edu by primost.cs.wisc.edu; Wed, 9 Feb 94 08:59:56 -0600
Received: from hpserv0.cs.UiT.No by cs.wisc.edu; Wed, 9 Feb 94 08:59:39 -0600
Received: from lglab11.cs.UiT.No by hpserv0.cs.uit.no (1.37.109.4/Task/HJ-5)
	id AA02365; Wed, 9 Feb 94 15:59:37 +0100
Received: by lgserv1.cs.uit.no (1.37.109.8/Task/HJ-5)
	id AA03260; Wed, 9 Feb 1994 15:59:35 +0100
Date: Wed, 9 Feb 1994 15:59:35 +0100
From: kjetilja@stud.cs.uit.no (Kjetil Jacobsen)
Message-Id: <9402091459.AA03260@lgserv1.cs.uit.no>
Disclaimer: This message was sent from, not by, the University of Tromsoe
To: larus
Subject: SPIM_and_Amiga

Here's a sample of the changes necessary to make SPIM (and XSPIM) compile
on the Amiga. You will need gcc 2.3.3 (maybe other versions will work),
a lex derivative and libnet.a to link with. Thus you need ixemul v39.47 too.

To run SPIM you need to assign SPIM: to some spot where SPIM can find the
trap.handler (usually spim:lib/trap.handler). This can be specified in the
makefile (which is supplied at the bottom of this text)

- Kjetil Jacobsen (kjetilja@stud.cs.uit.no)


diff -c spim.amiga//cl-except.h spim.orig//cl-except.h
*** spim.amiga//cl-except.h	Mon Feb  7 00:34:34 1994
--- spim.orig//cl-except.h	Mon May 17 22:36:02 1993
***************
*** 20,30 ****
     PURPOSE.
  */
  
- #ifndef amiga
  #include <syscall.h>
- #else
- #include <sys/syscall.h>
- #endif
  #include <signal.h>
  
  /* gdb-style for tracking each signal */
--- 20,26 ----
diff -c spim.amiga//cl-except.h spim.orig//cl-except.hspim.amiga//mips-syscall.c spim.orig//mips-syscall.c
*** spim.amiga//mips-syscall.c	Tue Feb  8 23:32:08 1994
--- spim.orig//mips-syscall.c	Tue Jan 18 04:22:28 1994
***************
*** 36,41 ****
--- 36,42 ----
  #include <limits.h>
  #endif
  
+ 
  #include "spim.h"
  #include "inst.h"
  #include "mem.h"
***************
*** 848,860 ****
    arg1 = SYSCALL_ARG (REG_V0,arg1, REG_A1);
    arg2 = SYSCALL_ARG (REG_V0,arg2, REG_A2);
    arg3 = SYSCALL_ARG (REG_V0,arg3, REG_A3);
- 
- #ifdef amiga /* There's no reason for us to get here, just over-anxious :) */ 
-   printf("Amiga warning: Unsupported syscall\n");
-   return -1;
- #else
    R[REG_RES] = syscall (R[REG_V0], arg0, arg1, arg2, arg3);
! #endif
    /* See if an error has occurred during the system call. If so, the
       libc wrapper must be notifified by setting register 7 to be less than
       zero and the return value should be errno. If not, register 7 should
--- 849,856 ----
    arg1 = SYSCALL_ARG (REG_V0,arg1, REG_A1);
    arg2 = SYSCALL_ARG (REG_V0,arg2, REG_A2);
    arg3 = SYSCALL_ARG (REG_V0,arg3, REG_A3);
    R[REG_RES] = syscall (R[REG_V0], arg0, arg1, arg2, arg3);
! 
    /* See if an error has occurred during the system call. If so, the
       libc wrapper must be notifified by setting register 7 to be less than
       zero and the return value should be errno. If not, register 7 should
diff -c spim.amiga//mips-syscall.c spim.orig//mips-syscall.cspim.amiga//spim-utils.c spim.orig//spim-utils.c
*** spim.amiga//spim-utils.c	Thu Feb  3 22:40:12 1994
--- spim.orig//spim-utils.c	Tue Jan 18 04:22:50 1994
***************
*** 524,530 ****
  #endif
    fmt = va_arg (args, char *);
  
! #if defined(mips) || defined(amiga)
    vfprintf (stderr, fmt, args);
  #else
    _doprnt (fmt, args, stderr);
--- 524,530 ----
  #endif
    fmt = va_arg (args, char *);
  
! #ifdef mips
    vfprintf (stderr, fmt, args);
  #else
    _doprnt (fmt, args, stderr);
diff -c spim.amiga//spim-utils.c spim.orig//spim-utils.cspim.amiga//spim.c spim.orig//spim.c
*** spim.amiga//spim.c	Wed Feb  9 15:39:05 1994
--- spim.orig//spim.c	Tue Jan 18 15:47:20 1994
***************
*** 1183,1189 ****
    fmt = va_arg (args, char *);
  #endif
  
! #if defined(mips) || defined(amiga)
    vfprintf (stderr, fmt, args);
  #else
    _doprnt (fmt, args, stderr);
--- 1183,1189 ----
    fmt = va_arg (args, char *);
  #endif
  
! #ifdef mips
    vfprintf (stderr, fmt, args);
  #else
    _doprnt (fmt, args, stderr);
***************
*** 1218,1224 ****
  
    console_to_spim ();
  
! #if defined(mips) || defined(amiga)
    vfprintf (stderr, fmt, args);
  #else
    _doprnt (fmt, args, stderr);
--- 1218,1224 ----
  
    console_to_spim ();
  
! #ifdef mips
    vfprintf (stderr, fmt, args);
  #else
    _doprnt (fmt, args, stderr);
***************
*** 1266,1272 ****
        console_to_spim ();
      }
  
! #if defined(mips) || defined(amiga)
    if (f != 0)
      vfprintf (f, fmt, args);
    else
--- 1266,1272 ----
        console_to_spim ();
      }
  
! #ifdef mips
    if (f != 0)
      vfprintf (f, fmt, args);
    else

-------------------------Makefile.amiga (gcc)-------------------------
#
# SPIM S20 MIPS Simulator.
# Makefile for SPIM.
# Copyright (C) 1990-1992 by James Larus (larus@cs.wisc.edu).
# ALL RIGHTS RESERVED.
#
# SPIM is distributed under the following conditions:
#
#   You may make copies of SPIM for your own use and modify those copies.
#
#   All copies of SPIM must retain my name and copyright notice.
#
#   You may not sell SPIM or distributed SPIM in conjunction with a commerical
#   product or service without the expressed written consent of James Larus.
#
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE.
#
# NOTES ON AMIGA VERSION:
#   Amiga modifications by Kjetil Jacobsen / Ymir's Thoughts
#   The distributed binaries were compiled with gcc2.3.3, using gmake and flex.
#   You need ixemul v39.47 (or later) to run SPIM.
#   This Amiga version is based on spim/xspim version 5.4
#
# To make spim, type:
#
#   make spim
#
# To make xpsim, type:
#
#   make xspim
#

#
# To make cl-spim (cycle level SPIM simulator), type:
#
#   make cl-spim
#
# To make cl-xpsim, type:
#
#   make cl-xspim
#

# This is amiga specific, so it's got an unique vesion number.
ENDIAN = BIGENDIAN
AMIGAVER = 1

# Full path for directory containing X11 include files:
X_INCLUDE_DIR = gcc:include/x11r5

# Location of X11 root directory.
TOPDIR = gcc:


# Full path for directory that will hold the trap handler file:
TRAP_DIR = spim:lib

# Full path for the directory that will hold the executable files:
BIN_DIR = bin:

# Full path for the directory that will hold the man files:
MAN_DIR = doc:

# Full path for the trap handler file:
TRAP_PATH = \"$(TRAP_DIR)/trap.handler\"

# If you have flex, use it instead of lex.  If you use flex, define this
# variable and set LEXFLAGS.
MYLEX = flex

# SPIM needs flex's -I flag since the scanner is used interactively.
# You can set the -8 flag so that funny characters do not hang the scanner.
LEXFLAGS = -I -8


# If you use lex, set the variables this way:
#MYLEX = lex
#LEXFLAGS =


# Size of the segments when spim starts up (data segment must be >= 64K).
# (These sizes are fine for most users since SPIM dynamically expands
# the memory as necessary.)
MEM_SIZES = -DTEXT_SIZE=65536 -DDATA_SIZE=131072 -DK_TEXT_SIZE=65536


#
# End of parameters
#


CC = gcc
OPTFLAGS = 
AMIFLAGS = -Damiga -D_ANSI_SOURCE
IFLAGS = -Igcc:include
CL_FLAG =
CFLAGS = -c $(OPTFLAGS) $(IFLAGS) -D$(ENDIAN) $(AMIFLAGS) $(MEM_SIZES) -I$(X_INCLUDE_DIR) $(EXTRA_C_FLAGS) $(CL_FLAG)
YFLAGS = -d
YCFLAGS =
LDFLAGS = -lnet -lamy -lm
XLDFLAGS = -L$(TOPDIR)/lib -lXaw -lXmu -lXt -lXext -lX11


# lex.yy.c is usually compiled with -O to speed it up.

LEXCFLAGS = -O

OBJS = spim-utils.o run.o mem.o inst.o data.o sym-tbl.o y.tab.o lex.yy.o \
       read-aout.o mips-syscall.o


XOBJS = windows.o buttons.o


CLOBJS = cl-cache.o cl-except.o cl-tlb.o cl-cycle.o


spim:	$(OBJS) spim.o
	$(CC) -o spim $(OBJS) spim.o $(LDFLAGS)

xspim:	$(OBJS) $(XOBJS) xspim.o
	$(CC) -o xspim $(OBJS) $(XOBJS) xspim.o $(XLDFLAGS) $(LDFLAGS) 


cl-spim: $(OBJS) $(CLOBJS) spim.o
	$(CC) -o cl-spim $(OBJS) $(CLOBJS) spim.o $(LDFLAGS)

cl-xspim: $(OBJS) $(CLOBJS) $(XOBJS) xspim.o
	$(CC) -o cl-xspim $(OBJS) $(CLOBJS) $(XOBJS) xspim.o $(XLDFLAGS) $(LDFLAGS) 


TAGS:	*.c *.h *.l *.y
	etags *.l *.y *.c *.h


clean:
	delete spim xspim cl-spim cl-xspim *.o y.output *.bak core a.out \
	  .spim-made .cl-spim-made \
	  spim.tar.* spim.aux spim.log spim.dvi spim.shar*

install: spim xspim
	install -c -s  spim $(BIN_DIR)
	install -c -s  xspim $(BIN_DIR)
	install -c -m 0444 trap.handler $(TRAP_DIR)
	install -c -m 0444 spim.man $(MAN_DIR)
	install -c -m 0444 xspim.man $(MAN_DIR)

very-clean: clean
	delete y.tab.h y.tab.c lex.yy.c spim.tar* Documentation/spim.ps


SRC = spim-utils.c run.c mem.c inst.c data.c sym-tbl.c y.tab.o lex.yy.o \
       read-aout.c mips-syscall.c

XSRC = windows.c buttons.c


#
# Dependences not handled well by makedepend:
#

spim-utils.o: spim-utils.c spim.h inst.h mem.h reg.h y.tab.h 
	$(CC) $(CFLAGS) -DDEFAULT_TRAP_HANDLER=$(TRAP_PATH) -DSPIM_VERSION=$(AMIGAVER) -c spim-utils.c


y.tab.h: y.tab.c

y.tab.c: parser.y
	yacc $(YFLAGS) parser.y

y.tab.o: y.tab.c
	$(CC) $(CFLAGS) $(YCFLAGS) -c y.tab.c


lex.yy.c: scanner.l
	$(MYLEX) $(LEXFLAGS) scanner.l

lex.yy.o: lex.yy.c
	$(CC) $(LEXCFLAGS) -c lex.yy.c

