Oxygen Basic
Programming => Bugs & Feature Requests => Topic started by: Emil_halim on April 11, 2013, 09:38:27 AM
-
Hi Charles'
does Oxygen basic has something like 'incBin' include binary that will load a file and put it with exe file while
compilation , giving the user the start address of memory containing the file and the length?
-
Yes you can use embedfile to embed any kind of file (within the includepath spec)
Supposing you had a file: t.txt containing ABC
sys p
embedfile "t.txt",p
byte b at p
print b[3] '67
I haven't got a formal parameter for length but, since it is stored as a pseudo-bstring, you can recover the length like this:
dword le at (p-4)
print le '3
-
Ok , thanks Charles,
for the length , i have an idea .
can we put a label before and after embedfile instruction , then we can subtract this label to get the length.
so what do you think?
-
Embedded data is stored in dataspace, which is curently unlabelled. All refernces are assigned to pointer variables (also string variables)
PS: Just realised you can also refer to embedded data as a bstring constant
bstring p
embedfile "t.txt",p
print p
print len p
-
Charles ..
I never ask about this but this looks to me like command bind
so do i can bind any file to already created exe ?
-
The bind keyword is used for low level linkage to DLLs. EmbedFile is more like embedding resources.
-
Hi Charles,
what about Bin file that may contains many text terminator char.
does the len get it correctly?
-
Yes, it stores the whole file content as a binary string of specified byte count.
-
so deos len get the correct length?
-
Yes, if you map a bstring onto the data
sys p
embedfile "t.something",p
bstring s at p
print len s
You can also map any type or structure to p at the same time
byte b at p
image img at p
or at any offset of p
rgba pixel at (p+256)
print pixel[10].blue
-
that's great Charles.
one more thing , Sphinx C-- also support including a specific part of the file as well.
what do you think?
-
Could add offset and length as optional parameters. Does Sphinx do it this way?
-
No , it is only include the needed part of the file.
something like this
sys p
embedfile "t.something",p , optional offset ,optional len