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:
Tomasz Sowa 2008-10-22 18:56:04 +00:00
parent f8f324f98f
commit ca51020fe6
7 changed files with 423 additions and 417 deletions

View File

@ -1,7 +1,7 @@
CC = g++
o = main.o uinttest.o
CFLAGS = -Wall -pedantic
ttmath = /d/roboczy/prog/ttmath
ttmath = ..
name = tests

View File

@ -58,8 +58,6 @@ int main()
{
using namespace ttmath;
test_uint();

View File

@ -265,9 +265,9 @@ public:
xor eax,eax
sub eax,[c]
lahf // flags -> AH (flags: SF ZF AF CF) PF?
lahf // flags -> AH (flags: SF ZF AF PF CF)
p:
sahf // AH -> flags (flags: SF ZF AF CF) PF?
sahf // AH -> flags (flags: SF ZF AF PF CF)
mov eax,[ebx]
adc eax,[edx]
mov [ebx],eax
@ -276,7 +276,7 @@ public:
add ebx,4
add edx,4
sub ecx,1
dec ecx
jnz p
// checking carry from the last word
@ -318,7 +318,7 @@ public:
"add $4,%%ebx \n"
"add $4,%%edx \n"
"subl $1,%%ecx \n"
"decl %%ecx \n"
"jnz 1b \n"
"test $1,%%ah \n"

View File

@ -225,37 +225,36 @@ namespace ttmath
"push %%rcx \n"
"push %%rdx \n"
"movq $0, %%rax \n"
"xorq %%rax, %%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"
//"sahf \n"
".byte 0x9e \n"
"movq (%%rbx),%%rax \n"
"adcq (%%rdx),%%rax \n"
"movq %%rax,(%%rbx) \n"
"inc %%rbx \n"
"inc %%rbx \n"
"inc %%rbx \n"
"inc %%rbx \n"
"inc %%rbx \n"
"inc %%rbx \n"
"inc %%rbx \n"
"inc %%rbx \n"
//"lahf \n"
".byte 0x9f \n"
"inc %%rdx \n"
"inc %%rdx \n"
"inc %%rdx \n"
"inc %%rdx \n"
"inc %%rdx \n"
"inc %%rdx \n"
"inc %%rdx \n"
"inc %%rdx \n"
"addq $8, %%rbx \n"
"addq $8, %%rdx \n"
"loop 1b \n"
"decq %%rcx \n"
"jnz 1b \n"
"movq $0, %%rax \n"
"adcq %%rax,%%rax \n"
"movq %%rax, %%rsi \n"
"test $1, %%ah \n"
"setnz %%al \n"
"movzx %%al, %%rsi \n"
"pop %%rdx \n"
"pop %%rcx \n"
@ -680,11 +679,14 @@ namespace ttmath
"push %%rbx \n"
"push %%rcx \n"
"lahf \n"
//"lahf \n"
".byte 0x9f \n"
"1: \n"
"sahf \n"
//"sahf \n"
".byte 0x9e \n"
"rclq $1,(%%rbx) \n"
"lahf \n"
//"lahf \n"
".byte 0x9f \n"
"addq $8,%%rbx \n"
@ -698,7 +700,8 @@ namespace ttmath
"jnz 2b \n"
"xor %%rdx,%%rdx \n"
"sahf \n"
//"sahf \n"
".byte 0x9e \n"
"setc %%dl \n"
"pop %%rsi \n"
@ -762,13 +765,17 @@ namespace ttmath
"xorq %%rax, %%rax \n"
"subq %%rdx, %%rax \n"
"lahf \n"
//"lahf \n"
".byte 0x9f \n"
"1: \n"
"subq $8, %%rbx \n"
"sahf \n"
//"sahf \n"
".byte 0x9e \n"
"rcrq $1,(%%rbx) \n"
"lahf \n"
//"lahf \n"
".byte 0x9f \n"
"subq $1,%%rcx \n"
"jnz 1b \n"
@ -781,7 +788,8 @@ namespace ttmath
"jnz 2b \n"
"xor %%rdx,%%rdx \n"
"sahf \n"
//"sahf \n"
".byte 0x9e \n"
"setc %%dl \n"
"pop %%rsi \n"