Форум программистов
 

Восстановите пароль или Зарегистрируйтесь на форуме, о проблемах и с заказом рекламы пишите сюда - alarforum@yandex.ru, проверяйте папку спам!

Вернуться   Форум программистов > Низкоуровневое программирование > Assembler - Ассемблер (FASM, MASM, WASM, NASM, GoASM, Gas, RosAsm, HLA) и не рекомендуем TASM
Регистрация

Восстановить пароль
Повторная активизация e-mail

Купить рекламу на форуме - 42 тыс руб за месяц

Ответ
 
Опции темы Поиск в этой теме
Старый 27.08.2012, 14:02   #1
f.hump
C/C++, Asm
Участник клуба
 
Аватар для f.hump
 
Регистрация: 02.03.2010
Сообщений: 1,323
По умолчанию FXTRACT

Периодически читаю мануал от Интела, и тут вдруг читаю:
Цитата:
FXTRACT также очень полезна при приведении даблов к десятичному представлению (для вывода или печати).
Как себя не мучаю, не могу найти откуда происходит полезность в данном случае. Может кто знает пример или кусок кода, чтобы подсмотреть и принять на вооружение.
f.hump вне форума Ответить с цитированием
Старый 28.08.2012, 09:48   #2
Mikl___
Участник клуба
 
Регистрация: 11.01.2010
Сообщений: 1,139
По умолчанию

f.hump
смотри в пакете masm32
\m32lib\fptoa.asm и fptoa2.asm и \tutorial\fputute
Mikl___ вне форума Ответить с цитированием
Старый 28.08.2012, 19:51   #3
f.hump
C/C++, Asm
Участник клуба
 
Аватар для f.hump
 
Регистрация: 02.03.2010
Сообщений: 1,323
По умолчанию

спасибо.
немного разочарован. FXTRACT использовали, чтобы порядок числа по быстрому оценить, надеялся, что можно что-то более умное сделать.
f.hump вне форума Ответить с цитированием
Старый 29.08.2012, 04:35   #4
Mikl___
Участник клуба
 
Регистрация: 11.01.2010
Сообщений: 1,139
По умолчанию

FXTRACT (Extract exponent and significand)

Syntax: fxtract (no operand)

Exception flags: Stack Fault, Invalid operation, Denormalized value,
Zero divide
This instruction splits the content of ST(0) into two parts, the true unbiased exponent and the significand. The content of ST(0) is overwritten with the true unbiased exponent in floating point format, the TOP field of the Status Word is decremented, and the significand is inserted in the new ST(0) with a biased exponent of 0 (3FFFh for the REAL10 format of the data registers).
If ST(0) originally had a value of ±0, the true unbiased exponent would be set at -INFINITY and the significand would be set to a value of 0 with the same sign as the original one.

If ST(0) originally had a value of ±INFINITY, the true unbiased exponent would be set at +INFINITY and the significand would be set at INFINITY with the same sign as the original one.

An Invalid operation exception is detected if ST(0) is empty, or is a NAN, setting the related flag in the Status Word. The content of ST(0) would be overwritten with the INDEFINITE value, the TOP field of the Status Word decremented, and the INDEFINITE value inserted in the new ST(0).

A Stack Fault exception is also detected if ST(0) is empty, setting the related flag in the Status Word.

A Denormal exception is detected when the content of ST(0) is a denormalized number, setting the related flag in the Status Word.

A Zero divide exception is detected when the content of ST(0) is 0.

This instruction could be used for logarithmic scaling operations. The extracted exponent would be multiplied by the scaling factor, its antilog computed with the F2XM1 instruction, and that result multiplied by the extracted significand.

Пишу программу
Код:
finit
fldpi
fxtract
после fxtaract st(0)=1,570796326794896619231321691 6398 денормализованное основание числа Пи = 3,1415926535897932384626433832795/2 в st(1)=1 степень числа Пи так как 2<3,14<4
Mikl___ вне форума Ответить с цитированием
Старый 29.08.2012, 13:58   #5
f.hump
C/C++, Asm
Участник клуба
 
Аватар для f.hump
 
Регистрация: 02.03.2010
Сообщений: 1,323
По умолчанию

та ясна, ясна
Код:
DoubleToCStr	PROC
	MOVSD QWORD PTR [rcx], xmm0
		
	FLD QWORD PTR [rcx]
	
	FXTRACT

	FLDLG2
	FMUL st(0), st(2)
	FISTP DWORD PTR [rcx]
	
	FSCALE
	
	MOV eax, [rcx]
	SUB eax, 16
	MOV r10d, eax
	NEG r10d

	CMOVNS eax, r10d

	FLD1
	FLD QWORD PTR [float_10]

align 16
	muloop:
		SHR eax, 1
		JZ muldone
		JNC nomul
			FMUL st(1), st(0)
		nomul:
			FMUL st(0), st(0)
		JMP muloop
	muldone:

	FMULP st(1), st(0)

	NEG r10d

	JS mulscale
		FDIVP st(1), st(0)
	JMP scaledone
	mulscale:
		FMULP st(1), st(0)
	scaledone:


	FBSTP TBYTE PTR [rcx]

бла-бла-бла

	RET
DoubleToCStr

Последний раз редактировалось f.hump; 29.08.2012 в 15:22.
f.hump вне форума Ответить с цитированием
Ответ


Купить рекламу на форуме - 42 тыс руб за месяц