2009-03-29 07:30:54 +00:00
|
|
|
# This file is part of Metasm, the Ruby assembly manipulation suite
|
2010-09-09 18:19:35 +00:00
|
|
|
# Copyright (C) 2006-2009 Yoann GUILLOT
|
2009-03-29 07:30:54 +00:00
|
|
|
#
|
|
|
|
# Licence is LGPL, see LICENCE in the top-level directory
|
|
|
|
|
|
|
|
#
|
|
|
|
# here we build a simple a.out executable
|
|
|
|
#
|
|
|
|
|
|
|
|
require 'metasm'
|
|
|
|
|
|
|
|
Metasm::AOut.assemble(Metasm::Ia32.new, <<EOS).encode_file('m-a.out')
|
|
|
|
.text
|
|
|
|
.entrypoint
|
|
|
|
mov eax, 4
|
|
|
|
mov ebx, 1
|
|
|
|
|
|
|
|
.data
|
|
|
|
str db "kikoo\\n"
|
|
|
|
strend:
|
|
|
|
|
|
|
|
.text
|
|
|
|
mov ecx, str
|
|
|
|
mov edx, strend - str
|
|
|
|
int 80h // linux sys_write
|
|
|
|
|
|
|
|
mov eax, 1
|
|
|
|
mov ebx, 42
|
|
|
|
int 80h // linux sys_exit
|
|
|
|
ret
|
|
|
|
EOS
|