Is it possible to execute assembly language instructions in the immediate window

3

I have written a small program in C++. I have the Disassembly window side-by-side the C++ program window. I want to see what happens at the assembly level, when I execute assembly instructions in the immediate window. But, I am not able to do so. For example, when I type "add eax, 1" in the immediate window, I get the result "identifier "add" is undefined".

Is there a way to execute assembly instructions such that I am able to do something like "add eax, 1", while debugging? I want to do this so that I can understand what is going on at the assembly level better. Any help is highly appreciated.

I researched the internet a lot, but couldn't find a solution to my question.

C++ code:

#include<iostream>
using namespace std;

int AddMe(int a, int b)
{
    int c;
    c = a + b;
    return c;
}

int main() 
{
    AddMe(10, 20);
    return 0;
}

snippet of equivalent assembly code:

int main() 
{
00BCDC40  push        ebp  
00BCDC41  mov         ebp,esp  
00BCDC43  sub         esp,0C0h  
00BCDC49  push        ebx  
00BCDC4A  push        esi  
00BCDC4B  push        edi  
00BCDC4C  lea         edi,[ebp-0C0h]  
00BCDC52  mov         ecx,30h

Assembly Watch window:

+       (int*)(ebp) 0x001ef898 {2029812}    int *
+       (int*)(esp) 0x001ef878 {2029720}    int *
+       (int*)(esi) 0x00bc1712 {TryCatch2.exe!_mainCRTStartup} {9030121}    int *
+       (int*)(edi) 0x00bc1712 {TryCatch2.exe!_mainCRTStartup} {9030121}    int *
+       (int*)ecx   0x00000001 {???}    int *
+       (int*)(ecx) 0x00000001 {???}    int *
+       (int*)(eax) 0x00615180 {6377864}    int *
+       (int*)(edx) 0x00614fe8 {6377728}    int *
+       (int*)(esi) 0x00bc1712 {TryCatch2.exe!_mainCRTStartup} {9030121}    int *
+       (int*)(ebx) 0x002e7000 {67174400}   int *

Actual result: When I type "add eax, 1" in immediate window, it gives the result "identifier "add" is undefined". Expected result: When I type "add eax, 1" in immediate window, it should add 1 to eax register.

debugging
assembly
visual-c++
visual-studio-2019
asked on Stack Overflow Aug 15, 2019 by Vikram Singh • edited Aug 16, 2019 by Vikram Singh

1 Answer

1

We can't make changes to register values in the Immediate Window. But, we can make changes to register values in the Registers window, and the watch window (by simply editing the register values).

answered on Stack Overflow Aug 24, 2019 by Vikram Singh

User contributions licensed under CC BY-SA 3.0