comp.lang.ada
 help / color / mirror / Atom feed
* Low Level Ada
@ 2003-11-19 13:43 Stephane Richard
  2003-11-19 18:40 ` Jeffrey Carter
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Stephane Richard @ 2003-11-19 13:43 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 403 bytes --]

By the subject line I mean:

Is there a way, in Ada to move memory around so to speak.

For instance, let's say I want to create an Array that would hold characters
with the goal to send it to the video card directly (address $B800).

Could I take an array of Characters, and "move it" to address $B800 ?  or
something like it?

-- 
St�phane Richard
"Ada World" Webmaster
http://www.adaworld.com






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

* Re: Low Level Ada
  2003-11-19 13:43 Low Level Ada Stephane Richard
@ 2003-11-19 18:40 ` Jeffrey Carter
  2003-11-19 18:47 ` Jim Rogers
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Jeffrey Carter @ 2003-11-19 18:40 UTC (permalink / raw)


Stephane Richard wrote:

> For instance, let's say I want to create an Array that would hold characters
> with the goal to send it to the video card directly (address $B800).
> 
> Could I take an array of Characters, and "move it" to address $B800 ?  or
> something like it?

Assuming you're talking about an OS such as DOS, where I've done this 
kind of thing in Turbo Pascal and Ada 83, sure. The basic premise is 
something like

type Screen_Image is array (...) of ...; -- char/attr pairs, or whatever

Screen_Memory : Screen_Image;
for Screen_Memory'address use ...;

Work_Space : Screen_Image;

...

-- Mess around with Work_Space

Screen_Memory := Work_Space;

This was fast enough, on a 16 MHz 386, that you didn't see any flicker, 
and I was working in graphics mode, with a lot more bytes than character 
mode.

In Turbo Pascal I had to use pointers, and set one pointer to point to 
the screen memory. Then I did something like

Screen^ := Work^;

(equivalent to Screen.all := Work.all;)

HTH.

-- 
Jeff Carter
"I wave my private parts at your aunties."
Monty Python & the Holy Grail
13




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

* Re: Low Level Ada
  2003-11-19 13:43 Low Level Ada Stephane Richard
  2003-11-19 18:40 ` Jeffrey Carter
@ 2003-11-19 18:47 ` Jim Rogers
  2003-11-19 18:56 ` tmoran
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Jim Rogers @ 2003-11-19 18:47 UTC (permalink / raw)


"Stephane Richard" <stephane.richard@verizon.net> wrote in message news:<ysKub.36397$hB5.217@nwrdny02.gnilink.net>...
> By the subject line I mean:
> 
> Is there a way, in Ada to move memory around so to speak.
> 
> For instance, let's say I want to create an Array that would hold characters
> with the goal to send it to the video card directly (address $B800).
> 
> Could I take an array of Characters, and "move it" to address $B800 ?  or
> something like it?

Yes. Ada allows you to specify the address of a variable.
You can simply assign the array value to a variable whose address 
is B800.

Of course, your operating system may get in your way. WIN32 does not 
allow direct writing to low level addresses by high level languages.
In that case you may need to call the appropriate OS library call
to achieve your goals.

Jim Rogers



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

* Re: Low Level Ada
  2003-11-19 13:43 Low Level Ada Stephane Richard
  2003-11-19 18:40 ` Jeffrey Carter
  2003-11-19 18:47 ` Jim Rogers
@ 2003-11-19 18:56 ` tmoran
  2003-11-20  2:32   ` Stephane Richard
  2003-11-19 23:37 ` Freejack
  2003-11-20 13:09 ` Marin David Condic
  4 siblings, 1 reply; 9+ messages in thread
From: tmoran @ 2003-11-19 18:56 UTC (permalink / raw)


> For instance, let's say I want to create an Array that would hold characters
> with the goal to send it to the video card directly (address $B800).
   You can use an address clause to put an object (eg an array) anywhere
and then just do normal assignment operations.  So if you declare
  type Display_Strings is array(Integer range <>) of Char_Attribute_Pairs;
  Screen : Display_Strings(1 .. 24*80);
  for Screen'address use 16#B800#;
you can
  Screen(1) := ('a',Blinking);
or
  Screen(Start .. Start+Last-1) := Work_Buffer(1 .. Last);
Note of course that if you are running on a Windows machine 16#B800# is
a virtual memory address, not a hardware one.  In that case you would need:
  Video_Memory_Address: constant System.Address := Beg_Of_Windows(16#B800);
  for Screen'address use Video_Memory_Address;



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

* Re: Low Level Ada
  2003-11-19 13:43 Low Level Ada Stephane Richard
                   ` (2 preceding siblings ...)
  2003-11-19 18:56 ` tmoran
@ 2003-11-19 23:37 ` Freejack
  2003-11-20 13:09 ` Marin David Condic
  4 siblings, 0 replies; 9+ messages in thread
From: Freejack @ 2003-11-19 23:37 UTC (permalink / raw)


On Wed, 19 Nov 2003 08:43:58 -0500, Stephane Richard wrote:

> By the subject line I mean:
> 
> Is there a way, in Ada to move memory around so to speak.
> 
> For instance, let's say I want to create an Array that would hold
> characters with the goal to send it to the video card directly (address
> $B800).
> 
> Could I take an array of Characters, and "move it" to address $B800 ? or
> something like it?
 
Yes. I've been toying(like I do with just about everything else on this
sytem) with the Linux Framebuffer.

Now, at least under Linux, you can map your video cards memory space to
an Ada structure, and then shove things into that structure. Of course,
that could be alot of work if you want to get access to all your cards
advanced features.(Multihead, etc...)

The easier approach is to see if your video cards manufacturer provides
an API or other method of interfacing with your video card driver. This
is the approach taken by the Framebuffer(mostly).
With Windows you'd probably have to use DirectX, MFC, or some other
absurdly large high level abstraction.

Some OpenGL drivers provide a limited set of methods for doing
direct drawing to the screen. SGI has an Ada OpenGL binding. I dont know
if it supports direct memory address access and/or manipulation, but it
comes pretty darn close. If you developing an app the requires precision
control over the screen methods, this is probably the best route to go.

If your goal is to develope your own video card driver, master the
Systems Annex, Interfaces.C, and at least make sure you have basic
understanding of your machines Assembler language. A bad video card
Ramdac timing or Res setting can toast your monitor, your video card, or
both.
In any case, you will be doing a fair amount of interfacing with C code.

Anyways...theres a whole hell of a lot more that can be said here, but
I'll leave it at that. I spent a while working on a Forth interpreter
that would run in the Framebuffer. Still working on it. Slowly
progressing, but I think I'll stick with Ada95 for now. Heh.


Freejack



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

* Re: Low Level Ada
  2003-11-19 18:56 ` tmoran
@ 2003-11-20  2:32   ` Stephane Richard
  2003-11-20  5:39     ` tmoran
       [not found]     ` <m2vfpfgsnt.fsf@jvdsys.demon.nl>
  0 siblings, 2 replies; 9+ messages in thread
From: Stephane Richard @ 2003-11-20  2:32 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1154 bytes --]

How about if I want to call an interrupt in Ada?

Say Interrupt 10h to set the video mode to 132x50 (mode 10Ah on a vesa/bde
standard video card) for example.


-- 
St�phane Richard
"Ada World" Webmaster
http://www.adaworld.com


