I decided to dive into the world of programming. I have been using MEL (Autodesk Maya scripting language) and Python as a scripting language recently. So I liked the idea of programming. So I decided to start exploring python and learn it a bit more in depth.
However, I have an old obsession that has been around since the day I got my first computer in the beginning of the 90's and it is "Assembly". Back in those days i did not have an internet connection or any of the remote resources to extend my knowledge so I ended up banging my head on the monitor of my 80286 PC and eventually give it up and grow up :)
As I started to build my Python dev environment on my Mac, I realised that Assembler is still around (not surprised) and that even it exist almost as a default programming tool under OSX, as NASM. Anyway... it it still complicated and ofcourse very low level. But still... if compiling Python code means:
Python -> C++ -> Assembler -> Machine code
Is it possible to see how that Assembler code looks like?
Will something like:
print "Hello world!"
Look like:
section .text ;section declaration ;we must export the entry point to the ELF linker or global _start ;loader. They conventionally recognize _start as their ;entry point. Use ld -e foo to override the default. _start: ;write our string to stdout mov edx,len ;third argument: message length mov ecx,msg ;second argument: pointer to message to write mov ebx,1 ;first argument: file handle (stdout) mov eax,4 ;system call number (sys_write) int 0x80 ;call kernel ;and exit mov ebx,0 ;first syscall argument: exit code mov eax,1 ;system call number (sys_exit) int 0x80 ;call kernel section .data ;section declaration msg db "Hello, world!",0xa ;our dear string len equ $ - msg ;length of our dear string
Thanks.
Edited by Symbolix, 10 May 2010 - 07:51 AM.


Sign In
Create Account

Back to top









