flat assembler
Message board for the users of flat assembler.
Index
> Main > flat assembler 1.69.15+ Goto page Previous 1, 2, 3, 4 Next |
Author |
|
Tomasz Grysztar 15 Sep 2010, 09:03
edemko wrote:
|
|||
15 Sep 2010, 09:03 |
|
revolution 15 Sep 2010, 09:22
0 x 10^32770 == 0
But fasm says: "error: value out of range." |
|||
15 Sep 2010, 09:22 |
|
edemko 15 Sep 2010, 11:30
Found same error in my code today - fixed, looks neat.
rozz |
|||
15 Sep 2010, 11:30 |
|
Tomasz Grysztar 15 Sep 2010, 13:43
This is adding a special case, whose usefulness is highly doubtful. TASM had the limit 16321 for exponent and fasm has 32769, that's all about it.
|
|||
15 Sep 2010, 13:43 |
|
Tomasz Grysztar 15 Sep 2010, 14:39
However, while we are speaking about floating point values - I've added support for half-precision (16-bit) floats in 1.69.24 release. Since fasm already implements F16C instruction set, it seems only fair that it should allow 16-bit floats to be defined as well.
|
|||
15 Sep 2010, 14:39 |
|
revolution 15 Sep 2010, 14:42
Tomasz Grysztar wrote: However, while we are speaking about floating point values - I've added support for half-precision (16-bit) floats in 1.69.24 release. Since fasm already implements F16C instruction set, it seems only fair that it should allow 16-bit floats to be defined aswell. |
|||
15 Sep 2010, 14:42 |
|
LocoDelAssembly 15 Sep 2010, 15:57
Quote: Since fasm already implements F16C instruction set Thanks |
|||
15 Sep 2010, 15:57 |
|
Tomasz Grysztar 15 Sep 2010, 16:02
Right.
These are just two instructions: VCVTPH2PS and VCVTPS2PH. Documented in Intel® Advanced Vector Extensions Programming Reference, Chapter 7, sections 7.3 and 7.6. |
|||
15 Sep 2010, 16:02 |
|
edemko 16 Sep 2010, 16:58
COMPILER:
Tomasz wrote: This is adding a special case, whose usefulness is highly doubtful. By TG: You should be careful, sometimes you may miss something important. exprpars.inc, ln. 259 Code: ... movzx eax,byte [esi] sub al,30h ;jc bad_number cmp al,9 ja bad_number ... FORUM: People, could you make quick_answer_window's text font mono-width, please. LOCO: Cool, http://board.flatassembler.net/topic.php?t=7852&start=17 |
|||
16 Sep 2010, 16:58 |
|
bitRAKE 17 Sep 2010, 01:43
Code: get_dec_digit: ; N = [2,10], good for bin,oct,dec cmp esi,ebx ja number_ok cmp byte [esi],27h je next_dec_digit mov eax,10 ; N mul dword [edi] mov [edi],eax push edx mov eax,10 ; N mul dword [edi+4] pop edx jc dec_out_of_range mov [edi+4],eax movzx eax,byte [esi] sub al,30h cmp al,10 ; N jnc bad_number add [edi],eax adc dword [edi+4],edx jc dec_out_of_range |
|||
17 Sep 2010, 01:43 |
|
Tomasz Grysztar 17 Sep 2010, 05:39
edemko: I think you are missing the point of what is important.
Well, what do I know? Once again I have no idea what are you trying to convey, anyway. |
|||
17 Sep 2010, 05:39 |
|
edemko 17 Sep 2010, 06:03
hi people
ok, i'm too pedantic fasm, as always, dedicated, written in 5 minutes, test version Code: ; ;getting remainder of ten division example ; mov ebx,0123456789 ;number ; .loop: mov eax,$cccc'cccd ;0.1 shl 3 mul ebx ;(number * 0.1) shl 3 = number * 0.1 * 2^3 shrd eax,edx,3 ;make edx:eax whole.fraction shr edx,3 ;make done mov ebx,edx ;update whole reservoir for smth. subsequent mov edx,10 mul edx ;edx = remainder test ebx,ebx jnz .loop |
|||
17 Sep 2010, 06:03 |
|
edemko 17 Sep 2010, 06:06
Tomasz wrote:
? |
|||
17 Sep 2010, 06:06 |
|
Tomasz Grysztar 17 Sep 2010, 06:39
edemko wrote: ok, i'm too pedantic You are losing some precision in that floating-point conversion routine. 0.3333333333333333333 converts to 3F FD AA AA AA AA AA AA AA A4 - fasm/TASM make it 3F FD AA AA AA AA AA AA AA A9. 0.33333333333333333333 does not convert at all (?) - fasm converts it to 3F FD AA AA AA AA AA AA AA AB. Maybe you could aim at quadruple precision? |
|||
17 Sep 2010, 06:39 |
|
edemko 17 Sep 2010, 10:03
Tomasz wrote:
In the purpose of curiosity fpu mode was added yesterday and: 0.3333333333333333333 ->no fpu-> 3F'FD'AA'AA'AA'AA'AA'AA'AA'A4h 0.3333333333333333333 ->by fpu-> 3F'FD'AA'AA'AA'AA'AA'AA'AA'A9h Useful tip. That can be fixed using 1 more dword when multiplying. I feel fasm does that way. Tools made just for fun, and Tomasz to remove that annoying DIV, and for some people Tomasz wrote:
<a2f> encodes string into 64bit qword and then calls power function regardless fpu mode on/off. Hence that value cannot be stored in qword and 1 more dword must be improved. Anyway we are using TBYTES and no quadruple precision planned, do you? rozz's updated fasm source. http://wasm.ru/forum/viewtopic.php?pid=397202#p397202 Mention this line when compiling: Code: stdcall bsa_a2f,buf260+4,$100 or "'" ;no fpu stdcall bsa_a2f,buf260+4,$000 or "'" ;by fpu edit: and thanks for the tip |
|||
17 Sep 2010, 10:03 |
|
ouadji 17 Sep 2010, 11:22
tennis match? |
|||
17 Sep 2010, 11:22 |
|
edemko 17 Sep 2010, 14:44
edit 2010_09_17: i deleted previous post
Getting unnormalized fraction: Code: format pe gui 4.0 include 'win32ax.inc' section '' code executable import readable writeable library kernel32,'kernel32.dll',\ user32,'user32.dll' include 'api\kernel32.inc' include 'api\user32.inc' buf rb 4096 entry $ cld mov edi,buf xor esi,esi mov edx,[.int64a+4] mov ebx,[.int64a] mov ecx,2048 .loop:shld esi,edx,1 shld edx,ebx,1 shl ebx,1 mov al,'0' test esi,esi jnz .a cmp edx,[.int64b+4] jnae .nae ja .a cmp ebx,[.int64b] jb .nae .a: mov al,'1' sub ebx,[.int64b] sbb edx,[.int64b+4] sbb esi,0 .nae: stosb dec cx jz .stop_loop add ecx,$0400'0000 jnc .loop mov al,10 stosb jmp .loop .stop_loop: mov al,0 stosb invoke MessageBoxA,0,buf,"2'048 bits of an un-normalized fraction; 64 bits/per a row",0 ret 0 .int64a: dq 03'333'333'333'333'333'333 ;075 ;03'141'592'653'589'793'238 ;0'123'456'789 ;065'535 ;0'625 .int64b: dq 10'000'000'000'000'000'000 ;100 ;10'000'000'000'000'000'000 ;1'000'000'000 ;100'000 ;1'000 I tried doing that with macro but... When will bit65 come, Tomasz? Code: ;display 13,10 ;v1 = $2E'42'61'01'83'4D'55'55; 3'333'333'333'333'333'333 ;v2 = $8A'C7'23'04'89'E8'00'00;10'000'000'000'000'000'000 ;repeat 64 ; v1 = v1 shl 1 ; if v1 > v2 ; v1 = v1 - v2 ; display '1' ; else ; display '0' ; end if ;end repeat ;display '0' |
|||
17 Sep 2010, 14:44 |
|
edemko 19 Sep 2010, 02:28
Hi Tomasz.
Try that code please. edited as wrong comment was given Code: format pe gui 4.0 include 'win32ax.inc' section '' code executable import readable writeable library kernel32,'kernel32.dll',\ user32,'user32.dll' include 'api\kernel32.inc' include 'api\user32.inc' a dt 3333333333333333333.0 entry $ movzx esi,word[a+8] ;head and si,$7fff ;positive head mov edx,dword[a+4] ;high dword mov ebx,dword[a+0] ;low dword mov eax,$0000'0000 ;lowest dword repeat 19 ;any power of 10 call tg_div add esi,ecx ;final number end repeat push esi edx ebx fld tbyte[esp] add esp,3*4 repeat 19 call tg_mul add esi,ecx end repeat push esi edx ebx fld tbyte[esp] add esp,3*4 hlt ;check st1,st0 ret 0 ; normalized mantissa -> edx:ebx:eax ; edx:ebx:eax <- if tg_div: normalized (mantissa * 0.1) ; if tg_mul: normalized (mantissa * 10.0) ; ecx <- exponent delta ; flags <- ? proc tg_div push edx ebx eax 0 mov eax,esp mov ebx,$cccc'cccc lea ecx,[ebx+1] push ebx ebx ecx 0 mov ebx,esp stdcall _128mul128,ebx,eax add esp,4*4 pop ecx eax ebx edx test edx,edx setns cl shld edx,ebx,cl shld ebx,eax,cl shld eax,ecx,cl movzx ecx,cl neg ecx sub ecx,3 ret 0 endp ;fasm internals simulants, test version proc tg_mul push edx ebx eax 0 mov eax,esp push $a000'0000 0 0 0 mov ebx,esp stdcall _128mul128,ebx,eax add esp,4*4 pop ecx eax ebx edx test edx,edx setns cl shld edx,ebx,cl shld ebx,eax,cl shld eax,ecx,cl movzx ecx,cl neg ecx add ecx,4 ret 0 endp ;/* ; [m2:m1] = [m2]*[m1]. ; flags <-? ; low 128 bits stored at <m1> then high 128 bits stored at <m2> ; there will be fun when buffers overlap :) ;*/ proc _128mul128; m1,m2 push ebp mov ebp,esp push edi mov edi,[ebp+2*4] ;m1 push esi mov esi,[ebp+3*4] ;m2 push edx ecx ebx eax ;we'll use stepping _64mul64 ;[m1]*[m2] = [m1.1]*[m2.1] + ;00I ; + ([m1.1]*[m2.2]) shl 064 + ;0II ; + ([m1.2]*[m2.1]) shl 064 + ;III ; + ([m1.2]*[m2.2]) shl 128 ;0IV mov edx,[esi+4] mov ecx,[esi] mov ebx,[edi+4] mov eax,[edi] call _64mul64 push 0 0 0 0 edx ecx ebx eax ;00I mov edx,[esi+12] mov ecx,[esi+8] mov ebx,[edi+4] mov eax,[edi] call _64mul64 add [ebp-12*4],eax adc [ebp-11*4],ebx adc [ebp-10*4],ecx adc [ebp-9*4],edx adc dword[ebp-8*4],0 ;0II mov edx,[esi+4] mov ecx,[esi] mov ebx,[edi+12] mov eax,[edi+8] call _64mul64 add [ebp-12*4],eax adc [ebp-11*4],ebx adc [ebp-10*4],ecx adc [ebp-9*4],edx adc dword[ebp-8*4],0 ;III mov edx,[esi+12] mov ecx,[esi+8] mov ebx,[edi+12] mov eax,[edi+8] call _64mul64 add [ebp-10*4],eax adc [ebp-9*4],ebx adc [ebp-8*4],ecx adc [ebp-7*4],edx ;0IV pop dword[edi] dword[edi+4] dword[edi+8] dword[edi+12] dword[esi] dword[esi+4] dword[esi+8] dword[esi+12] pop eax ebx ecx edx pop esi edi leave ret 8 ;2010_08_20 endp ; edx:ecx:ebx:eax <- edx:ecx * ebx:eax = (edx*ebx:eax) shl 32 + ecx*ebx:eax ; flags <- result.edx + 0 ; ; $ffffffff'ffffffff * $ffffffff'ffffffff = $ffffffff'ffffffff * $1'00000000'00000000 - $ffffffff'ffffffff = $ffffffff'ffffffff'00000000'00000000 - $ffffffff'ffffffff = $ffffffff'fffffffe'00000000'00000001 = 128bit proc _64mul64 push ecx ebx eax mov ecx,edx call _64mul32 xchg ecx,[esp+8] xchg ebx,[esp+4] xchg eax,[esp] call _64mul32 pop edx add ebx,edx pop edx adc ecx,edx pop edx adc edx,0 ret 0 endp ; ecx:ebx:eax <- ecx * ebx:eax = (ecx*ebx) shl 32 + ecx*eax ; edx <- ecx*eax ; flags <- result.ecx + 0 ; ; $ffffffff'ffffffff * $ffffffff = $ffffffff'ffffffff * $1'00000000 - $ffffffff'ffffffff = $ffffffff'ffffffff'00000000 - $ffffffff'ffffffff = $fffffffe'ffffffff'00000001 = 96bit proc _64mul32 xchg ebx,eax mul ecx xchg ebx,eax xchg edx,ecx mul edx add ebx,edx adc ecx,0 ret 0 endp |
|||
19 Sep 2010, 02:28 |
|
Treant 19 Sep 2010, 15:01
Code: struc IRP { ... } This code has error "reserved word used as symbol" because "The irp directive iterates the single argument through the given list of parameters. The syntax is irp followed by the argument name, then the comma and then the list of parameters." Can you fix struc directive for could be set structure name to any? |
|||
19 Sep 2010, 15:01 |
|
Goto page Previous 1, 2, 3, 4 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.