From d7cb83d869b8762971cb802ca61493e1e67ae902 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D1=8B=D1=82=D0=BA=D0=BE=D0=B2=20=D0=A0=D0=BE=D0=BC?= =?UTF-8?q?=D0=B0=D0=BD?= Date: Sat, 20 Sep 2025 20:32:39 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A1=D0=BB=D0=BE=D0=B6=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=B4=D0=B2=D1=83=D1=85=20=D1=87=D0=B8=D1=81=D0=B5?= =?UTF-8?q?=D0=BB=20=D0=B2=20=D0=BA=D0=BE=D0=BD=D1=81=D0=BE=D0=BB=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- casm/.vscode/launch.json | 1 - casm/asm.asm | 13 ++++++++++++- casm/c.c | 8 +++++++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/casm/.vscode/launch.json b/casm/.vscode/launch.json index 9a128b1..e3c42af 100644 --- a/casm/.vscode/launch.json +++ b/casm/.vscode/launch.json @@ -5,7 +5,6 @@ "name": "(lldb) Launch", "type": "lldb", "request": "launch", - // Resolved by CMake Tools: "program": "${command:cmake.launchTargetPath}", "args": [], "cwd": "${workspaceFolder}", diff --git a/casm/asm.asm b/casm/asm.asm index fa0b1cc..99cf597 100644 --- a/casm/asm.asm +++ b/casm/asm.asm @@ -1,7 +1,18 @@ global main +extern sum, print, scan section .text main: - mov rdi, 125 + push rbx ; сохранить rbx + call scan ; прочитать первое число + mov rbx, rax ; сохранить первое число + call scan ; прочитать второе число + mov rdi, rbx ; a + mov rsi, rax ; b + call sum ; сумма + mov rdi, rax ; результат + call print ; напечатать + pop rbx ; восстановить rbx + mov rdi, 0 mov rax, 60 syscall \ No newline at end of file diff --git a/casm/c.c b/casm/c.c index bca2640..b74424d 100644 --- a/casm/c.c +++ b/casm/c.c @@ -5,5 +5,11 @@ int sum(int a, int b) { } void print(int num) { - printf("%d", num); + printf("%d\n", num); +} + +int scan() { + int res; + scanf("%d", &res); + return res; } \ No newline at end of file