translating Python to Assembler

Bjoern Schliessmann usenet-mail-0306.20.chr0n0ss at spamgourmet.com
Sat Jan 26 08:47:50 EST 2008


over at thepond.com wrote:

> Intel processors can only process machine language[...] There's no
> way for a processor to understand any higher level language, even
> assembler, since it is written with hexadecimal codes and basic
> instructions like MOV, JMP, etc. The assembler compiler can
> convert an assembler file to a binary executable, which the
> processor can understand.

This may be true, but I think it's not bad to assume that machine
language and assembler are "almost the same" in this context, since
the translation between them is non-ambiguous (It's
just "recoding"; this is not the case with HLLs).

> Both Linux and Windows compile down to binary files, which are
> essentially 1's and 0's arranged in codes that are meaningful to
> the processor.

(Not really -- object code files are composed of header data and
different segments, data and code, and only the code segments are
really meaningful to the processor.)

> Once a python py file is compiled into a pyc file, I can
> disassemble it into assembler. 

But you _do_ know that pyc files are Python byte code, and you could
only directly disassemble them to Python byte code directly?

> Assembler is nothing but codes, which are combinations of 1's and
> 0's. 

No, assembly language source is readable text like this (gcc):

.LCFI4:
    movl    $0, %eax
    popl    %ecx
    popl    %ebp
    leal    -4(%ecx), %esp
    ret

Machine language is binary codes, yes.

> You can't read a pyc file in a hex editor, 

By definition, you can read every file in a hex editor ...

> but you can read it in a disassembler. It doesn't make a lot of
> sense to me right now, but if I was trying to trace through it
> with a debugger, the debugger would disassemble it into 
> assembler, not python.

Not at all. Again: It's Python byte code. Try experimenting with
pdb.

Regards,


Björn

-- 
BOFH excuse #340:

Well fix that in the next (upgrade, update, patch release, service
pack).




More information about the Python-list mailing list