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 > Non-x86 architectures > [fasmarm] using BX

Author
Thread Post new topic Reply to topic
pepe



Joined: 26 Feb 2015
Posts: 7
[fasmarm] using BX
Hi,

Probably a lame question, but i could not yet figure out ...
i am trying to separate code to different asm files by their function.
For example i wrote some wrappers for exception handlers. They do context saving, call the handler function and restore context.
they are put in a file called Exception.asm.
now this file is included into the main asm file where the hanlders are supposed to be written, but their names are not known in the included file during compilation.
For example:

Code:
 ; Exception.asm
org 0
   b _Reset
   b _UndefInstr
...

org 1000
_Reset:
   bx Reset

_UndefInstr:
   ... context saving...
   blx UndefHandler
   ... context restore...




Code:
 ; main.asm

include "Exception.asm"

Reset:
   ... reset code...

UndefHandler:
   ... undef handler code...





What would be the correct way to handle such a situation? In other environments i could declare the handlers as external, but how about fasmarm?

thanks a lot,
pepe
Post 18 Jun 2015, 18:44
View user's profile Send private message Reply with quote
pepe



Joined: 26 Feb 2015
Posts: 7
hmm, answering myself.... Smile
the situation is strange, it was caused by the BX instruction (BX Reset). if i used B or BL, it compiled ok, which is odd.
Post 18 Jun 2015, 19:12
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 12911
Location: One second in the future
The BX instruction only supports register destinations. There is no BX encoding for immediate offsets.

If you want to declare external constants then you have to use a format that is linkable.
Post 19 Jun 2015, 00:42
View user's profile Send private message Visit poster's website Reply with quote
pepe



Joined: 26 Feb 2015
Posts: 7
Linkable: yes, i was thinking about that too, since 'include' only inserts the content into the main file, that's why i thought it should work...
BX: i told in the beginning it is a lame question Smile

But thank you for all your answers and reading my lame posts Smile
Post 19 Jun 2015, 05:33
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 12911
Location: One second in the future
Everyone is welcome to ask as many "lame" questions as they wish. In your case the answer was not obvious so it was worthwhile to explain the restrictions for BX that the other B* instructions don't have.
Post 19 Jun 2015, 05:49
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


Powered by phpBB © 2001-2005 phpBB Group.

Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2013, Tomasz Grysztar.