diff --git a/casm/CMakeLists.txt b/casm/CMakeLists.txt index 48c399c..d61c00b 100644 --- a/casm/CMakeLists.txt +++ b/casm/CMakeLists.txt @@ -7,4 +7,4 @@ enable_language(ASM_NASM) set(CMAKE_ASM_NASM_FLAGS "-f elf64") set(CMAKE_ASM_NASM_FLAGS_DEBUG "-gdwarf") -add_executable(casm asm.asm c.c) \ No newline at end of file +add_executable(casm asm.asm c.c cpp.cpp) \ No newline at end of file diff --git a/casm/asm.asm b/casm/asm.asm index 99cf597..be431d4 100644 --- a/casm/asm.asm +++ b/casm/asm.asm @@ -1,5 +1,5 @@ global main -extern sum, print, scan +extern sum, print, scan, test_vector, a section .text main: @@ -12,7 +12,11 @@ main: call sum ; сумма mov rdi, rax ; результат call print ; напечатать + call test_vector pop rbx ; восстановить rbx + + mov dword [rel a], 42 ; записать значение 42 в переменную a + mov rdi, 0 mov rax, 60 syscall \ No newline at end of file diff --git a/casm/c.c b/casm/c.c index 02c4a95..f90fb1c 100644 --- a/casm/c.c +++ b/casm/c.c @@ -1,6 +1,8 @@ #include #include +int a; + int sum(int a, int b) { return a+b; } diff --git a/casm/cpp.cpp b/casm/cpp.cpp new file mode 100644 index 0000000..eb50a8c --- /dev/null +++ b/casm/cpp.cpp @@ -0,0 +1,11 @@ +#include +#include + +extern "C" void test_vector() { + std::vector vec = std::vector(); + for(auto i = 0; i < 10; i++) + vec.push_back(i); + for(auto num : vec) + std::cout << num << ", "; + std::cout << std::endl; +} \ No newline at end of file