flat assembler
Message board for the users of flat assembler.
Index
> Main > its time to float numbers |
Author |
|
edfed 30 May 2011, 14:51
start with some methodology, with FP, it is better to always comment the code.
like this: Code: finit ; EMPTY fld1 fimul dword[ss:esp+4] ; fidiv dword[ss:esp] fadd [.angle] fstp [.angle] fldpi ; pi ; fmul [.angle] ; pi*angle ; fdiv dword[ss:esp+8] ; rad ; fsincos ; cos ; sin fld [.module] ; module ; cos ; sin fimul dword[ss:esp+4] ; ticks*mod ; cos ; sin fidiv dword[ss:esp] ; pixels ; cos ; sin fxch ; cos ; pixels ; sin fmul st0,st1 ; cos*pix ; pixels ; sin fadd [.x] ; x ; pixels ; sin fst [.x] ; fsub [.rayon] ; fistp dword[eax+item.x] ; pixels ; sin fmul st0,st1 ; pix*sin ; fsubr [.y] ; y fst [.y] ; fsub [.rayon] ; fistp dword[eax+item.y] ; EMPTY look at some codes from djmauretto, he submitted a lot of good code with fpu. and forget everything you know about general purpose assembly, fpu is a lot different, on many points. there are effectivelly 8 registers, but they are 80 bits wide. they are effectivelly 8, but are disposed as a stack. st0 is the top of stack register. the stack can be empty, full, trashed, etc... don't mix MMX code and FPU code. etc, etc... a good tutorial is linked somewhere in the faq, i think it redirects to x86asm.net site. |
|||
30 May 2011, 14:51 |
|
Teehee 31 May 2011, 18:03
Then registers st0 to st7...
1. disposed as a stack? these registers live in CPU or memory? whats exactly "disposed as a stack" means: do i have an order to follow in order to access them? (i'm thinking on push/pop) 2. whats the difference among MMX & FPU? 3. what do you mean by empty, full, trashed.. 4. why they're 80bits wide? sorry _________________ Sorry if bad english. |
|||
31 May 2011, 18:03 |
|
mindcooler 31 May 2011, 21:38
|
|||
31 May 2011, 21:38 |
|
Overflowz 31 May 2011, 21:53
instruction set here:
http://www.ray.masmcode.com/tutorial/appen1.htm |
|||
31 May 2011, 21:53 |
|
ctl3d32 01 Jun 2011, 00:01
Teehee wrote: Then registers st0 to st7... It works like that: Code: fld dword[variable] ;loads variable to st0 fld dword[constant];loads constant to st0, and what was is st0 goes to st1 fmul st0,st1;multiplies st0 by st1 - st0 holds the result and st1 holds variable fstp dword[value];store what's in st0 to value, pop(delete) what's in st0, and what's in st1 goes to st0 So, for example: Code: fld [a] fld [b] fld [c] ;gives st0 = c, st1 = b, st2 = a fstp[d] ;gives st0 = b, st1 = a, st2 = empty Like an HP calculator in RPN mode. |
|||
01 Jun 2011, 00:01 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.