23 votes

Using Clang to compile MS-DOS executables

There’s more to it than the linker, especially if you want to support real mode. You need a DOS C library, and a compiler which can output 16-bit code. If you want to produce binaries in anything ...
Stephen Kitt's user avatar
23 votes

Has there ever been a C compiler where using ++i was faster than i++?

I would answer "yes" on the basis that C compilers are (or at least appear) simple enough that plenty of amateurs and students will have a go at writing one, and at least some of them will ...
pndc's user avatar
  • 11.3k
15 votes

Gameboy Key Input Causes Crash

The modern compiler, or rather, the underlying libraries and build system that come with the compiling environment put some important code and/or data in the addresses FF80 and FF81 which you happily ...
Justme's user avatar
  • 32.1k
14 votes

Has there ever been a C compiler where using ++i was faster than i++?

A bit of tinkering in turns up a counter-example to the first statement. The below code in produces generates the below assembly when compiled with current GCC for x64 (https://godbolt.org/z/9naWMrjf3)...
doynax's user avatar
  • 241
13 votes
Accepted

How can I make the Microsoft C compiler for DOS emit a loop with an intermediate jump to continue?

It turns out that in MS C 5.1, in addition to all the /O... options there is one seemingly unrelated one that influences the optimizations for this compiler: /Zi. In the output of CL /help it is ...
neuviemeporte's user avatar
10 votes

Has there ever been a C compiler where using ++i was faster than i++?

Yes, but these are not semantically equivalent, of course, so we're not comparing apples to apples as it were. The HP/1000 is effectively an accumulator machine; its C compiler in the early 1980's ...
Erik Eidt's user avatar
  • 3,357
10 votes

Has there ever been a C compiler where using ++i was faster than i++?

I now can replace i++ with ++i. But does this make it faster? No, as in the form used both are to be reduced as a simple increment (sequence). There are no other operations done with either old or ...
Raffzahn's user avatar
  • 223k
9 votes

Are there any statistics or data showing how much more productive the C programming language is compared to x86 assembly language?

You'll never find a good single number for this sort of thing. One factor is that software time estimation is famously difficult in-general. Nobody has ever been good at estimating how long software ...
wrosecrans's user avatar
  • 2,264
9 votes

How to use external asm function in "vscode-amiga-debug" cross compiler?

There are two caveats involved when mixing C and assembly: You must tell the assembler that a symbol is meant to be externally visible (so that the linker can see it). With vasm, there are several ...
tofro's user avatar
  • 35k
9 votes

What do the pins D0-D7 on the Intel 8080 exactly signify?

Basics The data bus carries time multiplexed information: At the end of the first clock cycle (*1) of each machine cycle (*2) it always carries the status signals as described on Page 2-6. During the ...
Raffzahn's user avatar
  • 223k
8 votes

Has the “entry” keyword ever been implemented in C?

Per the document Rationale for American National Standard for Information Systems - Programming Language - C, which is an accompanying informative document to American National Standard for ...
dave's user avatar
  • 35.6k
8 votes

Are there any statistics or data showing how much more productive the C programming language is compared to x86 assembly language?

TL;DR The productivity gain is in the portability of the "C" language relative to Assembly. I think you might have an unintended caveat in the question in referencing a specific dialect of ...
Brian H's user avatar
  • 60.8k
8 votes

Has there ever been a C compiler where using ++i was faster than i++?

Did any compiler ever save the old value of a variable which is then never used (the old value)? For the C code int i; foo() { ++i; } bar() { i++; } the PDP-11 Unix V6 C compiler produces: .globl _i ...
Leo B.'s user avatar
  • 19.1k
8 votes

Has there ever been a C compiler where using ++i was faster than i++?

This was definitely the case for the Consulair C compiler for MacOS that I used for a few years in the mid 1980s. The 68000 processor has post-increment instructions, allowing you to calculate *p++ ...
gnasher729's user avatar
7 votes

Has there ever been a C compiler where using ++i was faster than i++?

It depends on the way the optimizer works. Basically, everything that uses SSA form internally will generate the same code, because both ++i and i++ generate a new register for the incremented value ...
Simon Richter's user avatar
7 votes
Accepted

Where to find the Cray arithmetic library?

As it turned out, the required arithmetic library is present in the filesystem, though at different place: # ls -l /usr/gen/lib/arith -rwxr-xr-- 1 bin bin 326028 Dec 4 2022 /usr/gen/lib/...
Serge.V's user avatar
  • 86
5 votes
Accepted

Gameboy Key Input Causes Crash

The issue was that the default address set for GBDK's OAM refresh function was 0xFF80 which conflicted with code. Luckily, GBDK offers a solution via LCC during the linker phase: lcc -Wl-g_refresh_OAM=...
OPM eStudio's user avatar
4 votes

Has there ever been a C compiler where using ++i was faster than i++?

I used to be a compiler writer, and had the opportunity to test this code on many CPUs, operating systems, and compilers. The only compiler I found that didn't optimize the i++ case (in fact, the ...
4 votes

Are there any statistics or data showing how much more productive the C programming language is compared to x86 assembly language?

Yes, there probably have been studies, but they are almost certainly in paywalled journals. You can find some links if you go to scholar.google.com and search for something like "programmer ...
don bright's user avatar
4 votes

Why does my MZ executable's BSS inflate by ~1,5KB after linking fopen() with MSC?

Turns out the MSC linker can put BSS data in an executable that is not referenced anywhere. I inspected the map file generated by the linker and found some public names (__bufin/__bufout/__buferr) ...
neuviemeporte's user avatar
3 votes
Accepted

Has the “entry” keyword ever been implemented in C?

According to Bell Labs in 1984, no The C Programmer's Handbook was published by AT&T Bell Laboratories in 1984. This is after the 1st edition of K&R, but before the ANSI standard and K&R ...
DrSheldon's user avatar
  • 16k
3 votes

Using Clang to compile MS-DOS executables

Digital Mars claims to compile for MS-DOS. I have used it for Windows and it is quite good and generate small and fast executables. This page might help too.
user10191234's user avatar
  • 1,945
2 votes

Are there any statistics or data showing how much more productive the C programming language is compared to x86 assembly language?

There's not single answer here because you have a number of compromises involved. Calling Conventions For example, in assembly language you get (roughly) three choices about how to pass parameters to ...
Jerry Coffin's user avatar
  • 4,842
2 votes

Are there any statistics or data showing how much more productive the C programming language is compared to x86 assembly language?

Assuming that the developers were equally good at both and the hardware would not be a limit in terms of RAM and performance requirements? Is it possible to estimate, say, if a project took 80 man-...
Raffzahn's user avatar
  • 223k
2 votes

Most modern C compilers targeting DOS 8086, running on DOS 8086 (16-bit)

(As I'm not allowed to comment, I have to "answer".) Turbo C/C++ or Turbo Pascal for DOS can still be downloaded from Embarcadero. I have working links at https://www.bttr-software.de/links/#...
bttr's user avatar
  • 21
2 votes

Why does my MZ executable's BSS inflate by ~1,5KB after linking fopen() with MSC?

TL;DR: Linker Links Without Judgeing A linker doesn't know about programs and functions and even less about usage. A linker combines objects, including all segments and resolving open relation. If a ...
Raffzahn's user avatar
  • 223k
1 vote

Has there ever been a C compiler where using ++i was faster than i++?

The knee jerk to go to ++i might be there just to avoid confusion. For any given person one of those is going to feel like it returns the correct value and the other like it doesn't. A mathematical ...
davolfman's user avatar
  • 663
1 vote

Is this the reason why fread/fwrite has 2 `size_t` arguments?

The Standard is silent with regard to what happens if the amount of data that is immediately available to be read is smaller than total the request size, but not a multiple of the record size. The ...
supercat's user avatar
  • 36.3k

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