From: Anh Hai Trinh on
On Feb 23, 10:08 am, Lawrence D'Oliveiro <l...(a)geek-
central.gen.new_zealand> wrote:
>
> Let me suggest an alternative approach: use Python itself as the assembler.
> Call routines in your library to output the code. That way you have a
> language more powerful than any assembler.
>
> See <http://github.com/ldo/crosscode8> for an example.

SyntaxError: Non-matching "#end if" in crosscode8.py:345
From: Robert Kern on
On 2010-02-22 21:47 PM, Ed Keith wrote:
>> Subject: Re: Writing an assembler in Python
>> Giorgos
>> Tzampanakis wrote:
>>
>>> I'm implementing a CPU that will run on an FPGA. I
>> want to have a
>>> (dead) simple assembler that will generate the machine
>> code for
>>> me.
>>
>> Let me suggest an alternative approach: use Python itself
>> as the assembler.
>> Call routines in your library to output the code. That way
>> you have a
>> language more powerful than any assembler.
>>
>> See<http://github.com/ldo/crosscode8> for
>> an example.
>> --
>> http://mail.python.org/mailman/listinfo/python-list
>>
>
> Not a bad idea, has anyone tried this for x86 machine code?

http://www.corepy.org/

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco

From: Lawrence D'Oliveiro on
In message <da970fce-bd6b-4eb3-bb66-3ca52cc0fd4a(a)k5g2000pra.googlegroups.com>, Anh Hai Trinh wrote:

> On Feb 23, 10:08 am, Lawrence D'Oliveiro <l...(a)geek-central.gen.new_zealand> wrote:
>>
>> Let me suggest an alternative approach: use Python itself as the
>> assembler. Call routines in your library to output the code. That way you
>> have a language more powerful than any assembler.
>>
>> See <http://github.com/ldo/crosscode8> for an example.
>
> SyntaxError: Non-matching "#end if" in crosscode8.py:345

What mismatch? Line 345 is the last line of this routine:

def org(self, addr) :
"""sets the origin for defining subsequent consecutive memory contents."""
self.curpsect.setorigin(self.follow(addr))
self.lastaddr = self.curpsect.origin
return self # for convenient chaining of calls
#end org

From: Albert van der Horst on
In article <Xns9D28186AF890Cfdnbgui7uhu5h8hrnuio(a)127.0.0.1>,
Giorgos Tzampanakis <gt67(a)hw.ac.uk> wrote:
>I'm implementing a CPU that will run on an FPGA. I want to have a
>(dead) simple assembler that will generate the machine code for
>me. I want to use Python for that. Are there any libraries that
>can help me with the parsing of the assembly code?

I have a pentium assembler in perl on my website below.
(postit-fixup principle).
You could borrow some idea's, if you can read perl.
The main purpose is to have a very simple and straightforward
assembler at the expense of ease of use.

Groetjes Albert
--
--
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- being exponential -- ultimately falters.
albert(a)spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst

From: Holger Mueller on
Giorgos Tzampanakis <gt67(a)hw.ac.uk> wrote:
> I'm implementing a CPU that will run on an FPGA. I want to have a
> (dead) simple assembler that will generate the machine code for
> me. I want to use Python for that. Are there any libraries that
> can help me with the parsing of the assembly code?

Why coding assembler if you can type in hexdumps...

scnr
Holger
--
http://www.kati-und-holger.de/holgersblog.php