103 votes
Accepted

Why do C to Z80 compilers produce poor code?

Quite often people don't know how to use the compilers or don't understand fully the consequences of code they write. There is optimization going on in the Z80 C compilers but it's not as complete as,...
aralbrec's user avatar
  • 1,146
78 votes
Accepted

Is it possible to make a ROM converter?

Note: This answer mainly focuses on the NES, since that's what I'm most familiar with. Yes; this is called static recompilation or static binary translation, and it is theoretically possible -- ...
NobodyNada's user avatar
  • 5,434
76 votes
Accepted

How was C ported to architectures that had no hardware stack?

How was C ported to architectures that had no hardware stack? Simply by implementing a dynamic memory management for subroutine calling, parameter passing and local memory. If there is a known ...
Raffzahn's user avatar
  • 218k
65 votes

Why do C to Z80 compilers produce poor code?

If you try translating C into Z80, you'll see that Z80 index registers and stack don't behave quite as you expect. So, let us begin with Arrays Suppose you have a standard C construction int c[10]; ...
introspec's user avatar
  • 4,152
59 votes
Accepted

Did any compiler fully use Intel x87 80-bit floating point?

Yes. For example, the C math library has had full support for long double, which on x87 was 80 bits wide, since C99. Previous versions of the standard library supported only the double type. ...
Davislor's user avatar
  • 8,667
58 votes

Why do C to Z80 compilers produce poor code?

The main downside of "historic" CPU's (non?)-suitability for C programs is the lack of capability to form more than one register into an address without using the ALU. Most more modern CPUs can use ...
tofro's user avatar
  • 34k
58 votes

What languages are better fit for generating efficient code for 8-bit CPU's than C?

One language that was popular on early 8-bit micros, including those that used the 6502 CPU, was Forth. Forth is exceptionally good for this use case, and superior to a C compiler, because Forth can ...
Brian H's user avatar
  • 60.5k
56 votes

Did any compiler fully use Intel x87 80-bit floating point?

TL:DR: Yes, most C/C++ compilers other than MSVC expose an 80-bit IEEE754 Extended Precision format (x87, 68881) as long double, and some implementations of other languages have it as REAL10 or ...
Peter Cordes's user avatar
  • 3,197
55 votes
Accepted

When did compilers start generating optimized code that runs faster than an average programmer's assembly code?

As a former professional assembly language programmer I would say that by the late 1980s a number of C compilers had become available whose output was as good as something a skilled assembler ...
Cecil Ward's user avatar
55 votes

When if ever was the C language 'int' size altered from the host machine word (register) size into a literal 32 bit size?

The C standard of the language doesn't mandate a 32-bit int. It defines sizeof(char) = 1 and sizeof(long long) ≥ sizeof(long) ≥ sizeof(int) ≥ sizeof(short) ≥ sizeof(char) It also mandates that the ...
Patrick Schlüter's user avatar
46 votes
Accepted

Which tools were used to create the C language?

C didn't spring into being suddenly, but was created by slowly modifying the B language--which was written in itself. Therefore you might say that C was always written in itself, but at first it was ...
Wayne Conrad's user avatar
  • 2,706
43 votes

How to get started writing C for the IBM PC in 1980-81

So you want to write a C program for the IBM PC before the first C compiler for the PC is released. How do you go about it? There are three options I can see: Write your own C compiler Use a cross ...
JeremyP's user avatar
  • 11.6k
42 votes

Why do C to Z80 compilers produce poor code?

Simple answers one easily gets to this question are The Z80 Sucks and C Sucks - depending on the side someone is on. While they are of course, untrue (*1), there are real issues. A major argument for ...
Raffzahn's user avatar
  • 218k
40 votes

When and why did high-level language compilers start targeting assembly language rather than machine code?

why did high-level language compilers start targeting assembly language rather than machine code Well, the answer is probably: to avoid developing a high level language to binary converter for each ...
Jean-François Fabre's user avatar
40 votes

When did compilers start generating optimized code that runs faster than an average programmer's assembly code?

For a start, it is widely known that FORTRAN II for the IBM 1401 series was specifically designed to generate high enough quality object code to make assembly programming of numerical routines ...
Chromatix's user avatar
  • 16.8k
