Questions tagged [c]

The C programming language: its historical aspects and use on/targetting retro platforms.

Filter by
Sorted by
Tagged with
4 votes
1 answer
299 views

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

I would like to write functions in assembly along with the c source code, but somehow I can't find the syntax. I tried e.g. in the fname.asm file (simplified): fill_bmap: rts In the fname.c ...
30 votes
3 answers
5k views

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

I'm looking for the most recent versions of modern C compilers which were/are targeting DOS 8086, also running on DOS 8086 (16-bit). I'm mostly interested in production-ready C compilers, rather than ...
1 vote
0 answers
236 views

DirectX 8 Win32 GUI Not Appearing/Flickering While Running

I am programming a game with DirectX 8, and I am trying to use the GUI options that are provided by the Win32 window that I am using. However, when I try to render a button or, in this case, a textbox ...
5 votes
1 answer
278 views

Where to find the Cray arithmetic library?

Given a Cray simulator and a pre-installed UniCOS HD image, attempting to compile Steven Pemberton's ENQUIRE (literally, the second thing to try after "Hello, Cray") fails with CC-1153 cc: ...
15 votes
2 answers
848 views

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

I posted this question on StackOverflow, but someone commented and advised me to publish it here. Here the terms K&R1 and K&R2 refer to a book written by the C creators about the language. K&...
29 votes
10 answers
10k views

Was there any technological reason that C was designed to return only a single thing from a function?

I'm asking specifically about C, not about other contemporary languages, but if the reason is "that's how B did it" or something please assume I'm talking about "in the lineage of C&...
15 votes
4 answers
3k views

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

It just came to me that, the C standard I/O functions fread and fwrite are having 2 size_t arguments because of I guess possibly, that on some systems, there may be more memory of which whose size can ...
3 votes
1 answer
680 views

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

