Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > size of a pointer on 4-bit system

Reply
Thread Tools

size of a pointer on 4-bit system

 
 
BartC
Guest
Posts: n/a
 
      02-05-2013


"Shao Miller" <(E-Mail Removed)> wrote in message
news:kes0df$gto$(E-Mail Removed)...
> On 2/5/2013 06:02, BartC wrote:
>> "Shao Miller" <(E-Mail Removed)> wrote in message


>> (In my implementation...


> You have a C implementation? Your pointers can point to bits?


No, only an implementation of bit-types in another language. But many of the
issues are the same.

And pointers can point to bits; they just require an ordinary pointer plus a
bit-offset.

That would be an extremely useful addition to C; in fact probably more
useful than bit-types themselves. But it's unlikely they will ever form a
part of the language when it's so easy to throw something together with
shifts and masks and bit-pointers emulated using (char*,int) structs. It
doesn't even have binary literals so I can't see it happening!

--
Bartc

 
Reply With Quote
 
 
 
 
David Thompson
Guest
Posts: n/a
 
      02-11-2013
On Sun, 3 Feb 2013 00:03:02 +0000 (UTC), glen herrmannsfeldt
<(E-Mail Removed)> wrote:

> Keith Thompson <(E-Mail Removed)> wrote:


> > It's not universal, but I think most languages that have an
> > exponentiation operator spell it "**".

>
> Well, when BASIC was new ASCII had an up-arrow character, later
> replaced by tilde. EBCDIC has no up-arror or tilde, so it wasn't
> likely that any IBM language would use them.
>

Nit: 5/14 was uparrow and became officially circumflex often called
caret or hat. IIRC EBCDIC of those days did not have circumflex but
did have hook aka logical-not, which was usually a good mapping.

(Also 5/15 was leftarrow and became underline.)

 
Reply With Quote
 
 
 
 
glen herrmannsfeldt
Guest
Posts: n/a
 
      02-11-2013
David Thompson <(E-Mail Removed)> wrote:
> On Sun, 3 Feb 2013 00:03:02 +0000 (UTC), glen herrmannsfeldt
> <(E-Mail Removed)> wrote:


>> Keith Thompson <(E-Mail Removed)> wrote:


>> > It's not universal, but I think most languages that have an
>> > exponentiation operator spell it "**".


>> Well, when BASIC was new ASCII had an up-arrow character, later
>> replaced by tilde. EBCDIC has no up-arror or tilde, so it wasn't
>> likely that any IBM language would use them.


> Nit: 5/14 was uparrow and became officially circumflex often called
> caret or hat. IIRC EBCDIC of those days did not have circumflex but
> did have hook aka logical-not, which was usually a good mapping.


Yes. EBCDIC has not and cent, ASCII has tilde and circumflex.
They usually get cross mapped, but not always the same way.

After a while, I forget which one should go to which.

Most fun is seeing PL/I with the tilde-equal operator.

> (Also 5/15 was leftarrow and became underline.)


Yes, that too.

-- glen
 
Reply With Quote
 
Tim Rentsch
Guest
Posts: n/a
 
      02-12-2013
Keith Thompson <(E-Mail Removed)> writes:

> Tim Rentsch <(E-Mail Removed)> writes:
>> Keith Thompson <(E-Mail Removed)> writes:

> [...]
>>> For example, `(size_t)1 / 2` would yield a result that would
>>> compare equal to 0, but if you look at the padding bits of the
>>> result and interpret them as fractional bits, you can interpret
>>> it as 1/2 (a value midway between 0 and 1).

>>
>> If you think about this a little while I expect you'll see that
>> expressions like (size_t)1 / 2 must not set any "fraction" bits.
>> This expression is well-defined by the Standard - it must behave
>> exactly like 0 in all respects for all subsequent operations (ie,
>> operations whose behavior is defined by the Standard). The only
>> value operations that produce size_t representations with non-zero
>> fractions must have an element of undefined behavior, or possibly
>> implementation-defined behavior. This expression is completely
>> defined so it mustn't do that.

>
> Hmm.
>
> There can be representations for an integer 0 other than all-bits-zero,
> so I'm not sure that having `(size_t)1 / 2` set some of the
> padding/fraction bits to 1 would be forbidden. But certainly
> `(size_t)1 / 2 * 2` must be 0.
>
> On the other hand, we'd want `sizeof (_Nybble[2])` to denote 1
> 8-bit byte, and `sizeof (_Nybble[2]) / 2` to denote 1 4-bit nybble.


To get that result, you could use

sizeof (char[ sizeof(nibble[2]) / 2. ])

taking advantage of a companion extension that allows floating-point
values as integer expressions in array bounds expressions. (Note
for purists: after doing a #include <nibble.h>.)

<editorial>
Spelling nibble with a 'y' rather than 'i' is an affectation.
There is good reason to use 'y' rather than 'i' in byte, and
it also makes sense phonetically. Neither is true for nibble.
</editorial>

> The only way I can think of to make this work consistently
> would be to add another padding bit to size_t, a flag that
> indicates whether it's an ordinary C size value or something
> that takes nybbles into account.


Possible. I don't think it's absolutely necessary, but it
might be worth trying out.

> I'm even more convinced that it wouldn't be worth the effort.
> The C language is not conveniently portable to 4-bit
> addressable systems (or trinary systems, or analog systems, or
> ...).


I think you're assuming the target of such an implementation
would be a four-bit system. That needn't be the case. Certainly
I would like a C implementation on a large system that supported
four-bit, two-bit, and one-bit quantities.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
pointer to an array vs pointer to pointer subramanian100in@yahoo.com, India C Programming 5 09-23-2011 10:28 AM
Pointer to pointer or reference to pointer A C++ 7 07-05-2011 07:49 PM
Pointer to pointer Vs References to Pointer bansalvikrant@gmail.com C++ 4 07-02-2009 10:20 AM
passing the address of a pointer to a func that doesnt recieve a pointer-to-a-pointer jimjim C Programming 16 03-27-2006 11:03 PM
Pointer-to-pointer-to-pointer question masood.iqbal@lycos.com C Programming 10 02-04-2005 02:57 AM



Advertisments