comp.lang.ada
 help / color / mirror / Atom feed
* Re: Gnat For use at Question
  1996-07-11  0:00 Gnat For use at Question Spasmo
  1996-07-11  0:00 ` Robert Dewar
@ 1996-07-11  0:00 ` Jerry van Dijk
  1996-07-11  0:00 ` Robert A Duff
  1996-07-11  0:00 ` Jon S Anthony
  3 siblings, 0 replies; 18+ messages in thread
From: Jerry van Dijk @ 1996-07-11  0:00 UTC (permalink / raw)



Spasmo (cosc19z5@Bayou.UH.EDU) wrote:

: Gnat305S for DOS
               ^^^
Note the DOS!

: I'm trying to create an array at an absolute memory location

Sounds reasonable, but:

: Some_Array : String(1..4000);
: for Some_Array use at 16#bbbbb#;

apart from the syntax problems already mentioned by Bob, if this address
is in conventional memory (< 1 Mb, say accessing the screen memory :-)
it it not possible to address it this way, due to the way the djgpp
protected mode system works.

The way to do this safely is to use the djgpp far pointer package or
any of the other two less safe methods outlined in the djgpp FAQ.

If you are feeling really adventures *and* know for sure that your
program will only be run with the CWSDPMI or other DMPI v1.0 provider,
it is possible to do this using the dpmi_map_conventional_memory...
functions. But, warning: the CWSDPMI dpmi_get_capabilities call is
not always as reliable as it should be!

If I guessed right but the above doesn't make sense, email me.

Regards,
Jerry.

-- 
-----------------------------------------------------------------------
--  Jerry van Dijk       --   e-mail: jerry@jvdsys.nextjk.stuyts.nl  --
--  Banking Consultant   --              Member Team-Ada             -- 
--  Ordina Finance BV    --    Located at Haarlem, The Netherlands   --




^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Gnat For use at Question
  1996-07-11  0:00 Gnat For use at Question Spasmo
@ 1996-07-11  0:00 ` Robert Dewar
  1996-07-19  0:00   ` Spasmo
  1996-07-11  0:00 ` Jerry van Dijk
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 18+ messages in thread
From: Robert Dewar @ 1996-07-11  0:00 UTC (permalink / raw)



Spasmo asks why GNAT rejects:
"Some_Array : String(1..4000);
for Some_Array use at 16#bbbbb#;"

GNAT rejects this because it is plainly illegal. Address, in accordance
with the implementation ad vice in the Ada 95 RM is a private type in
GNAT, and you obviously can't use an integer literal as the value of 
a private type.

Look up the facilities in System.Storage_Elements to find out how to
do what you want. Rememeber that GNAT implements the restriction that
the address expression must be a prior defined constant, so you cannot
just use To_Address directly, since a call to To_Address is not static.
So you want something like:

	Some_Array_Address : constant Address := To_Address (16#bbbb#);
        Some_Array : String (1 .. 4000);
        for Some_Array'Address use Some_Array_Address;

P.S. since almost certainly what you have in mind is overlaying the
display buffer, it would be much neater to have an Ada variable with
more structure (something like a two dimensional array of records
containing an attribute which is a packed record and a character).





^ permalink raw reply	[flat|nested] 18+ messages in thread

* Gnat For use at Question
@ 1996-07-11  0:00 Spasmo
  1996-07-11  0:00 ` Robert Dewar
                   ` (3 more replies)
  0 siblings, 4 replies; 18+ messages in thread
From: Spasmo @ 1996-07-11  0:00 UTC (permalink / raw)



Hey all.

I've recently leeched Gnat305S for DOS, and installed it using
ginstall, and I've run into a problem.

I'm trying to create an array at an absolute memory location, but
I keep on getting some error with "expect System.Address blah blah"
whenever I try.

Here's what I'm doing:

Some_Array : String(1..4000);
for Some_Array use at 16#bbbbb#;

Well I've tried variations, including trying to declare the
address of type System.Address, but then I get a "universal
integer" error.  I've looked throughout my gnat305 directory
tree for docs on this, but to no avail.

Would someone please tell me the proper way of doing this?
Is System.Address a special type that has fields, or uses some
kind of access procedures in the package to initialize?

Thanks in advance.


--
Spasmo
"Here's a present just for you
When you open it, you'll be through"
	"Letter Bomb" by the Circle Jerks





^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Gnat For use at Question
  1996-07-11  0:00 Gnat For use at Question Spasmo
  1996-07-11  0:00 ` Robert Dewar
  1996-07-11  0:00 ` Jerry van Dijk
@ 1996-07-11  0:00 ` Robert A Duff
  1996-07-11  0:00 ` Jon S Anthony
  3 siblings, 0 replies; 18+ messages in thread
From: Robert A Duff @ 1996-07-11  0:00 UTC (permalink / raw)



In article <4s2eb5$qt6@masala.cc.uh.edu>, Spasmo <cosc19z5@Bayou.UH.EDU> wrote:
>Is System.Address a special type that has fields, or uses some
>kind of access procedures in the package to initialize?

Look at package System in the RM.  It's a private type (not an integer
type), and there are various conversion functions in System and its
children that can be used to create Address values.

Also, you will need to declare a *constant* of type Address, and use
that in the address clause.  Put the constant before the variable you're
setting the address of.

In Ada 95, the preferred syntax is "for X'Address use Blah;", rather
than "for X use at Blah;".

- Bob




^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Gnat For use at Question
  1996-07-11  0:00 Gnat For use at Question Spasmo
                   ` (2 preceding siblings ...)
  1996-07-11  0:00 ` Robert A Duff
@ 1996-07-11  0:00 ` Jon S Anthony
  1996-07-11  0:00   ` Robert A Duff
                     ` (6 more replies)
  3 siblings, 7 replies; 18+ messages in thread