I am currently trying to create a FPGA styled simulator of the 8080 in C. I have a couple of questions regarding the D0-D7 pins. As far as I can see the D0-D7 lines are used in order to store data (a ...
4 votes
2 answers
2k views

Gameboy Key Input Causes Crash

I made a Key Tester using the STDIO header included with GBDK. It works... Until it doesn't. All the keys register and print to the screen, except the Left(5) and Right(4) Directional Keys, which ...
3 votes
2 answers
447 views

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

For a game reversing project, I am trying to undo linking with the C library performed by the MSC 5.1 C compiler+linker. To that end, I have created a simple executable that does nothing except ...
32 votes
1 answer
3k views

Did DOS zero out the BSS area when it loaded a program?

As an example, say we have a DOS MZ EXE file that's around 20 KiB in size. The EXE header contains the value 0x1400 at offset 0x0A indicating that the program is requesting 5,120 paragraphs (or 80 KiB)...
44 votes
7 answers
9k views

The history of the NULL pointer

As we know, in C to dereference a null pointer is undefined behaviour. From what I understand, the PDP-7 and the PDP-11 both have ordinary memory that can be written to and read from at address 0. On ...
18 votes
1 answer
4k views

What was the first C compiler for the Mac?

When did a C compiler first become commercially available for the Apple Macintosh? And what was its name? The only programming languages that I recall were available for the Mac at launch (January ...
10 votes
3 answers
905 views

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

I am trying to recreate the exact C source code from some 16bit DOS 8086 assembly generated by the MS C 5.0 compiler. After making some progress, I've hit a wall with the following code (annotated in ...
8 votes
1 answer
647 views

How to make Microsoft C for MS-DOS emit an immediate-target far call into the data segment?

I am trying to recreate the C source code from some 16bit DOS 8086 assembly generated by the MS C 5.0 compiler. I've hit a wall with this far call instruction. 0000008D 9A2F0CB506 call 0x6b5:...
20 votes
1 answer
2k views

How can I set up the Microsoft C compiler to make it prefer immediate-mode push instructions?

I started a project to get a better understanding on how to compile a game for Windows 3.x. I tried to set up the build workflow so that it produce the byte-exact clone of a great open sourced Win16 ...
3 votes
1 answer
245 views

How to remove ___EXPORTEDSTUB statement from a NE (Win16) program's MAP?

I started a project to get a better understanding on how to compile a game for Windows 3.x. I tried to set up the build workflow so that it produce the byte-exact clone of a great open sourced Win16 ...
3 votes
1 answer
545 views

Did DEMOS have a C compiler?

DEMOS was a Soviet operating system derived from BSD Unix. The answer to this question shows that the familiar, English-derived BSD commands were essentially the same in DEMOS. Did DEMOS have a C ...
49 votes
7 answers
36k views

How could early UNIX OS comprise so few lines of code?

I start my journey to become a hardware / software specialist with an internship in two weeks time and decided to start studying the C language early. I came across this video, Learn C Programming ...
32 votes
11 answers
12k views

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

Please take a look at this post: Is there a performance difference between i++ and ++i in C? There are two essential statements in the answer: Modern compiler produce the same machine code no matter ...
2 votes
1 answer
982 views

How do I compile C code with the IRIX X Window System?

I have typed out a rather large file in C code that is defining OpenGL graphics and will draw a triangle on the screen. While I know all of the functions of the X Windowing System, I do not know how ...
23 votes
2 answers
3k views

Using Clang to compile MS-DOS executables

I have a simple C program, and I would like to compile it targeting MS-DOS. Can this be achieved with Clang? I would like to produce the following formats: COM executable 16-bit MZ executable 32-bit ...
5 votes
5 answers
804 views

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

I found out today that a large project like Microsoft Windows 1.0 took 80 man-years to develop. And this one was written in x86 assembly language. Is there a form or rule of thumb that states how much ...
22 votes
1 answer
596 views

Where is Mike Lesk's (circa 1973) "portable I/O package" for C?

According to Dennis Ritchie's 1993 paper The Development of the C Language: Also during this period, the compiler was retargeted to other nearby machines, particularly the Honeywell 635 and IBM 360/...
21 votes
2 answers
694 views

What is the history of SysV i386 calling convention for struct return?

I would like to understand historical roots of the quirk in the SysV calling convention for the 32-bit x86, which was inherited by the ELF standard, and so remains used on Linux to this day. Consider ...
14 votes
10 answers
3k views

Alternatives for TurboVision on DOS

TurboVision was a library by Borland for developing TUI's (Text User Interfaces). It was included with their C++ and Pascal compilers. Were there any other TUI libraries that supported multiple ...
6 votes
1 answer
388 views

What is the earliest use in C of indexing the bits of a float or double to sample a table lookup?

One common way to produce an approximation of a function like the logarithm or the exponential is to precompute a table of values (a lookup table) for the output or some intermediate stage of the ...
8 votes
2 answers
976 views

Tiny libc for DOS 8086

I'm looking for a tiny libc (C runtime library) targeting small model DOS 8086, and providing (most of) the C89 library functions, including fread(...), printf(...) and scanf(...). The libc must work ...
17 votes
2 answers
2k views

When did type punning through violating the strict aliasing rule become disallowed?

Looking at the C code from the Fast Inverse Square Root, the casting of a float to a long is done via pointer arithmetic: i = * ( long * ) &y; // evil floating point bit level hacking The ...
23 votes
8 answers
7k views

Why were nested functions excluded from B and C?

I'm learning C and was curious as to why the language does not allow nested functions. From what I've read, the lack of nested functions seems to have been a simplification that was inherited from its ...
9 votes
1 answer
501 views

Was the design of the PDP-11 Floating Point Processor responsible for C's willingness to do arithmetic on floats at double precision?

The Wikipedia page on PDP-11 architecture has a very interesting bullet point in the section on the Floating Point Processor extension to the basic architecture: full floating point operations on ...
49 votes
3 answers
7k views

How did varargs in C develop?

C has a feature for variadic functions, my understanding is this feature was originally a hack, relying on the simple stack-based parameter passing used by early C implementations and that some time ...
9 votes
1 answer
2k views

What is the meaning of asctime?

I see asctime in C, C++ and Python. What does the abbreviation mean? All those functions of max 8 characters are pretty obvious (strcpy e.g.) but this one eludes me. Is it ASCII time? Is it 'as ctime' ...
110 votes
10 answers
43k views

Why do C to Z80 compilers produce poor code?

When reading some other questions about compiling C for the Z80, How much benefit should be expected on a more advanced compiler for z80/r800 based computers? Native C compiler for Sinclair ZX ...
15 votes
1 answer
937 views

Why would an implementation of getwd call mktemp?

As mentioned here the book Expert C Programming contains the claim that there was a bug in SunOS 4.0.3's version of lpr, (a printing program) caused by a custom mktemp function overriding the library ...
4 votes
2 answers
537 views

Do any of the open source Sinclair ZX Spectrum emulators support both TR-DOS and 3DOS?

The number of Spectrum emulators has been growing for decades now so there's quite a lot for different platforms and written in different languages. I'm interested in learning about two of the disk ...
18 votes
1 answer
3k views

In P.J. Plauger's "The Standard C Library" (1992), why are for loops used so frequently instead of while loops in the implementations?

I think I'm getting into such a specific question that there may be no answer, but it seems curious to me. This is a retrocomputing question, I promise, see the last paragraph to see how. In Plauger's ...
33 votes
6 answers
6k views

In the ISO 1990 C standard library, what was the rationale for having memcpy return one of its inputs?

The function memcpy is defined as: void* memcpy(void* s1, void* s2, size_t n) and the 1990 ISO standard (ISO 9899:1990) defines the function as: Description The memcpy function copies n characters ...
54 votes
5 answers
17k views

Why did C have the return type before function names?

In general, there are two types of syntax of defining functions - Something like C, C++, C#, or Java (int functionName(char arg)) vs the ML (and others) tradition of defining the return type after the ...
90 votes
20 answers
20k views

Have programming languages driven hardware development?

Programming language development has been influenced by hardware design. One example from this answer mentions how C pointers were, at least in part, influenced by the design of the PDP-11. Has the ...
9 votes
2 answers
686 views

Which linker or object-file format imposed the 6-character restriction on external names?

It's my understanding that the reason that external identifiers in portable C programs had (still have?) to be unique in the first six characters is that six 6-bit characters¹ fill a 36-bit machine ...
11 votes
3 answers
2k views

Are there architectures with alignment greater than the size of machine word in the pre-32-bit era?

I'm writing a hobbyist cryptography project, and I want to ensure the data structures I define don't have padding bytes. The only assumption I've made about the environment, is that bytes are exactly ...
42 votes
4 answers
6k views

When was this C function definition style, with type declarations of parameters after the parameter list, invented?

Recently I dug a little bit into old graphics libraries and found libxmi. The site was last updated on 08/09/2000. And in the source code I found the following style of function definitions which I ...
74 votes
5 answers
19k views

Why did C use the arrow (->) operator instead of reusing the dot (.) operator?

In the C programming language, the syntax to access the member of a structure is structure.member However, a member of a structure referenced by a pointer is written as pointer->member ...
16 votes
3 answers
2k views

Are there any public tools for the TMS34010?

I am interested to learn about the Texas Instruments TMS34010, a 32-bit fully functional CPU with built-in graphics manipulation capabilities, which appeared in Atari's Hard Drivin' arcade boards ...
38 votes
6 answers
7k views

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

In modern C, you may place variable declarations between statements: do_something(); int x; x = something_else(); However, older C compilers required that variables are declared before all statements:...
3 votes
1 answer
203 views

CC65 ignores request to correctly offset memory areas in output files

I'm trying to segment my C code into two distinct memory areas, one which will be flashed to a ROM chip and another which will end up somewhere else. Here is what I have in sbc.cfg (I was originally ...
24 votes
11 answers
11k views

Why weren't 80s arcade games programmed in C?

I know many arcade games from the 80s were programmed in 68000 assembly. This carried on probably well into the 90s, even though Motorola C compilers existed in the 80s. Why then weren't C compilers ...
26 votes
9 answers
5k views

How common was programming in C targeting 8-bit processors in 1983?

How often was C used to program firmware for 8-bit processors in the early 80s? I'm reverse engineering a firmware binary for a device built around a Hitachi 6303 processor, manufactured in 1983. Even ...
-2 votes
2 answers
353 views

1980s version of printf in C [closed]

In a well-known article by Ken Thompson, ( http://users.ece.cmu.edu/~ganger/712.fall02/papers/p761-thompson.pdf ) in figure 1, that formats printf with decimal %d printf("\t%d, \n", s[i]); ...