2011-12-20 73 views
-8

我的老板让我把它转换成组件,我对组件的了解不多。有人可以帮我吗?组装C伪代码

这是C-伪代码给我

//Global Variables 
#define HRM_PERIOD 15 

int hrArr [HRM_PERIOD] 

int *hrPt = hrArr; 

/* 
Function addtoarray 
Parameter: int np - a value to add to the array 

Description: Stores 16-bit value np in array using global pointer hraPt. 
hraPt is incremented so that the next call will add the value 
to the next element in the array. The pointer wraps to start 
when it reaches the end of the array 
*/ 

void addToArray(int np) 
{ 
*hraPt = np;// save value 
hraPt++; // increment pointer 
// wrap around 
if (hraPt == hrArr + HRM_PERIOD) 
hraPt = hrArr 
} 

请帮我

+2

对于什么架构和处理器? – rzetterberg 2011-12-20 15:50:57

+3

听起来不太显眼,但你的老板似乎有问题有效地将任务分配给资源。如果公司需要完成组装开发,他们可能需要聘请组装开发人员。 – David 2011-12-20 15:52:31

+13

你的“老板”是大学教授吗? – 2011-12-20 15:55:07

回答

7

你可以尝试GCC的-S选项?

This是文档

-S选项:

“停止汇编适当的阶段之后,不进行汇编的输出是在每一非汇编的汇编代码文件的形式输入文件 默认情况下,源文件的汇编程序文件名是通过将'.c','.i'等后缀替换为'.s'来创建的 不需要编译的输入文件被忽略。“

我相信,如果你把这些代码在一个文件中“由source.c”,和你有GCC安装,这将做的工作:

gcc -S source.c 

输出将是一个文件名为:源。 s - >汇编代码。

+2

更好的是,告诉你的老板检查'-S'选项。 – Tom 2011-12-20 18:21:04