Sign in

username:

password:



Not a member?

Search Comp.Arch.FPGA



Search tips

fpga by Keywords

Altera | ASIC | CPLD | Cyclone | DCM | DDR | DSP | Ethernet | ISE | JTAG | Linux | LVDS | Microblaze | ML310 | Modelsim | NIOS | OPB | PCI | Quartus | RocketIO | SDRAM | Spartan | Spartan3 | SRAM | Stratix | Verilog | VHDL | Virtex | Virtex-4 | Virtex-II | Xilinx | XST


Ads

See Also

DSPEmbedded SystemsElectronics

Comp.Arch.FPGA | using an FPGA to emulate a vintage computer

There are 235 messages in this thread.

You are currently looking at messages 110 to 120.

Re: using an FPGA to emulate a vintage computer - Scott Lurndal - 2010-02-25 13:33:00

Joe Pfeiffer <p...@cs.nmsu.edu>
writes:
>Eric Chomko <p...@comcast.net> writes:
>
>> On Feb 23, 2:07 pm, "(see below)" <yaldni...@blueyonder.co.uk>
wrote:
>>> On 23/02/2010 17:52, in article
>>> 3ec03225-3a0f-4bcd-9db1-51201d1b3...@w12g2000vbj.googlegroups.com,
"Eric
>>>
>>> Chomko" <pne.cho...@comcast.net> wrote:
>>> > But an ALGOL "activation record" (stack frame) had a lot more
than
>>> > that. As I recall, they copied a lot more just pointers and parameter
>>> > values.
>>>
>>> Just the usual red tape: return address, frame pointer of caller; and either
>>> a static pointer or some housekeeping for 'display' registers (if used) to
>>> access non-locals. But bear in mind that in decent languages arrays are
>>> storable values, so a value array parameter gets copied in toto, unlike C.
>>>
>>
>> Are you saying that C doesn't implement true recursion? I have only
>> used recursion in college and not with C. ALGOL, SIMPL-T and LISP were
>> the only languages I used to write recursive algorithms.
>
>Yes, C does recursion.  Local variables are also on the stack.

More precisely, variables with non-file scope declared implicitly
or explicitly automatic, are on the stack.   Variables with non-file
scope can still be declared static, if desired.


int
f(int a, int b)
{
   int   c;           /*  Implicit auto: on stack */
   auto int d;        /*  Explicit auto: on stack */
   static int e;      /*  Explicit static: in data section */

   return a + b;
}



Re: using an FPGA to emulate a vintage computer - (see below) - 2010-02-25 14:52:00

On 24/02/2010 20:37, in article
h...@news6.newsguy.com, "Michael
Wojcik" <m...@newsguy.com> wrote:

> (see below) wrote:
>> 
>> Just the usual red tape: return address, frame pointer of caller; and either
>> a static pointer or some housekeeping for 'display' registers (if used) to
>> access non-locals. But bear in mind that in decent languages arrays are
>> storable values, so a value array parameter gets copied in toto, unlike C.
> 
> It will be in C if the array is wrapped in a struct. Letting array

That is passing a struct, not an array.

> parameters decay to pointers was a feature of early C that couldn't be
> changed for historical reasons, but when the standardization committee
> added support for struct parameters, they made them first-class.
 
> struct (and not the misnamed "typedef") is C's mechanism for creating
> new types and ADTs, so if you want a pass-by-value array in C, the
> correct thing to do is to put it in a struct.

Yes. Preposterous, isn't it?

> This is not to say that C's parameter passing doesn't still have a
> number of infelicities. Exposing the use of pointers to implement
> pass-by-reference (which C lacks, strictly speaking) has some
> advantages, but it has led to great confusion over matters like the
> const and restrict qualifiers.

To say the least of it.

-- 
Bill Findlay
<surname><forename> chez blueyonder.co.uk



Re: using an FPGA to emulate a vintage computer - (see below) - 2010-02-25 14:59:00

On 25/02/2010 17:34, in article
e...@o3g2000yqb.googlegroups.com, "Eric
Chomko" <p...@comcast.net> wrote:

> On Feb 24, 6:20 pm, "(see below)" <yaldni...@blueyonder.co.uk>
wrote:
>> On 24/02/2010 19:31, in article
>> d902c75e-e33a-4281-a796-7c56c3276...@o16g2000prh.googlegroups.com, "Eric
>> 
>> 
>> 
>> Chomko" <pne.cho...@comcast.net> wrote:
>>> On Feb 23, 2:07 pm, "(see below)"
<yaldni...@blueyonder.co.uk> wrote:
>>>> On 23/02/2010 17:52, in article
>>>> 3ec03225-3a0f-4bcd-9db1-51201d1b3...@w12g2000vbj.googlegroups.com,
"Eric
>> 
>>>> Chomko" <pne.cho...@comcast.net> wrote:
>>>>> But an ALGOL "activation record" (stack frame) had a lot
more than
>>>>> that. As I recall, they copied a lot more just pointers and
parameter
>>>>> values.
>> 
>>>> Just the usual red tape: return address, frame pointer of caller; and
>>>> either
>>>> a static pointer or some housekeeping for 'display' registers (if used)
to
>>>> access non-locals. But bear in mind that in decent languages arrays are
>>>> storable values, so a value array parameter gets copied in toto, unlike
C.
>> 
>>> Are you saying that C doesn't implement true recursion? I have only
>>> used recursion in college and not with C. ALGOL, SIMPL-T and LISP were
>>> the only languages I used to write recursive algorithms.
>> 
>> No. I'm at a loss as to how you could put that interpretation on it.
> 
> Perhaps I misunderstood your reference, "unlike C".  As I recall the
> difference between a global and local variable in a block-structured
> language is that a global is statically stored like all FORTRAN IV
> variables. And locals get put onto the stack with each call to the
> function and are dynamically allocated. It is this last aspect that
> allows recursion to occur other than allowing a function to call
> itself.

