flat assembler
Message board for the users of flat assembler.

Index > Non-x86 architectures > [AVR] fasmg assembles with error(s)

Author
Thread Post new topic Reply to topic
tomi



Joined: 08 Nov 2017
Posts: 3
tomi 08 Nov 2017, 15:15
I tried to assemble a lil project that correctly assembles with avrasm2.exe but fasmg throws error(s). Is there a better add-on for fasmg available?
Post 08 Nov 2017, 15:15
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20445
Location: In your JS exploiting you and your system
revolution 08 Nov 2017, 16:00
Can you show the source code, or the line(s) that give(s) an error?
Post 08 Nov 2017, 16:00
View user's profile Send private message Visit poster's website Reply with quote
tomi



Joined: 08 Nov 2017
Posts: 3
tomi 08 Nov 2017, 16:41
This is the output:
Quote:

flat assembler version g.hykpg
sensor.asm [35]:
.include 'sensor.inc'
Processed: .include 'sensor.inc'
Error: illegal instruction.

Original line is: .include "sensor.inc"
Post 08 Nov 2017, 16:41
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20445
Location: In your JS exploiting you and your system
revolution 08 Nov 2017, 16:53
".include" is not fasm syntax. fasm uses "include" without the dot (.) character. fasmg follows this convention also. You can change the source code and remove the leading dot.

Note that all assemblers are different. In general you usually can't assemble unchanged source code from one assembler on another assembler, unless you take specific steps to support it and the assemblers are very similar.
Post 08 Nov 2017, 16:53
View user's profile Send private message Visit poster's website Reply with quote
tomi



Joined: 08 Nov 2017
Posts: 3
tomi 08 Nov 2017, 17:02
Thanks for explanation. I'll see if I can make fasmg to accept .include as well, because changing my sources is not an option, I code in asm almost every day and there is tons of code there.
Post 08 Nov 2017, 17:02
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8358
Location: Kraków, Poland
Tomasz Grysztar 08 Nov 2017, 20:26
At the end of AVR.INC that comes as an example with fasmg you may find a macro that already adds support for some directives starting with dot:
Code:
macro ? line&
        match =BREAK?, line
                _BREAK
        else match .=ORG? addr, line
                if ~ DSEG?
                        org (addr) shl 1
                else
                        org addr
                end if
        else match .=EQU? name == value, line
                name? = value
        else match .=DSEG?, line
                if ~ DSEG?
                        virtual at DSEG?.$
                        DSEG? = 1
                end if
        else match .=CSEG?, line
                if DSEG?
                        DSEG?.$ = $
                        end virtual
                        DSEG? = 0
                end if
        else
                line
        end match
end macro    
You could add support for ".include" by adding another clause like:
Code:
        else match .=INCLUDE? file, line
                include file    
But still, the AVR example included in fasmg package is only a very simple one and it does not attempt to fully emulate syntax of any other AVR assembler. Someone probably could make a better set of macros for this purpose, but I don't know if anyone tried.
Post 08 Nov 2017, 20:26
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.