Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add sincos md

  • Loading branch information...
commit de9f6866a3b3732ddb977ee11f6506cccde311b6 1 parent cd1972f
@dharmatech authored
Showing with 92 additions and 0 deletions.
  1. +73 −0 sincos.md
  2. +19 −0 sincos.md.in
View
73 sincos.md
@@ -0,0 +1,73 @@
+
+# Call the sincos glibc C function
+
+# C
+
+```c
+
+#define _GNU_SOURCE
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+int main ( int argc , char * argv[] )
+{
+ double a ;
+ double b ;
+ double c ;
+
+ a = atof( argv[1] ) ;
+
+ sincos( a , &b , &c ) ;
+
+ printf( "%f %f\n" , b , c ) ;
+
+ return 0 ;
+}
+```
+
+# Assembly
+
+```s
+
+ .include "utils.s"
+
+ global_text main
+
+ prepare_stack
+
+ .set offset , 0
+
+ stack_allocate ARGV , 8
+ stack_allocate A , 8
+ stack_allocate B , 8
+ stack_allocate C , 8
+
+ mov %rsi , ARGV(%rbp)
+
+ ref8 ARGV , 1 , %rdi
+ call atof ;
+ movsd %xmm0 , A(%rbp)
+
+ movsd A(%rbp) , %xmm0
+ lea B(%rbp) , %rdi
+ lea C(%rbp) , %rsi
+
+ call sincos
+
+ print_double B(%rbp)
+ print_literal_string " "
+ print_double C(%rbp)
+
+ print_nl
+
+ return_integer $0
+
+
+ ```
+
+# Assemble and run
+
+ $ gcc sincos.s -lm && ./a.out 0.0
+ 0.000000 1.000000
View
19 sincos.md.in
@@ -0,0 +1,19 @@
+
+# Call the sincos glibc C function
+
+# C
+
+```c
+#include file="sincos.c"
+```
+
+# Assembly
+
+```s
+#include file="sincos.s"
+```
+
+# Assemble and run
+
+ $ gcc sincos.s -lm && ./a.out 0.0
+ 0.000000 1.000000
Please sign in to comment.
Something went wrong with that request. Please try again.