Написал простой код: section .text extern printf, puts global main main: lea rcx, [message] call puts xor rax, rax ret section .data message: db 'Hello world!', 0 Код section .text extern printf, puts global main main: lea rcx, [message] call puts xor rax, rax ret section .data message: db 'Hello world!', 0 когда доходит до строки с вызовом, дебагер выбрасывает ошибку: "Program received signal SIGSEGV, Segmentation fault.". Что написано понятно, а что делать нет...
Muha665161, SIGSEGV это значит что ты обосрался с выделением памяти. нейронка говорит: section .data message db 'Hello, World!', 0xA ; The message to print, followed by a newline character message_len equ $ - message ; Calculate the length of the message section .text global _start ; Entry point for the program _start: ; Write the message to stdout mov rax, 1 ; syscall: write mov rdi, 1 ; file descriptor: stdout mov rsi, message ; pointer to the message mov rdx, message_len ; message length syscall ; invoke the syscall ; Exit the program mov rax, 60 ; syscall: exit xor rdi, rdi ; exit code: 0 syscall ; invoke the syscall Код section .data message db 'Hello, World!', 0xA ; The message to print, followed by a newline character message_len equ $ - message ; Calculate the length of the message section .text global _start ; Entry point for the program _start: ; Write the message to stdout mov rax, 1 ; syscall: write mov rdi, 1 ; file descriptor: stdout mov rsi, message ; pointer to the message mov rdx, message_len ; message length syscall ; invoke the syscall ; Exit the program mov rax, 60 ; syscall: exit xor rdi, rdi ; exit code: 0 syscall ; invoke the syscall
Если надо puts printf (КОД НЕ ПРОВЕРЯЛ): section .data message db 'Hello, World!', 0 ; Null-terminated string for puts format db 'Formatted number: %d', 10, 0 ; Format string for printf section .text extern puts ; Declare external function puts extern printf ; Declare external function printf global main ; Entry point for the program main: ; Call puts lea rdi, [message] ; Load address of message into rdi call puts ; Call puts ; Call printf mov rdi, format ; Load address of format string into rdi mov rsi, 42 ; Load the integer to print into rsi call printf ; Call printf ; Exit the program mov rax, 60 ; syscall: exit xor rdi, rdi ; exit code: 0 syscall ; invoke the syscall Код section .data message db 'Hello, World!', 0 ; Null-terminated string for puts format db 'Formatted number: %d', 10, 0 ; Format string for printf section .text extern puts ; Declare external function puts extern printf ; Declare external function printf global main ; Entry point for the program main: ; Call puts lea rdi, [message] ; Load address of message into rdi call puts ; Call puts ; Call printf mov rdi, format ; Load address of format string into rdi mov rsi, 42 ; Load the integer to print into rsi call printf ; Call printf ; Exit the program mov rax, 60 ; syscall: exit xor rdi, rdi ; exit code: 0 syscall ; invoke the syscall