From the course: Learning Assembly Language

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Executing assembler in Python

Executing assembler in Python - Python Tutorial

From the course: Learning Assembly Language

Start my 1-month free trial

Executing assembler in Python

- [Instructor] Using assembler with Python is more complicated than using it with C because Python is a scripted language that runs as byte code, not machine code, however it is possible. And we'll tell look because it demonstrates some interesting techniques. The folks at ActiveState provide a novel approach which calls out to nasm and does a compile on the fly. There's a couple of issues we need to fix in order to run it. So let's take a look at this. There's a lot of code. So I've prepared this for us to go through. It's quite involved. So if you want to really understand it, you'll need to read up on the details provided by the ActiveState team. We start by importing the libraries we'll need and defining our memory page size. At line eight, we define a class called AssemblerFunction with a standard init method. At line 13, the initialization writes the assembly code into a temporary file called source. Then at…

Contents