всякое

This commit is contained in:
Пытков Роман
2025-09-21 19:25:45 +03:00
parent 62bcc7f9cd
commit 6ef051900a
11 changed files with 615 additions and 52 deletions

View File

@@ -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
}
]
}
]
}

View File

@@ -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)

View File

@@ -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

View File

@@ -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;
}