flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > [help] d[w|d|q|t] float INTEGER_CONSTANT

Author
Thread Post new topic Reply to topic
idle



Joined: 06 Jan 2011
Posts: 440
Location: Ukraine
idle 02 Jan 2016, 15:50
Code:
INTEGER_CONSTANT = 1
dt INTEGER_CONSTANT ;error, float would save, tnx in advance!
    


Last edited by idle on 02 Jan 2016, 19:16; edited 1 time in total
Post 02 Jan 2016, 15:50
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20300
Location: In your JS exploiting you and your system
revolution 02 Jan 2016, 18:03
DT only supports floating point numbers. There is no 10 byte integer support in fasm.
Post 02 Jan 2016, 18:03
View user's profile Send private message Visit poster's website Reply with quote
idle



Joined: 06 Jan 2011
Posts: 440
Location: Ukraine
idle 02 Jan 2016, 19:15
edit: 2016.01.03:
handle negative nums correctly
revo, tnx!

Code:
;http://board.flatassembler.net/topic.php?t=18849

macro dt' [n]{
  ;float?   -> let fasm
  if n eqtype 0.0
    dt n
  ;0?       -> let fasm
  else if n = 0
    dt 0.0

  ;int expr -> compose
  else
    local bin_log,bin_shl,bin_man,bin_exp
    local n'
    bin_exp = $3fff
    n' = n
    if n' < 0
      n' = 0 - n'
      bin_exp = bin_exp or $8000
    end if
    bin_log = bsr n'
    bin_exp = bin_exp + bin_log
    bin_shl = 63 - bin_log
    bin_man = n' shl bin_shl
    dq bin_man
    dw bin_exp
  end if
}








format pe gui 4.0

INTEGER_CONSTANT_0 = 0
INTEGER_CONSTANT_1 = 1
m1 equ INTEGER_CONSTANT_0 - INTEGER_CONSTANT_1

L1: dt' INTEGER_CONSTANT_0,\
        INTEGER_CONSTANT_1,\
        1+1               ,\
        3.0               ,\
        65'535+1-1        ,\
        m1                   ;fasm bs? fails on negative nums, should be fixed!

entry $
        hlt ;hi, olly!
        finit
        fld tbyte[L1]
        fld tbyte[L1+10]
        fld tbyte[L1+20]
        fld tbyte[L1+30]
        fld tbyte[L1+40]
        fld tbyte[L1+50]  ; stack: -1, 65535, 2, 1, 0
        ret

    


Last edited by idle on 03 Jan 2016, 10:48; edited 1 time in total
Post 02 Jan 2016, 19:15
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20300
Location: In your JS exploiting you and your system
revolution 03 Jan 2016, 06:03
Or maybe:
Code:
macro _dt n {
        if n eqtype 0.0
                dt n
        else
                dt n#.0
        end if
}
_dt 1.0
_dt 1    
Post 03 Jan 2016, 06:03
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< 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.