I am trying to work out a way to generate mutiple output files (from multiple sources) that can access each other if they are in memory together. Like, the source of my OS' bootloader generates a file which i then write to the bootsector of my disk, another source generates the kernel whose bin file i then put as a file in the disk's file system.

So when the bootloader has loaded the kernel image, both ?programs? reside in memory. I then want one of them to be able to call functions in the other which will, of course, have different locations after every change.
What I have done till now is putting both into one source file and then splitting the output up at a specific location, but that does neither work in all cases (since I mostly don't know where to split) nor is it a very good way of handling this I find.

Is there any good way of handling this so the codes know the locations of some/all symbols in each other?

Posted on 2003-03-29 16:50:23 by ThFabba
Hehe, noone seems to have an idea about this...

The ability to write the symbols to a file would solve this, load directive would be exactly the counterpart of that... So, is there a way to write to some extra file? Thinking of it, I could write that to my output file and make the other source just read that, but that'd make me have unwanted stuff in there...

So, any better way? :rolleyes:
Posted on 2003-04-05 10:48:28 by ThFabba
Well, maybe it would be useful to provide some directive for writing into additional files, maybe some kind of display directive redirection... I'll think about it.
Currently the are only "dirty" solutions:

1) Include the whole other source in the virtual block to get all labels from there defined. I would be something like:

virtual at 0
include 'otherfile.asm'
end virtual

2) Use display directive like in the Tetris example from the fasm website. You can also redirect the output from compiler into some file and make some fasm-source script to load values from it. Well, it's not really bad idea - when you redirect compiler output into file, you can usedisplay directive to write pure binary values and the read them with load directive in the other source. You can write some ID string before them and then search for them before reading, for example if you write character '>' and then some binary bytes with the display directive, then you can read them this way:

fname equ "fasm.out"

virtual at 0
file fname
fsize = $
end virtual

pos = -1
repeat fsize
load a byte from fname:%-1
if a = '>' & pos = -1
pos = %
end if
end repeat

if pos <> -1
load x dword from pos
; etc.
end if

PS. Sorry I didn't answer earlier, but when you had posted it I was out of net for a few days and I have missed this thread.
Posted on 2003-04-05 11:04:54 by Tomasz Grysztar