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
Thread Post new topic Reply to topic
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8356
Location: Kraków, Poland
Tomasz Grysztar 15 Sep 2010, 09:03
edemko wrote:
Wink
dt 0e32769
dt 0e32770
Do you see some problem here?
Post 15 Sep 2010, 09:03
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20363
Location: In your JS exploiting you and your system
revolution 15 Sep 2010, 09:22
0 x 10^32770 == 0

But fasm says: "error: value out of range."
Post 15 Sep 2010, 09:22
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8356
Location: Kraków, Poland
Tomasz Grysztar 15 Sep 2010, 09:24
fasm has its own limitations for allowed exponent values. They are still substantially wider than the range of 80-bit float (you will not really be able to use them up with values other than 0).
Post 15 Sep 2010, 09:24
View user's profile Send private message Visit poster's website Reply with quote
edemko



Joined: 18 Jul 2009
Posts: 549
edemko 15 Sep 2010, 11:30
Found same error in my code today - fixed, looks neat.
rozz
Post 15 Sep 2010, 11:30
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8356
Location: Kraków, Poland
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.
Post 15 Sep 2010, 13:43
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8356
Location: Kraków, Poland
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.
Post 15 Sep 2010, 14:39
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20363
Location: In your JS exploiting you and your system
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.
Oh good, because ARM also supports 16-bit floats. Looks like I need to make an update.
Post 15 Sep 2010, 14:42
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 15 Sep 2010, 15:57
Quote:
Since fasm already implements F16C instruction set
I'm getting a little bit tired of Google showing me pages about jets. Could you please tell me just one representative instruction so I can follow up from there? Razz

Thanks
Post 15 Sep 2010, 15:57
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8356
Location: Kraków, Poland
Tomasz Grysztar 15 Sep 2010, 16:02
Very Happy 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.
Post 15 Sep 2010, 16:02
View user's profile Send private message Visit poster's website Reply with quote
edemko



Joined: 18 Jul 2009
Posts: 549
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
Post 16 Sep 2010, 16:58
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4054
Location: vpcmpistri
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    
Post 17 Sep 2010, 01:43
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8356
Location: Kraków, Poland
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.
Post 17 Sep 2010, 05:39
View user's profile Send private message Visit poster's website Reply with quote
edemko



Joined: 18 Jul 2009
Posts: 549
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
    
Post 17 Sep 2010, 06:03
View user's profile Send private message Reply with quote
edemko



Joined: 18 Jul 2009
Posts: 549
edemko 17 Sep 2010, 06:06
Tomasz wrote:

Well, what do I know?

?
Post 17 Sep 2010, 06:06
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8356
Location: Kraków, Poland
Tomasz Grysztar 17 Sep 2010, 06:39
edemko wrote:
ok, i'm too pedantic
Well, I am pedantic in a different way. Wink

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?
Post 17 Sep 2010, 06:39
View user's profile Send private message Visit poster's website Reply with quote
edemko



Joined: 18 Jul 2009
Posts: 549
edemko 17 Sep 2010, 10:03
Tomasz wrote:

You are losing some precision in that floating-point conversion routine.

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 Wink
Tomasz wrote:

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?

<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
Post 17 Sep 2010, 10:03
View user's profile Send private message Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji 17 Sep 2010, 11:22

tennis match?
Razz Wink

_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 17 Sep 2010, 11:22
View user's profile Send private message Send e-mail Reply with quote
edemko



Joined: 18 Jul 2009
Posts: 549
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'   
    
Post 17 Sep 2010, 14:44
View user's profile Send private message Reply with quote
edemko



Joined: 18 Jul 2009
Posts: 549
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
    
Post 19 Sep 2010, 02:28
View user's profile Send private message Reply with quote
Treant



Joined: 09 Oct 2009
Posts: 16
Location: Russia
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?
Post 19 Sep 2010, 15:01
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2, 3, 4  Next

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.