0

I am trying to Link one function developed in assembly with .s extensions to C code main program main.c

I need to debug assembly routine to see my stack and registers. How can i do it?

int main() {
    char str[] = "remembering toUpperSelective exercise..";
    const char* findChars = "re";

    int result = toUpperSelective(str, findChars);
    printf("Result Expected is %d and got %d \n", 14, result);
    printf("Printing result: %s \n", str);
    getchar();
    return 0;
}

how i say the compiler to search in a X location and stop throwing this error? (Linking)

Bart
  • 19,692
  • 7
  • 68
  • 77
gds03
  • 1,349
  • 3
  • 18
  • 39
  • Are you asking how to debug or how to link? What error are you getting? – interjay Nov 20 '11 at 16:36
  • @interjay, what i need is to link the code via visual studio and i need debug after to check if assembly is well developed. Thanks – gds03 Nov 20 '11 at 16:39
  • @gonçaloR what do you mean by "assembly is well developed" ? – Yahia Nov 20 '11 at 16:42
  • @Yahia basically what i need to do is: Develop functions in assembly language (not C!) and call them from C code. After that i need to debug and go within that function (in assembly) and debug instruction by instruction. – gds03 Nov 20 '11 at 16:45
  • @gonçaloR and what exactly is the problem/error ? – Yahia Nov 20 '11 at 16:46
  • @Yahia this is the error: Error 1 error LNK2019: unresolved external symbol _toUpperSelective referenced in function _main C:\Users\Goncalo\Desktop\test\ctoAsm\main.obj ctoAsm – gds03 Nov 20 '11 at 16:51
  • Means you are not linking the toUpperSelective code ? I think what you're REALLY asking for is how to compile the function into assembly not the object code using Visual Studio. see http://stackoverflow.com/questions/34635/how-do-i-get-the-assembler-output-from-a-c-file-in-vs2005 for details on how to do in 2005 ... 2010 should be similar. – Ahmed Masud Nov 20 '11 at 16:53
  • No. I written a function in assembly and i want to use her in C code. Later i want to debug too. I did that already on linux, i used Insight Debugger, but, on windows, i don't know how can i do this.. – gds03 Nov 20 '11 at 16:59

3 Answers3

0

You can certainly use Assembly Language commands (either single or in block) in your C code. Look at ASM C-function that is used to run assembly language instruction.

I am not so sure if break point will work in inline Assembly language. What you can do is define a regular function. Inside that function, use your ASM Assembly block to write your assembly. If the code is complex and you really want to debug it, test is separately in ASM language. May be you will need a simulator for the processor you are using. Can you point out what exactly the ASM will be doing?

I know this is not the right answer but at least it will put you on the right track.

This thread might be somewhat helpfull

TheTechGuy
  • 16,560
  • 16
  • 115
  • 136
0

Visual Studio didn't use to come with an assembler. Which means you either use the inline assembler functionality of the C compiler, or install a separate assembler.

If you use a separate assembler, you have to add the source to your project, and create custom build rules for it that calls the assembler with the correct flags. Visual Studio will then be able to handle the actual linking. As for the debugging, the Visual Studio debugger is capable of showing assembler code from object code, but your selected assembler has to output debugging info in a format Visual Studio can recognize if you want to be able to properly see all labels and such.

Some programmer dude
  • 400,186
  • 35
  • 402
  • 621
0

alright. I was trying doing this on visual studio, but before i tried use insight debugger without any success on Windows Platform.

I started another question in StackOverflow before this, but i already achieved what i want. The thread is here.

I link assembly with C code and debug on Insight C + My Assembly routine. Thanks!

Community
  • 1
  • 1
gds03
  • 1,349
  • 3
  • 18
  • 39