there is signbit and exponent and number
so is there a simple way to check exponent to tell the size of the number is between for example
10 million and one million,1 million and 100000,100000 and 10000...........?in decimal
use display in 16bit unicode instead,I want to exchange the display "INF" to "∞" =221Eh,when infinity
From the FPU tutorial, you could find the following:
The relationship between a logarithm base 2 and a logarithm using some other base b is as follows:
logbx = log2x*(log2b)-1 = log2x*logb2
The FPU has both the log(2) and ln(2) as hard-coded constants which can be loaded with the FLDLG2 and FLDLN2 instructions respectively. As an example, the following code could be used to compute the common logarithm of a positive REAL number zzz located in memory.
fldlg2 ;ST(0)=log10(2), ST(1)=zzz
fld real_var ;ST(0)=real_var, ST(1)=log10(2), ST(2)=zzz
fyl2x ;log2(real_var)*log10(2)=>ST(1) and ST(0) is POPed
;ST(0)=log10(real_var), ST(1)=zzz
The log(zzz) would then be in ST(0). You could store the integer portion with the FISTTP instruction (http://www.ray.masmcode.com/tutorial/fpuchap5.htm#fisttp) or use other means. This will give you the lower limit of the range you are looking for.
Thanks raymond :thumbsup:
I am working on AVX calculator, and other exercises to do things in AVX
This is for Double2 ascii conversion proc
Movss xmm0,z
Movd eax,xmm0
Mov string,'+'
Test eax,8000 0000h
Je L1
Mov string,'-'
L1: sar eax,23
And eax,7fh
Here I get strange results
When z 987654321, eax=25, when z -1000, eax is 8 =range 256?
After this I want to start with the range I detect above
To start toascii conversion loop
Unfortunately, I am not at all familiar with the SSE instructions.
Furthermore, I don't know which assembler you may be using. And, for that reason, I would not know if an instruction such as "sar eax,23" would be interpreted by the assembler as meaning 23h or 23d without the specification. Similarly, would "eax=25" be a binary or decimal value of eax???
I think is:
.data
r4t real4 0.0
.code
fild z
fstp r4t
mov eax, r4t
shr eax, 23d
and eax, 0FFh ; mantissa is 8 bit
sub eax, 127d ; mantissa is biased
Quote from: HSE on July 27, 2021, 09:05:37 AM
I think is:
.data
r4t real4 0.0
.code
fild z
fstp r4t
mov eax, r4t
shr eax, 23d
and eax, 0FFh ; mantissa is 8 bit
sub eax, 127d ; mantissa is biased
I can understand that but this would give the range in the binary system. His first post indicated he wants to know the range in the decimal system.
Hi Raymond!!
Quote from: raymond link=topic=9464.msg103615#msg103615
I can understand that but this would give the range in the binary system.
His first post indicated he wants to know the range in the decimal system.
Just following Daydreamer's code.
I don't know what he want :biggrin:
Quote from: raymond on July 27, 2021, 11:05:39 AM
Quote from: HSE on July 27, 2021, 09:05:37 AM
I think is:
.data
r4t real4 0.0
.code
fild z
fstp r4t
mov eax, r4t
shr eax, 23d
and eax, 0FFh ; mantissa is 8 bit
sub eax, 127d ; mantissa is biased
I can understand that but this would give the range in the binary system. His first post indicated he wants to know the range in the decimal system.
I want todo it with a LUT, from binary, speed like in converting lots of primes or other numbers, solving it with SSE/AVX I am limited to +,-,*,/,,sqrt and without fpu fully equipped math functions
Quote from: HSE on July 27, 2021, 09:05:37 AM
I think is:
.data
r4t real4 0.0
.code
fild z
fstp r4t
mov eax, r4t
shr eax, 23d
and eax, 0FFh ; mantissa is 8 bit
sub eax, 127d ; mantissa is biased
Thanks Héctor :thumbsup:
Quote from: daydreamer on July 27, 2021, 05:10:53 PM
[ I am limited to +,-,*,/,,sqrt
Sorry to know your machine FPU is broken, but I think Raymond explanation will work even in your phone!
Quote from: HSE on July 28, 2021, 12:08:14 AM
Quote from: daydreamer on July 27, 2021, 05:10:53 PM
[ I am limited to +,-,*,/,,sqrt
Sorry to know your machine FPU is broken, but I think Raymond explanation will work even in your phone!
Seem I need to add some checking nan's and infinity., same float or double independent of instruction set
I have partly working float2ascii, sometimes cvtss2si eax,xmm0 gets very high number,character becomes 0ffh+'0'
One divss maxrange and Multiple mulss 10.0,causes precision loss,causes this infinity,or nan?
Magnus,
The hardest part of a calculator is the interface, the calculations in SSE2 are trivial. If you want higher precision you would use the FP unit.
Quote from: hutch-- on July 28, 2021, 09:00:51 AM
Magnus,
The hardest part of a calculator is the interface, the calculations in SSE2 are trivial. If you want higher precision you would use the FP unit.
this has been a nice avx exercise,singlestepping,because register usage is different from SSE
also exercise to SIMD version of ascii to double works
Quote from: hutch-- on July 28, 2021, 09:00:51 AM
Magnus,
The hardest part of a calculator is the interface, the calculations in SSE2 are trivial. If you want higher precision you would use the FP unit.
I am trying to get unicode gui working in asm
But test button shows only ascii?
Whole create main window needs to be unicode first?
Newer. Inc files for createwindowW needed?
Different flags in invoke to treat string as 16bit unicode instead?
doesnt work,trying to convert to unicode windows program
; invoke RegisterWinClass,ADDR WndProc,ADDR szClassName,
hIcon,hCursor,COLOR_BTNFACE+1
invoke RegisterClassExW,ADDR WndProc,ADDR szClassName,hIcon,hCursor,COLOR_BTNFACE+1
mov Wwd, 1024
mov Wht, 768
invoke TopXY,Wwd,sWid
mov Wtx, eax
invoke TopXY,Wht,sHgt
mov Wty, eax
;HWND hWnd = CreateWindowW(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, 0, 0, 1280, 1024,nullptr, nullptr, hInstance, nullptr);CPP working unicode
invoke CreateWindowExW,WS_EX_LEFT OR WS_EX_ACCEPTFILES,szClassName,szDisplayName,WS_OVERLAPPEDWINDOW,Wtx,Wty,Wwd,Wht,NULL,NULL,hInstance,NULL
;invoke CreateWindowEx,WS_EX_LEFT or WS_EX_ACCEPTFILES,
; ADDR szClassName,
; ADDR szDisplayName,
; WS_OVERLAPPEDWINDOW,
; Wtx,Wty,Wwd,Wht,
; NULL,NULL,
; hInstance,NULL
mov hWnd,eax
;mov hwndButton,rv(CreateWindowExW,0,ADDR btnClass,ADDR lpTextu,WS_VISIBLE or WS_CHILD or BS_DEFPUSHBUTTON or BS_TEXT,400,300,256,256,hWnd,B1,hInstance,NULL)
check RegisterClassEx
ATOM WINAPI RegisterClassEx( _In_ const WNDCLASSEX *lpwcx);
Quote from: TimoVJL on August 10, 2021, 05:01:47 PM
check RegisterClassEx
ATOM WINAPI RegisterClassEx( _In_ const WNDCLASSEX *lpwcx);
Maybe better to find unicode template for Windows program
wcx WNDCLASSEXW <sizeof WNDCLASSEXW,NULL,WndProc,0,0,?,?,?,COLOR_SCROLLBAR+1,NULL,szClassName,?>
...
INVOKE RegisterClassExW,ADDR wcx
Standard control can all use UNICODE ,just use headers who can switch from ansi to unicode.
Just have a look here http://masm32.com/board/index.php?topic=1796.msg103837#msg103837 (http://masm32.com/board/index.php?topic=1796.msg103837#msg103837)
Just add "UNICODE equ" at the first line of the source and all will be in unicode.