C-pseudo代码用于汇编

时间:2011-12-20 15:48:23

标签: c assembly

我的老板让我把它转换为装配,我对装配知之甚少。有人可以帮帮我吗?

这是给我的C-pseudo代码

 //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
}

请帮帮我

1 个答案:

答案 0 :(得分:7)

你能试试GCC的-S选项吗?

This是文档

-S选项:

“在编译阶段之后停止;不进行汇编。对于指定的每个非汇编器输入文件,输出采用汇编代码文件的形式。  默认情况下,源文件的汇编程序文件名是通过将后缀“.c”,“。i”等替换为“.s”来完成的。  不需要编译的输入文件将被忽略。“

我相信如果你把这些代码放在一个文件“source.c”中,并且你安装了gcc,那么就可以完成这项工作:

gcc -S source.c

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