home bbs files messages ]

Just a sample of the Echomail archive

COMPLANC:

<< oldest | < older | list | newer > | newest >> ]

 Message 242,488 of 243,097 
 bart to David Brown 
 Re: 8 bit cpu 
 19 Dec 25 13:43:20 
 
From: bc@freeuk.com

On 19/12/2025 08:19, David Brown wrote:
> On 18/12/2025 19:20, Rosario19 wrote:
>> 8 bit cpu for access memory other than 0..255 location has need at
>> last one 16 bit register and 16 bits operations, so i think that even
>> a 8 bit cpu has to have int in C language as 16 bits
>
> No, 8-bit cpus don't need 16-bit registers or 16-bit operations.  8-bit
> cpus typically only have 8-bit general registers (though most will have
> a 16-bit PC register).  Some will allow you to use a couple of 8-bit
> registers in a pair, primarily for memory addressing, but a pair of 8-
> bit registers is not the same as a 16-bit register.

>
> The C requirement for a minimum size of 16-bit int, together with the
> integer promotion rules, is one of the reasons C was often considered
> inefficient and inappropriate for small 8-bit microcontrollers.


I'm targeting Z80 right now from my systems language.

As well as making 'int' 16 bits, I've removed the promotion rules. This
means 8-bit quantities needing to be cast to 16 bits as needed.

So if 'a b c' are 8 bits, and 'x' is 16 bits then the Clang Z80 compiler
generates 8-bit code only for:

     a = b + c;

No promotions. But here:

     x = b + c;

'b' and 'c' are first widened to 16 bits (using some ugly code when they
are signed).

This is where my language will differ: b + c produces an 8-bit result,
and it is that that is widened.

Casts are needed to emulate the behaviour of the auto-widening done in
C. But this means somewhat more efficient code with a simpler compiler.

--- SoupGate-Win32 v1.05
 * Origin: you cannot sedate... all the things you hate (1:229/2)

<< oldest | < older | list | newer > | newest >> ]


(c) 1994,  bbs@darkrealms.ca