Questions tagged [c]

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

Filter by
Sorted by
Tagged with
2
votes
1answer
115 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 ...
36
votes
6answers
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:...
24
votes
11answers
10k 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
9answers
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 ...
14
votes
1answer
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
1answer
162 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 ...
-2
votes
2answers
302 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]); ...
45
votes
3answers
5k 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 ...
15
votes
1answer
2k views

How would old software using the SIGPIPE signal really work if it were to manage _many_ pipes?

I'm wondering what was the thinking behind having a SIGPIPE signal. From my own experience, the first thing I do is turn off that signal (SIGIGN) and use the return value of the calls to make sure it ...
57
votes
4answers
11k views

Why were single quotes ('…') chosen for characters, and double quotes ("…") for strings?

In C, '' is used to denote a character, while "" is used to denote a string. Why was this syntax chosen? I tried to research this using Wikipedia’s Timeline of Programming Languages along ...
2
votes
1answer
186 views

Where can I find the software for "DESIGN: a program to create data entry programs" by J. Michael Wuerth?

I have a copy of the book, DESIGN: a program to create data entry programs by J. Michael Wuerth. Does anyone know where I can obtain a copy of the accompanying software for the book?
9
votes
1answer
507 views

Which pre-ANSI C compilers allowed a conditional expression as Lvalue?

Soon after learning the C language in the late 80s, before an ANSI C compiler was available on the machines I was using, it occurred to me to check if the following compiles int a, b, c; foo() { (...
1
vote
1answer
319 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 ...
2
votes
1answer
282 views

Microsoft C 6, far pointer, cast to int, warning C4047

Trying to access one byte in memory using segment/offset, like this union REGS in, out; struct SEGS segs; int v; char _far* p; ... int86x(...,&in,&out,&segs); p = (segs.es << 16) + ...
26
votes
1answer
4k views

Where is the ancient preprocessor?

I found the old C compiler from V6, and, though it seems to the modern eye a little different from good, idiomatic C, evidently it uses things like #include and #define, but I do not see how it ...
1
vote
1answer
214 views

When did cross-platform C start assuming function prototypes? [closed]

The most important difference between the original 'K&R' C, and ANSI/ISO C89/90, was function prototypes. These started being supported by some compilers in the mid-eighties, were formally ...
36
votes
6answers
5k views

Why is this gcd implementation from the 80s so complicated?

First of all, I hope this is the right place to post this question. I was looking through one of my dad's old programming books from the 80s, and at the back it has a list of utility functions, one of ...
31
votes
3answers
4k views

Why is the ‘auto’ storage class specifier included in C?

The auto keyword in C seems quite redundant: wherever it makes sense to define a variable with automatic storage duration, it is already the default, so there is no reason to use the keyword. The ...
14
votes
2answers
2k views

How would I reliably detect the amount of RAM, including Fast RAM?

If I was to write an Amiga game, what would be the best/most reliable way to detect how much RAM is actually available? Looking at Action's Guide to AGA-Fixing!, he mentions Faulty Memory Detection: ...
7
votes
2answers
570 views

Labels in cc65 inline assembler with #define macro

In general, it is possible to use inline assembler statements within C macros, for example #define toscreencode(C) (__AX__ = (C), \ asm("cmp #$60"),\ ...
11
votes
3answers
2k 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 ...
19
votes
10answers
7k views

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

From the earliest K&R reference manuals I read, 'int' was synonymous with machine word and it seemed to raise adverse reactions in various user domains. With the UNIX crowd, they minimally ...
2
votes
2answers
234 views

Why isn't this invocation of XMS function Move EMB 0Bh in Turbo C correct?

Following on from my last question, I cannot get Move Extended Memory Block (Function 0Bh) working in Turbo C 2.01. The following main.c contains only the minimum functions: get the XMS driver pointer,...
8
votes
2answers
687 views

How can I malloc() a block that's guaranteed to lie within a single DMA segment in Turbo C 2.01?

I'm following root42's videos about DOS programming using Turbo C 2.01. I've written my own Soundblaster 1.xx driver following the Creative Labs documentation, and I'm confused about memory allocation....
0
votes
3answers
283 views

Should C be regarded as an Intermediate Language? [closed]

Should C be regarded as an intermediate language on a virtual machine named PDP-11 Architecture (which have a plain memory space and stacks), like opcode to jvm, msil to dotnet, asm.js to v8, which ...
2
votes
0answers
176 views

Hitting the CMS Limits of Portable Code

I wrote this arbitrary precision arithmetic utility on BSD in my postgraduate days, then after graduating ported it to DOS using TurboC. Was proud that it would do the same thing with 16bit word ...
1
vote
1answer
229 views

Working on programming a retro z80 computer (SDCC error)

I am working on coding a driver of sorts for a Z80 based computer I am making. I am compiling with SDCC and I have been getting the following? ASlink-Warning-Undefined Global 'data' referenced by ...
2
votes
2answers
351 views

How to implement a 'write' function in pdp-11 / MACRO-11 / ODT using simh?

So, I'm working on a project where I'm aiming to get the first winner of the IOCCC (obfuscated c code contest) dissected down to the last detail... The program is mullender.c which you can find by ...
5
votes
1answer
311 views

What is the format of the static libraries shipping with legacy Microsoft C for DOS?

I have installed Microsoft C 5.10 on DOS 6.22. It created a 'LIB' directory with static libraries to link against. Now I need to extract the symbols and the code for the functions from them, but can't ...
0
votes
1answer
312 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 interesting in learning about two of the disk ...
6
votes
4answers
664 views

C/C++ UI library similar to Visual Basic for DOS

I'm looking for a UI library that offers a similar "experience" to that provided by Microsoft's infamous, Visual Basic for DOS RAD environment. I mean, it's such a compelling environment, ...
0
votes
4answers
369 views

What is the earliest implementation of the stack data structure in C? [closed]

I am trying to find the source code for the earliest implementation of the stack data structure in C, but I can't find anything. I am particularly interested in knowing if the member variables of the ...
8
votes
4answers
2k views

Imaging a HDD from DOS over Serial

I have recently fixed an old IBM Clone, which has an MFM hard drive. The PC booted up fine, but then I saw, that a few years back, I have deleted a few important files (probably by mistake). The ...
4
votes
2answers
467 views

ZX Spectrum scroll waiting for user input problem

I'm trying to compile a C program with z88dk for the ZX Spectrum. Using printf(), when the text hits the bottom line of the screen on line 24 the program stops executing until a key is pressed on the ...
4
votes
5answers
753 views

Z88DK ZX Spectrum "%f" printf not working

I'm attempting to compile a program in C for the ZX Spectrum using Z88DK. However, I'm facing an issue when trying to use printf to print out the value of a float. The code I'm trying to compile: #...
13
votes
3answers
1k views

Memory models for assembly libraries for Turbo C

Turbo C follows the Intel Memory Model where in Tiny, Small and Compact models calling a function is near but in Medium, Large and Huge models calling a function uses far calls. If I want to develop ...
6
votes
2answers
338 views

Why isn't the 'restrict' keyword useful in SDCC when compiling for Z80 target? [closed]

Context SDCC claims to support C11. I use it to write games on Z80 target (for fun and experience). C11 defines restrict C11 specifies the restrict keyword on pointers, which can improve generated ...
19
votes
0answers
943 views

Oxford C compiler for Commodore 64

I kept one floppy from my Commodore 128 (which I used mostly in C64 mode), labelled ‘Oxford C compiler’. It is a 5.25″ floppy. Don't ask me why I kept just this one; probably because I thought I ...
11
votes
1answer
765 views

cprintf printing invisible characters in C program on VIC 20

I want to compile and run a Hello World program in C with the cc65 compiler for an unexpanded VIC-20 model. For printing I'm using the conio.h function cprintf, since the conio implementation requires ...
30
votes
1answer
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)...
29
votes
9answers
10k views

How did early x86 BIOS programmers manage to program full blown TUIs given very few bytes of ROM/EPROM?

I've always wondered how so much functionality and relative luxuries(CMOS Configuration Utilities. See: https://geekprank.com/bios/ for an example) included with most popular x86 BIOSes could be ...
6
votes
3answers
942 views

Why is modulo operation an operator for integer types but only a function for floating-point ones?

In C, we have the % operator which finds remainder of division. But it's only applicable to integral types. For floating-point types we have to use fmod function from math.h. This makes an impression ...
30
votes
3answers
8k views

Was Dennis Ritchie being too modest in this quote about C and Pascal?

In his 1993 conference proceeding The Development of the C Language, Dennis Ritchie stated Successors C and even B have several direct descendants, though they do not rival Pascal in ...
66
votes
5answers
15k views

Why did C use the -> operator instead of reusing the . 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 ...
11
votes
3answers
3k views

How can I create a pipe for stdin/stdout of command.com (or 4dos.com) in C or a batch file?

I'm working on a retro project and was trying to create a pipe of stdin/out/err in DOS, but I can't find any functions to to this. For instance the pipe() function from unistd.h isn't present in ...
1
vote
2answers
150 views

DOS, create pipe for stdin/stdout of command.com(or 4dos.com) in C or Batch? [duplicate]

I'm working on a retro project and was trying to create a pipe of stdin/out/err in DOS, but I can't find any functions to to this? For instance the pipe() command from unistd.h isn't present in ...
11
votes
9answers
1k 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 ...
87
votes
20answers
19k 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 ...
5
votes
3answers
1k views

Were some Atari 2600 games written in C?

I thought all Atari 2600 games had been programmed in 6502/6507 assembly language (plus whatever activated the Stella sound system), but at a party recently, a friend indicated that some 2600 ...
3
votes
1answer
466 views

How to read disk files using CBM specific functions in cc65 with proper error checking

TL:DR What is the reason my kernel_read() function ignoring file errors? I'm trying to understand how to work with files in cc65 using CBM specific functions. My target is Commodore 64 with 1541 ...