VAR
myout: CARDINAL ;
BEGIN
- ASM VOLATILE ("movq %1,%%rax; addq %2,%%rax; movq %%rax,%0"
+ ASM VOLATILE ("movl %1,%%eax; addl %2,%%eax; movl %%eax,%0"
: "=rm" (myout) (* outputs *)
: "rm" (foo), "rm" (bar) (* inputs *)
- : "rax") ; (* we trash *)
+ : "eax") ; (* we trash *)
RETURN( myout )
END Example ;
@end example
myout: CARDINAL ;
BEGIN
ASM VOLATILE (
- "movq %[left],%%rax; addq %[right],%%rax; movq %%rax,%[output]"
+ "movl %[left],%%eax; addl %[right],%%eax; movl %%eax,%[output]"
: [output] "=rm" (myout) (* outputs *)
: [left] "rm" (foo), [right] "rm" (bar) (* inputs *)
- : "rax") ; (* we trash *)
+ : "eax") ; (* we trash *)
RETURN( myout )
END Example ;
@end example
--- /dev/null
+# Compile tests, no torture testing.
+#
+# These tests should all pass.
+
+# Load support procs.
+load_lib gm2-dg.exp
+
+gm2_init_pim4 $srcdir/$subdir
+
+# Initialize `dg'.
+dg-init
+
+# Main loop.
+
+dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.mod]] "" ""
+
+# All done.
+dg-finish
--- /dev/null
+(* { dg-do assemble { target { x86_64-*-* } } } *)
+(* { dg-options "-g" } *)
+
+MODULE exampleadd ;
+
+FROM libc IMPORT printf, exit ;
+
+
+PROCEDURE Example (foo, bar: CARDINAL) : CARDINAL ;
+VAR
+ myout: CARDINAL ;
+BEGIN
+ ASM VOLATILE ("movl %1,%%eax; addl %2,%%eax; movl %%eax,%0"
+ : "=rm" (myout) (* outputs *)
+ : "rm" (foo), "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 exampleadd.
--- /dev/null
+(* { 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.
--- /dev/null
+(* { dg-do run } *)
+(* { dg-options "-g -fno-scaffold-dynamic" } *)
+
+MODULE hello ;
+
+FROM libc IMPORT printf ;
+
+BEGIN
+ printf ("hello world\n")
+END hello.
--- /dev/null
+(* { dg-do run } *)
+(* { dg-options "-g -fno-scaffold-dynamic" } *)
+
+MODULE hellopim ;
+
+FROM StrIO IMPORT WriteString, WriteLn ;
+
+BEGIN
+ WriteString ("hello world") ; WriteLn
+END hellopim.