C needs 16 bit adresses.....why? 
Author Message
 C needs 16 bit adresses.....why?

Hi,

A few days ago I read (I believe in this newsgroup) that a C compiler
for a 6502-based machine is NOT possible. supposed reason: such a compiler
needs 16 bits adresses. I was wondering why? can anyone explain this to me?
They also said there exist C compilers for say a C64 (which is a 6502
machine, or 6510) but they only generate p-code. I remember I programmed
my C64 in Pascal years ago. That compiler also generated p-code. I never
figured out what p-code is?

--
Martijn Dekker            +----------------------------------------------+
University of Amsterdam   |     member of PFF-software developers        |
department of Mathematics +----------------------------------------------+



Fri, 21 Feb 1997 22:29:53 GMT  
 C needs 16 bit adresses.....why?


Quote:
>Hi,

>A few days ago I read (I believe in this newsgroup) that a C compiler
>for a 6502-based machine is NOT possible. supposed reason: such a compiler
>needs 16 bits adresses. I was wondering why? can anyone explain this to me?

It would be possible but very inefficient since C doesn't translate well
to 6502 machine code. The 6502 does use 16 bit addresses (but only 8
bit offsets directly). The problem is that doing operations on quantities
larger than 8 bits requires a great deal of work on a 6502 and the standard
requires short and larger types to be at least 16 bits. Also the 6502's
native stack is only 256 bytes which means it couldn't be used for C
function frames. The 6502 has very limited registers and register operations
and no multiplication which again makes implementing C difficult. Then of
course there's only so much you can do with inefficient code in a 64K
address space!

Quote:
>They also said there exist C compilers for say a C64 (which is a 6502
>machine, or 6510) but they only generate p-code. I remember I programmed
>my C64 in pascal years ago. That compiler also generated p-code. I never
>figured out what p-code is?

p-code is a sort of intermediate code which is a simple sequence of tokens
which an interpreter can execute efficiently.

--
-----------------------------------------


-----------------------------------------



Sat, 22 Feb 1997 19:17:08 GMT  
 C needs 16 bit adresses.....why?

: A few days ago I read (I believe in this newsgroup) that a C compiler
: for a 6502-based machine is NOT possible. supposed reason: such a compiler
: needs 16 bits adresses. I was wondering why? can anyone explain this to me?
: They also said there exist C compilers for say a C64 (which is a 6502
: machine, or 6510) but they only generate p-code. I remember I programmed
: my C64 in pascal years ago. That compiler also generated p-code. I never
: figured out what p-code is?

Try to read the hp48 news group, people are talking about porting Gcc
C compiler to cross compile to Saturn assembly code, which is a 4_bit
machine but having 20_bit address lines.

p-code as an intermediate code generated by some Pascal compilers, it's
the basis of the UCSD p_system which has a Pascal,C and fortran compiler.
It's working on a stack machine and normally interpreted by a interpreter.
I read somewhere that p_code in used in Microsoft Words for Windows to
make sure the object code isn't so huge.

YUAN Feng
HP Singapore



Sat, 22 Feb 1997 09:38:16 GMT  
 C needs 16 bit adresses.....why?
: Hi,

: A few days ago I read (I believe in this newsgroup) that a C compiler
: for a 6502-based machine is NOT possible. supposed reason: such a compiler
: needs 16 bits adresses. I was wondering why? can anyone explain this to me?

A compiler on a 6502 machine needs 16 bit addresses because the
addressing modes on a 6502 are based on 16 bits (with an 8 bit mode, and
8 bit offsets only).  It's a hardware limitation that should be
transparent most of the time with a good compiler.  What a good compiler
cannot mask is the fact that this leaves you with only 64k of address
space.  A bit of a problem.

: They also said there exist C compilers for say a C64 (which is a 6502
: machine, or 6510) but they only generate p-code. I remember I programmed
: my C64 in pascal years ago. That compiler also generated p-code. I never
: figured out what p-code is?

This isn't true.  At least one comercial C compiler existed for the 64
(and there may have been a second as well) that compiler to machine
code.  I remember seeing a benchmark test for it, and it came in at about
50% more time for a prime number sieve that pure assembler (generally
agreed upon as the fastest type of code, although C can be written a lot
faster).

--
                        * N E W   I M P R O O V E D   . S I G *  
                                        w i t h  
                  * W E D N E S D A Y     S P A C I N G *   ( t m )
------------------------------------------------------------------------------
T h e   a g g r e g a t e   i n t e l l i g e n c e   o n   t h i s  
p l a n e t   i s   a   c o n s t a n t .   T h e   p o p u l a t i o  n ,
h o w e v e r ,   i s   g r o w i n g .                    
------------------------------------------------------------------------------
"O K ,   s o    h e ' s   n o t   t e r r i b l y   f e a r s o m .    
B u t   h e   c e r t a i n l y   c a u g h t   u s   b y  
s u r p r i s e !"
------------------------------------------------------------------------------



Sat, 22 Feb 1997 10:04:03 GMT  
 C needs 16 bit adresses.....why?
Hi!

Quote:

> I read somewhere that p_code in used in Microsoft Words for Windows to
> make sure the object code isn't so huge.

...and to make sure it is slow?!

-- __

\XX/  MIME & any PGP V2 supported * V:+49-2225-5870 \\ for algorithms!

Drink wet cement and get really stoned.



Mon, 24 Feb 1997 23:50:12 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Need Help: 16 bit to 32 bit

2. need an algorithm for converting 32-bit color to 16-bit color

3. 16 bit intergers on PC's - why?

4. Need help on 16 bit C compiler

5. 16-bit DAO-class needed

6. NEED Tracer / Monitor for DOS 16-bit Prg Calls

7. NEED Tracer / Monitor for DOS 16-bit Prg Calls

8. NEED Tracer / Monitor for DOS 16-bit Prg Calls

9. need to compile 16 bit code

10. VC - Need 16 bit compiler?

11. Need Visual C++ 4.0 or 1.52 for 16-bit Windows

12. Need help from MSVC guru's - GPF's with 16-bit

 

 
Powered by phpBB® Forum Software