Fasm4eu.ew: fasm.dll wrapper for Euphoria 3.1+, created by Hayden McKay,
1st official release date: 05/2016.
flat assembler version 1.67
Copyright (c) 1999-2006, Tomasz Grysztar.
All rights reserved. www.flatassembler.net
GLOBAL ROUTINES:
'create_asm': returns a sequence of machine level byte codes.
'define_asm': defines a c_func or c_proc machine code routine.
'inline_asm' : build machine code and execute during runtime.
DEBUGGING:
'fasm.err': generated in the event of a fatal error, and assembler syntax errors.
'ex.err' : generated by euphoria in the event of eu machine level exemptions.
syntax and fatal errors in regards to calls made to inline_asm are not caught by fasm4eu, euphoria will generate the appropriate exemption: see ex.err.
Your program must explicitly include the to 'use64' directive at the top off your assembler routines for ia64 bit encoding, the next release might make some calls to kernel.dll and assume the right model for your program.
USING FASM4EU WITH EUPHORIA
For examples and documentation, download the flat assembler bundle from the flat assembler homepage here, then you will have access to all the features of TG's flat assembler, including: masm.inc, win32a.inc with all the libraries that come with the bundle.
The basic outline for parsing assembler code to fasm4eu is as follows:
syntax that is parsed to fasm4eu must be enclosed in braces;
{“mov eax, [ss:esp + 4]” , – separated by comas
“mov ebx, [ss:esp + 8]”}
{“mov eax, [ss:esp +4] \n mov ebx, [ss:esp + 8]} – is also allowed
the standard euphoria rules apply for calling machine code from eu;
id_fmul = define_asm(
{C_INT, C_DOUBLE},{
“fild [ss:esp + 4]” ,
“fmul [ss:esp + 8]” ,
“retn 12” },
C_DOUBLE )
FASM4EU ROUTINES:
– ENTER
? crate_asm({“push ebp”,
“mov ebp, esp”})
– hello world!
? create_asm(
{ “org 100h” , -- make 'com' file
“use16” , – use 16 bit code
“mov ax, 0300h” , – cursor location
“int 10h” ,
“mov ax, 1301h” , – puts tty string
“mov cx, 000Ch” , – string's length
“mov bl, 00f0h” , – black on white
“mov bp, message” ,
“int 10h” , – call video bios
“int 20h” , – exits 'com' file
“message db 'Hello World!'” })
id_poke2u = define_asm{
{C_POINTER, C_USHORT},
{“mov ebx, dword [ss:esp + 4]” ,
“mov ax, word [ss:esp + 8]” ,
“mov word [ds:ebx], ax” ,
“retn 6” },
NULL ) – returns nothing
c_proc(id_poke2u,{pointer, integer})