flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > High Level Languages > FASM in Euphoria 4.0+

Thread Post new topic Reply to topic

Joined: 06 Oct 2005
Posts: 132

FASM in Euphoria 4.0+

I wrote this little wrapper for euphroia for win to allow assembler in eu.
Tested with Euphoria 4.1 32 bit and latest version of fasm.dll wich still returns version 1.67. Technicly it will work with EU-64 bit with 64-bit fasm.dll.

Euphoria can be found here www.rapideuphoria.com
install EU and uzip my wrapper to %euphoria directory%\includes

Description: TG's FASM Wrapper for Euphoria
Filename: fasm4e.zip
Filesize: 68.8 KB
Downloaded: 192 Time(s)

New User.. Hayden McKay.
Post 08 Dec 2015, 09:47
View user's profile Send private message Reply with quote
When all else fails, read the source

Joined: 24 Aug 2004
Posts: 15725
Location: Yonada

I am curious to know what does fasm.dll add to an interpreted language? Or does Euphoria pre-compile code or something?
Post 08 Dec 2015, 10:31
View user's profile Send private message Visit poster's website Reply with quote

Joined: 06 Oct 2005
Posts: 132

Code is executed with a backend. the euphoria bundle also comes with an E 2 C tranlator with your option of compilers to use eg; watcom, borland, gcc. Code is passed through the euphoria interpreter, any syntax checking, type checking is done here., if all ok the code is executed with euphoria backend (written in C) while codeing you can output to windows console like fasm's display directive. eu files can be bined together with the backend to create dll's, windows console apps or just a plain windows executable.

Euphoria has built in function to call machine code. the old way was to compile with fasm the open the binary file in binary mode use sprintf() to format byte sequence as hex output the to file the copy past into eu so you end up with something like this

integer mycode = allocate(CODE_SIZE)
poke(mycode,{90h, 90h, 90h})

to call it we use eu built in call()


this way makes it hard to make adjustments and updates to code because it all lookes like hexidecimal. Now I can use FASM in euphoria by passing strings.

to get the frequency of CPU in euphoria using embeded fasm syntax lookes like this

-- 5 recomended. a longer reference period gives better accuracy

constant refperiod = 5
constant intervals = 18.2 -- number of bios intervals per second

puts(SCREEN,"please wait...")

constant lower = allocate(4)
constant upper = allocate(4)

sprintf("mov [%d], eax",lower), -- stores the tsc qword
sprintf("mov [%d], edx",upper)})

sleep(refperiod) -- wait refernce period

sprintf("sub eax, [%d]",lower), -- subtract saved qword
sprintf("sbb edx, [%d]",upper),
sprintf("mov [%d], eax",lower), -- store result
sprintf("mov [%d], edx",upper)})

constant mHz

= floor(
int_to_bits(peek4u (lower),64),
int_to_bits(peek4u (upper)*power(2,32),64))) -- 64bit tsc result
/ (((1/intervals)*1000000)
* (intervals*refperiod))
+ .5) -- grab nearest mHz

printf(1,"~ %dmHz",mHz) -- done!
while get_key() = -1 do
end while

New User.. Hayden McKay.
Post 08 Dec 2015, 11:54
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

Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2018, Tomasz Grysztar.
Powered by rwasa.