flat assembler
Message board for the users of flat assembler.

Index > Non-x86 architectures > [fasmarm] using BX

Author
Thread Post new topic Reply to topic
pepe



Joined: 26 Feb 2015
Posts: 19
pepe 18 Jun 2015, 18:44
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: 19
pepe 18 Jun 2015, 19:12
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: 20333
Location: In your JS exploiting you and your system
revolution 19 Jun 2015, 00:42
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: 19
pepe 19 Jun 2015, 05:33
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: 20333
Location: In your JS exploiting you and your system
revolution 19 Jun 2015, 05:49
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


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.