Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C Programming (http://www.velocityreviews.com/forums/f42-c-programming.html)
-   -   size of a pointer on 4-bit system (http://www.velocityreviews.com/forums/t957069-size-of-a-pointer-on-4-bit-system.html)

Mark 01-30-2013 02:30 AM

size of a pointer on 4-bit system
 
Hello

I ran in a such interview question on the net: what is the size of pointer
on 4-bit system. Regardless of the fact that such system probably don't
exist, what would be the reasonable answer to such question? (I think saying
that in theory the size is 4, however the standard doesn't allow bytes to be
less than 8 bits).

Mark



W Karas 01-30-2013 02:48 AM

Re: size of a pointer on 4-bit system
 
On Tuesday, January 29, 2013 9:30:01 PM UTC-5, Mark wrote:
> Hello
>
>
>
> I ran in a such interview question on the net: what is the size of pointer
>
> on 4-bit system. Regardless of the fact that such system probably don't
>
> exist, what would be the reasonable answer to such question? (I think saying
>
> that in theory the size is 4, however the standard doesn't allow bytes tobe
>
> less than 8 bits).
>
>
>
> Mark


Seems like a trick question. 4-bit processors were perhaps the most commonembedded processors back in the early 80s, when affordable personal computers where based on 8-bit processors. It wouldn't surprise me if immediate was the only addressing mode, making a "pointer" impossible without self-modifying code. I'd think bragging rights would be the only reason anyone would write a C compiler for a 4-bit processor.

If you build a system with main memory on a PCIe bus, could that be called a 1-bit system?

Geoff 01-30-2013 04:34 AM

Re: size of a pointer on 4-bit system
 
On Tue, 29 Jan 2013 21:30:01 -0500, "Mark" <mark_cruzNOTFORSPAM@hotmail.com>
wrote:

>Hello
>
>I ran in a such interview question on the net: what is the size of pointer
>on 4-bit system. Regardless of the fact that such system probably don't
>exist, what would be the reasonable answer to such question? (I think saying
>that in theory the size is 4, however the standard doesn't allow bytes to be
>less than 8 bits).
>
>Mark
>


The correct answer is "it cannot be determined". The size of the "system" is not
a relevant question within the context of C.

The Intel 4004 had a 4-bit ALU but 8-bit and 16-bit instructions and 12-bit
addressing. It had indirect mode addressing into 4k ROM but could access only
640 bytes of RAM. The FIN n instruction fetched indirect via index register pair
0 and loaded the contents into register n where 1 <= n <=15.

Any theoretical 4-bit processor could have any number of address bits and still
be called a 4-bit system.

Lew Pitcher 01-30-2013 04:35 AM

Re: size of a pointer on 4-bit system
 
On Tuesday 29 January 2013 21:48, in comp.lang.c, wkaras@yahoo.com wrote:

> On Tuesday, January 29, 2013 9:30:01 PM UTC-5, Mark wrote:
>> Hello
>>
>>
>>
>> I ran in a such interview question on the net: what is the size of
>> pointer
>>
>> on 4-bit system. Regardless of the fact that such system probably don't
>>
>> exist, what would be the reasonable answer to such question? (I think
>> saying
>>
>> that in theory the size is 4, however the standard doesn't allow bytes to
>> be
>>
>> less than 8 bits).
>>
>>
>>
>> Mark

>
> Seems like a trick question. 4-bit processors were perhaps the most
> common embedded processors back in the early 80s, when affordable personal
> computers where based on 8-bit processors.


Intel's predecessor to the 8008 (and later, the 8080) was the 4004.
Wikipedia describes it as having:
Separate program and data storage.
12-bit addresses
8-bit instructions
4-bit data words

It would seem to me, /if/ a C compiler were targetted to such a processor,
it would use pointers of 11 bits in width.


--
Lew Pitcher
"In Skills, We Trust"

glen herrmannsfeldt 01-30-2013 05:51 AM

Re: size of a pointer on 4-bit system
 
Lew Pitcher <lpitcher@teksavvy.com> wrote:

(snip)
>> On Tuesday, January 29, 2013 9:30:01 PM UTC-5, Mark wrote:


(snip)
>>> I ran in a such interview question on the net: what is the
>>> size of pointer on 4-bit system.


(snip)

> Intel's predecessor to the 8008 (and later, the 8080) was the 4004.


You forgot about the 4040.

> Wikipedia describes it as having:
> Separate program and data storage.
> 12-bit addresses
> 8-bit instructions
> 4-bit data words


> It would seem to me, /if/ a C compiler were targetted to such a processor,
> it would use pointers of 11 bits in width.


I would think one would want to have a nybble type, even if char was
an 8 bit type. The 4004 was supposed to be used for building
calculators, presumably in BCD.

Are there C implementations for any Harvard (separate program and
data space) machines? Maybe the 8048 series?

-- glen



Shao Miller 01-30-2013 06:53 AM

Re: size of a pointer on 4-bit system
 
On 1/29/2013 21:30, Mark wrote:
>
> I ran in a such interview question on the net: what is the size of pointer
> on 4-bit system. Regardless of the fact that such system probably don't
> exist, what would be the reasonable answer to such question? (I think saying
> that in theory the size is 4, however the standard doesn't allow bytes to be
> less than 8 bits).
>


Did the interview question have anything to do with the computer
programming language called C?

--
- Shao Miller
--
"Thank you for the kind words; those are the kind of words I like to hear.

Cheerily," -- Richard Harter

Robert Miles 01-30-2013 08:11 AM

Re: size of a pointer on 4-bit system
 
On Tuesday, January 29, 2013 8:30:01 PM UTC-6, Mark wrote:
> Hello
>
> I ran in a such interview question on the net: what is the size of pointer
> on 4-bit system. Regardless of the fact that such system probably don't
> exist, what would be the reasonable answer to such question? (I think saying
> that in theory the size is 4, however the standard doesn't allow bytes to be
> less than 8 bits).
>
> Mark


If only one 4-bit word is used to hold the pointer, 4 bits. However, such a system can only address 16 4-bit words, which must include both the program that is running and the data it is running on - not a very interesting system.

However, if the hardware allows loading addresses as multiple 4-bit words, 4 bits times the number of words in that type of address.

I used to have a PC board that included a 4004, but never did much with it.

Server systems now use a similar idea of using more than one word to hold an address - some 32-bit servers use 2 32-bit words to hold an address, and can therefore reach more than tha 4 GB of memory they could use if they only used one 32-bit word.

Noob 01-30-2013 08:28 AM

Re: size of a pointer on 4-bit system
 
Robert Miles wrote:

> Server systems now use a similar idea of using more than one word to
> hold an address - some 32-bit servers use 2 32-bit words to hold an
> address, and can therefore reach more than tha 4 GB of memory they
> could use if they only used one 32-bit word.


Which (computer) architecture do you have in mind?

glen herrmannsfeldt 01-30-2013 09:02 AM

Re: size of a pointer on 4-bit system
 
Robert Miles <robertmilesxyz@gmail.com> wrote:

(snip)
> I used to have a PC board that included a 4004, but never did much with it.


> Server systems now use a similar idea of using more than one
> word to hold an address - some 32-bit servers use 2 32-bit words
> to hold an address, and can therefore reach more than tha 4 GB of
> memory they could use if they only used one 32-bit word.


How about ones that use a 16 bit segment selector and 32 bit
segment offset? Plenty of those around, but not many OS that
let programs use multiple segments.

Last I knew, the Watcom C compiler would generate large model 32 bit
code, and maybe OS/2 could run it.

-- glen

Nobody 01-30-2013 01:16 PM

Re: size of a pointer on 4-bit system
 
On Tue, 29 Jan 2013 21:30:01 -0500, Mark wrote:

> I ran in a such interview question on the net: what is the size of pointer
> on 4-bit system. Regardless of the fact that such system probably don't
> exist, what would be the reasonable answer to such question?


The correct answer is "whatever the compiler's authors chose to make it".

The hardware only matters insofar as the compiler's authors want it to
matter. Compilers for the 8086 (and later CPUs running in 8086 mode)
typically offered both 16-bit and 32-bit pointers. C explicitly allows
different types of pointer to have different sizes (char* and void* may be
larger than an int*, and the size of function pointers isn't related to
the size of data pointers).



All times are GMT. The time now is 09:50 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.