2011-12-20 77 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