Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python

can i write a assemly language programs in python

 

 

Python python RSS feed   Index | Next | Previous | View Threaded


reddy.mrp at gmail

Jul 9, 2009, 12:17 AM

Post #1 of 12 (244 views)
Permalink
can i write a assemly language programs in python

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


gagsl-py2 at yahoo

Jul 9, 2009, 2:03 AM

Post #2 of 12 (236 views)
Permalink
Re: can i write a assemly language programs in python [In reply to]

En Thu, 09 Jul 2009 04:17:52 -0300, m.reddy prasad reddy
<reddy.mrp[at]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


tkermode at gmail

Jul 9, 2009, 3:13 AM

Post #3 of 12 (236 views)
Permalink
Re: can i write a assemly language programs in python [In reply to]

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-py2[at]yahoo.com.ar>:
> En Thu, 09 Jul 2009 04:17:52 -0300, m.reddy prasad reddy
> <reddy.mrp[at]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


davea at ieee

Jul 9, 2009, 6:41 AM

Post #4 of 12 (228 views)
Permalink
Re: can i write a assemly language programs in python [In reply to]

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


tjreedy at udel

Jul 9, 2009, 10:40 AM

Post #5 of 12 (224 views)
Permalink
Re: can i write a assemly language programs in python [In reply to]

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


tn.pablo at gmail

Jul 9, 2009, 3:49 PM

Post #6 of 12 (224 views)
Permalink
Re: can i write a assemly language programs in python [In reply to]

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 Reedy<tjreedy[at]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


sajmikins at gmail

Jul 9, 2009, 4:38 PM

Post #7 of 12 (224 views)
Permalink
Re: can i write a assemly language programs in python [In reply to]

On Thu, Jul 9, 2009 at 3:17 AM, m.reddy prasad reddy<reddy.mrp[at]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


bearophileHUGS at lycos

Jul 9, 2009, 4:49 PM

Post #8 of 12 (223 views)
Permalink
Re: can i write a assemly language programs in python [In reply to]

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


davea at ieee

Jul 10, 2009, 4:48 AM

Post #9 of 12 (220 views)
Permalink
Re: can i write a assemly language programs in python [In reply to]

Terry Reedy wrote:
> <div class="moz-text-flowed" style="font-family: -moz-fixed">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
>
>
> </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


python.list at tim

Jul 10, 2009, 5:37 AM

Post #10 of 12 (220 views)
Permalink
Re: can i write a assemly language programs in python [In reply to]

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


thudfoo at opensuse

Jul 10, 2009, 10:24 AM

Post #11 of 12 (213 views)
Permalink
Re: can i write a assemly language programs in python [In reply to]

On Fri, Jul 10, 2009 at 5:37 AM, Tim Chase<python.list[at]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


tjreedy at udel

Jul 10, 2009, 1:32 PM

Post #12 of 12 (213 views)
Permalink
Re: can i write a assemly language programs in python [In reply to]

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

Python python RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.