comp.lang.ada
 help / color / mirror / Atom feed
From: Gautier <Gautier.deMontmollin@Maths.UniNe.CH>
To: jboulais@my-deja.com
Subject: Re: Assembly and Gnat
Date: 1999/06/03
Date: 1999-06-03T00:00:00+00:00	[thread overview]
Message-ID: <3756BAC7.AB4C531@Maths.UniNe.CH> (raw)
In-Reply-To: 7j41mg$rtf$1@nnrp1.deja.com

> Does anyone have experience using Gnat's machine_code.asm procedures and
> functions?  I am in need of good examples.  Thanks...

Here is one excerpted from a line drawing routine
(in http://members.xoom.com/gdemont/logiciel/svga02x3.zip ).

NB: it might be perfectible and/or the GNAT optimizer
is a good challenger: the code produced by -O2 on the Ada
equivalent is much bigger but as fast as my ASM attempt!
-> only use ASM for special needs like hardware I/O, or be
a real ASM guru!

         ASM(
                             -- for I in reverse 0 .. D_Y loop
"   .align 2,0x90  " & LF &
"0: movb  %0, (%3) " & LF &  --   Buffer_Data(Left_Top_Line) := Color;
"   testl %2, %2   " & LF &  --   while Limit >= 0 loop
"   jl    3f       " & LF &
"   .align 2,0x90  " & LF &
"2: addl  %4, %3   " & LF &  --     Left_Top_Line := Left_Top_Line + S_X;
"   subl  %7, %2   " & LF &  --     Limit := Limit - D_Y_2;
"   jns   2b       " & LF &  --   end loop;
"3: addl  %5, %3   " & LF &  --   Left_Top_Line := Left_Top_Line + Line_S_Y;
"   addl  %6, %2   " & LF &  --   Limit := Limit + D_X_2;
"   decl  %1       " & LF &  -- end loop;
"   jns   0b",
             No_Output_Operands,
             (byte'Asm_Input    ("b", Color),           -- %0 = Color
              integer'Asm_Input ("r", D_Y),             -- %1 = I in reverse 0
.. D_Y
              integer'Asm_Input ("r", D_X_2 - D_Y),     -- %2 = Limit := D_X_2
- D_Y
              address'Asm_Input ("r", Buffer_Data(Left + Buffer.Width *
Top)'address), -- %3 = start
              integer'Asm_Input ("g", S_X),        -- %4
              integer'Asm_Input ("g", Line_S_Y),   -- %5
              integer'Asm_Input ("g", D_X_2),      -- %6
              integer'Asm_Input ("g", D_Y_2)       -- %7
));

-- 
Gautier

--------
http://members.xoom.com/gdemont/




      reply	other threads:[~1999-06-03  0:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-06-02  0:00 Assembly and Gnat jboulais
1999-06-03  0:00 ` Gautier [this message]
replies disabled

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