Permalink
Browse files

more md

  • Loading branch information...
1 parent f01184d commit 6c95218b33980a9095aa9516d29969cfc8c523b3 @dharmatech committed Jul 23, 2011
Showing with 164 additions and 0 deletions.
  1. +41 −0 print-literal-double.md
  2. +20 −0 print-literal-double.md.in
  3. +5 −0 print-literal-int.md
  4. +5 −0 print-literal-int.md.in
  5. +4 −0 print-literal-string.md
  6. +4 −0 print-literal-string.md.in
  7. +66 −0 strcat.md
  8. +19 −0 strcat.md.in
View
@@ -0,0 +1,41 @@
+
+# Print a literal double
+
+# C
+
+```c
+
+#include <stdio.h>
+
+int main ()
+{
+ printf ( "%f\n" , 1.2 ) ;
+
+ return 0 ;
+}
+```
+
+# Assembly
+
+```s
+
+ .include "utils.s"
+
+ global_text main
+
+ prepare_stack
+
+ literal_double 0e1.2 %xmm0
+
+ print_double %xmm0
+
+ print_nl
+
+ return_integer $0
+```
+
+# Assemble and run
+
+ $ gcc print-literal-double.s -lm && ./a.out
+ 1.2
+
View
@@ -0,0 +1,20 @@
+
+# Print a literal double
+
+# C
+
+```c
+#include file="print-literal-double.c"
+```
+
+# Assembly
+
+```s
+#include file="print-literal-double.s"
+```
+
+# Assemble and run
+
+ $ gcc print-literal-double.s -lm && ./a.out
+ 1.2
+
View
@@ -34,4 +34,9 @@ int main ()
return_integer $0
```
+# Assemble and run
+
+ $ gcc print-literal-int.s -lm && ./a.out
+ 123
+
View
@@ -13,4 +13,9 @@
#include file="print-literal-int.s"
```
+# Assemble and run
+
+ $ gcc print-literal-int.s -lm && ./a.out
+ 123
+
View
@@ -35,3 +35,7 @@ int main ()
```
+# Assemble and run
+
+ $ gcc print-literal-string.s -lm && ./a.out
+ abc
@@ -14,3 +14,7 @@
```
+# Assemble and run
+
+ $ gcc print-literal-string.s -lm && ./a.out
+ abc
View
@@ -0,0 +1,66 @@
+
+# Call the strcat glibc C function
+
+# C
+
+```c
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+int main ( int argc , char * argv[] )
+{
+ char * data = malloc( 1000 ) ;
+
+ data[0] = '\0' ;
+
+ strcat( data , argv[1] ) ;
+ strcat( data , argv[2] ) ;
+
+ printf( "%s\n" , data ) ;
+
+ return 0 ;
+}
+```
+
+# Assembly
+
+```s
+
+ .include "utils.s"
+
+ global_text main
+
+ prepare_stack
+
+ .set offset , 0
+
+ stack_allocate ARGV , 8
+ stack_allocate DATA , 8
+
+ mov %rsi , ARGV(%rbp)
+
+ mov $1000 , %rdi
+
+ call malloc ; mov %rax , DATA(%rbp)
+
+ set1 $0 , DATA , 0
+
+ mov DATA(%rbp) , %rdi ; ref8 ARGV , 1 , %rsi ; call strcat
+ mov DATA(%rbp) , %rdi ; ref8 ARGV , 2 , %rsi ; call strcat
+
+ print_string DATA(%rbp)
+ print_nl
+
+ return_integer $0
+
+
+
+
+ ```
+
+# Assemble and run
+
+ $ gcc strcat.s -lm && ./a.out abc def
+ abcdef
View
@@ -0,0 +1,19 @@
+
+# Call the strcat glibc C function
+
+# C
+
+```c
+#include file="strcat.c"
+```
+
+# Assembly
+
+```s
+#include file="strcat.s"
+```
+
+# Assemble and run
+
+ $ gcc strcat.s -lm && ./a.out abc def
+ abcdef

0 comments on commit 6c95218

Please sign in to comment.