* [COFF] Re: [TUHS] Re: Maximum Array Sizes in 16 bit C
[not found] ` <11d46ab4-b90c-83fe-131a-ee399eebf342@horsfall.org>
@ 2024-09-20 15:56 ` Stuff Received
2024-09-20 17:15 ` segaloco via COFF
[not found] ` <20240920171126.vgtl23xwj37kardb@illithid>
1 sibling, 1 reply; 3+ messages in thread
From: Stuff Received @ 2024-09-20 15:56 UTC (permalink / raw)
To: COFF
Moved to COFF.
On 2024-09-20 11:07, Dave Horsfall wrote (in part):
>
> Giggle... In a device driver I wrote for V6, I used the expression
>
> "0123"[n]
>
> and the two programmers whom I thought were better than me had to ask me
> what it did...
>
> -- Dave, brought up on PDP-11 Unix[*]
>
> [*]
> I still remember the days of BOS/PICK/etc, and I staked my career on Unix.
Working on embedded systems, we often used constructs such as a[-4] to
either read or modify stuff on the stack (for that particular
compiler+processor only).
S.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [COFF] Re: [TUHS] Re: Maximum Array Sizes in 16 bit C
2024-09-20 15:56 ` [COFF] Re: [TUHS] Re: Maximum Array Sizes in 16 bit C Stuff Received
@ 2024-09-20 17:15 ` segaloco via COFF
0 siblings, 0 replies; 3+ messages in thread
From: segaloco via COFF @ 2024-09-20 17:15 UTC (permalink / raw)
To: COFF
On Friday, September 20th, 2024 at 8:56 AM, Stuff Received <stuff@riddermarkfarm.ca> wrote:
> Moved to COFF.
>
> On 2024-09-20 11:07, Dave Horsfall wrote (in part):
>
> > Giggle... In a device driver I wrote for V6, I used the expression
> >
> > "0123"[n]
> >
> > and the two programmers whom I thought were better than me had to ask me
> > what it did...
> >
> > -- Dave, brought up on PDP-11 Unix[*]
> >
> > [*]
> > I still remember the days of BOS/PICK/etc, and I staked my career on Unix.
>
>
> Working on embedded systems, we often used constructs such as a[-4] to
> either read or modify stuff on the stack (for that particular
> compiler+processor only).
>
> S.
My takeaway on out of bounds array access is you're taking the wheel in your own hands WRT the memory characteristics of your application. If you're using some pointer to the middle of a known memory region (e.g. I/O registers) then you're fine stepping a subscript out of bounds in either direction. If you're making assumptions about how compiler and linker <xyz> are going to map C abstractions into RAM/stack...then you better be prepared for a compiler author to have a different mapping plan in mind. As John Mashey put it, paraphrasing, C doesn't require you to agonize over all the details of the machine, but it also allows you to get at many of those details if you so choose.
- Matt G.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [COFF] Re: Maximum Array Sizes in 16 bit C
[not found] ` <0B54746F-504A-40E0-AFFD-4486167FBAD5@iitbombay.org>
@ 2024-09-29 0:17 ` Aron Insinga
0 siblings, 0 replies; 3+ messages in thread
From: Aron Insinga @ 2024-09-29 0:17 UTC (permalink / raw)
To: COFF
FWIW, I just saw this in code generated by bison:
(yyvsp[-4].string_val), (yyvsp[-2].string_val), (yyvsp[0].string_val)
(IIUC) referencing the addresses under the top of the stack when passing
$2, $4, $6 into a function from an action (skipping a couple of
tokens). So the sign just depends on which way the stack is growing.
As for range checking of pointers into a malloc'd block of memory, the
pointer could have just 2 things: the address at the start of the block
and the pointer itself, some moving address in the block; and then
before the start of the block malloc could stash the address of the end
of the block (where it could be referenced by all pointers into the
block). So instead of a triple word, the pointer is a double word, and
the malloc'd block has an extra word before it. This must have been
done before by someone, somewhere.
I don't think of pointers and arrays in C as the same thing, but rather
array references as an alternate syntax for pointer arithmetic (or vice
versa).
- Aron
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-09-29 0:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <CAKH6PiWvuxfa_ek=L=n=mgovFk_ms37u6F2N1qcMLs6RXLRWvA@mail.gmail.com>
[not found] ` <CAEdTPBfPcmZybb0CVLxhzB-nLTQb3aohWV-o_8ZqQJXmUc4yPA@mail.gmail.com>
[not found] ` <CAFH29to4_DFdx=U=ZRVY_HE0YGR8tw00Ya4PJhLGR4Z1UMF6_g@mail.gmail.com>
[not found] ` <CABH=_VR6=wJdgCLArHLd8q3N+BGj=5m16X4WBkB+o5XksbSsbw@mail.gmail.com>
[not found] ` <11d46ab4-b90c-83fe-131a-ee399eebf342@horsfall.org>
2024-09-20 15:56 ` [COFF] Re: [TUHS] Re: Maximum Array Sizes in 16 bit C Stuff Received
2024-09-20 17:15 ` segaloco via COFF
[not found] ` <20240920171126.vgtl23xwj37kardb@illithid>
[not found] ` <69643008-F7FE-4AC7-8519-B45E4C1CEA66@iitbombay.org>
[not found] ` <CANCZdfpy9AsOfE+mvt+DkBYXiwfENLjscMHCT0nnU7WGz54T_Q@mail.gmail.com>
[not found] ` <0B54746F-504A-40E0-AFFD-4486167FBAD5@iitbombay.org>
2024-09-29 0:17 ` [COFF] " Aron Insinga
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).