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