1. Computing & Technology

Discuss in my forum

David Bolton

Something a Bit Different - AsmJit

By , About.com GuideApril 19, 2009

Follow me on:

Having spent several years working in assembly language, I find my life is not in the slightest troubled by me not programming in it anymore. CISC (Complex Instruction Set Computer) CPUs are not the easiest to write highly optimized code by hand. Compilers do a pretty good job of code generation these days.

But sometimes you just have to do it or you want to. Asmjit is a decent looking cross-platform assembler (MIT License so anything goes!) written in C++ that lets you write assembler code in C++. I.e it uses an instance of a class called Assembler so you get code like

Assembler a;
  a.push(ebp) ;
  a.mov(ebp, esp) ;
  a.push(esi) ;
  a.push(edi) ;
  Label L_Exit;

  a.mov(eax, dword_ptr(esi)) ;
  a.mov(dword_ptr(edi), eax) ;
  a.jz(&L_Exit) ;

Which is quite ingenious! It has libraries for x86 and x64 bit CPUs as well. There's also a Compiler class that lets you develop cross-platform assembler code without worrying about function calling conventions and register allocation.

Comments
No comments yet.  Leave a Comment
Leave a Comment

Line and paragraph breaks are automatic. Some HTML allowed: <a href="" title="">, <b>, <i>, <strike>

©2012 About.com. All rights reserved.

A part of The New York Times Company.