L
L
lukepker2019-10-27 18:13:42
linux
lukepker, 2019-10-27 18:13:42

How to fix segmentation error in program (assembler)?

I am writing an assembler lab.
The essence of the program is this: 5db5b36cec9c4779268589.png
Here is the code

SECTION .data
  ask:		DB	'Please, input string',10
  askLen:		EQU	$-ask

SECTION .bss
  buf1		RESB	80
  buf2		RESB	80

SECTION .text
GLOBAL _start

convert:
  xor	ecx,ecx
  xor	ebx,ebx
  mov	eax,[buf1]
  mov	bl,2

.divide:
  xor	edx,edx
  div	ebx
  add	dl,'0'
  push	dx
  inc	ecx
  cmp	eax,0
  jnz	.divide

.reverse:
  pop	ax
  stosb
  loop	.reverse
  ret

bit:
  mov	ecx,0

lpl:
  mov	edi,esi
  inc	esi
  mov	al,[edi]
  cmp	al,10
  je	end
  sub	al,'0'
  cmp	al,0
  JB	lpl
  cmp	al,9
  JA	lpl
  mov	cl,al
  mov	edx,1
  shl	edx,cl
  or	[buf1],edx
  jmp	lpl

end:
  ret

_start:
  mov	eax,4
  mov	ebx,1
  mov	ecx,ask
  mov	edx,askLen
  int	80h

  mov	eax,3
  mov	ebx,1
  mov	ecx,buf2
  mov	edx,10
  int	80h

  call	convert
  mov	eax,4
  mov	ebx,1
  mov	ecx,buf1
  mov	edx,10
  int	80h

  mov	eax,1
  mov	ebx,0
  int	80h

This happens on startup: 5db5b40d72608093209394.png
Please tell me what is the error

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question