Family Day update
This commit is contained in:
parent
aac6731f2c
commit
9ad63ea473
2442 changed files with 39761 additions and 8255 deletions
|
|
@ -0,0 +1,24 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc,char** argv) {
|
||||
|
||||
int arg1 = atoi(argv[1]), arg2 = atoi(argv[2]), sum, diff, product, quotient, remainder ;
|
||||
|
||||
__asm__ ( "addl %%ebx, %%eax;" : "=a" (sum) : "a" (arg1) , "b" (arg2) );
|
||||
__asm__ ( "subl %%ebx, %%eax;" : "=a" (diff) : "a" (arg1) , "b" (arg2) );
|
||||
__asm__ ( "imull %%ebx, %%eax;" : "=a" (product) : "a" (arg1) , "b" (arg2) );
|
||||
|
||||
__asm__ ( "movl $0x0, %%edx;"
|
||||
"movl %2, %%eax;"
|
||||
"movl %3, %%ebx;"
|
||||
"idivl %%ebx;" : "=a" (quotient), "=d" (remainder) : "g" (arg1), "g" (arg2) );
|
||||
|
||||
printf( "%d + %d = %d\n", arg1, arg2, sum );
|
||||
printf( "%d - %d = %d\n", arg1, arg2, diff );
|
||||
printf( "%d * %d = %d\n", arg1, arg2, product );
|
||||
printf( "%d / %d = %d\n", arg1, arg2, quotient );
|
||||
printf( "%d %% %d = %d\n", arg1, arg2, remainder );
|
||||
|
||||
return 0 ;
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
#include<python2.7/Python.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
Py_Initialize();
|
||||
PyRun_SimpleString("a = [3*x for x in range(1,11)]");
|
||||
|
||||
PyRun_SimpleString("print 'First 10 multiples of 3 : ' + str(a)");
|
||||
|
||||
PyRun_SimpleString("print 'Last 5 multiples of 3 : ' + str(a[5:])");
|
||||
|
||||
PyRun_SimpleString("print 'First 10 multiples of 3 in reverse order : ' + str(a[::-1])");
|
||||
|
||||
Py_Finalize();
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
void myfunc_a();
|
||||
float myfunc_b(int, float);
|
||||
char *myfunc_c(int *);
|
||||
char *myfunc_c(int *, int);
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ caml_myfunc_a(value unit) {
|
|||
}
|
||||
|
||||
CAMLprim value
|
||||
caml_myfunc_b(value a; value b) {
|
||||
caml_myfunc_b(value a, value b) {
|
||||
float c = myfunc_b(Int_val(a), Double_val(b));
|
||||
return caml_copy_double(c);
|
||||
}
|
||||
|
|
@ -24,7 +24,7 @@ caml_myfunc_c(value ml_array) {
|
|||
for (i=0; i < len; i++) {
|
||||
arr[i] = Int_val(Field(ml_array, i));
|
||||
}
|
||||
s = myfunc_c(arr);
|
||||
s = myfunc_c(arr, len);
|
||||
free(arr);
|
||||
return caml_copy_string(s);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
open Ctypes
|
||||
open Foreign
|
||||
|
||||
let myfunc_a = foreign "myfunc_a" (void @-> returning void)
|
||||
let myfunc_b = foreign "myfunc_b" (int @-> float @-> returning float)
|
||||
let myfunc_c = foreign "myfunc_c" (ptr void @-> int @-> returning string)
|
||||
|
||||
let myfunc_c lst =
|
||||
let arr = CArray.of_list int lst in
|
||||
myfunc_c (to_voidp (CArray.start arr)) (CArray.length arr)
|
||||
;;
|
||||
Loading…
Add table
Add a link
Reference in a new issue