简体   繁体   English

可以使用Visual Studio通过ARM脚本运行C代码吗?

[英]Can Visual Studio be used to run C code with ARM scripts?

so I have these two files, one is a .c and one is a .s . 所以我有这两个文件,一个是.c ,一个是.s These are just test files so I can get the hang of working C with ARM scripts, but for the life of me I can't get them to work together. 这些只是测试文件,因此我无法掌握使用C脚本与ARM脚本一起工作的习惯,但是对我而言,我无法使它们一起工作。 I was wondering if I could make this easier by using either Visual Studio or VS code (or any other IDE if y'all know). 我想知道是否可以通过使用Visual Studio或VS代码(或大家知道的任何其他IDE)来简化此过程。

Here's my code: 这是我的代码:

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 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 */
}

Currently the weird java program I've been using to link them is giving me the error 目前,我一直用来链接它们的怪异的Java程序给了我错误

"D:\\Joe\\College Stuff\\CS 252\\add.s:1: Error: bad instruction ` .global add2'" “ D:\\ Joe \\ College Stuff \\ CS 252 \\ add.s:1:错误:错误的指令'.global add2'”

Any help would be appreciated 任何帮助,将不胜感激

To fix this error, configure your editor to not insert a BOM (byte order mark) at the beginning of the file. 要解决此错误,请将编辑器配置为不在文件开头插入BOM(字节顺序标记)。 You might be able to do this by selecting “save as” and then selecting a different encoding (eg “ASCII” or “UTF-8 no BOM” or something like this). 您可以选择“另存为”,然后选择其他编码(例如“ ASCII”或“ UTF-8 no BOM”或类似方法)来执行此操作。 If you could tell us what editor you used to create the ARM assembly file, I could provide you with more specific help. 如果您可以告诉我们您使用什么编辑器来创建ARM程序集文件,我可以为您提供更具体的帮助。

For future people who come across this, no , you cannot run ARM scripts with C from visual studio. 对于以后遇到此问题的人, no ,您不能从Visual Studio中使用C运行ARM脚本。 One way of doing it though is from the command line, which I found out from this question: 不过,一种方法是从命令行中获取,我从以下问题中发现了这一点:

Using the GNU ToolChain to Run ARM/C on Windows Command Line 使用GNU ToolChain在Windows命令行上运行ARM / C

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM