scopium45
March 12th, 2005, 08:03 PM
does anyone know how to convert c code to assembly code?
i really need this
thanks
sean
i really need this
thanks
sean
|
Click to See Complete Forum and Search --> : converting c code to assembly code scopium45 March 12th, 2005, 08:03 PM does anyone know how to convert c code to assembly code? i really need this thanks sean NoHero March 13th, 2005, 06:07 AM does anyone know how to convert c code to assembly code? i really need this thanks sean Well ... this is one of the most difficult parts of writing a compiler. You must have a good sense of programming with assembler and C. You can disassembler compiled programs to look how other compilers does this job, or you can take a look at the open source compilers such as the gcc. But I can give you an example: // 32bit code int foo ( int x, int x ) { return (x + y); } Should result in: foo: push ebp mov ebp, esp ; Return value expected in EAX mov eax, [ebp+8] ; First parameter add eax, [ebp+12] ; Second one pop ebp ret ; Somtimes it is also retf (return far) Hobson March 13th, 2005, 12:04 PM Most of compilers has option 'generate assembler source'. When you enable it and compile your files, assembly source files will be generated. However, they contain a lot of extra data, like debug info etc, and are hard to read (huh, sounds like assembler is easy to read sometimes :) ) barrensoul March 13th, 2005, 12:28 PM some ASM is easy to read :) it's rather nice being able to put ASM inside the code for C++ or C for GFX programs in certain parts :) (if you look at the source code for the build engine ken silverman put some of the more intensive GFX parts in pure ASM) NoHero March 13th, 2005, 12:42 PM (huh, sounds like assembler is easy to read sometimes :) ) It's easy if you are a trained ASM reader. :) Hobson March 13th, 2005, 02:40 PM I mean that it is not hard to read three letters long mnemonics and not so much longer arguments, which is like ~10 characters per line. But understand a story which is hidden behind those sentences is lotta harder :) NoHero March 13th, 2005, 03:35 PM I mean that it is not hard to read three letters long mnemonics and not so much longer arguments, which is like ~10 characters per line. But understand a story which is hidden behind those sentences is lotta harder :) Practice makes perfect :cool: Also very difficult: Writing something heavy in Assembler (like DistributionSort) and then try to read it months ago, and try to make changes in it :sick:. codeguru.com
Copyright WebMediaBrands Inc., All Rights Reserved. |