Announcement

Collapse
No announcement yet.

Umwandlung von float zu ascii-code

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Umwandlung von float zu ascii-code

    Hallo!

    Bin neu in der Assembler-Programmierung und ich muss eine 32bit-Gleitkommazahl (float) in ASCII-Format umwandeln!

    Als Vorlage soll die Umwandlung von Int zu ASCII dienen, mit folgendem Code:

    void RNOInteger::toASCII_asm(char str[])
    {
    __asm__ __volatile__( //volatile: Wert der Variable kann immer modifiziert werden
    "XOR %%ebx, %%ebx\n\t" //set string offset to zero
    "loop:\n\t"
    "XOR %%edx, %%edx\n\t" //set edx register to zero
    "MOV $0xa, %%ecx\n\t" //copy radix(=10) to ecx register
    "IDIV %%ecx\n\t" //divide value in eax by the radix in ecx
    "ADD $0x30, %%edx\n\t" //convert remainder to ASCII
    "MOV %%dl, (%%esi,%%ebx,1)\n\t" //save result in string
    "INC %%ebx\n\t" //increment string length
    "CMP $0x0, %%eax\n\t" //break if register eax is empty
    "JNE loop\n\t" //start again
    "MOVB $0x0, (%%esi,%%ebx,1)\n\t" //add string termination
    "XOR %%ecx, %%ecx\n\t" //set reverse index to zero
    "reverse_loop:\n\t"
    "DEC %%ebx\n\t" //decrement string index
    "MOVB (%%esi,%%ebx,1), %%al\n\t" //reverse byte order
    "MOVB (%%esi,%%ecx,1), %%ah\n\t"
    "MOVB %%ah,(%%esi,%%ebx,1)\n\t"
    "MOVB %%al, (%%esi,%%ecx,1)\n\t"
    "INC %%ecx\n\t"
    "CMP %%ecx, %%ebx\n\t"
    "JG reverse_loop\n\t" //if not finished, loop again
    : // no output variables
    : "a" (value), "S" (str)
    : "ebx", "ecx", "edx" // clobber registers
    );
    }

    Kann mir jemand diesen Code genauer erklären??
    und hat jemand eine Idee, wie das Coding für den float ausschauen könnte??
    Bin für jeden Tipp dankbar!!

    lg Stefan
Working...
X