flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > virtual, labels and multiple passes

Author
Thread Post new topic Reply to topic
shutdownall



Joined: 02 Apr 2010
Posts: 518
Location: Munich
shutdownall
I want to use codeblocks to be generated and place them to other locations in output file / source file.

Short example

Code:
        org 1000h
        mov eax,55
        <codeblock1>
        mov edx,eax

<codeblock1 definition>
   push ebx
   pop eax
<codeblock1 definition end>

    


So I tried to use macro to define codeblock1 what works but I want to define the codeblock later in source, so want to have codeblock1 somewhere in the source files and referenced during a second or multiple passes when resolving.

Next idea was to use virtual directive but can not find a way to move the virtual content to the location of <codeblock1>. There is existing a load and store instruction in combination but need a datatype (codeblock1 could be any data with any size) and found problems to write it at correct position in output file when using org directive. In the example it has to be written to byte 0005h in output file but not to $$+5 because this means 1005h which is physically not existing. So I think virtual can not really help to put code in that location.

Resolving of forward references is done for labels.
So is it possible to use labels in this context ?
I know that there is some hard coding needed in preproce.inc, parser.inc or maybe assemble.inc but want to find a comfortable way to implement this feature. So internal structures/functions which could be used easily in this context.

So maybe somebody has an idea. Very Happy

And I have to add a reference for org processing, so need the org of the codeblock from the position to be inserted (1005h) and let the code continue after inserting with previous org value + size of codeblock.

By the way, in some older assemblers I found directives called PHASE and DEPHASE for changing ORG value (with phase) and restore ORG value with DEPHASE.
Post 05 May 2012, 21:42
View user's profile Send private message Send e-mail Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17620
Location: In your JS exploiting you and your system
revolution
Perhaps the patch macro I use for fasmarm can be useful for you to study. It creates small code sections an places them into code that has already been generated. It is not precisely what you explain above but you might be able to modify it.
Post 05 May 2012, 22:12
View user's profile Send private message Visit poster's website Reply with quote
shutdownall



Joined: 02 Apr 2010
Posts: 518
Location: Munich
shutdownall
Thanks, I will give a try.
Do I find this with the ARM version (download) ?
Let me check. Wink
Post 06 May 2012, 20:11
View user's profile Send private message Send e-mail 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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.