如何使用 vscode 运行 ARM/汇编代码?

问题描述 投票:0回答:1

我有两门课程,其中一门使用了scheme,或者更确切地说是Racket,我已经成功地在VSCode中实现了它,没有太多问题。第二个教汇编,他们建议使用一个名为

ARMSim#
的程序来模拟它,该程序相当古老。

我很想开始在我的 ARM 上使用 VSCode 和 Copilot(非常确定它是 32 位版本,但不确定,是否有人知道如何检查),但谷歌搜索并没有多大帮助,我只能找到有关如何运行的说明VSCode 在 Arm 设备上,而不是相反。

副驾驶聊天说这是可能的,还没有测试过,因为我真的不喜欢它谈论项目,我将有很多不同的文件,其中有练习,所以必须为每个文件执行此操作一个会让人头疼。

Yes, it is possible to write and run ARM32 assembly code on Visual Studio Code. Here are the steps:

1. Install the "C/C++" extension by Microsoft from the VS Code marketplace. This extension provides language support for C/C++ to Visual Studio Code, including features such as IntelliSense and debugging.

2. Install an ARM cross compiler on your system. For example, you can use the GNU ARM Embedded Toolchain. You can download it from the official website and add it to your system's PATH.

3. Install an ARM emulator. For example, you can use QEMU, an open-source machine emulator and virtualizer. This will allow you to run your ARM assembly code on your computer, even if it doesn't have an ARM processor.

4. Configure your tasks.json file in VS Code to use the ARM cross compiler for building your ARM assembly code, and QEMU for running it.

Here's an example of how you might configure your tasks.json file:

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Build ARM assembly",
            "type": "shell",
            "command": "arm-none-eabi-as",
            "args": [
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}.o",
                "${file}"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        },
        {
            "label": "Link ARM assembly",
            "type": "shell",
            "command": "arm-none-eabi-ld",
            "args": [
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}",
                "${fileDirname}/${fileBasenameNoExtension}.o"
            ],
            "dependsOn": "Build ARM assembly"
        },
        {
            "label": "Run ARM assembly",
            "type": "shell",
            "command": "qemu-arm",
            "args": [
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "dependsOn": "Link ARM assembly"
        }
    ]
}

5. Now you can write your ARM assembly code in a .s file, and use the build task (Terminal -> Run Build Task) to compile and run it.

Please note that the exact configuration may vary depending on your specific ARM chip and development environment.
assembly arm vscode-extensions
1个回答
0
投票

也许你应该向 ChatGPT 询问这个问题,它给出了如何解决这个问题的详细说明。

© www.soinside.com 2019 - 2024. All rights reserved.