Re: Namespaces in assembly language
From: The Wannabee (faq_at_.@.@SZMyggenPV.com)
Date: 08/29/04
- Next message: The Wannabee: "Re: Namespaces in assembly language"
- Previous message: Herbert Kleebauer: "Re: Namespaces in assembly language"
- In reply to: Herbert Kleebauer: "Re: Namespaces in assembly language"
- Next in thread: The Wannabee: "Re: Namespaces in assembly language"
- Reply: The Wannabee: "Re: Namespaces in assembly language"
- Reply: The Wannabee: "Re: Namespaces in assembly language"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 29 Aug 2004 23:15:19 +0200
> The GCC code is one instruction shorter (the constant 20 is
> stored in floating point format):
Okey. I was just stupid, because I have just to little experience with
this, but the same can be done in RosAsm, of course, I just never used the
R$, F$ before :
[IntegerResult : D$ 0]
[TWenty : R$ 20.0]
Blah:
fld Q$eax
fmul R$TWenty
fistp D$IntegerResult
mov eax D$IntegerResult
ret
(Now tested, the other code was not, and the FPU stack is also balanced)
However, now I know this, and each day, I add some piece of info to my
memory bank. While using a HLL, you never will know this, as its all taken
care of. But I dont have to set the rounding mode, each time, but only,
when it needs to be changed.
>
> ====================================================
>
> int blah(double x){return (int)(20 * x);}
>
> ====================================================
>
> .section .text
> .p2align 2
> LC0:
> .long 1101004800
> .p2align 4,,15
> .globl _blah
> _blah:
> pushl %ebp
> movl %esp, %ebp
> pushl %eax ; local variable
> pushl %eax ; local variable
> flds LC0
> fmull 8(%ebp)
> fnstcw -2(%ebp) ; save FPU conrol
> movw -2(%ebp), %dx
> movb $12, %dh
> movw %dx, -4(%ebp)
> fldcw -4(%ebp) ; set rounding mode
> fistpl -8(%ebp)
> fldcw -2(%ebp) ; restore FPU control
> movl -8(%ebp), %eax ; return value -> eax
> movl %ebp, %esp
> popl %ebp
> ret
- Next message: The Wannabee: "Re: Namespaces in assembly language"
- Previous message: Herbert Kleebauer: "Re: Namespaces in assembly language"
- In reply to: Herbert Kleebauer: "Re: Namespaces in assembly language"
- Next in thread: The Wannabee: "Re: Namespaces in assembly language"
- Reply: The Wannabee: "Re: Namespaces in assembly language"
- Reply: The Wannabee: "Re: Namespaces in assembly language"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|