39 votes

Why couldn't early C compilers handle variable declarations between statements?

Some early compilers, such as the ones described in the 1974 C reference manual, required that all automatic object declarations within a function precede the first executable code therein. Imposing ...
supercat's user avatar
  • 35.7k
34 votes
Accepted

Were Windows 3.x applications dependent upon 80286 instructions?

Windows 3.x wasn’t “stuck to the 80286 platform”: Windows 3.0 still supported real mode on 8086 processors. The requirement for a 286 at the platform level only came with Windows 3.1. As far as ...
Stephen Kitt's user avatar
31 votes
Accepted

How to get started writing C for the IBM PC in 1980-81

One option might have been using “Small C,” which was published in 1980 in Dr. Dobb's Journal magazine. Initially it generated code for the 8080, but was adapted for a few other CPU's. It was adapted ...
mannaggia's user avatar
  • 3,264
31 votes

Why were nested functions excluded from B and C?

Keeping all functions as a flat array/list that can simply be iterated over does make life a lot simpler for a compiler writer. No nested functions allows that, and also resolves some forms of the ...
RETRAC's user avatar
  • 13.6k
30 votes

How to get started writing C for the IBM PC in 1980-81

The BDS C compiler was released in 1979, ran on CP/M, and was capable of generating code for the Intel 8080 microprocessor. (It also ran on and generated code for the Zilog Z80, but that's not ...
Cody Gray - on strike's user avatar
29 votes
Accepted

How were bugs reported for compilers that were shipped on floppy disks?

In the early PC days, letter-writing was still common, and that was at first the main channel of communication to report issues. When CompuServe took off that became the preferred forum, at least in ...
Stephen Kitt's user avatar
29 votes

When did compilers start generating optimized code that runs faster than an average programmer's assembly code?

Compilers started generating more efficient code than the average assembler programmer the moment that architectures became so complex that the assembler programmer wasn't been able to cope with all ...
mcleod_ideafix's user avatar
27 votes
Accepted

Native C compiler for Sinclair ZX Spectrum

If you want it contemporary, use HiSoft C. Back then the standard compiler and compatible with other HiSoft Tools. For a more up to date and rather comfortable (cross) compiler Z88dk with its ...
Raffzahn's user avatar
  • 218k
27 votes

What languages are better fit for generating efficient code for 8-bit CPU's than C?

C can be greatly improved as a language for the 6502 and Z80, as well as micros like the PIC and 8051, if one abandons the notion that implementations must provide for recursive subroutine calls, and ...
supercat's user avatar
  • 35.7k
26 votes

Did any compiler fully use Intel x87 80-bit floating point?

I worked for Borland back in the days of the 8086/8087. Back then, both Turbo C and Microsoft C defined long double as an 80-bit type, matching the layout of Intel's 80-bit floating-point type. Some ...
Pete Becker's user avatar
26 votes
Accepted

Were there cross-compiler online services for the public?

I too doubt the premise of the question, on several counts: The notion of using a teletype for access to remote compiling services seems ill-advised, since punching the object module on paper tape (...
dave's user avatar
  • 35.2k
25 votes
Accepted

What was the first Lisp implementation that could generate machine code?

The first LISP compiler was implemented very early in the life of the first LISP, LISP I for the IBM 704. The LISP I Compiler From the LISP I Programmer's Manual (March 1, 1960) section 4.2, "...
cjs's user avatar
  • 25k
24 votes
Accepted

How much benefit should be expected on a more advanced compiler for z80/r800 based computers?

Places where LLVM will provide no benefit, and may reduce performance: The Z80 has no CPU cache, accessing memory directly instead. Any optimizations based around increasing cache efficiency (eg. ...
Mark's user avatar
  • 8,547
24 votes

What languages are better fit for generating efficient code for 8-bit CPU's than C?

I know that the Z80 and the 6502 are very different, but I was wondering if there are any languages on a higher level than assembly which can generate compact and efficient 8-bit machine code by ...
Raffzahn's user avatar
  • 218k

Only top scored, non community-wiki answers of a minimum length are eligible