* Assembly and Gnat
@ 1999-06-02 0:00 jboulais
1999-06-03 0:00 ` Gautier
0 siblings, 1 reply; 2+ messages in thread
From: jboulais @ 1999-06-02 0:00 UTC (permalink / raw)
Does anyone have experience using Gnat's machine_code.asm procedures and
functions? I am in need of good examples. Thanks...
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Assembly and Gnat
1999-06-02 0:00 Assembly and Gnat jboulais
@ 1999-06-03 0:00 ` Gautier
0 siblings, 0 replies; 2+ messages in thread
From: Gautier @ 1999-06-03 0:00 UTC (permalink / raw)
To: jboulais
> 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/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1999-06-03 0:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-06-02 0:00 Assembly and Gnat jboulais
1999-06-03 0:00 ` Gautier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox