#NEWLINE# def assemble( str ) : #NEWLINE# #INDENT# 'Play test' #NEWLINE# shellcode = MultipleInstr ( ) #NEWLINE# for instr in split_in_instruction ( str ) : #NEWLINE# #INDENT# data = instr . split ( ' ' , 1 ) #NEWLINE# ( mnemo , args_raw ) = ( data [ 0 ] , data [ 1 : ] ) #NEWLINE# try : #NEWLINE# #INDENT# instr_object = globals ( ) [ mnemo . capitalize ( ) ] #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# raise ValueError ( 'Unknow mnemonic <{0}>' . format ( mnemo ) ) #NEWLINE# #UNINDENT# args = [ ] #NEWLINE# if mnemo : #NEWLINE# #INDENT# for arg in args_raw [ 0 ] . split ( ',' ) : #NEWLINE# #INDENT# arg = arg . strip ( ) #NEWLINE# if ( ( ( arg [ 0 ] == '[' ) or ( arg [ 2 : 4 ] == ':[' ) ) and ( arg [ ( - 1 ) ] == ']' ) ) : #NEWLINE# #INDENT# print ( 'MEM' ) #NEWLINE# arg = mem ( arg ) #NEWLINE# #UNINDENT# args . append ( arg ) #NEWLINE# #UNINDENT# #UNINDENT# shellcode += instr_object ( * args ) #NEWLINE# #UNINDENT# return shellcode . get_code ( )