Visual Studio 可以用来运行带有 ARM 脚本的 C 代码吗?

标签 c assembly visual-studio-2015 arm visual-studio-code

所以我有这两个文件,一个是.c,一个是.s。这些只是测试文件,因此我可以掌握使用 C 语言和 ARM 脚本的窍门,但对于我来说,我无法让它们一起工作。我想知道我是否可以通过使用 Visual Studio 或 VS 代码(或者任何其他 IDE,如果你们都知道的话)来简化这件事。

这是我的代码:

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

目前我用来链接它们的奇怪 java 程序给我错误

"D:\Joe\College Stuff\CS 252\add.s:1: Error: bad instruction ` .global add2'"

任何帮助将不胜感激

最佳答案

要修复此错误,请将您的编辑器配置为不在文件开头插入 BOM(字节顺序标记)。您可以通过选择“另存为”然后选择不同的编码(例如“ASCII”或“UTF-8 no BOM”或类似的东西)来做到这一点。如果您能告诉我们您使用什么编辑器创建 ARM 汇编文件,我可以为您提供更具体的帮助。

关于Visual Studio 可以用来运行带有 ARM 脚本的 C 代码吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46536613/

相关文章:

c - 使用十六进制数

c - fork() 的工作

assembly - .double 类型的变量是否存储在两个寄存器中?

c - 在 C 中使用内联汇编进行位奇偶校验?

Clang 集成汇编程序和 “unknown token in expression” 在否定期间

vb.net - Structure 中的无参数构造函数

c# - 设计 View Xaml 显示手机机身而不显示黑屏

c - 指针到指针的使用

installation - Visual Studio 2015 社区版安装卡在 Windows 10 中

c - 使用 PrintWindow 渲染 chrome