From: Jon S Anthony @ 1996-07-11  0:00 UTC (permalink / raw)



In article <4s2eb5$qt6@masala.cc.uh.edu> cosc19z5@Bayou.UH.EDU (Spasmo) writes:

> I'm trying to create an array at an absolute memory location, but
> I keep on getting some error with "expect System.Address blah blah"
> whenever I try.

Actually, the error messages are _extremely_ clear and tell you _exactly_
what is wrong and even how to fix it:

procedure Junk2 is
     Some_Array : String(1..4000);
        for Some_Array'Address use 16#bbbbb#;
 begin
    null;
end;

$ gnat junk2.adb
junk2.adb:4:36: expected private type "System.Address"
junk2.adb:4:36: found type universal integer
junk2.adb:4:36: invalid address clause for "Some_Array"
junk2.adb:4:36: must be constant defined before "Some_Array" (RM 13.1(22))

As you can see there is even an RM reference.  Let's just follow our
nose a little on this error trail and see what pops out.  The first
error sez that at the 16#... stuff location the compiler expected
System.Address but found universal integer.  Hence, 16#... is a
universal integer and it is no good for an address clause.  So, you
know that you need to make the value an instance of System.Address for
it to have a hope of working.  Next, the errors say that the clause
itself is wrong because it must be a _constant_ defined _before_ the
variable to which it applies (Some_Array).  Even gives an RM ref for
this.  So, you now know that you must define the address as a constant
before the variable Some_Array and that it must be of type
System.Address.  So,

with System.Storage_Elements;
use  System.Storage_Elements;
procedure Junk2 is
    Some_Array_Address : constant System.Address := To_Address(16#bbbbb#);
    Some_Array : String(1..4000);
        for Some_Array'Address use Some_Array_Address; 
begin
    null;
end;

$ gnat junk2.adb
$

The only goofy thing about this I suppose, is that To_Address (which takes
integers and returns the proper address) is not defined in System (along
with Address) but in the child Storage_Elements.  Goodness knows how that
happened...

/Jon
-- 
Jon Anthony
Organon Motives, Inc.
1 Williston Road, Suite 4
Belmont, MA 02178

617.484.3383
jsa@organon.com





^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Gnat For use at Question
  1996-07-11  0:00 ` Jon S Anthony
@ 1996-07-11  0:00   ` Robert A Duff
  1996-07-12  0:00   ` Laurent Guerby
                     ` (5 subsequent siblings)
  6 siblings, 0 replies; 18+ messages in thread
From: Robert A Duff @ 1996-07-11  0:00 UTC (permalink / raw)



In article <JSA.96Jul11143114@organon.com>,
Jon S Anthony <jsa@organon.com> wrote:
>The only goofy thing about this I suppose, is that To_Address (which takes
>integers and returns the proper address) is not defined in System (along
>with Address) but in the child Storage_Elements.  Goodness knows how that
>happened...

Goodness indeed knows, but then so do I.  ;-)

