Answer the question
In order to leave comments, you need to log in
How to fix ASM Sigmentation fault when calling a macro?
I am developing a Qt C++ application. Some methods call functions written in assembler in a separate file. I am compiling the application for a 64-bit processor, so 64-bit registers are used in asma. A segmentation fault is thrown when trying to run a simple macro from a function.
.macro my_asm_macro src, so, dest, do
movl \so+60(\src), %r8d
movl \so+44(\src), %r9d
movl \so+28(\src), %r10d
movl \so+12(\src), %r11d
movl %r8d, \do+12(\dest)
movl %r9d, \do+28(\dest)
movl %r10d, \do+44(\dest)
movl %r11d, \do+60(\dest)
movl \so+40(\src), %r8d
movl \so+8(\src), %r9d
movl \so+48(\src), %r10d
movl \so+16(\src), %r11d
movl %r8d, \do+8(\dest)
movl %r9d, \do+40(\dest)
movl %r10d, \do+16(\dest)
movl %r11d, \do+48(\dest)
movl \so+20(\src), %r8d
movl \so+4(\src), %r9d
movl \so+52(\src), %r10d
movl \so+36(\src), %r11d
movl %r8d, \do+4(\dest)
movl %r9d, \do+20(\dest)
movl %r10d, \do+36(\dest)
movl %r11d, \do+52(\dest)
movl \so+0(\src), %r8d
movl \so+24(\src), %r9d
movl \so+32(\src), %r10d
movl \so+56(\src), %r11d
movl %r8d, \do+0(\dest)
movl %r9d, \do+24(\dest)
movl %r10d, \do+32(\dest)
movl %r11d, \do+56(\dest)
.endm
my_asm_function:
my_asm_macro %rdi, 0, %rsp, 0 # sigfault here
my_asm_macro %rdi, 64, %rsp, 64
my_asm_macro %rdi, 128, %rsp, 128
my_asm_macro %rdi, 192, %rsp, 192
movdqa 64(%rsp), %xmm0
movdqa 80(%rsp), %xmm1
movdqa 96(%rsp), %xmm2
movdqa 112(%rsp), %xmm3
movdqa 128+64(%rsp), %xmm8
movdqa 128+80(%rsp), %xmm9
movdqa 128+96(%rsp), %xmm10
movdqa 128+112(%rsp), %xmm11
movdqa 256+64(%rsp), %xmm12
movdqa 256+80(%rsp), %xmm13
movdqa 256+96(%rsp), %xmm14
movdqa 256+112(%rsp), %xmm15
movq %rsi, %rbx
leaq 3*131072(%rsi), %rax
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question