Assembly Language Forums??

This is a discussion on Assembly Language Forums?? within the Tech Board forums, part of the Community Boards category; Anyone know any I'm trying to convert Hexadecimal to a Integer but I'm getting Core dumps unless someone eless knows ...

  1. #1
    Registered User
    Join Date
    Apr 2003
    Posts
    82

    Assembly Language Forums??

    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;
    }

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,453
    Why use ASM when you have a perfectly good C compiler to do the same thing for you?

    If you're desperately curious, just do
    gcc -c -S prog.c
    Then marvel at the assembler equivalent in prog.s

  3. #3
    Registered User
    Join Date
    Apr 2004
    Posts
    100
    http://www.masmforum.com/
    You might give this a try.

  4. #4
    5|-|1+|-|34|) ober's Avatar
    Join Date
    Aug 2001
    Posts
    4,429
    http://www.flashdaddee.com/forums/index.php?s=

    Very first board. It doesn't get a ton of traffic, but several people frequent that site that use assembly and they're more than willing to help if they see someone post there.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Why C Matters
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 136
    Last Post: 01-16-2008, 08:09 AM
  2. Learning Assembly
    By mrafcho001 in forum Tech Board
    Replies: 5
    Last Post: 03-12-2006, 04:00 PM
  3. Strange loop
    By D@rk_force in forum C++ Programming
    Replies: 22
    Last Post: 12-18-2004, 01:40 PM
  4. Language Script..
    By vasanth in forum A Brief History of Cprogramming.com
    Replies: 12
    Last Post: 03-30-2003, 05:48 AM
  5. help in assembly language
    By ema in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 12-14-2002, 01:22 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21