[Bug modula2/119779] ASM examples no longer work

2025-06-09 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119779

--- Comment #12 from GCC Commits  ---
The master branch has been updated by Gaius Mulley :

https://gcc.gnu.org/g:0adb415d128cf54b607b71f1022bbf088ab6ae36

commit r16-1345-g0adb415d128cf54b607b71f1022bbf088ab6ae36
Author: Gaius Mulley 
Date:   Mon Jun 9 15:26:35 2025 +0100

PR modula2/119779: ASM examples no longer work

This patch introduces a regression test using the example in the
documentation and tests it using -masm=intel on x86_64-*-gnu systems.

gcc/testsuite/ChangeLog:

PR modula2/119779
* gm2.dg/doc/examples/run/pass/doc-examples-run-pass.exp: New test.
* gm2.dg/doc/examples/run/pass/exampleadd2.mod: New test.

Signed-off-by: Gaius Mulley 

[Bug modula2/119779] ASM examples no longer work

2025-04-15 Thread zbigniew2011 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119779

--- Comment #11 from Zbigniew  ---
(*  gm2 exampleadd2.mod -o exampleadd2 -masm=intel  *)

MODULE exampleadd2 ;  

FROM libc IMPORT printf, exit ;


PROCEDURE Example (foo, bar: LONGCARD) : CARDINAL ;
VAR
   myout: LONGCARD ;
BEGIN
   ASM VOLATILE (
"mov rax, %[left]; add rax, %[right]; mov %[output], rax;"
  : [output] "=rm" (myout)  (* outputs *)
  : [left] "rm" (foo), [right] "rm" (bar)   (* inputs  *)
  : "rax") ;(* we trash *)
   RETURN( myout )
END Example ;

VAR
   a, b, c: CARDINAL ;
BEGIN
   a := 1 ;
   b := 2 ;
   c := Example (a, b) ;
   IF c # 3
   THEN
  printf ("Example procedure function failed to return 3, seen %d", c) ;
  exit (1)
   ELSE
  printf ("It's OK,  procedure function returned 3, seen %d", c) ;
  exit (0)
   END
END exampleadd2.

[Bug modula2/119779] ASM examples no longer work

2025-04-15 Thread zbigniew2011 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119779

--- Comment #10 from Zbigniew  ---
Even "better"... :(
I'm seriously afraid it won't be possible to switch somehow to GAS, regarding
assembly, instead of C-inline?

[Bug modula2/119779] ASM examples no longer work

2025-04-15 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119779

--- Comment #9 from Andrew Pinski  ---
See
https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/x86-Options.html#index-masm_003ddialect-1

[Bug modula2/119779] ASM examples no longer work

2025-04-15 Thread zbigniew2011 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119779

--- Comment #8 from Zbigniew  ---
I modified somewhat the example and it seems to be working using RAX too (BTW:
does there exist any way — any „pragma” or anything — to switch from that
atrocious AT&T syntax to Intel syntax?):


MODULE exampleadd2 ;  

FROM libc IMPORT printf, exit ;


PROCEDURE Example (foo, bar: CARDINAL) : CARDINAL ;
VAR
   myout: LONGCARD ;
BEGIN
   ASM VOLATILE (
"mov %[left],%%rax; add %[right],%%rax; mov %%rax,%[output];"
  : [output] "=rm" (myout)  (* outputs *)
  : [left] "rm" (foo), [right] "rm" (bar)   (* inputs  *)
  : "eax") ;(* we trash *)
   RETURN( myout )
END Example ;

VAR
   a, b, c: CARDINAL ;
BEGIN
   a := 1 ;
   b := 2 ;
   c := Example (a, b) ;
   IF c # 3
   THEN
  printf ("Example procedure function failed to return 3, seen %d", c) ;
  exit (1)
   ELSE
  printf ("It's OK,  procedure function returned 3, seen %d", c) ;
  exit (1)
   END
END exampleadd2.

[Bug modula2/119779] ASM examples no longer work

2025-04-15 Thread zbigniew2011 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119779

--- Comment #7 from Zbigniew  ---
I mean: the arith limit doesn't bother me that much — 32-bit is quite enough —
but being limited to 32-bit registers while working in 64-bit OS means PUSH/POP
cannot be used, and all these new, additional R* registers won't be available.
While working without R8-R15 is imaginable, still being unable to PUSH/POP can
sometimes be VERY limiting, regarding ML programming.

[Bug modula2/119779] ASM examples no longer work

2025-04-15 Thread zbigniew2011 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119779

Zbigniew  changed:

   What|Removed |Added

 CC||zbigniew2011 at gmail dot com

--- Comment #6 from Zbigniew  ---
So the point is: on 64-bit processor we have to use 32-bit registers? Not full
64 bit?

[Bug modula2/119779] ASM examples no longer work

2025-04-15 Thread gaius at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119779

--- Comment #5 from Gaius Mulley  ---
For clarity the tests both run from the command line:

$ gm2 -g exampleadd2.mod
$ ./a.out 
$ cat exampleadd2.mod
(* { dg-do assemble { target { x86_64-*-* } } } *)
(* { dg-options "-g" } *)

MODULE exampleadd2 ;  

FROM libc IMPORT printf, exit ;


PROCEDURE Example (foo, bar: CARDINAL) : CARDINAL ;
VAR
   myout: CARDINAL ;
BEGIN
   ASM VOLATILE (
"movl %[left],%%eax; addl %[right],%%eax; movl %%eax,%[output]"
  : [output] "=rm" (myout)  (* outputs *)
  : [left] "rm" (foo), [right] "rm" (bar)   (* inputs  *)
  : "eax") ;(* we trash *)
   RETURN( myout )
END Example ;

VAR
   a, b, c: CARDINAL ;
BEGIN
   a := 1 ;
   b := 2 ;
   c := Example (a, b) ;
   IF c # 3
   THEN
  printf ("Example procedure function failed to return 3, seen %d", c) ;
  exit (1)
   END
END exampleadd2.

$ gm2 --version
gm2 (GCC) 15.0.1 20250413 (experimental)

Also works for gm2-14

$ gm2 --version
gm2 (GCC) 14.2.1 20250415

$ gm2 exampleadd2.mod 
$ ./a.out 
$ echo $?
0

[Bug modula2/119779] ASM examples no longer work

2025-04-14 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119779

--- Comment #3 from GCC Commits  ---
The master branch has been updated by Gaius Mulley :

https://gcc.gnu.org/g:9e0a98a47c98fd159a26de4433a3ed1d85afb8c3

commit r15-9421-g9e0a98a47c98fd159a26de4433a3ed1d85afb8c3
Author: Gaius Mulley 
Date:   Mon Apr 14 10:13:40 2025 +0100

PR modula2/119779 ASM examples no longer work

This patch introduces four dejagnu tests matching four
documentation examples.  Both asm examples are added and only built if
the x86_64 target is available.  The other two are hello world using
libc and StrIO.  The doc/gm2.texi asm examples are changed to
use eax rather than rax.

gcc/ChangeLog:

PR modula2/119779
* doc/gm2.texi (Interface to assembly language): Use eax
rather than rax in both examples.

gcc/testsuite/ChangeLog:

PR modula2/119779
* gm2.dg/doc/examples/pass/doc-examples-pass.exp: New test.
* gm2.dg/doc/examples/pass/exampleadd.mod: New test.
* gm2.dg/doc/examples/pass/exampleadd2.mod: New test.
* gm2.dg/doc/examples/pass/hello.mod: New test.
* gm2.dg/doc/examples/pass/hellopim.mod: New test.

Signed-off-by: Gaius Mulley 

[Bug modula2/119779] ASM examples no longer work

2025-04-14 Thread gaius at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119779

Gaius Mulley  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #4 from Gaius Mulley  ---
Closing now that the patch has been applied.

[Bug modula2/119779] ASM examples no longer work

2025-04-14 Thread gaius at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119779

--- Comment #2 from Gaius Mulley  ---
Created attachment 61105
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=61105&action=edit
Proposed fix for documentation and accompanying dg testcases

PR modula2/119779 ASM examples no longer work

This patch introduces four dejagnu tests matching four
documentation examples.  Both asm examples are added and only built if
the x86_64 target is available.  The other two are hello world using
libc and StrIO.  The doc/gm2.texi asm examples are changed to
use eax rather than rax.

gcc/ChangeLog:

PR modula2/119779
* doc/gm2.texi (Interface to assembly language): Use eax
rather than rax in both examples.

gcc/testsuite/ChangeLog:

PR modula2/119779
* gm2.dg/doc/examples/pass/doc-examples-pass.exp: New test.
* gm2.dg/doc/examples/pass/exampleadd.mod: New test.
* gm2.dg/doc/examples/pass/exampleadd2.mod: New test.
* gm2.dg/doc/examples/pass/hello.mod: New test.
* gm2.dg/doc/examples/pass/hellopim.mod: New test.

[Bug modula2/119779] ASM examples no longer work

2025-04-13 Thread gaius at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119779

Gaius Mulley  changed:

   What|Removed |Added

 Ever confirmed|0   |1
 Status|UNCONFIRMED |ASSIGNED
   Last reconfirmed||2025-04-13

--- Comment #1 from Gaius Mulley  ---
Confirmed and I will introduce dejagnu tests for these examples.