flat assembler
Message board for the users of flat assembler.
![]() Goto page 1, 2 Next |
Author |
|
cod3b453 10 Sep 2005, 18:02
If you read the FPU section in the documentation [page 36 in my version], fldpi will load PI into the register stack for you so you don't have to declare it, you then use FPU operands (fadd,fsub,fmul,fdiv etc) on registers st0 - st7 to perform all normal operations.
HTH |
|||
![]() |
|
madmatt 10 Sep 2005, 20:47
Yeh, I know that stuff already. But In many cases it would be easier to use equates, like when you need to change a value, you won't have to go though all your code and change every occurance of that value.
thanks anyways for your help. |
|||
![]() |
|
vid 11 Sep 2005, 09:07
i usually precompute it myself ("calc.exe"), and define it as constant, with equate in comment so i can easily recompute (of course there are dependancy issues, but they are problems only in som extreme cases)
|
|||
![]() |
|
polygon7 11 Sep 2005, 15:27
Hi,
maybe this will help you: http://board.flatassembler.net/topic.php?t=3947 _________________ best regards p7 |
|||
![]() |
|
madmatt 11 Sep 2005, 17:12
Vid:
Most of the time I do this too. In some case though It would be nice to define an equation and use a standard macro to calculate the value. an example of the c snip that caused me to ask this question: Code: #define D3DX_PI 3.141592654 #define D3DX_1BYPI 0.318309886f #define D3DXToRadian( degree ) ((degree) * (D3DX_PI / 180.0f)) #define D3DXToDegree( radian ) ((radian) * (180.0f / D3DX_PI)) Id like to be able to do the same with FASM and a macro define Polygon7: Those macro's might work, but It would be better to have this as a standard feature for a future release of FASM. I don't think this would be much harder to implement than FASMs integer parser/calculator. I'll try the macro's and see if they will work for me. thanks. |
|||
![]() |
|
vid 13 Sep 2005, 07:37
madmatt: you would end up having both whole-number constants (including labels) and floating constant, which wouldn't be distinguishable, so it will be just mess.
|
|||
![]() |
|
madmatt 13 Sep 2005, 16:42
naaa, these caculations would be all done internally and only the final result would be actual data:
mov eax, D3DXToRadian degree OR myvalue dd D3DXToRadian degree anyways, If this would be to much trouble, I'll just find some work arounds. Just thought I would ask anyways |
|||
![]() |
|
vid 13 Sep 2005, 18:18
ah, so you are talking about inline-macros, sorry, i didn't read carefully. I wanted to say that FASM doesn't allow FP calculations, so even 4.0/2.0 wouldn't work.
|
|||
![]() |
|
madmatt 13 Sep 2005, 19:46
Maybe in the next version of fasm Tomasz would look into adding this feature?
|
|||
![]() |
|
vid 14 Sep 2005, 19:14
i think not, it will cause mess with whole number constants. or you would allow somehting like "label jozo at 4.5"?
|
|||
![]() |
|
madmatt 14 Sep 2005, 23:52
I don't think it would be too much trouble to find the difference between a float and an integer. And where only an integer would be allowed and a fp number. Your example above would be flaged as an error in fasm, only floats would be allowed to be defined with equ, =, macro, data definitions, and direct loading of registers, (mov eax, 1.5). I think that covers about everything.
|
|||
![]() |
|
Tomasz Grysztar 15 Sep 2005, 00:10
The operations performed by fasm are the integer operations, and thus:
Code: beta = alpha * 2 always means an integer operation, even if you defined alpha with a floating point value, since it is anyway stored as a binary representation, and then the integer operations are performed on this binary form. Thus this works the same as: Code: beta = alpha shl 1 and in this case it's even more obvious that the operation is performed on binary. To enable the floating point operations, they would have to be distinguished from the integer operations, and this means the floating point multiplication would have to get some other symbol than just the "*" like integer multiplication - in the same way like the floating point and integer arithmetics have separate instruction sets. |
|||
![]() |
|
revolution 15 Sep 2005, 00:58
Maybe this?
Code: beta = alpha ** 2 |
|||
![]() |
|
Tomasz Grysztar 15 Sep 2005, 01:33
But on what fp precision would it operate? You can define constants of various precisions, like:
Code: a = dword 1.0 b = qword 1.0 Would it needs separate operators for each precision, too? Is this feature worth such mess at all? That's why I suggested the macro solution - at least it's clear what's going on there. |
|||
![]() |
|
revolution 15 Sep 2005, 01:57
Quote: But on what fp precision would it operate? Code: beta = alpha ** 2 ;for SP beta = alpha *** 2 ;for DP |
|||
![]() |
|
madmatt 15 Sep 2005, 08:53
revolution:
or how about beta == alpha * 2 everything behind the '==' would be float, or get converted to floats. tomasz: as far as size, use the best percision available, and scale down too what ever the data element needs, like dd beta, or dq beta, or mov eax, beta, etc. |
|||
![]() |
|
revolution 15 Sep 2005, 09:11
Quote: how about beta == alpha * 2 Quote: use the best percision available, and scale down |
|||
![]() |
|
madmatt 15 Sep 2005, 19:58
Hello Revolution,
Require floats to have a decimal point in them, or else it gets treated like an integer. All the values calclulated are going to be replaced withe the text equivalent, so the type of instruction and/or data define would determine the size, all internal fasmw calculations would be done using the highest precision possible (tword). MadMatt |
|||
![]() |
|
Tomasz Grysztar 15 Sep 2005, 22:14
Consider this:
Code: a = dword 1.0 ; so a = 3F800000h b = qword 1.0 ; so b = 3FF0000000000000h c = word 1 ; so c = 1 d = a+b*c Do you see what I mean? At least right now this sample doesn't cause any problems, since the * and + always mean the integer calculations in fasm, and when you know this it's simple to predict what the above definition will do. And what do you mean by "are going to be replaced with the text equivalent"? In fasm it doesn't work this way; preprocessor works on text, assembler works on binary values. |
|||
![]() |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.