Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | jacob navia <jacob@spamsink.net> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: A portable stack in C |
| Date | 2011-11-15 11:25 +0100 |
| Organization | lccwin |
| Message-ID | <j9temn$o6u$1@speranza.aioe.org> (permalink) |
| References | <4ec14700$0$1387$4fafbaef@reader2.news.tin.it> <j3r3c7tl1v45qjvee173t8759n1074h4ll@4ax.com> <j9t7gd$45e$1@speranza.aioe.org> <j9tdlo$669$1@dont-email.me> |
Le 15/11/11 11:05, BartC a écrit :
> "jacob navia" <jacob@spamsink.net> wrote in message
> news:j9t7gd$45e$1@speranza.aioe.org...
>> Le 15/11/11 05:55, Barry Schwarz a écrit :
>
>>> You have no control over the size of pointers.
>
>> Of course you can. Here is an 8 bit pointer:
>>
>> char table[255];
>> char pointerInTable;
>>
>> Now, "pointerInTable" points to any position within that table. For
>> instance to get the contents of position 154:
>>
>> pointerInTable = 154;
>> val = table[pointerInTable];
>
> That's not a pointer as understood in C. It's an array index. Try
> passing pointerInTable to a function, and see if the function can access
> the table!
of course it can
typedef unsigned Pointer;
int MyFn(Pointer p)
{
return table[p];
}
Conceptually ANY pointer is an index in a big array called "memory" (or
RAM if you like).
This huge array of characters can be accessed in some machines as a
discontinuous array, composed of several chunks (segments).
An index into those arrays is composed of two numbers: the chunk
index and the index within that chunk (segment:offset)
>
>> Using this (in plain C) you can have pointers of any size.
>>
>> Want a 10 bit pointer?
>>
>> Easy.
>>
>> char table[1024];
>> int pointerInTable; /* Values from 0 to 1023 */
>
> And that one's not even ten bits. It's more likely 32 bits.
>
Well, all my pointers in my machine are 35 bits (I have only 12GB of
memory) but they use 64... (Ignoring Virtual Memory)
>>> You shouldn't believe everything you read on Usenet.
>>
>> You are right. I don't believe you that there isn't (by convention)
>> a register pointing to the stack, and that
>>
>> sub stack,8
>> move value,[stack]
>>
>> doesn't work.
>>
>> Which system are you using?
>
> Clearly one without a stack, perhaps some lowly controller chip.
>
Impossible. There isn't a CALL instruction then. It is impossible
to implement a CALL without a conceptual stack. Yes, you can "push"
your return address into some register but this is conceptually a stack!
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
A portable stack in C "io_x" <a@b.c.invalid> - 2011-11-14 17:54 +0100
Re: A portable stack in C Barry Schwarz <schwarzb@dqel.com> - 2011-11-14 20:55 -0800
Re: A portable stack in C jacob navia <jacob@spamsink.net> - 2011-11-15 09:22 +0100
Re: A portable stack in C Ike Naar <ike@iceland.freeshell.org> - 2011-11-15 09:00 +0000
Re: A portable stack in C jacob navia <jacob@spamsink.net> - 2011-11-15 11:26 +0100
Re: A portable stack in C "BartC" <bc@freeuk.com> - 2011-11-15 10:05 +0000
Re: A portable stack in C jacob navia <jacob@spamsink.net> - 2011-11-15 11:25 +0100
Re: A portable stack in C "BartC" <bc@freeuk.com> - 2011-11-15 11:08 +0000
Re: A portable stack in C Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-11-15 11:45 +0000
Re: A portable stack in C jacob navia <jacob@spamsink.net> - 2011-11-15 12:57 +0100
Re: A portable stack in C Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-11-15 12:39 +0000
Re: A portable stack in C jacob navia <jacob@spamsink.net> - 2011-11-15 14:26 +0100
Re: A portable stack in C Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-11-15 15:31 +0000
Re: A portable stack in C Keith Thompson <kst-u@mib.org> - 2011-11-15 12:53 -0800
Re: A portable stack in C Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-11-15 21:15 +0000
Re: A portable stack in C Keith Thompson <kst-u@mib.org> - 2011-11-15 14:29 -0800
Re: A portable stack in C Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-11-15 22:59 +0000
Re: A portable stack in C James Kuyper <jameskuyper@verizon.net> - 2011-11-15 17:30 -0500
Re: A portable stack in C Willem <willem@toad.stack.nl> - 2011-11-15 22:33 +0000
Re: A portable stack in C Keith Thompson <kst-u@mib.org> - 2011-11-15 15:07 -0800
Re: A portable stack in C Seebs <usenet-nospam@seebs.net> - 2011-11-15 22:37 +0000
Re: A portable stack in C Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-11-15 23:01 +0000
Re: A portable stack in C "BartC" <bc@freeuk.com> - 2011-11-15 18:45 +0000
Re: A portable stack in C Keith Thompson <kst-u@mib.org> - 2011-11-15 12:41 -0800
Re: A portable stack in C Richard Damon <news.x.richarddamon@xoxy.net> - 2011-11-15 23:07 -0500
Re: A portable stack in C Keith Thompson <kst-u@mib.org> - 2011-11-15 20:18 -0800
Re: A portable stack in C Robert Wessel <robertwessel2@yahoo.com> - 2011-11-15 22:53 -0600
Re: A portable stack in C "BartC" <bc@freeuk.com> - 2011-11-16 12:00 +0000
Re: A portable stack in C falk@rahul.net (Edward A. Falk) - 2011-11-16 16:08 +0000
Re: A portable stack in C David Thompson <dave.thompson2@verizon.net> - 2012-01-19 02:41 -0500
Re: A portable stack in C Thomas David Rivers <rivers@dignus.com> - 2011-11-15 11:21 -0500
Re: A portable stack in C Barry Schwarz <schwarzb@dqel.com> - 2011-11-15 17:53 -0800
Re: A portable stack in C "io_x" <a@b.c.invalid> - 2011-11-15 19:21 +0100
Re: A portable stack in C Barry Schwarz <schwarzb@dqel.com> - 2011-11-15 17:53 -0800
Re: A portable stack in C "io_x" <a@b.c.invalid> - 2011-11-18 08:13 +0100
Re: A portable stack in C Rui Maciel <rui.maciel@gmail.com> - 2011-11-15 10:14 +0000
Re: A portable stack in C "io_x" <a@b.c.invalid> - 2011-11-15 19:20 +0100
Re: A portable stack in C Acid Washed China Blue Jeans <chine.bleu@yahoo.com> - 2011-11-15 08:13 -0800
Re: A portable stack in C Kaz Kylheku <kaz@kylheku.com> - 2011-11-15 16:27 +0000
Re: A portable stack in C "io_x" <a@b.c.invalid> - 2011-11-15 19:21 +0100
Re: A portable stack in C Keith Thompson <kst-u@mib.org> - 2011-11-15 13:19 -0800
Re: A portable stack in C blmblm@myrealbox.com <blmblm.myrealbox@gmail.com> - 2011-11-17 15:45 +0000
Re: A portable stack in C John Gordon <gordon@panix.com> - 2011-11-17 15:56 +0000
Re: A portable stack in C "io_x" <a@b.c.invalid> - 2011-11-17 18:02 +0100
Re: A portable stack in C "BartC" <bc@freeuk.com> - 2011-11-17 17:35 +0000
Re: A portable stack in C Vincenzo Mercuri <vincenzo.mercuri@yahoo.it> - 2011-11-17 18:45 +0100
Re: A portable stack in C Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-11-18 00:27 -0800
Re: A portable stack in C "io_x" <a@b.c.invalid> - 2011-11-18 10:40 +0100
Re: A portable stack in C "io_x" <a@b.c.invalid> - 2011-11-20 07:22 +0100
Re: A portable stack in C Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-11-21 00:38 -0800
Re: A portable stack in C "Jo" <none@none.none> - 2011-11-21 03:44 -0600
Re: A portable stack in C Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2011-11-21 13:00 +0200
Re: A portable stack in C "Jo" <none@none.none> - 2011-11-21 06:07 -0600
Re: A portable stack in C "Jo" <none@none.none> - 2011-11-21 03:50 -0600
Re: A portable stack in C "Jo" <none@none.none> - 2011-11-21 07:48 -0600
Re: A portable stack in C "io_x" <a@b.c.invalid> - 2011-11-21 20:11 +0100
Re: A portable stack in C "BartC" <bc@freeuk.com> - 2011-11-18 12:47 +0000
Re: A portable stack in C "Jo" <none@none.none> - 2011-11-18 23:31 -0600
Re: A portable stack in C blmblm@myrealbox.com <blmblm.myrealbox@gmail.com> - 2011-11-18 14:45 +0000
Re: A portable stack in C James Kuyper <jameskuyper@verizon.net> - 2011-11-18 10:14 -0500
Re: A portable stack in C Keith Thompson <kst-u@mib.org> - 2011-11-18 12:20 -0800
Re: A portable stack in C blmblm@myrealbox.com <blmblm.myrealbox@gmail.com> - 2011-11-19 17:23 +0000
Re: A portable stack in C Seebs <usenet-nospam@seebs.net> - 2011-11-19 18:49 +0000
Re: A portable stack in C "Jo" <none@none.none> - 2011-11-19 22:41 -0600
Re: A portable stack in C "io_x" <a@b.c.invalid> - 2011-11-20 07:27 +0100
Re: A portable stack in C "io_x" <a@b.c.invalid> - 2011-11-21 20:12 +0100
Re: A portable stack in C "io_x" <a@b.c.invalid> - 2011-11-20 07:50 +0100
Re: A portable stack in C "Jo" <none@none.none> - 2011-11-21 01:24 -0600
Re: A portable stack in C Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-11-21 05:22 -0800
Re: A portable stack in C "Jo" <none@none.none> - 2011-11-22 03:31 -0600
Re: A portable stack in C 88888 Dihedral <dihedral88888@googlemail.com> - 2011-11-21 06:38 -0800
csiph-web