True, but I'm still at a loss. How does "so a value array *parameter* gets
copied in toto, unlike C" lead you to a consideration of the scope and
lifetime of *variables*?

>> I'm saying that array parameters in C are not called by value, but they are
>> in Algol 60 and cognate languages, requiring more stack space than C does.
> 
> 
> Doesn't a C stack frame contain a lot less than an ALGOL activation
> record other than just parameter information?

If you mean the obligatory stuff to implement procedure calls, no, it
doesn't; with the possible exception of a static pointer/display (needed in
very recent C dialects, but not in versions lacking nested scopes).

-- 
Bill Findlay
<surname><forename> chez blueyonder.co.uk


______________________________
Join the blogging team on FPGARelated.com and earn rewards! Details Here.

Re: using an FPGA to emulate a vintage computer - Jon Elson - 2010-02-25 15:42:00

Eric Chomko wrote:

> 
> Are you saying that C doesn't implement true recursion? I have only
> used recursion in college and not with C. ALGOL, SIMPL-T and LISP were
> the only languages I used to write recursive algorithms.
> 
I think he's saying C doesn't, by default, copy entire arrays, it 
defaults to passing a pointer to the array.  If a recursive procedure 
NEEDS the array to be copied, there are mechanisms to do that.  But, of 
course, copying the pointer only is more efficient both in time and memory.

Jon

Re: using an FPGA to emulate a vintage computer - glen herrmannsfeldt - 2010-02-25 16:32:00

In comp.arch.fpga Jon Elson
<j...@wustl.edu> wrote:
> Eric Chomko wrote:
 
>> Are you saying that C doesn't implement true recursion? I have only
>> used recursion in college and not with C. ALGOL, SIMPL-T and LISP were
>> the only languages I used to write recursive algorithms.
 
> I think he's saying C doesn't, by default, copy entire arrays, it 
> defaults to passing a pointer to the array.  If a recursive procedure 
> NEEDS the array to be copied, there are mechanisms to do that.  But, of 
> course, copying the pointer only is more efficient both in time and memory.

But local arrays are automatic in C.  I would think that would
usually work fine for recursion.  K&R required initialized arrays
to be static, which doesn't seem like a bad requirement to me.
(Fortran requires all initialized variables to be static.)

-- glen

Re: using an FPGA to emulate a vintage computer - Scott Lurndal - 2010-02-25 18:26:00

"(see below)"
<y...@blueyonder.co.uk> writes:
>On 24/02/2010 20:37, in article h...@news6.newsguy.com, "Michael
>Wojcik" <m...@newsguy.com> wrote:
>
>> (see below) wrote:
>>> 
>>> Just the usual red tape: return address, frame pointer of caller; and either
>>> a static pointer or some housekeeping for 'display' registers (if used) to
>>> access non-locals. But bear in mind that in decent languages arrays are
>>> storable values, so a value array parameter gets copied in toto, unlike C.
>> 
>> It will be in C if the array is wrapped in a struct. Letting array
>
>That is passing a struct, not an array.
>
>> parameters decay to pointers was a feature of early C that couldn't be
>> changed for historical reasons, but when the standardization committee
>> added support for struct parameters, they made them first-class.
> 
>> struct (and not the misnamed "typedef") is C's mechanism for creating
>> new types and ADTs, so if you want a pass-by-value array in C, the
>> correct thing to do is to put it in a struct.
>
>Yes. Preposterous, isn't it?

Q?  Why would anyone want to pass an array by value?

scott


Re: using an FPGA to emulate a vintage computer - (see below) - 2010-02-25 18:32:00

On 25/02/2010 23:26, in article
SGDhn.70229$H...@news.usenetserver.com,
"Scott Lurndal" <s...@slp53.sl.home> wrote:

