I’m trying to compare 2 different char in assembly(calling assembly function in C program). One of the char belongs to a struct and the other is passed in when calling the function.
struct node {
void *previous;
void *next;
unsigned int num;
unsigned int A;
unsigned int B;
}
node something;
something.A = 'C'; //assume everything else is correct
char A = 'C';
int func( char A ){ }:
find_course:
pushl %ebp
movl %esp, %ebp
subl $28, %esp
movl 8(%ebp), %ebx
movl 10(%ebp), %ecx
movl 16(%ebp), %edx
movl something, %edi
cmpl 10(%edi), %ebx
.END:
leave
ret
when I debug with gdb, %ebx is 83 whereas 10(%edi) is 21315. If I print them out as characters, both appear to be ‘C’. Is there any way that I can convert 21315 to 83?
Yes: you want to use
movb 10(%edi), %alinstead.