December 22, 2006

Porting from ABI x86-64 assembler to Win64 x86-64 assembler

In this week, I tried writing MPI assembler code for Windows x64. Because when Michel sent code-review of MPI porting for Windows x64 that is written by C, code-reviwer rejected by "try using assember code". Most(all?) Mozilla.org people didn't know that assember of ABI x86-64 and Win64 x86 is different, and porting is complicated. But, since I finished writing code (but I don't checked in :-)), I wrote this article.

GAS (GNU Assembler) vs MASM (Microsoft Macro Assembler)

You know, GNU AS uses AT&T format and MASM uses Intel format.

AT&T format

movq %rdx, %rcx

Intel format

mov rcx, rdx

About this different, it is easy using script like perl or making converter. By modifing id software's converter, I resolve this.

Call parameter

At first, you have to understand call parameter registers.

ABI x86-64

normalfloat/double
1strdixmm0
2ndrsixmm1
3rdrdxxmm2
4thrcxxmm3
5thr8xmm4
6thr9xmm5

Windows x86-64

normalfloat/double
1strcxxmm0
2ndrdxxmm1
3rdr8xmm2
4thr9xmm3

So, you have to consider parameter registers.

Trackback URL: http://oldskool.s60.coreserver.jp/www.mozilla-x86-64.com/mt/mt-tb.cgi/70