7

Is there some sort of plugin in Visual Studio code (mac) that can run basic assembly, for example the following:

.section .text
.globl _start
_start:
    movl $1, %eax
    movl $0, %ebx
    int $0x80

As it is, currently I am ssh'ing into a linux server in order to run this assembly but I was hoping it would be possible to build/link/execute this assembly from within VS code, perhaps with a plugin.

zx485
  • 28,498
  • 28
  • 50
  • 59
  • 1
    In order to do that you need an assembler that understands this syntax (GAS), this has to be installed separately from VSCode (which is just an IDE) – UnholySheep Oct 06 '19 at 00:01
  • NASM is available for mac [Install nasm on Mac OSX – Mac App Store](http://macappstore.org/nasm/) Though, personally, ssh'ed into a Linux box would be fine for all practical purposes. You can either open two-terminals (one to edit in and one to compile/link/run in) or you can use a single terminal and `tmux` or `screen` to handle multiple sessions though a single terminal. – David C. Rankin Oct 06 '19 at 00:16
  • 2
    Do yourself a favor and use Intel syntax. To do that, add the directive `.intel_syntax noprefix` at the beginning of your file. – zx485 Oct 06 '19 at 00:33
  • This assembly program won't work on a Mac; it uses a somewhat different 32-bit system call ABI than Linux. Although `exit` might actually work, taking whatever random value was on the stack as the exit status arg, if it uses the same call number as Linux. – Peter Cordes May 20 '20 at 18:06

1 Answers1

1

You can make a task to assemble and link your code, after that, you can use the gdb extension to debug your code.

To make this process faster, if you don't know how to do it, you can use the .vscode folder.

As you are using AT&T syntax, you'll need to use the gas option to run the code.

If you still don't have gdb, you can install it opening a terminal and executing: brew install gdb.

Newtonsart
  • 11
  • 3