From: Simon Wright on
anon(a)att.net writes:

> As for the example supplied I decide use the intel "nop" for simplicity
> instead of using the codes for the attached processor.

Ah! I see what you meant by "special project".

> I prefer to use the Code Statement like the System.Machine_Code in SUN,
> instead of using the inline-assembler of gnat\gcc. which forces the
> following type of statements for non-native processors:
>
> ASM ( " .byte 0x90" ) ; -- intel x86 nop
> ASM ( " .byte 0x02" ) ; -- attach processor instruction "Load R2"
> ...
>
> And using the code statement allows the Ada compiler to emulate a small
> limited assembler without all of the work\time in rewriting\expanding
> the gcc "AS" to include the new processor.
>
> So, I see no problem in using code statement except for creating or
> expand and recompiling the "system.machine_code" package. Unless Adacore
> has crippled gnat's code statement routines.

I'm not sure what http://www.adaic.com/standards/05rm/html/RM-13-8.html
(2) means; does it give you a licence to use any type you lke? seems
unlikely.

> Now, the RM 13.8 (2), says that the code statement is qualified_expression
> so what the problem. In Gnat, the ASM routines are handled by the
> "Expand_Asm_Call" procedure ("exp_code" package) which expands the ASM
> statement into a qualified_expression. Also, "P_Code_Statement" ("par-ch13"
> package) directly processes code_statements as an qualified_expression.
> Afterwards, the "Analyze_Code_Statement" ("sem-ch13" package) analyzes
> should handle the code statements but this routine is where the error
> message is generated.

I expect the compiler is written to expect System.Machine_Code.Asm_Insn
of the specific type defined in System.Machine_Code.

You could write
Asm_Insn'(Asm (".byte 0x90"));
but it hardly seems worth the trouble. AdaCore have provided this as a
"feature" I think -- see the GNAT RM,
http://gcc.gnu.org/onlinedocs/gcc-4.5.0/gnat_rm/Machine-Code-Insertions.html
From: sjw on
On May 19, 7:07 am, Simon Wright <si...(a)pushface.org> wrote:

> I'm not sure what http://www.adaic.com/standards/05rm/html/RM-13-8.html
> (2) means; does it give you a licence to use any type you lke? seems
> unlikely.

Sorry, I meant (4): "The qualified_expression is expected to be of any
type."

Compare with (5): "The qualified_expression shall be of a type
declared in package System.Machine_Code."

From: AdaMagica on
On 19 Mai, 11:56, sjw <simon.j.wri...(a)mac.com> wrote:
> On May 19, 7:07 am, Simon Wright <si...(a)pushface.org> wrote:
>
> > I'm not sure whathttp://www.adaic.com/standards/05rm/html/RM-13-8.html
> > (2) means; does it give you a licence to use any type you lke? seems
> > unlikely.
>
> Sorry, I meant (4): "The qualified_expression is expected to be of any
> type."

This is a Name Resolution Rule used for overload resolution. As far as
overloading is concernded, any type can do.

> Compare with (5): "The qualified_expression shall be of a type
> declared in package System.Machine_Code."

This is a Legality Rule and applied only after overload resolution. So
this is where code becomes illegal when other types are used.