всякое
This commit is contained in:
21
casm/.vscode/launch.json
vendored
21
casm/.vscode/launch.json
vendored
@@ -11,6 +11,27 @@
|
||||
"env": {
|
||||
"PATH": "${env:PATH}:${command:cmake.getLaunchTargetDirectory}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "(gdb) Launch",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "${command:cmake.launchTargetPath}",
|
||||
"cwd": "${workspaceFolder}",
|
||||
"environment": [
|
||||
{
|
||||
"name": "PATH",
|
||||
"value": "${env:PATH}:${command:cmake.getLaunchTargetDirectory}"
|
||||
},
|
||||
],
|
||||
"MIMode": "gdb",
|
||||
"setupCommands": [
|
||||
{
|
||||
"description": "Enable pretty-printing for gdb",
|
||||
"text": "-enable-pretty-printing",
|
||||
"ignoreFailures": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -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 cpp.cpp)
|
||||
add_executable(casm asm.asm c.c)
|
||||
@@ -1,5 +1,6 @@
|
||||
global main
|
||||
extern sum, print, scan, test_vector, a
|
||||
extern sum, print, scan
|
||||
extern a
|
||||
|
||||
section .text
|
||||
main:
|
||||
@@ -11,11 +12,12 @@ main:
|
||||
mov rsi, rax ; b
|
||||
call sum ; сумма
|
||||
mov rdi, rax ; результат
|
||||
push rax
|
||||
call print ; напечатать
|
||||
call test_vector
|
||||
pop rax
|
||||
pop rbx ; восстановить rbx
|
||||
|
||||
mov dword [rel a], 42 ; записать значение 42 в переменную a
|
||||
mov dword [rel a], eax ; записать значение 42 в переменную a
|
||||
|
||||
mov rdi, 0
|
||||
mov rax, 60
|
||||
|
||||
11
casm/cpp.cpp
11
casm/cpp.cpp
@@ -1,11 +0,0 @@
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
|
||||
extern "C" void test_vector() {
|
||||
std::vector<int> vec = std::vector<int>();
|
||||
for(auto i = 0; i < 10; i++)
|
||||
vec.push_back(i);
|
||||
for(auto num : vec)
|
||||
std::cout << num << ", ";
|
||||
std::cout << std::endl;
|
||||
}
|
||||
Reference in New Issue
Block a user