I needed some help converting this C code into assembly:
Idea is:
sz = length of v
k = allocate array of ints, length v
if type = 0
k[i] = length v[i]
else
k[i] = sum v[i]
sort k the simplest swapping way: each time when k[i] and k[j] is swapped, swap v[i] and v[j] too
d开发者_JAVA百科eallocate k
gcc -O0 -S test.c
(compile to assembler)
This is not a C code, its not even an algorithm just an idea. You can convert your C code to assembly,
But if you're using I/O functions like printf/scanf or memory allocation functions, Its not pure assembly but its dependent on C and OS libraries. So it wont compile on its own.
Write up your C code into a function.
Read your compiler documentation on how to generate an assembly language listing.
Done.
精彩评论