Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
60 views

Guide-to-setting-up-NASM-in-VS-Code-for-Assembly-programming-on-Windows

This document provides a step-by-step guide for setting up NASM in Visual Studio Code for Assembly programming on Windows and Linux. It covers installation of NASM, GCC, and VS Code extensions, as well as writing, compiling, and debugging an Assembly program. The final setup ensures the user can write and debug Assembly code effectively in VS Code.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views

Guide-to-setting-up-NASM-in-VS-Code-for-Assembly-programming-on-Windows

This document provides a step-by-step guide for setting up NASM in Visual Studio Code for Assembly programming on Windows and Linux. It covers installation of NASM, GCC, and VS Code extensions, as well as writing, compiling, and debugging an Assembly program. The final setup ensures the user can write and debug Assembly code effectively in VS Code.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

IT 111 Platform Technologies

Guide to setting up NASM in VS Code for Assembly programming on


Windows/Linux.

🛠 Step 1: Install NASM


Windows

1. Download NASM from nasm.us


2. Extract the .zip file to C:\nasm
3. Add NASM to system PATH:
o Search "Environment Variables" in the Start Menu
o Edit Path → Add:

C:\nasm

oClick OK, then restart the terminal.


4. Verify installation:

nasm -v //If installed correctly, it shows the NASM version.

Linux (Ubuntu/Debian)

Run:

sudo apt update


sudo apt install nasm -y

Verify:

nasm -v

🛠 Step 2: Install GCC & LD (Linker)


Windows

Install MinGW-w64:

1. Download MinGW-w64:
https://winlibs.com/
2. Install it and add C:\mingw64\bin to Environment Variables (Path).
3. Verify with:

gcc --version
ld --version

Linux

Install GCC & LD:

sudo apt install gcc -y

🛠 Step 3: Install VS Code & Extensions


1. Install VS Code
2. Open VS Code and go to Extensions (Ctrl+Shift+X)
3. Search for and install:
o "x86 and x86_64 Assembly" (for syntax highlighting)
o "Code Runner" (optional, to run programs easily)

🛠 Step 4: Write an Assembly Program


1. Open VS Code and create a new file:

mkdir asm_project && cd asm_project


code .

2. Create a file: program.asm


3. Write this NASM 64-bit code:

section .data
msg db "Hello, World!", 0xA
len equ $ - msg

section .text
global _start

_start:
mov rax, 1 ; sys_write
mov rdi, 1 ; stdout
mov rsi, msg ; message address
mov rdx, len ; message length
syscall

mov rax, 60 ; sys_exit


xor rdi, rdi ; exit code 0
syscall
🛠 Step 5: Compile & Run Assembly Code
Windows

1. Open VS Code Terminal (Ctrl+~)


2. Run these commands:

nasm -f win64 program.asm


gcc program.obj -o program.exe
program.exe

Linux
nasm -f elf64 program.asm
gcc -no-pie program.o -o program
./program

Output: Hello, World!

🛠 Step 6: Debugging Assembly in VS Code


1. Install Debugger

• Install GDB:
o Windows: Use mingw-w64
o Linux: Run:

sudo apt install gdb -y

• Verify:

gdb --version

2. Create Debug Configuration

1. Open VS Code and go to Run → Add Configuration


2. Select C++ (GDB/LLDB), then edit .vscode/launch.json:

{
"version": "0.2.0",
"configurations": [
{
"name": "Debug Assembly",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/program",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb"
}
]
}

3. Set a breakpoint in program.asm


4. Press F5 to start debugging.

Final Setup Summary


✔ Installed NASM & MinGW (Windows) or GCC (Linux)
✔ Configured VS Code with Assembly extensions
✔ Compiled and ran an Assembly program
✔ Set up debugging with GDB

Now, you're ready to write & debug Assembly in VS Code!

You might also like