使用GNU ToolChain在Windows命令行上运行ARM/C
问题描述:
因此,您可能会从前几天识别出我在IDE中运行此代码时出现的类似问题。最终,我得到的建议是,我应该学会从命令行一起运行它们。因此,我接受了建议,并从Codesourcery Lite MentorGraphics安装了GNU工具链(不知道这是否合理)。我可以做的命令是类似的东西使用GNU ToolChain在Windows命令行上运行ARM/C
> 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”但我不知道是什么的工作确实。
这里是我的代码:
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}
Ç
#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上安装了apt-get from Bash,所以如果你有一个BASH解决方案也是可能的(https://packages.ubuntu.com/trusty/devel/gcc-arm-none-eabi)
答
如果有人遇到过这种情况,我最终得到它的方式将这些脚本行输入到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)
你得到了什么错误? –
对于哪个命令? – wjmccann
为你得到它的每一个命令。 –