changed: 64bit asm code didn't want to compile
there were used 'lahf' and 'sahf' instructions probably they are supported in a new version of GCC with '-msahf' option but GCC 4.2.1 has no such option at the moment I'm using opcodes: lahf -> 9f sahf -> 9e Warning! these instructions are not on all 64bit processors from: http://gcc.gnu.org/onlinedocs/gcc/i386-and-x86_002d64-Options.html "Early Intel CPUs with Intel 64 lacked LAHF and SAHF instructions supported by AMD64 until introduction of Pentium 4 G1 step in December 2005." changed: UInt::Add on 64bit platform changed: UInt::Add on 32bit platform (a little) git-svn-id: svn://ttmath.org/publicrep/ttmath/trunk@80 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
parent
f8f324f98f
commit
ca51020fe6
|
@ -1,7 +1,7 @@
|
||||||
CC = g++
|
CC = g++
|
||||||
o = main.o uinttest.o
|
o = main.o uinttest.o
|
||||||
CFLAGS = -Wall -pedantic
|
CFLAGS = -Wall -pedantic
|
||||||
ttmath = /d/roboczy/prog/ttmath
|
ttmath = ..
|
||||||
name = tests
|
name = tests
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -58,8 +58,6 @@ int main()
|
||||||
{
|
{
|
||||||
using namespace ttmath;
|
using namespace ttmath;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
test_uint();
|
test_uint();
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -265,9 +265,9 @@ public:
|
||||||
xor eax,eax
|
xor eax,eax
|
||||||
sub eax,[c]
|
sub eax,[c]
|
||||||
|
|
||||||
lahf // flags -> AH (flags: SF ZF AF CF) PF?
|
lahf // flags -> AH (flags: SF ZF AF PF CF)
|
||||||
p:
|
p:
|
||||||
sahf // AH -> flags (flags: SF ZF AF CF) PF?
|
sahf // AH -> flags (flags: SF ZF AF PF CF)
|
||||||
mov eax,[ebx]
|
mov eax,[ebx]
|
||||||
adc eax,[edx]
|
adc eax,[edx]
|
||||||
mov [ebx],eax
|
mov [ebx],eax
|
||||||
|
@ -276,7 +276,7 @@ public:
|
||||||
add ebx,4
|
add ebx,4
|
||||||
add edx,4
|
add edx,4
|
||||||
|
|
||||||
sub ecx,1
|
dec ecx
|
||||||
jnz p
|
jnz p
|
||||||
|
|
||||||
// checking carry from the last word
|
// checking carry from the last word
|
||||||
|
@ -318,7 +318,7 @@ public:
|
||||||
"add $4,%%ebx \n"
|
"add $4,%%ebx \n"
|
||||||
"add $4,%%edx \n"
|
"add $4,%%edx \n"
|
||||||
|
|
||||||
"subl $1,%%ecx \n"
|
"decl %%ecx \n"
|
||||||
"jnz 1b \n"
|
"jnz 1b \n"
|
||||||
|
|
||||||
"test $1,%%ah \n"
|
"test $1,%%ah \n"
|
||||||
|
|
|
@ -225,37 +225,36 @@ namespace ttmath
|
||||||
"push %%rcx \n"
|
"push %%rcx \n"
|
||||||
"push %%rdx \n"
|
"push %%rdx \n"
|
||||||
|
|
||||||
"movq $0, %%rax \n"
|
"xorq %%rax, %%rax \n"
|
||||||
"subq %%rsi, %%rax \n"
|
"subq %%rsi, %%rax \n"
|
||||||
|
|
||||||
|
//"lahf \n"
|
||||||
|
// in order to use this instruction one need to use -msahf option of the GCC
|
||||||
|
// but in my compiler (gcc version 4.2.1) there is no such option
|
||||||
|
// at the moment I'm using the opcode of this instruction
|
||||||
|
// In the future this can be simply change into 'lahf'
|
||||||
|
".byte 0x9f \n"
|
||||||
|
|
||||||
"1: \n"
|
"1: \n"
|
||||||
|
//"sahf \n"
|
||||||
|
".byte 0x9e \n"
|
||||||
|
|
||||||
"movq (%%rbx),%%rax \n"
|
"movq (%%rbx),%%rax \n"
|
||||||
"adcq (%%rdx),%%rax \n"
|
"adcq (%%rdx),%%rax \n"
|
||||||
"movq %%rax,(%%rbx) \n"
|
"movq %%rax,(%%rbx) \n"
|
||||||
|
|
||||||
"inc %%rbx \n"
|
//"lahf \n"
|
||||||
"inc %%rbx \n"
|
".byte 0x9f \n"
|
||||||
"inc %%rbx \n"
|
|
||||||
"inc %%rbx \n"
|
|
||||||
"inc %%rbx \n"
|
|
||||||
"inc %%rbx \n"
|
|
||||||
"inc %%rbx \n"
|
|
||||||
"inc %%rbx \n"
|
|
||||||
|
|
||||||
"inc %%rdx \n"
|
"addq $8, %%rbx \n"
|
||||||
"inc %%rdx \n"
|
"addq $8, %%rdx \n"
|
||||||
"inc %%rdx \n"
|
|
||||||
"inc %%rdx \n"
|
|
||||||
"inc %%rdx \n"
|
|
||||||
"inc %%rdx \n"
|
|
||||||
"inc %%rdx \n"
|
|
||||||
"inc %%rdx \n"
|
|
||||||
|
|
||||||
"loop 1b \n"
|
"decq %%rcx \n"
|
||||||
|
"jnz 1b \n"
|
||||||
|
|
||||||
"movq $0, %%rax \n"
|
"test $1, %%ah \n"
|
||||||
"adcq %%rax,%%rax \n"
|
"setnz %%al \n"
|
||||||
"movq %%rax, %%rsi \n"
|
"movzx %%al, %%rsi \n"
|
||||||
|
|
||||||
"pop %%rdx \n"
|
"pop %%rdx \n"
|
||||||
"pop %%rcx \n"
|
"pop %%rcx \n"
|
||||||
|
@ -680,11 +679,14 @@ namespace ttmath
|
||||||
"push %%rbx \n"
|
"push %%rbx \n"
|
||||||
"push %%rcx \n"
|
"push %%rcx \n"
|
||||||
|
|
||||||
"lahf \n"
|
//"lahf \n"
|
||||||
|
".byte 0x9f \n"
|
||||||
"1: \n"
|
"1: \n"
|
||||||
"sahf \n"
|
//"sahf \n"
|
||||||
|
".byte 0x9e \n"
|
||||||
"rclq $1,(%%rbx) \n"
|
"rclq $1,(%%rbx) \n"
|
||||||
"lahf \n"
|
//"lahf \n"
|
||||||
|
".byte 0x9f \n"
|
||||||
|
|
||||||
"addq $8,%%rbx \n"
|
"addq $8,%%rbx \n"
|
||||||
|
|
||||||
|
@ -698,7 +700,8 @@ namespace ttmath
|
||||||
"jnz 2b \n"
|
"jnz 2b \n"
|
||||||
|
|
||||||
"xor %%rdx,%%rdx \n"
|
"xor %%rdx,%%rdx \n"
|
||||||
"sahf \n"
|
//"sahf \n"
|
||||||
|
".byte 0x9e \n"
|
||||||
"setc %%dl \n"
|
"setc %%dl \n"
|
||||||
|
|
||||||
"pop %%rsi \n"
|
"pop %%rsi \n"
|
||||||
|
@ -762,13 +765,17 @@ namespace ttmath
|
||||||
"xorq %%rax, %%rax \n"
|
"xorq %%rax, %%rax \n"
|
||||||
"subq %%rdx, %%rax \n"
|
"subq %%rdx, %%rax \n"
|
||||||
|
|
||||||
"lahf \n"
|
//"lahf \n"
|
||||||
|
".byte 0x9f \n"
|
||||||
"1: \n"
|
"1: \n"
|
||||||
"subq $8, %%rbx \n"
|
"subq $8, %%rbx \n"
|
||||||
|
|
||||||
"sahf \n"
|
//"sahf \n"
|
||||||
|
".byte 0x9e \n"
|
||||||
|
|
||||||
"rcrq $1,(%%rbx) \n"
|
"rcrq $1,(%%rbx) \n"
|
||||||
"lahf \n"
|
//"lahf \n"
|
||||||
|
".byte 0x9f \n"
|
||||||
|
|
||||||
"subq $1,%%rcx \n"
|
"subq $1,%%rcx \n"
|
||||||
"jnz 1b \n"
|
"jnz 1b \n"
|
||||||
|
@ -781,7 +788,8 @@ namespace ttmath
|
||||||
"jnz 2b \n"
|
"jnz 2b \n"
|
||||||
|
|
||||||
"xor %%rdx,%%rdx \n"
|
"xor %%rdx,%%rdx \n"
|
||||||
"sahf \n"
|
//"sahf \n"
|
||||||
|
".byte 0x9e \n"
|
||||||
"setc %%dl \n"
|
"setc %%dl \n"
|
||||||
|
|
||||||
"pop %%rsi \n"
|
"pop %%rsi \n"
|
||||||
|
|
Loading…
Reference in New Issue