| Author |
Message |
Ask
Guest
|
Posted:
Mon Nov 28, 2005 9:15 am Post subject:
Max code size |
|
|
Hi All
A basic question that was confusing me - is there any upper limit on
the size of a program ? Say the architecture is 32 bit. I was of the
opinion that at most the program can have 2^32 instructions and virtual
memory size is 2^32 Is this correct ?
Thanks |
|
| Back to top |
|
 |
Patrick Schaaf
Guest
|
Posted:
Tue Nov 29, 2005 5:15 pm Post subject:
Re: Max code size |
|
|
"Ask" <ask.q@indiatimes.com> writes:
| Quote: | A basic question that was confusing me - is there any upper limit on
the size of a program ? Say the architecture is 32 bit. I was of the
opinion that at most the program can have 2^32 instructions and virtual
memory size is 2^32 Is this correct ?
|
A program can contain code which modifies part of the program itself,
or which accidentally permits such modification. Thus, program
instruction size, over the possible lifetime of a program, is not
restricted by local processor addressing issues.
The 32-bitness of an architecture only constrains where from
(virtual or physical, doesn't matter) instructions can be read.
It does not constrain in any way which instructions will then
be found, there.
best regards
Patrick |
|
| Back to top |
|
 |
Torben Ægidius Mogensen
Guest
|
Posted:
Tue Nov 29, 2005 5:15 pm Post subject:
Re: Max code size |
|
|
"Ask" <ask.q@indiatimes.com> writes:
| Quote: | A basic question that was confusing me - is there any upper limit on
the size of a program ? Say the architecture is 32 bit. I was of the
opinion that at most the program can have 2^32 instructions and virtual
memory size is 2^32 Is this correct ?
|
Not entirely. Some architectures reserve some portions of the address
space for memory-mapped i/o, interrupt vectors, etc. So you,
generally, can't have programs that fill the entire address space.
Also, the address space need not be 2^N, where N is the size of a
machine word. Some use segmented addressing to increase the address
space beyond this, and others limit the addressable space to something
smaller. And some limit the size of the PC to something smaller than
a machine word.
Early ARM processors used the top 4 bits of the PC for arithmetic
flags and the next two for interrupt enable flags, so programs could
only reside in the low 2^26 bytes (= 64MB) of memory. ARM was
designed in 1985, when most machines were limited to 64KB, so this
didn't seem unreasonable. Around 1990, ARM moved the flags into a
separate register, allowing the PC to use the full 32 bits.
Torben |
|
| Back to top |
|
 |
Alex Colvin
Guest
|
Posted:
Wed Nov 30, 2005 8:42 pm Post subject:
Re: Max code size |
|
|
| Quote: | A basic question that was confusing me - is there any upper limit on
the size of a program ? Say the architecture is 32 bit. I was of the
opinion that at most the program can have 2^32 instructions and virtual
memory size is 2^32 Is this correct ?
|
It varies. if you have a unified instrection and data address space, then
you could potentially have 2^32 instructions, as long as you had no data.
Architectures that run out of address bits often split instructions and
data into separate space, so that you can have 2^32 of instructions and
also 2^32 of data.
Some architectures further divide the address space, so that some large
chunk is set aside for priveleged access, so your instructions may be
limited to 2^31 or less.
Various software tricks can extend this, so that you may be limited to
somthing like 2^32 entry points (subroutines), without limit on
instructions.
And if your instructions are larger than one address unit (e.g. byte), you
probably get correspondingly fewer.
--
mac the naïf |
|
| Back to top |
|
 |
|
|
|
|