https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119779
--- Comment #5 from Gaius Mulley <gaius at gcc dot gnu.org> ---
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