🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by James Clark Mon, 22 May 1989 12:21
g++ 1.35.0 / i386g
#2025
Author: James Clark
Date: Mon, 22 May 1989 12:21
142 lines
3540 bytes
I brought up g++ 1.35.0 on a 386 machine running SVR3.2 (386/ix
version 2.0.1) using COFF encapsulation (I used config.g++ i386g). I
had to make one small change to newld.c

*** newld.c.distrib	Sun May 21 17:02:18 1989
--- newld.c	Sun May 21 17:12:02 1989
***************
*** 255,261 ****
  #define INITIALIZE_HEADER outheader.a_machtype = HP9000S200_ID
  #endif
  #if defined(i386) && !defined(sequent)
! #define INITIALIZE_HEADER outheader.a_machtype = M_386
  #endif
  
  #ifdef is68k
--- 255,261 ----
  #define INITIALIZE_HEADER outheader.a_machtype = HP9000S200_ID
  #endif
  #if defined(i386) && !defined(sequent)
! #define INITIALIZE_HEADER N_SET_MACHTYPE (outheader, M_386)
  #endif
  
  #ifdef is68k

(This is how the current version of ld.c in binutils defines it).

There seems to be a register allocation problem.  I compiled this using just -g.

class symbol {
  static const char **table;
  static int table_used;
  static int table_size;
  static char *block;
  static int block_size;
  const char *s;
public:
  symbol(const char *p, int how = 0);
  symbol();
  unsigned hash();
  operator ==(symbol);
  operator !=(symbol);
};

inline symbol::symbol() : s(0)
{
}

inline symbol::operator==(symbol p)
{
  return s == p.s;
}

inline symbol::operator!=(symbol p)
{
  return s != p.s;
}

inline unsigned symbol::hash()
{
  return unsigned(s);
}

struct association {
  symbol s;
  void *v;
  association() :  v(0) {}
};

class dictionary {
  int size;
  int used;
  double threshold;
  double factor;
  association *table;
  void rehash(int);
public:
  dictionary(int);
  void *lookup(symbol s, void *v=0); // returns value associated with key
};

static int is_good_size(int p);

void *dictionary::lookup(symbol s, void *v = 0)
{
  for (int i = s.hash() % size; 
       table[i].v != 0;
       i == 0 ? i = size - 1: --i)
    if (s == table[i].s) {
      if (v != 0) {
	void *temp = table[i].v;
	table[i].v = v;
	return temp;
      }
      else
	return table[i].v;
    }
  ++used;
  table[i].v = v;
  table[i].s = s;
  if ((double)used/(double)size >= threshold || used + 1 >= size) {
    int old_size = size;
    size = int(size*factor);
    while (!is_good_size(size))
      ++size;
    association *old_table = table;
    table = new association[size];
    used = 0;
    for (i = 0; i < old_size; i++)
      if (old_table[i].v != 0)
	(void)lookup(old_table[i].s, old_table[i].v);
  }
  return 0;
}

It generates incorrect assembler code for line 74:

    size = int(size*factor);

Here's the assembler code that's incorrect:

	.stabd 68,0,73
	movl 8(%ebp),%eax
	movl (%eax),%edx
	movl %edx,-16(%ebp)
	.stabd 68,0,74
	fildl (%eax)
	fstpl -88(%ebp)
	fldl -88(%ebp)
	fmull 16(%eax)
	fstpl -88(%ebp)
	pushl -84(%ebp)
	pushl -88(%ebp)
	call ___fixdfsi
	leal 8(%esp),%esp
	movl 8(%ebp),%eax  <--- eax isn't available here: it holds the return value
	movl %eax,(%eax)
	.stabd 68,0,75

If you need the rest of the assembler code, I can easily send it.

James Clark
jjc@jclark.uucp
Thread Navigation

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

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

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

Back to All Threads