Re: writing a function to parse assembly using dynasm

  • From: Amir Ramezani <amir.ramezani1370@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Wed, 11 Mar 2015 18:17:07 +0330

so, what do you recommend me to parse assembly?

۱۳۹۳-۱۲-۲۰ ۵:۳۶ GMT+۰۳:۳۰, zejian ju <juzejian@xxxxxxxxx>:
> DynASM is a C preprocessor which parses assembly in C source file C1 and
> generates another C source file C2. C2 can be used to generate machine code
> corresponding to the original assembly code in C1. So DynASM is wonderful
> to manipulate assembly code programatically (in C), but not suitable for a
> general-purpose assembler.
>
> 2015-03-10 23:31 GMT+08:00 Amir Ramezani <amir.ramezani1370@xxxxxxxxx>:
>
>> thanks, if i want to create an assembler for my application, i must
>> another assembler like yasm!, dynasm is just for parsing assembly in c
>> Sources!
>> thanks all
>>
>> ۱۳۹۳-۱۲-۱۹ ۱۸:۴۱ GMT+۰۳:۳۰, Peter Cawley <corsix@xxxxxxxxxx>:
>> > If you want to turn a plain assembly file (say foo.asm) into machine
>> > code (say foo.dat) using dynasm, then the process is:
>> > 1. Use the dynasm preprocessor (dynasm.lua) to turn foo.asm into
>> > foo.inc
>> > 2. Write a one-off C program foo.c which #includes the dynasm runtime
>> > component, #includes foo.inc, and contains code to: initialise the
>> > dynasm runtime component, feed the data in foo.inc through the dynasm
>> > runtime component, and write the resulting byte array to foo.dat.
>> > 3. Use a C compiler to compile foo.c to foo.exe
>> > 4. Run foo.exe, therein producing foo.dat
>> >
>> > This is a slightly contrived process, but dynasm isn't designed for
>> > turning plain assembly files into plain machine code files; it's
>> > designed for turning C files containing assembly containing C
>> > expressions into plain C files which can emit and combine fragments of
>> > machine code at runtime.
>> >
>> > On Tue, Mar 10, 2015 at 2:56 PM, Amir Ramezani
>> > <amir.ramezani1370@xxxxxxxxx> wrote:
>> >> ok, what way do you recommend?
>> >> what do i need to do in order for my assembler to work?
>> >> can you provide me with a minimal example?
>> >>
>> >> ۱۳۹۳-۱۲-۱۹ ۱۷:۵۴ GMT+۰۳:۳۰, Peter Cawley <corsix@xxxxxxxxxx>:
>> >>> Dynasm comes in two halves: the Lua preprocessor half, and the C
>> >>> runtime part. The Lua preprocessor half does the assembly parsing,
>> >>> whereas you seem to be looking for some way of assembly parsing at C
>> >>> runtime. In short, you're not going to find it (unless you spin up a
>> >>> Lua VM to run the Lua half of dynasm, or use something totally
>> >>> separate to dynasm).
>> >>>
>> >>> On Tue, Mar 10, 2015 at 2:08 PM, Amir Ramezani
>> >>> <amir.ramezani1370@xxxxxxxxx> wrote:
>> >>>> hi all,
>> >>>> i've read the dynasm tutorial, and i'm intrested in parsing the
>> >>>> asmbly
>> >>>> with dynasm
>> >>>> how can i write a function that take's a string as a parameter and
>> >>>> parse's the string in assembly?
>> >>>> the function prototype must be like this i'm thinking:
>> >>>> void parse_asm(char* asmcode);
>> >>>> please provide me with the instruction that how can i implement the
>> >>>> parser in this function?
>> >>>> thanks in advance
>> >>>>
>> >>>
>> >>>
>> >>
>> >
>> >
>>
>>
>

Other related posts: