I want to convert a simple print(“Hello, World!”)
code into the assembly language. I read a post, which showed that you can try to convert it to C++, and then to assembly, but that doesn’t work. Can someone help me covert Python3 to Assembly language(or to C++)?

- 175,061
- 34
- 275
- 318
-
I use macOS 10.15 – Vladimir Moskalenko Apr 13 '22 at 02:43
-
1Are you asking how to convert Python programs in general into asm, or just how to do Hello World in assembly on MacOS? (x86-64 or AArch64?) Are you looking for a tool to do this, or do you just want an example of hand-written asm so you can start learning asm? – Peter Cordes Apr 13 '22 at 02:48
-
Do you actually mean that you want to write assembly that calls into the Python interpreter in the same way as an embedded-in-C++ Python would, or do you just want a program that prints "Hello, World!"? – molbdnilo Apr 13 '22 at 07:30
1 Answers
Here is a Stackoverflow thread that asks a similar questions (at least how to get Python to C) and has a few links to different projects that should do just that: Writing code translator from Python to C?
Also here is another project called PyPy that seems to be a replacement and faster version of CPython mentioned in the thread linked above: https://www.pypy.org/index.html
Hopefully one of these can help you out with what you're trying to do. In general though, if you need something compiled to Assembly Code you would be best off to just write it in C. The problem with Python is that it compiles to bytecode which is then ran by an interpreter. So at no point is it assembly. C however is compiled directly to assembly so it would give you exactly what you want. By trying to go from Python to assembly you're just adding an extra middle man (which is one of these projects I've linked) that has a potential to mess up, have a bug, etc. All that being said, hopefully one of these options is able to work out for you and get the jobs done! Have a great one and good luck!

- 129
- 6