this is some code about fpu, I ener learn it some time.

hope will help someone.

joy it


.686
.model flat, stdcall
option casemap:none

include windows.inc
include kernel32.inc
includelib kernel32.lib
includelib msvcrt.lib

printf PROTO C:DWORD, :VARARG

.data
value1 dd 43.65
value2 dd 22
value3 dd 76.34
value4 dd 3.1
value5 dd 12.43
value6 dd 6
value7 dd 140.2
value8 dd 94.21

output db 'the result is %f', 0dH, 0aH, 0

.code
start:
finit
fld
fidiv

fld
fld
fmulp st(1), st(0)

faddp st(1), st(0)

fld
fimul

fld
fdiv

fsubp st(1), st(0)

fdivr st(0), st(1)

sub esp, 8
fstp qword ptr
push offset output
call printf
add esp, 8

invoke ExitProcess, NULL
end start




;; use sin, cos
.686
.model flat, stdcall
option casemap:none

include windows.inc
include kernel32.inc
includelib kernel32.lib
includelib msvcrt.lib

printf PROTO C :DWORD, :VARARG

.data
degree1 dd 90.0
val180 dd 180
output db 'sin = %f cos = %f', 0dH, 0aH, 0
.data?
radian1 dd ?

.code
start:
sub esp, 16

finit
fld
fidiv
fldpi
fmul st(0), st(1)
fsincos

fstp qword ptr
fstp qword ptr
push offset output
call printf
add esp, 20

invoke ExitProcess, NULL
end start


by the way, I want to learn nasm, and do some thing for it,so I hope someone show there code, best use nasm
thanks.
Posted on 2009-01-13 07:05:17 by mnzn2530