⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 modf.asm

📁 这是一个符合posix.13 pse51的实时内核
💻 ASM
字号:
; Project: 	HARTIK 3.0      				
; Description:  Hard Real TIme Kernel for 386 & higher machines 
; Author:	Gerardo Lamastra			
; Date:		9/5/96 						
; Revision:	Beta 1.0

;
; Assembler portion of the library!
; I shall use Watcom register calling convention along this module
;

.386
.387
.model flat

.code
PUBLIC modf_

; double modf(double v,int *e)
; Input:  On Stack
; Output: Using 80x87 regs
modf_		PROC
		push	ebp
		mov	ebp,esp
		sub	esp,16
		push	ebx
		;
		; Save Control Word & set rounding opts
		;
		fnstcw	word ptr -4[ebp]
		fwait
		mov	ax,word ptr -4[ebp]
		or	ax,0C3FH
		mov	word ptr -8[ebp],ax
		fldcw	word ptr -8[ebp]
		fwait
		;
		; Load v into st(0) & round it & store into 
		; temporary variable at -16 
		;
		fld	qword ptr +8[ebp]
		frndint 
		fstp	qword ptr -16[ebp]
		fwait
		;
		; Put into edx_ecx the rounded value
		;
		mov	edx,dword ptr -16[ebp]
		mov	ecx,dword ptr -12[ebp]
		; Access to the address of e
		; Load it into EBX
		mov	ebx,dword ptr +16[ebp]
		;
		; Put the rounded value into the pointer area!
		;
		mov	[ebx],edx
		mov	4[ebx],ecx
		;
		; Evaluate fractionary part = v - round(v)
		;
		fld	qword ptr +8[ebp]
		fsub	qword ptr -16[ebp]
		fst	qword ptr -16[ebp]
		fwait
		mov	eax,dword ptr -16[ebp]
		mov	edx,dword ptr -12[ebp]
		lea	esp,dword ptr -20[ebp]
		;
		; Restore control word!
		;
		fclex
		fldcw	word ptr -4[ebp]
		fwait
		pop	ebx
		leave
		ret		
modf_		ENDP

END

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -