Vscode-code-runner: x86 and x64 Assembly language support

Created on 8 Feb 2019  路  2Comments  路  Source: formulahendry/vscode-code-runner


Is it possible to compile assembly language with Microsoft Visual Studio Code?

The commands would look something like this:

sudo nasm -f elf64 helloWorld.asm

ld helloWorld.o -o helloWorld

./helloWorld

Most helpful comment

Yes it's possible. Just add this line to your settings:

{
// ...
  "code-runner.executorMap": {
        // Linux based
        "asm": "nasm -felf64 $fileName && ld $fileNameWithoutExt.o -o $fileNameWithoutExt && ./$fileNameWithoutExt",
        // Mac
        "asm": "nasm -fmacho64 $fileName && ld $fileNameWithoutExt.o -o $fileNameWithoutExt && ./$fileNameWithoutExt",
        // Windows (not tested)
        "asm": "nasm -win32 $fileName && ld $fileNameWithoutExt.o -o $fileNameWithoutExt.exe && ./$fileNameWithoutExt.exe",
        // ...
},
// ...

If anyone can test the windows and mac commands, i think it can be added as a default @formulahendry

EDIT: may be useful to use gcc instead of ld, but idk much about assembly to confirm.

All 2 comments

Yes it's possible. Just add this line to your settings:

{
// ...
  "code-runner.executorMap": {
        // Linux based
        "asm": "nasm -felf64 $fileName && ld $fileNameWithoutExt.o -o $fileNameWithoutExt && ./$fileNameWithoutExt",
        // Mac
        "asm": "nasm -fmacho64 $fileName && ld $fileNameWithoutExt.o -o $fileNameWithoutExt && ./$fileNameWithoutExt",
        // Windows (not tested)
        "asm": "nasm -win32 $fileName && ld $fileNameWithoutExt.o -o $fileNameWithoutExt.exe && ./$fileNameWithoutExt.exe",
        // ...
},
// ...

If anyone can test the windows and mac commands, i think it can be added as a default @formulahendry

EDIT: may be useful to use gcc instead of ld, but idk much about assembly to confirm.

I almost have MASM working also and will share my solution when I get home.

Edit: @maxjf1

MASM ml64 & ml

Commands to compile assembly for the Kip Irvine library

MASM Files location

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\bin

MASM ml64 x64 command

ml /DM=main example.asm /link /entry:main /subsystem:console

```
ml /DM=main example.asm /link /entry:main /subsystem:windows

## MASM ml x86 command

ml64 /DM=main example.asm /link /entry:main@0 /subsystem:console


ml64 /DM=main example.asm /link /entry:main@0 /subsystem:windows

## Code-Runner settings for cmd.exe

cd $dir && ml /DM=main $fileNameWithoutExt.asm /link /entry:main@0 /subsystem:console /OUT:$fileNameWithoutExt.exe

## Ml64 attempt

ml64 /nologo /Zi /Zd /I C:\Irvine /Fe link /ENTRY:"main" /LARGEADDRESSAWARE:NO C:/Irvine/Project64/Irvine64.obj kernel32.lib

Was this page helpful?
0 / 5 - 0 ratings

Related issues

0x7FFFFFFFFFFFFFFF picture 0x7FFFFFFFFFFFFFFF  路  3Comments

rana picture rana  路  5Comments

manikantag picture manikantag  路  4Comments

spacesuitdiver picture spacesuitdiver  路  3Comments

Salil03 picture Salil03  路  5Comments