There was some pressure from compiler vendors to avoid adding a lot of
junk to System, since System was in Ada 83, and was somewhat
implementation dependent, and various implementations had their own
versions of System.  They didn't want their customers disrupted by
making changes to System.  So, we avoided changing System, except in
certain cases where it really seemed worth the trouble.

Furthermore, converting integers to addresses is in some sense more
dangerous than simply using addresses (perhaps generated by 'Address,
for example).  Therefore, it makes sense to have a separate child
package containing that dirt.

We carefully considered whether each operation should be in System, or
in a child of System.  You might not agree with our decisions, but it
wasn't accidental, and I don't think "Goodness" had a lot to do with it.
;-)

- Bob




^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Gnat For use at Question
  1996-07-11  0:00 ` Jon S Anthony
                     ` (2 preceding siblings ...)
  1996-07-12  0:00   ` Jon S Anthony
@ 1996-07-12  0:00   ` Spasmo
  1996-07-12  0:00   ` Robert Dewar
                     ` (2 subsequent siblings)
  6 siblings, 0 replies; 18+ messages in thread
From: Spasmo @ 1996-07-12  0:00 UTC (permalink / raw)



Jon S Anthony (jsa@organon.com) wrote:
: In article <4s2eb5$qt6@masala.cc.uh.edu> cosc19z5@Bayou.UH.EDU (Spasmo) writes:

: > I'm trying to create an array at an absolute memory location, but
: > I keep on getting some error with "expect System.Address blah blah"
: > whenever I try.

: Actually, the error messages are _extremely_ clear and tell you _exactly_
: what is wrong and even how to fix it:

Well I never said that the error message was unclear, I was however
quite unfamiliar with what it was saying.  It made mention of a
"System.Address", but I couldn't figure out what it meant (I'm
an Ada newbie BTW).  


: procedure Junk2 is
:      Some_Array : String(1..4000);
:         for Some_Array'Address use 16#bbbbb#;
:  begin
:     null;
: end;


: $ gnat junk2.adb
: junk2.adb:4:36: expected private type "System.Address"
: junk2.adb:4:36: found type universal integer
: junk2.adb:4:36: invalid address clause for "Some_Array"
: junk2.adb:4:36: must be constant defined before "Some_Array" (RM 13.1(22))

That's exactly what I got. The thing is I don't have the RM so
I was unable to look up the specifics.  


: As you can see there is even an RM reference.  Let's just follow our
: nose a little on this error trail and see what pops out.  The first
: error sez that at the 16#... stuff location the compiler expected
: System.Address but found universal integer.  Hence, 16#... is a
: universal integer and it is no good for an address clause.  So, you
: know that you need to make the value an instance of System.Address for
: it to have a hope of working.  Next, the errors say that the clause
: itself is wrong because it must be a _constant_ defined _before_ the
: variable to which it applies (Some_Array).  Even gives an RM ref for
: this.  So, you now know that you must define the address as a constant
: before the variable Some_Array and that it must be of type
: System.Address.  So,

Ok, I pretty much had an idea about declaring the address as an
instance of System.Address and as a constant which is what I did.
I also did a with System, or something similar.


: with System.Storage_Elements;

Ok, I didn't do Storage_Elements;


: use  System.Storage_Elements;
: procedure Junk2 is
:     Some_Array_Address : constant System.Address := To_Address(16#bbbbb#);

Ok, To_Address -- that I didn't do either.


:     Some_Array : String(1..4000);
:         for Some_Array'Address use Some_Array_Address; 

Is the 'Address necessary?  Every book I have doesn't mention
it but just says for Some_Array.  


: begin
:     null;
: end;

: $ gnat junk2.adb
: $

: The only goofy thing about this I suppose, is that To_Address (which takes
: integers and returns the proper address) is not defined in System (along
: with Address) but in the child Storage_Elements.  Goodness knows how that
: happened...

Hmmmm ok, well here's a question about To_Address.  Since PC's use
segment, base addressing, is there an overload of To_Address that
accepts both a segment and base, or is it up to us to "massage"
the number into the proper format for To_Address?  Are there any
functions that do this "massaging" for us?  Thanks for the help.


: /Jon
: -- 
: Jon Anthony
: Organon Motives, Inc.
: 1 Williston Road, Suite 4
: Belmont, MA 02178

: 617.484.3383
: jsa@organon.com


--
Spasmo
"Here's a present just for you
When you open it, you'll be through"
	"Letter Bomb" by the Circle Jerks





^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Gnat For use at Question
  1996-07-11  0:00 ` Jon S Anthony
  1996-07-11  0:00   ` Robert A Duff
  1996-07-12  0:00   ` Laurent Guerby
@ 1996-07-12  0:00   ` Jon S Anthony
  1996-07-12  0:00   ` Spasmo
                     ` (3 subsequent siblings)
  6 siblings, 0 replies; 18+ messages in thread
From: Jon S Anthony @ 1996-07-12  0:00 UTC (permalink / raw)



In article <DuEECA.7r0@world.std.com> bobduff@world.std.com (Robert A Duff) writes:

> We carefully considered whether each operation should be in System, or
> in a child of System.  You might not agree with our decisions, but it
> wasn't accidental, and I don't think "Goodness" had a lot to do with it.
> ;-)

:-) :-) :-)

/Jon
-- 
Jon Anthony
Organon Motives, Inc.
1 Williston Road, Suite 4
Belmont, MA 02178

617.484.3383
jsa@organon.com





^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Gnat For use at Question
  1996-07-11  0:00 ` Jon S Anthony
  1996-07-11  0:00   ` Robert A Duff
@ 1996-07-12  0:00   ` Laurent Guerby
  1996-07-13  0:00     ` Jerry van Dijk
  1996-07-15  0:00     ` Spasmo
  1996-07-12  0:00   ` Jon S Anthony
                     ` (4 subsequent siblings)
  6 siblings, 2 replies; 18+ messages in thread
From: Laurent Guerby @ 1996-07-12  0:00 UTC (permalink / raw)



[...]
Spasmo> That's exactly what I got. The thing is I don't have the RM so
Spasmo> I was unable to look up the specifics.

   Where did you get GNAT from? I guess that most Ada CD have an
hypertext version of the RM lying somewhere (and may be even of the
Rationale, Ada Quality & Style, Ada in Action, FAQs, Lovelace and
other tutorials). If not, I hope the next releases will pick all this
free high quality material. Of course if you have web access, just
have a look at:

   http://lglwww.epfl.ch/Ada

[...]
Spasmo> : Some_Array : String(1..4000); 
Spasmo> : for Some_Array'Address use Some_Array_Address;

Spasmo> Is the 'Address necessary?  Every book I have doesn't mention
Spasmo> it but just says for Some_Array.

   Hum it's the Ada 95 syntax and I guess your books all are Ada 83
books. The Ada 83 syntax is:

   for Some_Array use at Some_Array_Address;
                      ^^

   The Ada 95 syntax is more uniform, clauses follow the general syntax:

   for Entity'Attribute use Value;

[...]
Spasmo> Hmmmm ok, well here's a question about To_Address.  Since PC's
Spasmo> use segment, base addressing, is there an overload of
Spasmo> To_Address that accepts both a segment and base, or is it up
Spasmo> to us to "massage" the number into the proper format for
Spasmo> To_Address?  Are there any functions that do this "massaging"
Spasmo> for us?  Thanks for the help.

   This is a question for a DJGPP master I guess. If you manage to
make it work with GCC/C, it should work the same way with GCC/Ada.

-- 
Laurent Guerby <guerby@gnat.com>, Team Ada.
   "Use the Source, Luke. The Source will be with you, always (GPL)."




^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Gnat For use at Question
  1996-07-11  0:00 ` Jon S Anthony
                     ` (3 preceding siblings ...)
  1996-07-12  0:00   ` Spasmo