> "(see below)" <y...@blueyonder.co.uk> writes:
>> On 24/02/2010 20:37, in article h...@news6.newsguy.com, "Michael
>> Wojcik" <m...@newsguy.com> wrote:
>> 
>>> (see below) wrote:
>>>> 
>>>> Just the usual red tape: return address, frame pointer of caller; and
>>>> either
>>>> a static pointer or some housekeeping for 'display' registers (if used)
to
>>>> access non-locals. But bear in mind that in decent languages arrays are
>>>> storable values, so a value array parameter gets copied in toto, unlike
C.
>>> 
>>> It will be in C if the array is wrapped in a struct. Letting array
>> 
>> That is passing a struct, not an array.
>> 
>>> parameters decay to pointers was a feature of early C that couldn't be
>>> changed for historical reasons, but when the standardization committee
>>> added support for struct parameters, they made them first-class.
>> 
>>> struct (and not the misnamed "typedef") is C's mechanism for
creating
>>> new types and ADTs, so if you want a pass-by-value array in C, the
>>> correct thing to do is to put it in a struct.
>> 
>> Yes. Preposterous, isn't it?
> 
> Q?  Why would anyone want to pass an array by value?

Why would anyone want to wrap an array in a struct and pass that by value?

-- 
Bill Findlay
<surname><forename> chez blueyonder.co.uk


______________________________
Join the blogging team on FPGARelated.com and earn rewards! Details Here.

Re: using an FPGA to emulate a vintage computer - Scott Lurndal - 2010-02-25 20:24:00

"(see below)"
<y...@blueyonder.co.uk> writes:
>On 25/02/2010 23:26, in article SGDhn.70229$H...@news.usenetserver.com,
>"Scott Lurndal" <s...@slp53.sl.home> wrote:
>
>> "(see below)" <y...@blueyonder.co.uk> writes:
>>> On 24/02/2010 20:37, in article h...@news6.newsguy.com, "Michael
>>> Wojcik" <m...@newsguy.com> wrote:
>>> 
>>>> (see below) wrote:
>>>>> 
>>>>> Just the usual red tape: return address, frame pointer of caller;
and
>>>>> either
>>>>> a static pointer or some housekeeping for 'display' registers (if
used) to
>>>>> access non-locals. But bear in mind that in decent languages arrays
are
>>>>> storable values, so a value array parameter gets copied in toto,
unlike C.
>>>> 
>>>> It will be in C if the array is wrapped in a struct. Letting array
>>> 
>>> That is passing a struct, not an array.
>>> 
>>>> parameters decay to pointers was a feature of early C that couldn't be
>>>> changed for historical reasons, but when the standardization committee
>>>> added support for struct parameters, they made them first-class.
>>> 
>>>> struct (and not the misnamed "typedef") is C's mechanism for
creating
>>>> new types and ADTs, so if you want a pass-by-value array in C, the
>>>> correct thing to do is to put it in a struct.
>>> 
>>> Yes. Preposterous, isn't it?
>> 
>> Q?  Why would anyone want to pass an array by value?
>
>Why would anyone want to wrap an array in a struct and pass that by value?

Why answer a question with another question?

I've never promoted or suggested that one put an array in a struct
and pass it by value, I frankly think it would be a stupid thing to
do in a C program.

I was curious if anyone thought passing an array by value was a
_good_ idea.

scott

______________________________
Join the blogging team on FPGARelated.com and earn rewards! Details Here.

Re: using an FPGA to emulate a vintage computer - glen herrmannsfeldt - 2010-02-25 21:02:00

In comp.arch.fpga Scott Lurndal
<s...@slp53.sl.home> wrote:
(snip, someone wrote)
>>> Q?  Why would anyone want to pass an array by value?

>>Why would anyone want to wrap an array in a struct and pass that by value?
 
> Why answer a question with another question?
 
> I've never promoted or suggested that one put an array in a struct
> and pass it by value, I frankly think it would be a stupid thing to
> do in a C program.

It might make sense for a small array.  You might have an rgb
array dimensioned [3] instead of three separae variables.  
The dimension, I believe, has to be a compile time constant.

-- glen 

Re: using an FPGA to emulate a vintage computer - Joe Pfeiffer - 2010-02-25 23:02:00

glen herrmannsfeldt <g...@ugcs.caltech.edu>
writes:

> In comp.arch.fpga Scott Lurndal <s...@slp53.sl.home> wrote:
> (snip, someone wrote)
>>>> Q?  Why would anyone want to pass an array by value?
>
>>>Why would anyone want to wrap an array in a struct and pass that by value?
>  
>> Why answer a question with another question?
>  
>> I've never promoted or suggested that one put an array in a struct
>> and pass it by value, I frankly think it would be a stupid thing to
>> do in a C program.
>
> It might make sense for a small array.  You might have an rgb
> array dimensioned [3] instead of three separae variables.  
> The dimension, I believe, has to be a compile time constant.

It doesn't.  You can use malloc() to allocate an arbitrary-sized buffer,
and then use array syntax to access elements of the buffer.  You can
also pass the address of the buffer, and use it like an array in the
called procedure.

Since C99, you can allocate an array with a variable number of elements
like this:

    printf(" array size >> ");
    scanf("%d", &size);

    int awry[size];
-- 
As we enjoy great advantages from the inventions of others, we should
be glad of an opportunity to serve others by any invention of ours;
and this we should do freely and generously. (Benjamin Franklin)

previous | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | next