flat assembler
Message board for the users of flat assembler.
Index
> Main > I found a new way of using FASM. 
Author 

revolution
Very good, you might also be interested in this thread


26 Mar 2007, 11:45 

Tomasz Grysztar
Check out also the "Using flat assembler as pure interpreter" section of the Understanding fasm article.


26 Mar 2007, 12:04 

2
Yes,FASM has a bigger use than any program I've ever encountered.
A long time ago,I was looking for the idea of regenerating files which contained many repeated bytes. I tried writing C programs which opened a file, wrote bytes to it and closed it. FASM can do all that in with less. For example,you need only the FASM executable, you don't need to include any stdio.h or main() . Seriously,thanks for making FASM great enough to be used as an every day tool ! It's a perfect example of what an assembler should be. It "assembles" anything. Not just programs! 

26 Mar 2007, 20:57 

2
Also,thought this might be worth sharing.
It's rather weird,but it ran just fine. It makes a text file of decimal powers of 2. Code: macro dec16dig a { b=a z=0 while z<0x10 while b>9999999999999999 b=b10000000000000000 end while y=b / 1000000000000000 db y or 0x30 b=b*0xA z=z+1 end while } d0=1 d1=0 e=0 while e<=64 dec16dig d1 dec16dig d0 db 0xA d0=d0 shl 1 d1=d1 shl 1 if d0>9999999999999999 d0=d010000000000000000 d1=d1+1 end if e=e+1 end while 

03 Apr 2007, 03:44 

revolution
I have been using a similar macro that suppresses leading zeros and you can choose signed or unsigned versions. Another advantage is it will display almost all possible values (64 bits) correctly, see below for the corrected code.
Code: macro display_decimal value { local leading_zero,digit,divisor,number number=value if number=1 shl 63 display '9223372036854775808' else if number<0 number=number display '' end if leading_zero=0 divisor=1000000000000000000 while divisor>0 digit=number/divisor leading_zero=leading_zero+digit if leading_zero  (divisor=1) display digit+'0' number=numberdigit*divisor end if divisor=divisor/10 end while end if } macro display_unsigned value { local number number=value if number<0 number=number10000000000000000000 if number<0 number=number+1000000000000000000 display '9' else display '1' end if end if display_decimal number } Last edited by revolution on 24 Dec 2007, 13:09; edited 1 time in total 

03 Apr 2007, 11:11 

vid
hey revolution, nice one, thanks


03 Apr 2007, 11:15 

m
2 wrote:
Nice it seems ! But. What's in the text file ? Curious ! 

05 Apr 2007, 10:59 

LocoDelAssembly
2 wrote: It makes a text file of decimal powers of 2. 

05 Apr 2007, 15:09 

OzzY
Very nice!
Thanks for the macros revolution! We can use FASM for testing logical expressions or math: Code: macro display_decimal value { local leading_zero,digit,divisor,number number=value if number=1 shl 63 display '9223372036854775808' else if number<0 number=number display '' end if leading_zero=0 divisor=1000000000000000000 while divisor>0 digit=number/divisor leading_zero=leading_zero+digit if leading_zero  (divisor=1) display digit+'0' number=numberdigit*divisor end if divisor=divisor/10 end while end if } macro display_unsigned value { local number number=value if number<0 number=number10000000000000000000 if number<0 number=number+1000000000000000000 display '9' else display '1' end if end if display_decimal number } x=0001b y=1111b z = x or y display_unsigned z This can be used for making "LIVE" comments on the source. Example: Code: include "display_macros.inc" mov eax,2 add eax, 4 ; Live comments: x=2 y=4 z=x+y display "eax=" display_unsigned x display "; " display "eax=eax+" display_unsigned y display "; " display "eax=" display_unsigned z display "; " Try it and see the output! Wrapping it into some macros it can turn into useful debugging tool. 

30 May 2007, 15:54 

revolution
A bug found. I didn't properly test all the corner cases. New code:
Code: macro display_decimal value*,put_zeros { local leading_zero,digit,divisor,number number=value if number=1 shl 63 display '9223372036854775808' else if number<0 number=number display '' end if leading_zero=put_zeros+0 divisor=1000000000000000000 while divisor>0 digit=number/divisor leading_zero=leading_zero+digit if leading_zero  (divisor=1) display digit+'0' number=numberdigit*divisor end if divisor=divisor/10 end while end if } macro display_unsigned value* { local number number=value if number<0 number=number10000000000000000000 if number<0 number=number+1000000000000000000 display '9' display_decimal number else display '1' display_decimal number,1 end if else display_decimal number end if } 

24 Dec 2007, 13:03 

< Last Thread  Next Thread > 
Forum Rules:

Copyright © 19992020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.