0
section .data ; данные

msg1 db "Enter the side of the square: ", 0xA ; приглашение для ввода стороны квадрата
msg2 db "Square area: S = ", 0xA ; вывод площади квадрата

section .bss ; переменные

a resd 1 ; переменная для стороны квадрата
S resd 1 ; переменная для площади квадрата

section .text ; код

global _start ; стартовая точка программы

_start:

; Вывод приглашения для ввода стороны квадрата

mov eax, 4 ; системный вызов write
mov ebx, 1 ; вывод в консоль
mov ecx, msg1 ; адрес строки
mov edx, 21 ; длина строки
int 0x80 ; вызов

; Ввод стороны квадрата

mov eax, 3 ; системный вызов read
mov ebx, 0 ; ввод с

this code ends with: command terminated by signal 11, on online compilers, and on linux: Enter the side of theSegmentation fault how can I fix this problem?

I tried to figure it out, but I couldn't figure out what exactly is causing the problem, so it also breaks the line.

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
n1rut
  • 3
  • 2
  • 1
    Hint: What happens after `mov ebx, 0` ? – ecm Mar 20 '23 at 14:04
  • 1
    Is that all your code? – Jester Mar 20 '23 at 14:22
  • Yes, this is all my code, I'm just starting to try something in assembler, this program counts the area of the square (S) on the side (a), mov ebx, 0 is responsible for entering values from the keyboard, isn't it? – n1rut Mar 20 '23 at 14:24
  • 1
    Either you truncated the code of your program, or it does no calculation whatsoever and falls off the end into uninitialised space. – ecm Mar 20 '23 at 15:04
  • yeah, i think i need to rewrite this program – n1rut Mar 20 '23 at 15:15

0 Answers0