flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > How to inline assembly in macros?

Author
Thread Post new topic Reply to topic
Azu



Joined: 16 Dec 2008
Posts: 1159
Azu
I think that's the right term anyways.

I want to run certain assembly code within a macro. Is there an interface for doing this? In particular, I'd like to use fld/fistp and fild/fstp to convert arguments passed to the macro between integer and float. I think this would compile a lot faster than trying to implement IEEE 754 at macro level. And also I'm lazy and don't want to do the latter if there is no need to.

Please help. I did look in the manual but I can't find anything on this.



p.s.
I know I can put in floats like 1.0 and FASM will put it that way in the file, but that doesn't work when for example they get added together (e.g. a 1.5 added to another 1.5) and I want it to round them and store as integer in the file..

_________________
Post 22 Dec 2009, 23:10
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
In other words, you need to "execute" FPU instructions at compile time? If not you should, that is a very good idea Laughing
Post 23 Dec 2009, 01:18
View user's profile Send private message Reply with quote
Azu



Joined: 16 Dec 2008
Posts: 1159
Azu
LocoDelAssembly wrote:
In other words, you need to "execute" FPU instructions at compile time? If not you should, that is a very good idea Laughing
I would but I don't know how. Confused

_________________
Post 23 Dec 2009, 01:29
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2466
Location: Bucharest, Romania
Borsuc
Well that's pretty unlikely to be possible in any assembler, FASM included. Also FASM floating point constants capability is limited.
Post 23 Dec 2009, 16:22
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Borsuc, but the interpreter layer language is powerful enough to implement a processor, and although it doesn't support floating point operations, you could still implement them in the same way FPU emulators did at the time where the FPU unit was not guaranteed to be present.
Post 23 Dec 2009, 16:57
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7734
Location: Kraków, Poland
Tomasz Grysztar
Quite a few years ago (about the time of fasm 1.3x, I think) I was trying to design some kind of "plugin" functionality that would allow you to write a kind of macros for assembly layer using the x86 assembly as well (since fasm itself cannot be ported to other architecture than x86, that wouldn't be any problem to execute such code). However I gave up because of the security problems that would arise from such feature.
Post 23 Dec 2009, 18:45
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: 4633
Location: Argentina
LocoDelAssembly
Oh damn, I forgot a very important instruction that would be hard to emulate (if not completely impossible), JMP/Jxx... But well, you could still use if, repeat, while from fasm and put inside of the control structures bodies the non-branching emulated instructions.

Here a very simple instruction to emulate:

Code:
; Some code to init the pseudo-registers

macro em_bswap reg
{
  virtual ; Test the instruction is valid
    bswap reg
  end virtual

  @#reg = @#reg shl 24 + (@#reg shl 8) and $FF0000 + @#reg shr 24 + (@#reg shr 8) and $FF00

}    
(use16 and use32 supported only)
Post 23 Dec 2009, 19:22
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr
Tomasz Grysztar,

May be some kind of *nix backtick functionality? I.e. replace `expr round(2*$pi*$r)` with output of that command (pi and r replaced with actual values). Separate process, almost safe bet.
Post 23 Dec 2009, 19:45
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Like `del c:\boot.ini`?Wink
Post 23 Dec 2009, 19:54
View user's profile Send private message Reply with quote
Azu



Joined: 16 Dec 2008
Posts: 1159
Azu
I didn't know *nix had c: or boot.ini.

_________________
Post 23 Dec 2009, 21:35
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Quote:

I didn't know *nix had c: or boot.ini.


Me neither, where you take that from?
Post 23 Dec 2009, 21:43
View user's profile Send private message Reply with quote
Azu



Joined: 16 Dec 2008
Posts: 1159
Azu
Arrow
LocoDelAssembly wrote:
Like `del c:\boot.ini`?Wink

_________________
Post 23 Dec 2009, 21:45
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Yep, you misunderstood your source.
Post 23 Dec 2009, 21:50
View user's profile Send private message Reply with quote
Azu



Joined: 16 Dec 2008
Posts: 1159
Azu
I thought it meant delete the file called "boot.ini" in the "c:\" directory.

What did it really mean? Confused

_________________
Post 23 Dec 2009, 21:54
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Yes, I meant that, using FASM under Windows, obviously. (The computer won't explode for using a feature borrowed from Unix, I can even use it right now by using bash for Windows)
Post 23 Dec 2009, 22:15
View user's profile Send private message Reply with quote
Azu



Joined: 16 Dec 2008
Posts: 1159
Azu
LocoDelAssembly wrote:
Yes, I meant that, using FASM under Windows, obviously. (The computer won't explode for using a feature borrowed from Unix, I can even use it right now by using bash for Windows)
Not even if you use that feature to delete boot.ini? Laughing

_________________
Post 23 Dec 2009, 22:17
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2466
Location: Bucharest, Romania
Borsuc
You could still, you know, delete the source code if not just boot.ini (which is easily replaced), and all your work goes to trash. Razz
Post 23 Dec 2009, 23:39
View user's profile Send private message 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-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.