im trying to receive two strings and their length and after that another number. like this: 5 hello 2 hi 8. i succeed at receiving both strings and their length but i can`t receive the last number. (The reason for allocating a lot of space is because i assume the strings length is 255 at max) i get the error "Program received signal SIGSEGV, Segmentation fault."
.data
.section .rodata #read only data section
_scanf_check: .string "%d" #in order to check output
_scanf_length1: .string "%d"
_scanf_length2: .string "%d"
_scanf_str1: .string "%s"
_scanf_str2: .string "%s"
_scanf_option: .string "%d"
.text
.global main
.type main, @function
main:
movq %rsp, %rbp #for correct debugging
pushq %rbp #save the old frame pointer
movq %rsp, %rbp #create the new frame pointer
#########################################################
#receiving the length of first pstring.
leaq -524(%rbp),%rsi #allocate 524 bytes on the stack.
movq $_scanf_length1,%rdi
xor %rax,%rax
call scanf
#########################################################
#receiving the string of first pstring.
leaq -520(%rbp),%rsi
movq $_scanf_str1,%rdi
xor %rax,%rax
call scanf
#########################################################
#receiving the length of second pstring.
leaq -264(%rbp),%rsi
movq $_scanf_length2,%rdi
xor %rax,%rax
call scanf
#########################################################
#receiving the string of first pstring.
leaq -260(%rbp),%rsi
movq $_scanf_str2,%rdi
xor %rax,%rax
call scanf
#########################################################
#receiving the option from the menu.
leaq -4(%rbp),%rsi
movq $_scanf_option,%rdi
xor %rax,%rax
call scanf
#########################################################
#move back the %rdi-first arg to point on the length of first pstring
#and %rsi-second arg to point on the length of second pstring also
#move back the %rdx-third arg to point on the number of option.
leaq -524(%rbp),%rdi
leaq -264(%rbp),%rsi
leaq -4(%rbp),%rdx
.char_pstrlength:
movq %rdx,%rsi #reload the address of the last number to %rsi
movq (%rsi),%rsi #insert the value to rsi.
movq $_scanf_check,%rdi
xor %rax,%rax
call printf
movq %rbp, %rsp #restore the old stack pointer - release all used memory.
popq %rbp #restore old frame pointer (the caller function frame)
ret
```