generating executables

R

rod

hi, i posted this question in alt.perl a week or two ago but no
response, wonder if anyone here can help...
i have written a compiler in perl (for my shit language, it's just for
fun) and i have been outputting pseudo assembler instructions to a text
file which i can then run on my own lil virtual machine (just things
like LDA, ADD, etc... simple simple)
that all works fine, but i was wondering how one would go about creating
real executables? can you do this from perl? does anyone have any
pointers to resources that would help? anything would be great.

thanx.
rod.
 
X

Xaonon

rod <[email protected]> said:
that all works fine, but i was wondering how one would go about creating
real executables? can you do this from perl? does anyone have any
pointers to resources that would help? anything would be great.

Try "man perlcompile".
 
R

rod

ok i looked at that and i know about perlcc and other ways of compiling
perl into executables, but that's not what i mean. forgive me here if
i've missed the point of ur reply, i'm sorry. what i want to do is
write my own executables not for my perl source but for the language i'm
parsing (a language i made up). am i making sense? can the B and O
modules help me with this or did i not make myself that clear in my
first post.

thanx anyway.
rod.
 
J

Jürgen Exner

rod said:
hi, i posted this question in alt.perl a week or two ago but no
response, wonder if anyone here can help...
i have written a compiler in perl (for my shit language, it's just for
fun) and i have been outputting pseudo assembler instructions to a
text file which i can then run on my own lil virtual machine (just
things like LDA, ADD, etc... simple simple)
that all works fine, but i was wondering how one would go about
creating real executables? can you do this from perl? does anyone
have any pointers to resources that would help? anything would be
great.

This really has little to do with Perl but much more with how compilers and
interpreters work.
What you have right now is a compiler from your toy language into your toy
assembler (no offence intended). And then you got an interpreter for your
toy assembler (your lil virtual machine).

What you need is a true compiler or assembler, which can translate your toy
assembler code into the actual machine instructions suitable for your
hardware (plus the integration pieces for the OS).

Of course this compiler can be implemented in Perl, just like in pretty much
any other language.
Another and probably easier option would be to bundle the toy interpreter
with the assembler code into a self-executable package, such that the OS
would start the interpreter which in turn would automatically begin
executing the bundled piece of toy assembler code.

jue
 
X

Xaonon

Try "man perlcompile".

ok i looked at that and i know about perlcc and other ways of compiling
perl into executables, but that's not what i mean. forgive me here if
i've missed the point of ur reply, i'm sorry. what i want to do is write
my own executables not for my perl source but for the language i'm
parsing (a language i made up).[/QUOTE]

Whoops, I misunderstood you. Sorry, I don't know much about that. You
could try modifying your compiler to generate real assembly code and put
that through an assembler like as, or just leave it as interpreted code.

Just out of curiosity, could we see a short sample of what your language
looks like? If it's similar enough to an already existing compiled
langauge, maybe you could write your Perl compiler to translate it into that
language and compile with already existing tools.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top