2017-10-04 15 views
1

でGNU ToolChainを使用してARM/Cを実行するので、IDEでこのコードを実行することについて同様の質問をしたときに、最終的に私が得たアドバイスは、コマンドラインから一緒に実行することを学ぶべきだったということでした。私はアドバイスを受けて、Codesourcery Lite MentorGraphicsからGNUツールチェーンをインストールしました。私ができるコマンドは、Windowsでコマンドライン

> arm-none-eabi-gcc -o main main.c -T script 

のようなものですが、私はコマンドの使用方法を正確に知ることができません。試しました

> arm-none-eabi-gcc -o main (my c filename).c -T (my ARM filename).s 

ただし、ARMファイルの構文エラーが表示されます。なぜなら私のファイル「のa.out」を取得しますが、私は何のことを知らない外部の「ADD2」

> arm-none-eabi-as add2.s 

の私はその後

> arm-none-eabi-gcc -o main (my c filename).c 

を実行しようとしました。しかし、それは動作しません。そうです。

はここに私のコードです:

ARM

.global add2 
add2: 
    stmfd sp!, {v1-v6, lr} @ 'standard' entry, save registers on the stack 
    add a1, a1, a2   @ do the addition requested 
    ldmfd sp!, {v1-v6, pc} 

C

#include <stdio.h> /* standard input and output */ 
#include <stdlib.h> /* standard library */ 
extern int add2(int i, int j); /* tell the compiler that the routine is not defined here */ 
int main(int argc, char * argv[]) /* entry point to the program */ 
{ 
    int i, j; /* declare the variable types */ 
    int answer; 
    i = 5; /* give the variables values */ 
    j = 20; 
    answer = add2(i, j); /* call the assembly language routine */ 
    printf("result is : %d\n", answer); /* print out the answer */ 
    exit(0); /* leave the driver program */ 
} 

任意の助けいただければ幸いです。また、Windows上のUbuntuのbashからこのツールキットをインストールしました。可能であればBASHの解決策があれば()

+0

どのようなエラーが表示されますか? –

+0

どのコマンドですか?あなたがそれを得ているすべてのコマンドのための – wjmccann

+0

。 –

答えて

1

誰かがこれに遭遇した場合、これらのスクリプト行をWindowsのコマンドラインに入力することでした:

Step 1: Compile your c-file 
arm-none-eabi-gcc -o (object file name 1) -c (c file name) 

Step 2: Assemble your ARM file 
arm-none-eabi-gcc -o (object file name 2) -c (ARM file name) 

Step 3: Link files and create executable 
arm-none-eabi-gcc -o (executable file name) (object file name 1) (object 
file name 2) -T armulator-ram-hosted.ld 

Step 4: Run the files 
arm-none-eabi-run (executable file name) 
関連する問題