Anyone know any I'm trying to convert Hexadecimal to a Integer but I'm getting Core dumps unless someone eless knows here
Code:
ptr =-8
value =-4
strPtr =8
.text
.globl hexToInt
hexToInt:
pushl %esp
movl %esp, %ebp
addl $ptr, %esp
movl $0, value(%ebp)
movl strPtr(%ebp), %eax
movl %eax, ptr(%ebp)
loop:
movl ptr(%ebp), %eax
cmpb $0, (%eax)
je allDone
movb (%eax), %al
shll $4, value(%ebp)
cmpb $'9', (%eax)
jbe temp1
addl $0x0f,(%eax)
addl $0x9, %eax
addl %eax, value(%ebp)
incl ptr(%ebp)
jmp loop
temp1:
addl $0x0f, %eax
addl %eax, value(%ebp)
incl ptr(%ebp)
jmp loop
allDone:
movl value(%ebp), %eax
movl %ebp, %esp
popl %ebp
ret
here is the C-Code
[CODE]
#include "HexToInt.h"
unsigned int HexToInt(char *theString)
{
unsigned int value = 0;
char temp;
while(*theString != '\0')
{
value *= 16; /* peel off right digit */
if (*theString <= '9')
temp = *theString & 0x0f;
else /* convert ascii to int */
{
temp = *theString & 0x0f;
temp = temp + 9;
}
value += (int) temp;
theString++;
}
return value;
}