-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
139 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
This is "C with assermbly interaction" application. | ||
|
||
Build it with: `make` | ||
|
||
* casm1 - call C function from asm | ||
* casm2 - gcc inline assembly | ||
* casm3 - call asm function from C | ||
|
||
More details at - [Say hello to x86_64 Assembly part 6](http://0xax.blogspot.com/2014/11/say-hello-to-x64-assembly-part-4.html) | ||
|
||
[@0xAX](http://twitter.com/0xAX) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
This is "C with assermbly interaction" application. | ||
|
||
Build it with: `make` | ||
|
||
More details at - [Say hello to x86_64 Assembly part 6](http://0xax.blogspot.com/2014/11/say-hello-to-x64-assembly-part-4.html) | ||
|
||
[@0xAX](http://twitter.com/0xAX) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
buildAsmc: | ||
gcc -c casm.c -o c.o | ||
nasm -f elf64 casm.asm -o casm.o | ||
ld -dynamic-linker /lib64/ld-linux-x86-64.so.2 -lc casm.o c.o -o casm | ||
|
||
clean: | ||
rm -rf *.o | ||
rm -rf casm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
buildAsmc: | ||
gcc -c casm.c -o c.o | ||
nasm -f elf64 casm.asm -o casm.o | ||
ld -dynamic-linker /lib64/ld-linux-x86-64.so.2 -lc casm.o c.o -o casm | ||
|
||
clean: | ||
rm -rf *.o | ||
rm -rf casm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
global _start | ||
|
||
extern print | ||
|
||
section .text | ||
|
||
_start: | ||
call print | ||
|
||
;; exit | ||
mov rax, 60 | ||
mov rdi, 0 | ||
syscall |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#include <stdio.h> | ||
|
||
extern int print(); | ||
|
||
int print() { | ||
printf("Hello World\n"); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
build: | ||
gcc casm.c -o casm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
build: | ||
gcc casm.c -o casm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include <string.h> | ||
|
||
int main() { | ||
char* str = "Hello World\n"; | ||
long len = strlen(str); | ||
int ret = 0; | ||
|
||
__asm__("movq $1, %%rax \n\t" | ||
"movq $1, %%rdi \n\t" | ||
"movq %1, %%rsi \n\t" | ||
"movl %2, %%edx \n\t" | ||
"syscall" | ||
: "=g"(ret) | ||
: "g"(str), "g" (len)); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#include <stdio.h> | ||
|
||
extern int print(); | ||
|
||
int print() { | ||
printf("Hello World\n"); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
build: | ||
nasm -f elf64 -o casm.o casm.asm | ||
gcc casm.o casm.c -o casm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
build: | ||
nasm -f elf64 -o casm.o casm.asm | ||
gcc casm.o casm.c -o casm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
global printHelloWorld | ||
|
||
section .text | ||
printHelloWorld: | ||
;; 1 arg | ||
mov r10, rdi | ||
;; 2 arg | ||
mov r11, rsi | ||
;; call write syscall | ||
mov rax, 1 | ||
mov rdi, 1 | ||
mov rsi, r10 | ||
mov rdx, r11 | ||
syscall | ||
ret |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
global _start | ||
|
||
extern print | ||
|
||
section .text | ||
|
||
_start: | ||
call print | ||
|
||
;; exit | ||
mov rax, 60 | ||
mov rdi, 0 | ||
syscall |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#include <string.h> | ||
|
||
int main() { | ||
char* str = "Hello World\n"; | ||
int len = strlen(str); | ||
printHelloWorld(str, len); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#include <stdio.h> | ||
|
||
extern int print(); | ||
|
||
int print() { | ||
printf("Hello World\n"); | ||
return 0; | ||
} |