Re: can i write a assemly language programs in python

2009-07-10 Thread Dave Angel

Terry Reedy wrote:
div class=moz-text-flowed style=font-family: -moz-fixedDave 
Angel wrote:

m.reddy prasad reddy wrote:
can any one tell me how to write assembly language programs in 
python...if

no is there any other way to write the programs in python

Reddi prasad reddy
ph.no:09958083797

  
Assembly language is a different programming language than Python.  
You can use both in the same process, much in the same way you can 
use C or C++ with Python.  In fact, some of the system DLL's are 
written (partly) in assembler, though mostly in C or C++.


It is possible that he meant how to write assembly *with* python.
Or how to translate python to assembly.

As it turns out, CPython translates Python to byte code and has a dis 
(assembly) module that produces very nice assembly code ;-)

So that is one answer to his question.


You'll need to tell us what your real goal is.


Definitely.

tjr


/div

If you mean dis.dis() that only gives you byte code.  I assumed he was 
referring to native code assembly.


I guess I'd better stop guessing grin.

DaveA

--
http://mail.python.org/mailman/listinfo/python-list


Re: can i write a assemly language programs in python

2009-07-10 Thread Tim Chase

m.reddy prasad reddy wrote:

can any one tell me how to write assembly language programs in python...if
no is there any other way to write the programs in python


Bah, writing assembly language is easy in Python:

  print(MOV EAX, [EBX])
  print(XOR EBX, EBX)

Just adjust the strings for your favorite processor architecture 
and Python will produce the assembly code you want.


Now compiling assembly to *machine* code...or calling between 
Python and assembly...that's another matter.  But writing 
assembly language programs in Python?  Easy. ;-)


-tkc



--
http://mail.python.org/mailman/listinfo/python-list


Re: can i write a assemly language programs in python

2009-07-10 Thread member thudfoo
On Fri, Jul 10, 2009 at 5:37 AM, Tim Chasepython.l...@tim.thechases.com wrote:
 m.reddy prasad reddy wrote:

 can any one tell me how to write assembly language programs in python...if
 no is there any other way to write the programs in python

 Bah, writing assembly language is easy in Python:

  print(MOV EAX, [EBX])
  print(XOR EBX, EBX)

 Just adjust the strings for your favorite processor architecture and Python
 will produce the assembly code you want.

 Now compiling assembly to *machine* code...or calling between Python and
 assembly...that's another matter.  But writing assembly language programs in
 Python?  Easy. ;-)


PyASM is a full-featured dynamic assembler written entirely in
Python. By dynamic, I mean that it can be used to generate and execute
machine code in python at runtime without requiring the generation of
object files and linkage. It essentially allow 'inline' assembly in
python modules on x86 platforms.

PyASM can also generate object files (for windows) like a traditional
standalone assembler, although you're probably better off using one of
the many freely available assemblers if this is you primary goal.

http://members.verizon.net/~olsongt/usersGuide.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: can i write a assemly language programs in python

2009-07-10 Thread Terry Reedy

Dave Angel wrote:

Terry Reedy wrote:



If you mean dis.dis() that only gives you byte code.


No, dis is a disassembler and it gives readable assembly code, not the 
raw numerical bytes. Its purpose is to make byte code + other parts of 
the code object humanly readable.


As far as I know, there is no assembler that would turn the exact output 
of dis back to its input.


tjr

--
http://mail.python.org/mailman/listinfo/python-list


can i write a assemly language programs in python

2009-07-09 Thread m.reddy prasad reddy
can any one tell me how to write assembly language programs in python...if
no is there any other way to write the programs in python

Reddi prasad reddy
ph.no:09958083797
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: can i write a assemly language programs in python

2009-07-09 Thread Gabriel Genellina
En Thu, 09 Jul 2009 04:17:52 -0300, m.reddy prasad reddy  
reddy@gmail.com escribió:


can any one tell me how to write assembly language programs in  
python...if

no is there any other way to write the programs in python


You write Python programs using Python, not assembly.

Perhaps if you provide more info on what you want to do, someone can  
suggest a different way...


--
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list


Re: can i write a assemly language programs in python

2009-07-09 Thread Tom Kermode
I wonder if the OP is trying to find out whether python programmes can
be compiled and run as stand alone executables.

