Since the 6502 has no inherent sound capability, you must be
trying to emulate the entire system containing the 6502?
This is a customized version of the 6502 made by Ricoh that has the audio built-in.

Well... there's problems...

In order to wrote a compiler for J, you'd need to have some
target system it would be generating code for.  At first glance,
C would seem like a good target -- C is widely available, and
does not impose too many explicit requirements on the generated
code.  Unfortunately, J's semantics do not map very well onto C.

For example, consider the following C code:
  int multiply(int x, int y) {
     return x*y;
  }

The result of executing this code is undefined, for arbitrary values
x and y.  (You can get defined results by using unsigned int, but
the definition for that case is... less than completely useful for
implementing J's semantics for multiplying integers.)

One workaround involves the use of double instead of int, but that
can get obscure on a system like amd64 where int identity(int y) {
    double t= (double) y;
    return (int) t;
  }
the result of identity(x) will not always be x.

The other approach -- targetting each machine's assembly (or
machine) language directly -- is perhaps natural for a compiler,
but... is an even bigger project than targetting something like
C.

My approach would be to use a J Variable class. The J Variable would be a byte buffer exactly like the J representation.

With operator overloading, I would do something like :

operator * (JVar x, JVar y)
{
  evaluate variable type of x (could be boolean, int, string, double...)
  evaluate variable type of y
  if there's a way to multiply type x by type y. (two numeric type)
   {
(type result) = find the resulting type... bool * int = int..... bool * double = double...etc...
       (type result) r;
       return r = x.value() * y.value();
   }
  else
   {
       printf ("|domain error\n");
       printf ("|\t%s\t%s\n", x.name(), y.name());
   }
}


----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to