News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Visual Studio Code

Started by mabdelouahab, August 11, 2024, 06:57:19 AM

Previous topic - Next topic

mabdelouahab

Visual Studio Code is well-known, so I will talk about how to use it with UASM.
First, after installing and opening it, go to the 'View' menu and then 'Extensions', or simply press 'ctrl+shift+x'. Next, search for 'GDB Debug v1.0.7 DamianKoper' and install it. Close the program.
Go to the working folder, and create a new project folder, for example, 'helloworld'. Right-click and select 'open with', then choose 'Visual Studio Code'. If it asks you about trust, select yes.
The first thing to do is go to 'Terminal' menu, then to 'configure task', and choose 'create tasks.json from template'. Paste the following code:
{
    "version": "2.0.0",
    "tasks": [        {
          "label": "Assemble with UASM X64",
          "type": "shell",
          "command": "../uasm -elf64 ${file} ",
          "problemMatcher": {
              "pattern":  {
                "regexp": "error"
                          }
                            },
          "presentation": {
              "focus": true,
              "panel": "dedicated",
              "reveal": "silent",
              "clear": true
          }
        },
        {
          "label": "Link with GCC X64",
          "type": "shell",
          "command": "gcc -o ${fileBasenameNoExtension} ${fileBasenameNoExtension}.o -fno-pie -no-pie -z noexecstack ",   // `pkg-config --libs gtk+-3.0`
          "problemMatcher": {
              "pattern": {
                "regexp": "error"
              }
            },
          "presentation": {
              "focus": true,
              "panel": "dedicated",
              "reveal": "silent",
              "clear": true
          },
          "dependsOn":"Assemble with UASM X64"
        }    ]
}
Then go to the 'Run' menu and select 'Add configuration'. Choose 'GDB Debug' from the list, and then paste the following code (in launch.json):
{
    "version": "0.2.0",
    "configurations": [{
            "type": "gdb",
            "request": "launch",
            "name": "GDB64",
            "program": "${fileBasenameNoExtension}",
            "stopOnEntry": false,
            "preLaunchTask": "Link with GCC X64"
        }    ]
}
After that, create a new file and name it -for example- 'main.asm', and paste the following example:
    OPTION LITERALS:ON
    printf proto :ptr,:vararg
    .code
        main  PROC  argc:QWORD, argv:QWORD
            printf ("hello world")
            xor rax,rax
            ret
        main  ENDP
    end


Finally, press F5 and enjoy.