yasm on 64-bit OpenBSD

Peter Johnson peter at tortall.net
Mon Oct 23 13:23:09 PDT 2006


Comments inline.

On Mon, 23 Oct 2006, Dave wrote:
> 	[bits 64]
> sse3test:	;entry point
> .LFB3:
>        ;loc 1 2 0
>        pushfq
> .LCFI0:
>        mov    rbp, rsp
> ;	push rax
> ;	push rbx
> ;	push rcx
> ;	push rdx
>
> 	addsubpd xmm5, xmm7
> 	addsubpd xmm0, [rax]

What sets rax or rdx?  This or the other [...] are what are causing your 
crash.

> 	addsubps xmm1, xmm5
> 	addsubps xmm3, dqword [rdx]
> 	fisttp word [0]
> 	fisttp dword [4]
> 	fisttp qword [8]
> 	haddpd xmm2, xmm4
> 	haddpd xmm7, [rcx+4]

Where is rcx set?

> 	haddps xmm6, xmm1
> 	haddps xmm0, dqword [0]
> 	hsubpd xmm5, xmm3
> 	hsubpd xmm1, [rbp]
> 	hsubps xmm4, xmm1
> 	hsubps xmm2, [rsp]
> 	lddqu xmm3, [rcx+rdx*4+8]

rdx?

> 	monitor
> 	movddup xmm7, xmm6
> 	movddup xmm1, qword [4]
> 	movshdup xmm3, xmm4
> 	movshdup xmm2, [0]
> 	movsldup xmm0, xmm7
> 	movsldup xmm5, dqword [rax+rbx]

rbx?

> 	mwait
>
> ;	pop rdx
> ;	pop rcx
> ;	pop rbx
> ;	pop rax
>
> .LCFI1:
>        ;loc 1 2 0
>        leave
>        ret
> 	end
> ============================================
>
>
> #include <stdio.h>
>
> #include <pmmintrin.h>
>
> void sse3test();
> extern void nullsub();
>
> int main(int argc, char* argv[])
> {
> 	typedef struct {double a; double b; } __m128d;
>
> 	float f0,f1,f2,f3;
> 	double d0,d1;
>
> 	__m128d d128_1;
> 	__m128d d128_2;
>
>
> 	printf("Hi!\n");
> 	nullsub();
> 	printf("---\n");
> 	sse3test();            ;<==segv occurs at beginning of this sub

Either you should be putting those variables into globals or you should 
pass them as arguments to the function, otherwise the function has no idea 
where they area or how to access them.  E.g. sse3test(&d128_1, &d128_2) or 
something like that, and read up in the AMD64 calling convention docs on 
how those are being passed in by the compiler (e.g. in registers, on the 
stack, etc).

> 	printf("Bye!\n");
> }
>

Peter


More information about the yasm-devel mailing list