flat assembler
Message board for the users of flat assembler.

Index > Linux > floating point numbers / output to console

Author
Thread Post new topic Reply to topic
andyz74



Joined: 26 Nov 2007
Posts: 36
Location: Germany
andyz74
I have this code

Code:
; fp-test.asm
; Beispiel zu Kommazahlen
; (soll eine festgelegte Kommazahl ausgeben
  format ELF executable
       
     
   entry start

     segment readable writable executable


macro schreibe satz,laenge                      ; macro for writing
{
       mov     eax,4
       mov     ebx,1
       mov     ecx, $ + 16
 mov     edx, laenge
 int     0x80
        db 0ebh
     db laenge+2
 nop
 nop
 db satz
}



macro bin_ax
{
     pusha
       xor cx, cx
  mov bx, 10
m1: xor dx, dx
    div bx
      push dx
     inc cx
      cmp ax, 0
   jnz m1
m2: pop dx
    add dl, 30h
 mov [_d], dl

    pusha
       mov eax, 4
  mov ebx, 1
  mov ecx, _d
 mov edx, 1
  int 80h
     popa
        
    loop m2
     popa
}

  puffer db "12345123451234512345"

msg1  db      "testest",0Ah,0 


; ################ Hauptprogramm ######################

start:

 fld [x1]                                ; l├Ądt Ganzzahl (hier word) in den stack
   fadd    [x2]
        fistp [y]                               ; und speichert diese in y
  wait
        
    pusha
       mov eax, [y]
        bin_ax
      popa
        
    schreibe 0ah,1                  ; macro for writing

     

        mov eax, 1
  mov ebx, 0
  int 80h




     segment readable writable
a  dd      3.5
b        dd      12.5
x1      dd      2.2
x2       dd      2.7
y        dd      0
_d db      0
    


...and it can calculate and write the numbers, but only with a rounded integer as result.

if i change "fistp [y]" to "fstp [y]" and "y" stores a real number in it, I can't manage to output this.

Has anybody a macro or sth, that can output floating-point-numbers, or is anybody able to explain, how i can output them?

Thanks in advance and sorry for my bad english. Confused
Post 15 May 2011, 15:11
View user's profile Send private message Visit poster's website Reply with quote
andyz74



Joined: 26 Nov 2007
Posts: 36
Location: Germany
andyz74
Hmmm..
maybe in this thread : http://board.flatassembler.net/topic.php?t=4377&start=53
is information for me, especially the part "FTOA" ?
Post 17 May 2011, 07:50
View user's profile Send private message Visit poster's website Reply with quote
Endre



Joined: 29 Dec 2003
Posts: 212
Location: Budapest, Hungary
Endre
Your dilemma: either writing your own libc or using an already existing one. It's up to you.
Post 17 May 2011, 09:54
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.