(I know assembly and machine code are not the same, but it might be
what they're after.)

On windows you can use http://www.py2exe.org/ to bundle python
programs into stand alone executables. They're not compiled, but your
code and all the modules it relies on are brought together, meaning
you can deliver a single exe than can be run like any other windows
program.

Maybe that helps...

2009/7/9 Gabriel Genellina gagsl-...@yahoo.com.ar:
 En Thu, 09 Jul 2009 04:17:52 -0300, m.reddy prasad reddy
 reddy@gmail.com escribió:

 can any one tell me how to write assembly language programs in python...if
 no is there any other way to write the programs in python

 You write Python programs using Python, not assembly.

 Perhaps if you provide more info on what you want to do, someone can suggest
 a different way...

 --
 Gabriel Genellina

 --
 http://mail.python.org/mailman/listinfo/python-list




-- 
http://www.kiloday.com
http://www.fourstopspast.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: can i write a assemly language programs in python

2009-07-09 Thread Dave Angel

m.reddy prasad reddy wrote:

can any one tell me how to write assembly language programs in python...if
no is there any other way to write the programs in python

Reddi prasad reddy
ph.no:09958083797

  
Assembly language is a different programming language than Python.  You 
can use both in the same process, much in the same way you can use C or 
C++ with Python.  In fact, some of the system DLL's are written (partly) 
in assembler, though mostly in C or C++.


You'll need to tell us what your real goal is.  Are you a python 
programmer trying to optimize some loop?  Are you taking a course in 
assembler, and hope that somehow Python will help?  Do you have Python 
installed on your system?  What system is it?


As far as I know, Python has no inline assembler mode, as C does.   So 
anything written in assembler would be in a separate DLL, not mixed in 
your .py files.  It's not hard to mix assembly files with C or C++ files 
(or Pascal, or dozens of other compiled languages), and link them into a 
single DLL.  But Python's access to that DLL will be done through a 
module like ctypes, or SWIG.



DaveA
--
http://mail.python.org/mailman/listinfo/python-list


Re: can i write a assemly language programs in python

2009-07-09 Thread Terry Reedy

Dave Angel wrote:

m.reddy prasad reddy wrote:
can any one tell me how to write assembly language programs in 
python...if

no is there any other way to write the programs in python

Reddi prasad reddy
ph.no:09958083797

  
Assembly language is a different programming language than Python.  You 
can use both in the same process, much in the same way you can use C or 
C++ with Python.  In fact, some of the system DLL's are written (partly) 
in assembler, though mostly in C or C++.


It is possible that he meant how to write assembly *with* python.
Or how to translate python to assembly.

As it turns out, CPython translates Python to byte code and has a dis 
(assembly) module that produces very nice assembly code ;-)

So that is one answer to his question.


You'll need to tell us what your real goal is.


Definitely.

tjr

--
http://mail.python.org/mailman/listinfo/python-list


Re: can i write a assemly language programs in python

2009-07-09 Thread Pablo Torres N.
Or maybe he meant if you can have both Python and assembler code in
the same source file, but I haven't heard of it.  If what you are
trying to do is write a faster version of some part of your code, try
SWIG: http://www.swig.org/

Playing the guessing game is a time sink, and since nobody has done it
so far, I will: OP, please read
http://www.mikeash.com/getting_answers.html and
http://catb.org/esr/faqs/smart-questions.html

On Thu, Jul 9, 2009 at 12:40, Terry Reedytjre...@udel.edu wrote:
 Dave Angel wrote:

 m.reddy prasad reddy wrote:

 can any one tell me how to write assembly language programs in
 python...if
 no is there any other way to write the programs in python

 Reddi prasad reddy
 ph.no:09958083797



 Assembly language is a different programming language than Python.  You
 can use both in the same process, much in the same way you can use C or C++
 with Python.  In fact, some of the system DLL's are written (partly) in
 assembler, though mostly in C or C++.

 It is possible that he meant how to write assembly *with* python.
 Or how to translate python to assembly.

 As it turns out, CPython translates Python to byte code and has a dis
 (assembly) module that produces very nice assembly code ;-)
 So that is one answer to his question.

 You'll need to tell us what your real goal is.

 Definitely.

 tjr

 --
 http://mail.python.org/mailman/listinfo/python-list




-- 
Pablo Torres N.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: can i write a assemly language programs in python

2009-07-09 Thread Simon Forman
On Thu, Jul 9, 2009 at 3:17 AM, m.reddy prasad reddyreddy@gmail.com wrote:

 can any one tell me how to write assembly language programs in python...if
 no is there any other way to write the programs in python

 Reddi prasad reddy
 ph.no:09958083797

 --
 http://mail.python.org/mailman/listinfo/python-list



Examine CorePy http://www.corepy.org

CorePy is a complete system for developing machine-level programs in
Python. CorePy lets developers build and execute assembly-level
programs interactively from the Python command prompt, embed them
directly in Python applications, or export them to standard assembly
languages.

HTH,
~Simon
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: can i write a assemly language programs in python

2009-07-09 Thread Bearophile
Simon Forman:
 Examine CorePyhttp://www.corepy.org

 CorePy is a complete system for developing machine-level programs in
 Python. CorePy lets developers build and execute assembly-level
 programs interactively from the Python command prompt, embed them
 directly in Python applications, or export them to standard assembly
 languages.

I have never used CorePy yet, but it's an awesome project ^_^
With some care and work even Python programs can get fast enough :-)

Bye,
bearophile
-- 
http://mail.python.org/mailman/listinfo/python-list