Find file
Fetching contributors…
Cannot retrieve contributors at this time
87 lines (80 sloc) 3.33 KB
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "">
<html xmlns="" xml:lang="en" lang="en">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></meta>
<title>Erasm++ - erasm</title>
<link rel="stylesheet" type="text/css" href="./css/default.css"></link>
<link rel="stylesheet" type="text/css" href="./css/syntax.css"></link>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-29123087-1']);
_gaq.push(['_setDomainName', '']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
<div id="main">
<div id="sidebar">
<div id="header">
<h1>Erasm++ </h1>
<!-- <h2>Navigation</h2> -->
<a href="./">About</a>
<li> <a href="./erasm.html">ERASM++</a> </li>
<li> <a href="./gendsm.html">GenericDsm</a> </li>
<li> <a href="./meta_prelude.html">MetaPrelude</a> </li>
<a href="./download.html">Download/Install</a>
<a href="./manual/manual.html">Online Manual</a>
<a href="./privacy.html">Privacy Policy</a>
<div id="content">
<h1 id="erasm">Erasm++</h1>
<p>ERASM++, the Embedded Runtime Assembler in C++, is an Embedded Domain Specific Language (<a href="">EDSL</a>) in C++ for runtime code generation on Intel 64/IA-32 architectures. The code looks like the following:</p>
<pre><code>p += adc (p,word_ptr [edx + esi * _2],ax);
p += and_ (p,dword_ptr [rip + 0x1000],r12d);
p += rep_movs (p, [di], [si]);
// Unfortunately, lables are not yet implemented!
p += jmp (p, 0x10);
<p>Although similar runtime assembler libraries already exist, I believe ERASM++ has the following strengths:</p>
<li><p>It is easier to use because the syntax is more natural.</p></li>
<li><p>It is safer to use because the syntactically invalid expressions cause compilation errors, rather than runtime errors or exceptions.</p></li>
<li><p>It is faster because most of the encoding and the error checking are done at compile-time, rather than at runtime.</p></li>
<p>It’s so fast that each encoder function is actually compiled into a series of MOV instructions with no branches and no external references.</p>
<p>Here’s an example: g++ 4.6.1 compiles the following code</p>
<pre><code>extern &quot;C&quot; int code_test(code_ptr p)
{ return adc(p ,cl,byte_ptr [eax+ebp*_4+12345678]); }
sub esp, 32
mov eax, DWORD PTR [esp+36]
mov BYTE PTR [esp+5], -88
mov DWORD PTR [esp+6], 12345678
mov BYTE PTR [esp+4], -116
mov BYTE PTR [eax], 103
mov BYTE PTR [eax+1], 18
mov edx, DWORD PTR [esp+4]
mov DWORD PTR [eax+2], edx
mov edx, DWORD PTR [esp+8]
mov WORD PTR [eax+6], dx
mov eax, 8
add esp, 32