Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.c    |    Meh, in C you gotta define EVERYTHING    |    243,242 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 242,485 of 243,242    |
|    David Brown to All    |
|    Re: 8 bit cpu    |
|    19 Dec 25 09:19:32    |
      From: david.brown@hesbynett.no              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.              And of course some 8-bit cpus don't have direct access to more than 256       memory locations - support for anything more is indirect in some way       (using page registers or other arrangements).              It is fair to say, however, that most "big" 8-bit cpus have either one       or more 16-bit address registers, or a reasonable way to combine two       8-bit registers in a pair for use in addressing. And many such "big"       8-bit cpus have a few 16-bit operations, such as for loading or storing       a register pair, or incrementing or decrementing them.              And all this is simply saying that if a processor is going to be able to       access more than 256 bytes of memory with reasonable efficiency, it has       to be able to handle pointer sizes of 16-bit without too much overhead.       It says nothing about the need for a general data size greater than       8-bit (and "int" is for general data, not pointers or addresses).              For 8-bit devices, using 16-bit data for logic, arithmetic, counters,       data movement, etc., is significantly slower than using 8-bit. That's       why they are called 8-bit devices.              C plays by different rules - it is defined on an abstract machine, not       any particular hardware. It says that the size of an "int" is       implementation-defined, but it must be at least 16 bits. Thus any C       implementation for 8-bit processors will have 16-bit ints - not because       it is a good size for the device (it certainly is not), but because       otherwise it would not be C. (The size of pointers is not specified by       the standard - though you can infer a minimum of at least 15-bit data       pointers for hosted systems, 12-bit data pointers for freestanding       systems, and 12-bit function pointers.)              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. In the       heyday of 8-bit microcontrollers, many were programmed in assembly       rather than C.              --- 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