translating Python to Assembler

ajaksu ajaksu at gmail.com
Sun Jan 27 17:58:23 EST 2008


This message got huge :/

Sorry for being so cryptic and unhelpful. I now believe that you're
incurring in a (quite deep) misunderstanding and wish to make things
clear for both of us :)

On Jan 27, 6:58 am, o... at thepond.com wrote:
> On Fri, 25 Jan 2008 17:44:07 -0800 (PST), ajaksu <aja... at gmail.com>
> wrote:
>
>
>
> >On Jan 25, 11:36 pm, ajaksu <aja... at gmail.com> wrote:
> >> On Jan 25, 11:10 pm, o... at thepond.com wrote:
> >[...]
>
> >Gaah, is this what's going on?
>
> >ajaksu at Belkar:~$ cat error.txt
> >This is not assembler...
>
> >ajaksu at Belkar:~$ ndisasm error.txt
> >00000000  54                push sp
> >00000001  686973            push word 0x7369
> >00000004  206973            and [bx+di+0x73],ch
> >00000007  206E6F            and [bp+0x6f],ch
> >0000000A  7420              jz 0x2c
> >0000000C  61                popa
> >0000000D  7373              jnc 0x82
> >0000000F  656D              gs insw
> >00000011  626C65            bound bp,[si+0x65]
> >00000014  722E              jc 0x44
> >00000016  2E                db 0x2E
> >00000017  2E                db 0x2E
> >00000018  0A                db 0x0A
>
> >:/
>
> not sure what you're saying. Sure looks like assembler to me. Take the
> '54   push sp'. The 54 is an assembler opcode for push and the sp is
> the stack pointer, on which it is operating.

What I did above was:
1- create a file called "error.txt" that contains the string "This is
not assembler..."
2- show the contents of the file ("cat" being the relevant command)
3- run the NetWideDisassembler (ndisasm) on error.txt
4- watch as it "disassembled" the text file (in fact, "assembling" the
code above reconstructs part of the string!)
5-  conclude that you were misguided by this behavior of
disassemblers, for AFAIK .pyc files contain Python
"opcodes" (bytecode), that in no way I can think of could be parsed by
a generic disassembler
6- form a belief that you were trying to understand meaningless
"assembler" like the above (that would have no bearing on what Python
does!)

Now, it seems that we're in flaming mode and that is unfortunate,
because I do believe in your expertise. In part, because my father was
a systems analyst for IBM mainframes and knows (a huge) lot about
informatics. However, I've seen him, due to simple misunderstandings
like this, building a complex scenario to explain his troubles with
MSWord. I believe this is what's happening here, so I suggest that we
take a step back and stop calling names.

Given that you're in the uncomfortable place of the "troll assigned by
votes" outsider in this issue, let me expose some relevant data. The
people you're pissed off with (and vice-versa) are very competent and
knowledgeable Python (and other languages) programmers, very kind to
newcomers and notably helpful (as you might find out lurking in this
newsgroup or reading the archives). They spend time and energy helping
people to solve problems and understand the language. Seriously, they
know about assembler (a lot more than I do) and how Python works. And
they know and respect each other.

Now, your attitude and faith in your own assumptions (of which,
"the .pyc contains assembler" in special) was both rude and upsetting.
This doesn't mean that you're not an assembler expert (I believe you
are). But it seemed like you were trying to teach us how Python works,
and that was considered offensive, specially due to your words.

OTOH, my responses were cryptic, unhelpful and smell of "mob
thinking". While Steven D'Aprano and others showed a lot more of
patience and willingness to help. So please forgive me and please PAY
ATTENTION to those trying to HELP and make things clearer to you.

As a simple example of my own e Dunning-Kruger effect, I was sure I'd
get errors on trying to "assemble" the output of the disassembling,
but it does roundtrip part of the string and I was baffled. I'd guess
you know why, I have no idea. The 0x74 finding was also curious, you
are indeed getting part of the binary format of bytecode, but (AFAICT)
you won't find real assembler there.

In summary, you can show us what you know and put your knowledge
(instead of what you got wrong and how you upset people) in focus. Try
to set things right. Believe me, this here community packs an uncommon
amount of greatness and openness.

HTH,
Daniel



More information about the Python-list mailing list