先日、IDE でのこのコードの実行について同様の質問をしたときのことをご存知かもしれません。最終的に私が得たアドバイスは、コマンド ラインからそれらを一緒に実行する方法を学ぶべきだというものでした。そのため、私はアドバイスを受けて、Codesourcery Lite MentorGraphics から GNU ツールチェーンをインストールしました (それが意味があるかどうかはわかりません)。私ができるコマンドは次のようなものです
> 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 ファイルの構文エラーが発生します。私はそれからやろうとしました
> arm-none-eabi-gcc -o main (my c filename).c
しかし、それは外部の「add2」のために機能しません
> arm-none-eabi-as add2.s
それは私にファイル「a.out」を取得しますが、それが何をするのかわかりません。
これが私のコードです:
腕
.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}
ハ
#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 から apt-get からインストールしたので、BASH ソリューションがあればそれも可能です ( https://packages.ubuntu.com/trusty/devel/gcc-arm-none-eabi )