comp.lang.ada
 help / color / mirror / Atom feed
* Inline ASM
@ 2004-05-18 17:13 Dan McLeran
  2004-05-18 23:17 ` Jeff C,
  0 siblings, 1 reply; 2+ messages in thread
From: Dan McLeran @ 2004-05-18 17:13 UTC (permalink / raw)


First of all, let me say that I am using Gnat 3.15p. Now the problem.
I have a piece of C code that outports 16-bit values to an ISA-bus
card. It seemed that I should be able to do this from within Ada,
using the Asm capabilities. I have been able to embed other Asm
instructions with success but this one is frustrating me. I keep
getting this error message:

"Error: suffix or operands invalid for 'out'"

Although, when I use the -S compiler option, it generates the asm code
without error and it appears to be correct.

I have checked the asm output of my C-code and it looks like this:

out	dx, ax

So, I figured the following Ada code should work. Does anyone see a
problem here?

with Ada.Text_IO;
with System.Machine_Code;
with Interfaces;

procedure Main is
    use Ada.Text_IO;
    
    procedure Outport(Address,Value : in Interfaces.Unsigned_16) is
        use System.Machine_Code;
        use Interfaces;
        use ASCII;
    begin
        Asm("out %%dx, %%ax" & LF & HT,
            Inputs =>
(Unsigned_16'Asm_Input("d",Address),Unsigned_16'Asm_Input("a",Value)));
    end Outport;
    
    Address : Interfaces.Unsigned_16 := 16#110#;
    Value : Interfaces.Unsigned_16 := 16#F#;
    
begin
    Put(Item => "** Using inline Asm **");
    New_Line;
    Put(Item => "Address = " & Interfaces.Unsigned_16'Image(Address));
    New_Line;
    Put(Item => "Value = " & Interfaces.Unsigned_16'Image(Value));
    New_Line;
    Outport(Address => Address, Value => Value);
end Main;



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

end of thread, other threads:[~2004-05-18 23:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-18 17:13 Inline ASM Dan McLeran
2004-05-18 23:17 ` Jeff C,

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