@ 1996-07-12  0:00   ` Robert Dewar
  1996-07-15  0:00   ` Jon S Anthony
  1996-07-15  0:00   ` Jon S Anthony
  6 siblings, 0 replies; 18+ messages in thread
From: Robert Dewar @ 1996-07-12  0:00 UTC (permalink / raw)



Jon notes that we give an RM reference on this error message

"junk2.adb:4:36: must be constant defined before "Some_Array" (RM 13.1(22))"

Normally we avoid giving RM references, since the RM is seldom helpful if
a message is not clear, and we regard the challenge in error messages
to get short clear messages that do NOT send you scurrying off to the RM
to understand them.

However, this particular case is a rather obscure restriction, and we got
bombarded with people demanding to know how we justified this restriction
Hence the (for GNAT) unusual RM reference in an error message :-)






^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Gnat For use at Question
  1996-07-12  0:00   ` Laurent Guerby
@ 1996-07-13  0:00     ` Jerry van Dijk
  1996-07-15  0:00     ` Spasmo
  1 sibling, 0 replies; 18+ messages in thread
From: Jerry van Dijk @ 1996-07-13  0:00 UTC (permalink / raw)



Laurent Guerby (guerby@gnat.com) wrote:

: Spasmo> Hmmmm ok, well here's a question about To_Address.  Since PC's
: Spasmo> use segment, base addressing,

:    This is a question for a DJGPP master I guess.

Now, I couldn't let that pass, could I ?

The segment:offset adressing is something that belongs to the real-mode
domain. As djgpp (and thus GNAT/DOS) is a protected mode eviroment it
uses the full 32-bit physical addressing. (Physical := 16 * segment + offset).
Instead of a segment, protected mode uses a selector, but a selectors memory
range can be 4 Gb, instead of real-mode's 64K.

-- 
-----------------------------------------------------------------------
--  Jerry van Dijk       --   e-mail: jerry@jvdsys.nextjk.stuyts.nl  --
--  Banking Consultant   --              Member Team-Ada             -- 
--  Ordina Finance BV    --    Located at Haarlem, The Netherlands   --




^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Gnat For use at Question
  1996-07-12  0:00   ` Laurent Guerby
  1996-07-13  0:00     ` Jerry van Dijk
@ 1996-07-15  0:00     ` Spasmo
  1 sibling, 0 replies; 18+ messages in thread
From: Spasmo @ 1996-07-15  0:00 UTC (permalink / raw)



Laurent Guerby (guerby@gnat.com) wrote:
: [...]
: Spasmo> That's exactly what I got. The thing is I don't have the RM so
: Spasmo> I was unable to look up the specifics.

:    Where did you get GNAT from? I guess that most Ada CD have an
: hypertext version of the RM lying somewhere (and may be even of the
: Rationale, Ada Quality & Style, Ada in Action, FAQs, Lovelace and
: other tutorials). If not, I hope the next releases will pick all this
: free high quality material. Of course if you have web access, just
: have a look at:

:    http://lglwww.epfl.ch/Ada

Yep got it--several kind people pointed out that site to me and
I leeched quite a bit.  Lovelace, AdaTutr, and a hypertext
version of the RM.

[Snip -- informative info on Ada95 syntax for such things]

Yep all my books are Ada83 ones.  I'm definitely going to look
for some Ada95 books.



: [...]
: Spasmo> Hmmmm ok, well here's a question about To_Address.  Since PC's
: Spasmo> use segment, base addressing, is there an overload of
: Spasmo> To_Address that accepts both a segment and base, or is it up
: Spasmo> to us to "massage" the number into the proper format for
: Spasmo> To_Address?  Are there any functions that do this "massaging"
: Spasmo> for us?  Thanks for the help.

:    This is a question for a DJGPP master I guess. If you manage to
: make it work with GCC/C, it should work the same way with GCC/Ada.

Hmmmm, well I managed to get it to work with Turbo C, but then I
had the MK_FP macro--but I think it all boiled down to shifting
the address.  I wasn't sure if that would cut it since my program
seemed to have some tie-ins to a memory manager so I wasn't sure
if some kind of mapping would occur that would obliterate any
hopes of manually doing something like that.  I know I finally
got the code to compile (thanks all), but running it resulted
in a Segmentation Fault.  Just like being on UNIX :)


: -- 
: Laurent Guerby <guerby@gnat.com>, Team Ada.
:    "Use the Source, Luke. The Source will be with you, always (GPL)."

--
Spasmo
"Here's a present just for you
When you open it, you'll be through"
	"Letter Bomb" by the Circle Jerks





^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Gnat For use at Question
  1996-07-15  0:00   ` Jon S Anthony
  1996-07-15  0:00     ` Jerry van Dijk
@ 1996-07-15  0:00     ` Spasmo
  1996-07-15  0:00     ` Robert Dewar
  2 siblings, 0 replies; 18+ messages in thread
From: Spasmo @ 1996-07-15  0:00 UTC (permalink / raw)



Jon S Anthony (jsa@organon.com) wrote:
: In article <DuI8zM.BJ@jvdsys.nextjk.stuyts.nl> jerry@jvdsys.nextjk.stuyts.nl (Jerry van Dijk) writes:

[Snip]

: > Now, I couldn't let that pass, could I ?
: > 
: > The segment:offset adressing is something that belongs to the real-mode
: > domain. As djgpp (and thus GNAT/DOS) is a protected mode eviroment it
: > uses the full 32-bit physical addressing. (Physical := 16 * segment + offset).

: Sounds like what you are saying is that for the user model (of the
: language and implementation in this case) the segmenation stuff is
: hidden and thus irrelevant.  True?

Hmmmm, well my whole purpose for using an absolute address array was
to get at Screen Memory to do some enhanced IO since I couldn't find
any such thing in Gnat.  You know stuff like colored text, filling 
various portions of the screen in color, etc... I might also have
tried my hand at poking into other keyboard addresses for some
better keyboard handling (if possible, last time I did anything
close I just wrote my own keyboard ISR and installed it in
place of the original and chained the original from there). 
The reason that would have happened is because Get_Immediate
seems to wait for CR before processing, which for me isn't
what I want.

Of course there still is the PDCurses package I managed to leech
so I can go for interfacing with C code at this point.

Thanks for all the help.


: /Jon
: -- 
: Jon Anthony
: Organon Motives, Inc.
: 1 Williston Road, Suite 4
: Belmont, MA 02178

: 617.484.3383
: jsa@organon.com


--
Spasmo
"Here's a present just for you
When you open it, you'll be through"
	"Letter Bomb" by the Circle Jerks





^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Gnat For use at Question
  1996-07-15  0:00   ` Jon S Anthony
  1996-07-15  0:00     ` Jerry van Dijk
  1996-07-15  0:00     ` Spasmo
@ 1996-07-15  0:00     ` Robert Dewar
  2 siblings, 0 replies; 18+ messages in thread
From: Robert Dewar @ 1996-07-15  0:00 UTC (permalink / raw)



Jon asked:

"Sounds like what you are saying is that for the user model (of the
language and implementation in this case) the segmenation stuff is
hidden and thus irrelevant.  True?
"

The segmentation stuff is hidden and irrelevant in all modern 32-bit
operating systems for the Intel x86 architecture, and arguably the
whole facility is an example of RISC-inspired rubbish (if you want
to know more about what I think on this subject, read my book on
microprocessor architecture :-)





^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Gnat For use at Question
  1996-07-11  0:00 ` Jon S Anthony
                     ` (5 preceding siblings ...)
  1996-07-15  0:00   ` Jon S Anthony
@ 1996-07-15  0:00   ` Jon S Anthony
  6 siblings, 0 replies; 18+ messages in thread
From: Jon S Anthony @ 1996-07-15  0:00 UTC (permalink / raw)



In article <4s6fk5$du5@masala.cc.uh.edu> cosc19z5@Bayou.UH.EDU (Spasmo) writes:

> Jon S Anthony (jsa@organon.com) wrote:
> : In article <4s2eb5$qt6@masala.cc.uh.edu> cosc19z5@Bayou.UH.EDU (Spasmo) writes:
> 
> : > I'm trying to create an array at an absolute memory location, but
> : > I keep on getting some error with "expect System.Address blah blah"
> : > whenever I try.
> 
> : Actually, the error messages are _extremely_ clear and tell you _exactly_
> : what is wrong and even how to fix it:
> 
> Well I never said that the error message was unclear, I was however
> quite unfamiliar with what it was saying.  It made mention of a
> "System.Address", but I couldn't figure out what it meant (I'm
> an Ada newbie BTW).  

Oh. Sorry.

> 
> 
> : procedure Junk2 is
> :      Some_Array : String(1..4000);
> :         for Some_Array'Address use 16#bbbbb#;
> :  begin
> :     null;
> : end;
> 
> 
> : $ gnat junk2.adb
> : junk2.adb:4:36: expected private type "System.Address"
> : junk2.adb:4:36: found type universal integer
> : junk2.adb:4:36: invalid address clause for "Some_Array"
> : junk2.adb:4:36: must be constant defined before "Some_Array" (RM 13.1(22))
> 
> That's exactly what I got. The thing is I don't have the RM so
> I was unable to look up the specifics.  

The best thing to do here is grab the HTML version or just use the online
HTML version at 

http://lglwww.epfl.ch/Ada/

> :         for Some_Array'Address use Some_Array_Address; 
> 
> Is the 'Address necessary?  Every book I have doesn't mention
> it but just says for Some_Array.  

It will be.  It is the Ada95 syntax for this and is really much better in
that it comes under the more regular umbrella of attribute clauses.
The "use at" stuff is Ada83 which will be accepted for some period of
time but is an "obsolete feature".

> Hmmmm ok, well here's a question about To_Address.  Since PC's use
> segment, base addressing, is there an overload of To_Address that
> accepts both a segment and base, or is it up to us to "massage"
> the number into the proper format for To_Address?  Are there any
> functions that do this "massaging" for us?  Thanks for the help.

Good question.  If there is it will be an implementation extension.
LabTek?  ACT?  Tomson?

/Jon
-- 
Jon Anthony
Organon Motives, Inc.
1 Williston Road, Suite 4
Belmont, MA 02178

617.484.3383
jsa@organon.com





^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Gnat For use at Question
  1996-07-11  0:00 ` Jon S Anthony
                     ` (4 preceding siblings ...)
  1996-07-12  0:00   ` Robert Dewar
@ 1996-07-15  0:00   ` Jon S Anthony
  1996-07-15  0:00     ` Jerry van Dijk
                       ` (2 more replies)
  1996-07-15  0:00   ` Jon S Anthony
  6 siblings, 3 replies; 18+ messages in thread
From: Jon S Anthony @ 1996-07-15  0:00 UTC (permalink / raw)



In article <DuI8zM.BJ@jvdsys.nextjk.stuyts.nl> jerry@jvdsys.nextjk.stuyts.nl (Jerry van Dijk) writes:

> Laurent Guerby (guerby@gnat.com) wrote:
> 
> : Spasmo> Hmmmm ok, well here's a question about To_Address.  Since PC's
> : Spasmo> use segment, base addressing,
> 
> :    This is a question for a DJGPP master I guess.
> 
> Now, I couldn't let that pass, could I ?
> 
> The segment:offset adressing is something that belongs to the real-mode
> domain. As djgpp (and thus GNAT/DOS) is a protected mode eviroment it
> uses the full 32-bit physical addressing. (Physical := 16 * segment + offset).

Sounds like what you are saying is that for the user model (of the
language and implementation in this case) the segmenation stuff is
hidden and thus irrelevant.  True?

