【问题标题】:C-pseudo code to assembly [closed]汇编的 C 伪代码 [关闭]
【发布时间】:2012-01-24 13:42:50
【问题描述】:

我的老板让我将其转换为组装,而我对组装知之甚少。有人可以帮帮我吗?

这是给我的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
}

请帮帮我

【问题讨论】:

  • 适用于什么架构和处理器?
  • 听起来不要太刻薄,但您的老板似乎在有效地分配任务到资源方面存在问题。如果公司需要完成组装开发,他们可能需要聘请组装开发人员。
  • 你的“老板”是大学教授吗?
  • 你不能用编译器来做吗?这基本上就是他们所做的,而且他们通常比我们做得更好。为什么你的老板要求你这样做?这看起来更像是家庭作业而不是工作。
  • 该死的。我刚刚用 MOS-6502 程序集写了它,问题就解决了。 :-(

标签: c assembly


【解决方案1】:

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

This 是文档

-S 选项:

“在适当的编译阶段后停止;不要汇编。对于每个指定的非汇编输入文件,输出是汇编代码文件的形式。 默认情况下,源文件的汇编文件名是通过将后缀“.c”、“.i”等替换为“.s”来创建的。 不需要编译的输入文件将被忽略。”

我相信,如果您将该代码放在文件“source.c”中,并且您安装了 gcc,这将完成工作:

gcc -S source.c

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

【讨论】:

  • 更好的是,告诉你的老板检查-S选项。
猜你喜欢
  • 2016-12-22
  • 2014-06-21
  • 2011-05-04
  • 1970-01-01
  • 1970-01-01
  • 2010-11-29
  • 2010-10-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多