开发者

Converting C code to assembly [closed]

开发者 https://www.devze.com 2023-02-16 16:31 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form. For help clari
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消