/Jon
-- 
Jon Anthony
Organon Motives, Inc.
1 Williston Road, Suite 4
Belmont, MA 02178

617.484.3383
jsa@organon.com





^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Gnat For use at Question
  1996-07-15  0:00   ` Jon S Anthony
@ 1996-07-15  0:00     ` Jerry van Dijk
  1996-07-15  0:00     ` Spasmo
  1996-07-15  0:00     ` Robert Dewar
  2 siblings, 0 replies; 18+ messages in thread
From: Jerry van Dijk @ 1996-07-15  0:00 UTC (permalink / raw)



Jon S Anthony (jsa@organon.com) wrote:

: Sounds like what you are saying is that for the user model (of the
: language and implementation in this case) the segmenation stuff is
: hidden and thus irrelevant.  True?

Yes, as long as all data you are referencing is within your own program
space. The video buffer (which Spasmo was trying to access) definitively
is not.

Regards,
Jerry.

-- 
-----------------------------------------------------------------------
--  Jerry van Dijk       --   e-mail: jerry@jvdsys.nextjk.stuyts.nl  --
--  Banking Consultant   --              Member Team-Ada             -- 
--  Ordina Finance BV    --    Located at Haarlem, The Netherlands   --




^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Gnat For use at Question
  1996-07-11  0:00 ` Robert Dewar
@ 1996-07-19  0:00   ` Spasmo
  0 siblings, 0 replies; 18+ messages in thread
From: Spasmo @ 1996-07-19  0:00 UTC (permalink / raw)



Robert Dewar (dewar@cs.nyu.edu) wrote:
: Spasmo asks why GNAT rejects:
: "Some_Array : String(1..4000);
: for Some_Array use at 16#bbbbb#;"

: GNAT rejects this because it is plainly illegal. Address, in accordance
: with the implementation ad vice in the Ada 95 RM is a private type in
: GNAT, and you obviously can't use an integer literal as the value of 
: a private type.

: Look up the facilities in System.Storage_Elements to find out how to
: do what you want. Rememeber that GNAT implements the restriction that
: the address expression must be a prior defined constant, so you cannot
: just use To_Address directly, since a call to To_Address is not static.
: So you want something like:

: 	Some_Array_Address : constant Address := To_Address (16#bbbb#);
:         Some_Array : String (1 .. 4000);
:         for Some_Array'Address use Some_Array_Address;

: P.S. since almost certainly what you have in mind is overlaying the
: display buffer, it would be much neater to have an Ada variable with
: more structure (something like a two dimensional array of records
: containing an attribute which is a packed record and a character).


Yep accessing the display buffer :).  Well the reason I had the
array was just to do a quick and dirty test to see if this
would in fact work, although I might have kept it (C habit,
forgive me :).  Still since I got a segmentation fault after
properly compiling this (thanks for all the help) that
idea is out, but it doesn't matter to me since now I can
just import the various conio functions available that will
more or less do what I want.  Thanks to Jerry (forgot the
last name) for the sample code on that.


--
Spasmo
"Here's a present just for you
When you open it, you'll be through"
	"Letter Bomb" by the Circle Jerks





^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~1996-07-19  0:00 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-07-11  0:00 Gnat For use at Question Spasmo
1996-07-11  0:00 ` Robert Dewar
1996-07-19  0:00   ` Spasmo
1996-07-11  0:00 ` Jerry van Dijk
1996-07-11  0:00 ` Robert A Duff
1996-07-11  0:00 ` Jon S Anthony
1996-07-11  0:00   ` Robert A Duff
1996-07-12  0:00   ` Laurent Guerby
1996-07-13  0:00     ` Jerry van Dijk
1996-07-15  0:00     ` Spasmo
1996-07-12  0:00   ` Jon S Anthony
1996-07-12  0:00   ` Spasmo
1996-07-12  0:00   ` Robert Dewar
1996-07-15  0:00   ` Jon S Anthony
1996-07-15  0:00     ` Jerry van Dijk
1996-07-15  0:00     ` Spasmo
1996-07-15  0:00     ` Robert Dewar
1996-07-15  0:00   ` Jon S Anthony

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox