Question: In the code I inherited, a buffer is passed to a procedure using its start address and length as parameters. This procedure code uses inline assembly language to process the buffer contents.

In a new procedure that uses the same parameters, I want to refer to the buffer as an array but I want to use the same parameters and their types that the existing procedure uses. This is so I don't have to make intrusive modifications to the original code except to use the same calling signature, which is like this:

```
procedure Push_Buffer(
    Source_Address : Address;
    Count          : Natural);

```

In this case, the buffer is just an array of machine words. I want to refer to it as an array of machine words, and already have types (Word and Buffer\_Type) that are used elsewhere without a problem. (The objects of unconstrained type Buffer\_Type have their constraints defined where they are used.)

I would like to refer to the buffer that's being passed by address as an array within my procedure. How would I do this?

Answer: 
Like this (which works with `-gnat83`, but might not work with a real Ada83 compiler; I don’t have one to check with):

```
with Text_IO; use Text_IO;
with System;
procedure Push is
   type Integers is array (Positive range <>) of Integer;

   procedure Push_Buffer (Source_Address : System.Address;
                          Count : Natural) is
      Source : Integers (1 .. Count);
      for Source use at Source_Address;
   begin
      for J in Source'Range loop
         Put_Line (Integer'Image (J) & " => " & Integer'Image (Source (J)));
      end loop;
   end Push_Buffer;

begin
   declare
      Data : Integers (1 .. 3) := (4, 5, 6);
   begin
      Push_Buffer (Data'Address, Data'Length);
   end;
end Push;

```

As a side note, probably not relevant to your situation: if there was any question of default initialization of the object whose address you’ve specified (for example, if it’s a structure containing access variables, which are default-initialized to `null`) you would need to suppress the initialization by writing the declaration as

```
  Source : Integers (1 .. Count);
  pragma Import (Ada, Source);
  for Source use at Source_Address;

```

(or something compiler-dependent like that; GNAT says `warning: (Ada 83) pragma "Import" is non-standard`). See the [GNAT Reference Manual 8.15, Address Clauses](https://gcc.gnu.org/onlinedocs/gnat_rm/Address-Clauses.html), about half-way down.
I would use an unconstrained array as the parameter, rather than a System.Address. This ensures that the compiler does not pass the bound information (aka "fat pointers" in gcc and gnat), and should be compatible with a pragma import.

```
type Unconstrained_Integer_Array is array (Positive) of Integer;
procedure Push_Buffer (Buffer : Unconstrained_Integer_Array;
                       Length : Natural)
is
begin
    for A in 1 .. Length loop
          ...
    end loop;
end Push_Buffer;

```

We use similar tricks when interfacing with C in the GtkAda bindings