<tmoran@acm.org> wrote in message news:Y1Pub.185870$mZ5.1346044@attbi_s54...
> > For instance, let's say I want to create an Array that would hold
characters
> > with the goal to send it to the video card directly (address $B800).
>    You can use an address clause to put an object (eg an array) anywhere
> and then just do normal assignment operations.  So if you declare
>   type Display_Strings is array(Integer range <>) of Char_Attribute_Pairs;
>   Screen : Display_Strings(1 .. 24*80);
>   for Screen'address use 16#B800#;
> you can
>   Screen(1) := ('a',Blinking);
> or
>   Screen(Start .. Start+Last-1) := Work_Buffer(1 .. Last);
> Note of course that if you are running on a Windows machine 16#B800# is
> a virtual memory address, not a hardware one.  In that case you would
need:
>   Video_Memory_Address: constant System.Address :=
Beg_Of_Windows(16#B800);
>   for Screen'address use Video_Memory_Address;





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

* Re: Low Level Ada
  2003-11-20  2:32   ` Stephane Richard
@ 2003-11-20  5:39     ` tmoran
       [not found]     ` <m2vfpfgsnt.fsf@jvdsys.demon.nl>
  1 sibling, 0 replies; 9+ messages in thread
From: tmoran @ 2003-11-20  5:39 UTC (permalink / raw)


> How about if I want to call an interrupt in Ada?
>
> Say Interrupt 10h to set the video mode to 132x50 (mode 10Ah on a vesa/bde
> standard video card) for example.
   You could use the Machine_Code provided by your compiler, but any
compiler targetted to DOS, say, would surely provide a library of routines
to set up registers, do a standard interrupt, and get the result
registers.  For instance, I have an Ada (83) binding to VESA that uses the
Janus compiler's DosCall package.  But your best bet is probably to look
at the page Jerry van Dijk mentioned earlier, www.jvdsys.demon.nl



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

* Re: Low Level Ada
       [not found]     ` <m2vfpfgsnt.fsf@jvdsys.demon.nl>
@ 2003-11-20 12:20       ` Stephane Richard
  0 siblings, 0 replies; 9+ messages in thread
From: Stephane Richard @ 2003-11-20 12:20 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 372 bytes --]

>
> Definitively DOS :-)
>
> For GNAT see my SVGA, VGA and VESA packages on my homepage.
>
> -- 
> --  Jerry van Dijk
> --  Leiden, Holland

I see you know what I'm trying to do :-).

Thanks I'll be looking probably at the VESA package (simply because I want
higher text modes, not graphics mode).

-- 
St�phane Richard
"Ada World" Webmaster
http://www.adaworld.com





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

* Re: Low Level Ada
  2003-11-19 13:43 Low Level Ada Stephane Richard
                   ` (3 preceding siblings ...)
  2003-11-19 23:37 ` Freejack
@ 2003-11-20 13:09 ` Marin David Condic
  4 siblings, 0 replies; 9+ messages in thread
From: Marin David Condic @ 2003-11-20 13:09 UTC (permalink / raw)


Of course. The customary way is to define an appropriate data structure 
and fix its address at 16#B800# - look at the "for X'Address use 
16#B800#". Other techniques involve writing a procedure that can write 
to specific addresses or even dipping into assembler from within Ada. A 
solution does exist - it depends to some extent on what your compiler 
will support. Look into ARM chapter 13 and the package System (and all 
its kids).

MDC


Stephane Richard wrote:
> By the subject line I mean:
> 
> Is there a way, in Ada to move memory around so to speak.
> 
> For instance, let's say I want to create an Array that would hold characters
> with the goal to send it to the video card directly (address $B800).
> 
> Could I take an array of Characters, and "move it" to address $B800 ?  or
> something like it?
> 


-- 
======================================================================
Marin David Condic
I work for: http://www.belcan.com/
My project is: http://www.jsf.mil/NSFrames.htm

Send Replies To: m   o   d   c @ a   m   o   g
                    c   n   i       c   .   r

     "Trying is the first step towards failure."
         --  Homer Simpson

======================================================================




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

end of thread, other threads:[~2003-11-20 13:09 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-11-19 13:43 Low Level Ada Stephane Richard
2003-11-19 18:40 ` Jeffrey Carter
2003-11-19 18:47 ` Jim Rogers
2003-11-19 18:56 ` tmoran
2003-11-20  2:32   ` Stephane Richard
2003-11-20  5:39     ` tmoran
     [not found]     ` <m2vfpfgsnt.fsf@jvdsys.demon.nl>
2003-11-20 12:20       ` Stephane Richard
2003-11-19 23:37 ` Freejack
2003-11-20 13:09 ` Marin David Condic

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