Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Mac > Mac Programmer Help > ****ting an ass...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 1 Topic 3701 of 3799
Post > Topic >>

****ting an assembly ITC forth (lina) to intel OS X

by robert.spykerman@[EMAIL PROTECTED] Apr 9, 2008 at 02:27 PM

Dear All,

I have just embarked upon a hobby project of ****ting a forth to OS X.
As far as I know forth options for the current intel form of the OS
are fairly limited, you can rosetta carbon MacForth and MOPS and some
people have managed to build gforth with varying degrees of success
on  platforms up to OS X 10.4 (I am actually unaware of anyone
successfully building gforth on leopard).

This so I have decided to try and ****t A van der Horst's small,
elegant and excellent forth.

http://home.hccnet.nl/a.w.m.van.der.horst/lina.html

Which resides in one single IA-32 asm file :) and builds a nice linux
elf binary.

****ting it to FreeBSD I figure is not so much of a problem as most
BSD's do elf as far as I know. Just a matter of changing the syscalls
appropriately.

The main snags I am having at the moment are:

1. OS X requires mach-o binaries exclusively. I have not figured out a
way yet to trick the assembler (in this case the apple xcode nasm
0.98) and the linker to produce an acceptable executable. This is
mainly because I am fairly new both to *nix programming and I do not
understand mach-o binaries very well. Or ELF's fully for that matter.

Why is this im****tant? It's because of the requirements of the
dictionary and SAVE-SYSTEM. I can't just put everything in a
section .text. It will be clear as you read on.

Unless someone here knows how to trick OS X into running ELF's... As
Albert's got a workaround for this

 2. Rerouting the syscalls to the appropriate vectors. I have already
embarked upon this, have fixed most of them, as well as patched the
calling convention but have yet to find equivalents for a couple of
them. Fortunately, the forth code I am ****ting is  easy to read and
clear where the calls are made.

3. Ultimately I will need to try and write a SAVE-SYSTEM. This implies
understanding how a program of this nature resides in memory, ie where
it is appropriate for me to site my dictionary and watch it grow and
then save the thing back into an executable binary.

4. I expect down the line, calling external libraries will be in order
but if I could solve the first 3 it would be already a major
accomplishment.

I guess the major goal of this is to produce an OS X ****t that is as
close as possible to Albert's original Linux source and after that,
it's up to whatever anyone else wants to do then. Go 64 bits, call
cocoa/whatever, bootstrap a native code compiler... whatever :)

I have some pretty rough code and a somewhat unstable binary already
running. (I was guessing how the ELF was being built and tried to
simulate it with what little I know about mach-o's).

I have decided to try and learn how to cvs stuff so:

http://xina.cvs.sourceforge.net

Albert's original linux source is there too.  (GPL)

For those who just want to see my source, go to the src dir. There's
also a binary there 'xina' which you can mess with. It does a lot
already but SAVE-SYSTEM clearly does not work. Most of the syscalls
have been remapped but I have yet to find equivalents for some of
them. And my memory map appears to be clearly quite fubar. While it
will add to the dictionary: defining words and like appear to work I
cannot guarantee stability.

Been only working on this for 2-3 days when I am not at work so excuse
the mess :) I've still got to figure out how to cvs everything nicely,
and tidy up the comments in the source, but it should be fairly clear
when you read it what I'm after doing to it.

Again, while I do know some assembler and forth, I am fairly new to
*nix's in general, so please assume you're talking to nub, especially
when it's regarding anything *nixish. Assume I know very little and
you will be fairly close to the truth :)

You may also want to follow the OS X Leopard thread on
comp.lang.forth.

Please send all hints, criticisms etc to me, here, on clf or to my
gmail as above.

Basically if someone could take a look at the current source and
advise me on how to section it out properly so that I can build a
proper mach-o binary, that's the first step. Thanks very much.

Robert Spykerman
 




 1 Posts in Topic:
porting an assembly ITC forth (lina) to intel OS X
robert.spykerman@[EMAIL P  2008-04-09 14:27:43 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Jul 9 5:55:08 CDT 2008.