| 1 |
(* { dg-do assemble { target { x86_64-*-* } } } *) |
| 2 |
(* { dg-options "-g" } *) |
| 3 |
|
| 4 |
MODULE exampleadd2 ; |
| 5 |
|
| 6 |
FROM libc IMPORT printf, exit ; |
| 7 |
|
| 8 |
|
| 9 |
PROCEDURE Example (foo, bar: CARDINAL) : CARDINAL ; |
| 10 |
VAR |
| 11 |
myout: CARDINAL ; |
| 12 |
BEGIN |
| 13 |
ASM VOLATILE ( |
| 14 |
"movl %[left],%%eax; addl %[right],%%eax; movl %%eax,%[output]" |
| 15 |
: [output] "=rm" (myout) (* outputs *) |
| 16 |
: [left] "rm" (foo), [right] "rm" (bar) (* inputs *) |
| 17 |
: "eax") ; (* we trash *) |
| 18 |
RETURN( myout ) |
| 19 |
END Example ; |
| 20 |
|
| 21 |
VAR |
| 22 |
a, b, c: CARDINAL ; |
| 23 |
BEGIN |
| 24 |
a := 1 ; |
| 25 |
b := 2 ; |
| 26 |
c := Example (a, b) ; |
| 27 |
IF c # 3 |
| 28 |
THEN |
| 29 |
printf ("Example procedure function failed to return 3, seen %d", c) ; |
| 30 |
exit (1) |
| 31 |
END |
| 32 |
END exampleadd2. |