flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > Feature request: label file offset directive/operator (LFO)

Author
Thread Post new topic Reply to topic
edfed



Joined: 20 Feb 2006
Posts: 4354
Location: Now
edfed 03 Dec 2007, 21:12
just an idea, but, in directives, can it be added a sector directive?
like a label, this one will bring the possibility to write disk images, sector by sector, and link them. like this:
Code:
sector 1 ;boot
org 7c00h
label1:
sdd label2  ;sdd for sector define dword
....
;here the space is tall like the difference between the too sectors definitions. 
....
sector 10h ;
org 3234
label2:
sdd label1
    

this idea is not very clear in my mind, but i was many times limited by unexistance of this directive.
Post 03 Dec 2007, 21:12
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 03 Dec 2007, 21:24
Quote:
this idea is not very clear in my mind, but i was many times limited by unexistance of this directive.


If it is not clear in your mind, how do you know what is the actual limitation and what do you expect from the directive? Confused

The "sdd" is a part that I really don't understand what do you mean. As for "sector directive", do you just need to ensure that certain part of the source will start at a given sector? This could be done by "overloading" ORG so you keep track of the adjustments of $ and $$ and then the padding can be calculated correctly. If that was you mean I could write it for you if you want. (if someone know that there are simplier ideas to achieve this please tell).

[edit]Perhaps I will move this discussion from this thread later, all depends in how it evolves[/edit]
Post 03 Dec 2007, 21:24
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4354
Location: Now
edfed 03 Dec 2007, 21:47
padding is not a problem for me
it's just that, when using many org statements in source, labels are always relative to the last org.
i just need a label global access, the real offset of the label. independant of the org.
this will permitt, as stated above, to directlly write DISK images and file systems.
i know there are the global and local directives, but i doubt it can be used for that.
sdd is for sector-define-dword, other names are possible, as:
chsd for CHS dword, or LBAd for a lba dword, etc...
these values will automatically be loader with the good sector number.

for exemple, in the boot sector, to address a sector, just give the name of a label into the desired sector.
then, preprocessor will give the exact location of the label in the linear assembled file or the sector number.
Post 03 Dec 2007, 21:47
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 03 Dec 2007, 22:07
OK, lets call this "sdd" d{w|d}fo (define {word|dword} file offset). No need for "sector" directive at all then?

I vote for having a macro that return the calculated offset on an assembly-time variable so you can do whatever you want later. You would invoke it as "offsetToFileOffset yourLabelOrPlainOffset, res" then, "res" variable will have the calculated value. Of course this is great but it isn't doable Sad I see no way to make it work with forward referencing.

Well, this request belong to compiler internals then. Do you agree in using "Feature request: label file offset directive (LFO)" as thread title?
Post 03 Dec 2007, 22:07
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 03 Dec 2007, 22:18
If you will start deleting before I move this specific topic, please move this first, since it is doable from compiler side (rest some definitions on what to do when you don't pass a plain nor out of virtual block label, though).
Post 03 Dec 2007, 22:18
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4354
Location: Now
edfed 03 Dec 2007, 22:31
i agree, in fact i've made an other mistake by putting the first post in general/fasm as a package for community

good choice for the title.


Description: in fact, it is for the addressing of files and directories in my file system directlly in asm.
to define the FIRSTSECTOR and SIZEOFFILE fields

Download
Filename: dirtables.inc
Filesize: 897 Bytes
Downloaded: 400 Time(s)

Post 03 Dec 2007, 22:31
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 03 Dec 2007, 22:58
Done, I have used the word "operator" too since looks more reasonable to be an operator like RVA, PLT and so on.
Post 03 Dec 2007, 22:58
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4354
Location: Now
edfed 03 Dec 2007, 23:04
RVA is for windows? no?
what is PLT?

what do you mean with Done?
you have the solution?

LFO is not a good idea for the directive name as it is the
Low Frequency Oscillator initials.
LFO is a label i'll use in the future for sound programming function.
Post 03 Dec 2007, 23:04
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 03 Dec 2007, 23:14
I would try to formulate this more generally:

You want named address spaces, and ability to reference base of address space from other address spaces. I think this can (in most cases) be overcomed by existing features.

Example:
Code:
org 7000h
sector1 = $$
 ... blahblah ...

org 7800h
sector2 = $$
  ... blahblah ...
  dd sector1
    
Post 03 Dec 2007, 23:14
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 03 Dec 2007, 23:14
No, I've done the split with the title I originally suggested except that I added "operator" on it. Tomasz (or perhaps someone else but in such case would not be officially released) has to implement it.

About PLT, check it yourself http://flatassembler.net/docs.php?article=manual#2.4.4

And what I mean by operator is that in the same way you can do "relativeAddress dd RVA someLabel" also be able to do "fileAddress dd FO someLabel". I would have the same ways of using it as RVA, but instead of retrieving the virtual address it would give you the file offset (or error if cannot be retrieved).
Post 03 Dec 2007, 23:14
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 03 Dec 2007, 23:28
vid, I think he wants this:
Code:
; Source starts here
fileOffset dd FO l1

include 'somethingThatDoesLotsOfKnownOrgs.inc'

l1:    


And if the number of bytes between the source beginning and l1 is 84, then fileOffset content will be 84.
Post 03 Dec 2007, 23:28
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4354
Location: Now
edfed 03 Dec 2007, 23:39
it is exactlly what i want, and as FO is the initial for a frensh politic team, i agree with FO for this offset calculation.
Code:
FO==absolute file offset ....... OK for me
    

Force Ouvriere
Travailleurs, Travailleuses .... votez pour moi! pffff mort de rire! Wink
Post 03 Dec 2007, 23:39
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.