всякое

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

@@ -36,14 +36,6 @@
"preLaunchTask": "asm64",
},
{
"name": "lldb+GCC x64",
"type": "lldb",
"request": "launch",
"program": "${workspaceFolder}/build/minimal",
"cwd": "${workspaceFolder}/build",
"preLaunchTask": "asm64+gcc",
}
]
}

3
minimal/.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,3 @@
{
"cmake.ignoreCMakeListsMissing": true
}

View File

@@ -9,7 +9,7 @@
"mkdir -p $builddir;",
"rawfilename=$builddir/minimal;",
"nasm -gdwarf -f elf64 -o $rawfilename.o ${workspaceFolder}/minimal.asm;",
"ld -g -m elf_x86_64 -o $rawfilename $rawfilename.o;"
"gcc -g -o $rawfilename $rawfilename.o;"
],
"problemMatcher": {
"pattern": {
@@ -26,28 +26,6 @@
"kind": "build",
"isDefault": true
}
},
{
"label": "asm64+gcc",
"type": "shell",
"command": [
"builddir=${workspaceFolder}/build;",
"mkdir -p $builddir;",
"rawfilename=$builddir/minimal;",
"nasm -gdwarf -f elf64 -o $rawfilename.o ${workspaceFolder}/minimal.asm;",
"gcc -o $rawfilename $rawfilename.o;"
],
"problemMatcher": {
"pattern": {
"regexp": "error"
}
},
"presentation": {
"focus": true,
"panel": "dedicated",
"reveal": "silent",
"clear": true
},
}
]
}

View File

@@ -1,11 +1,20 @@
global _start
section .data
nums dq 112, 113, 114, 115, 116 ; массив чисел типа qword
currentAddr dq $
section .text
_start:
mov rdi, [currentAddr - 8] ; rdi = 116
; Передаём два числа для суммирования
mov rsi, 12
mov rdi, 7
call calculate_sum
; Используем результат
mov rbx, rax
; Завершение программы
mov rax, 60
syscall
syscall
; Функция складывает два значения, переданных в RDI и RSI
calculate_sum:
lea rax, [rdi + rsi]
ret