Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

noexcuse4you

macrumors newbie
Original poster
Feb 25, 2010
7
0
I have a program written in C calling a function written in assembly. When I run the debugger, I can step through the C code just fine, but then when it reaches the function, it won't step through the assembly code. It'll just go on to the next statement. In the assembly viewer I see:

call 0x1eda <isgreater>

and then the rest of the main function after that. How do I view the function isgreater?

My professor uses the Eclipse IDE and it can do it just fine. I'd rather use the Xcode IDE as Eclipse is very buggy.

Thanks!
Kyle.
 
I thought I would update this in case anyone else runs into this problem. If you go to Run > Debugger Display > Disassembly Only, it'll step into the function. It won't work in the Source and Disassembly view.

Kyle.
 
Would you mind putting up your code?
I'm running into the same problem right now.
 
You just need to press "Step Into" rather than "Step Over" and it will enter the function. You can do this for any function as well, not just ones written in assembly.

Step Into won't enter the function written in assembly in the Source and Assembly View. It'll only work in Assembly Only.
 
Would you mind putting up your code?
I'm running into the same problem right now.

#include <stdio.h>
#include <stdlib.h>

/*void endianSwap(unsigned int *x)
{
*x = (*x>>24) |
((*x<<8) & 0x00FF0000) |
((*x>>8) & 0x0000FF00) |
(*x<<24);
}*/


int main(void)
{
unsigned int x = 0x01020304;
printf("%x",x);
endianSwap(&x);
printf("%x",x);

return EXIT_SUCCESS;
}

-------------------
In a separate file
-------------------

.globl _endianSwap
_endianSwap:
pushl %ebp
movl %esp, %ebp

movl 8(%ebp), %eax //copies x to eax
movl (%eax), %eax //copies address of x to eax
movl %eax, %ecx //copies address of x to ecx
movl %eax, %edx //copies address of x to edx

shrl $24, %edx //shifts address of x 24 bits right stores in edx

shll $8, %ecx //shifts address of x 8 bits left stores in ecx
andl $0x00FF0000, %ecx // ands it with 0x00FF0000
orl %ecx, %edx //ecx or edx - stores in edx

movl %eax, %ecx //recopies address of x to ecx
shrl $8, %ecx //shifts address of x 8 bits right stores in ecx
andl $0x0000FF00, %ecx //ands it with 0x0000FF00
orl %ecx, %edx //ecx or edx - stores in edx

movl %eax, %ecx //recopies address of x to ecx
shll $24, %ecx //shifts address of x 24 bits left stores in ecx
orl %ecx, %edx //ecx or edx - stores in edx

movl 8(%ebp), %eax //recopies x to eax
movl %edx, (%eax) //moves new address of x to old address of x

popl %ebp
ret
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.