11.1Sjtc/* 21.8Ssalo * Written by J.T. Conklin <jtc@NetBSD.org>. 31.3Sjtc * Public domain. 41.1Sjtc */ 51.1Sjtc 61.1Sjtc#include <machine/asm.h> 71.1Sjtc 81.10SandvarRCSID("$NetBSD: s_floor.S,v 1.10 2022/04/04 19:33:44 andvar Exp $") 91.2Sjtc 101.1SjtcENTRY(floor) 111.5Sfvdl#ifdef __i386__ 121.1Sjtc pushl %ebp 131.1Sjtc movl %esp,%ebp 141.1Sjtc subl $8,%esp 151.1Sjtc 161.7Sfvdl fstcw -4(%ebp) /* store fpu control word */ 171.7Sfvdl movw -4(%ebp),%dx 181.1Sjtc orw $0x0400,%dx /* round towards -oo */ 191.1Sjtc andw $0xf7ff,%dx 201.7Sfvdl movw %dx,-8(%ebp) 211.10Sandvar fldcw -8(%ebp) /* load modified control word */ 221.1Sjtc 231.9Sjoerg fldl 8(%ebp) /* round */ 241.1Sjtc frndint 251.1Sjtc 261.7Sfvdl fldcw -4(%ebp) /* restore original control word */ 271.1Sjtc 281.1Sjtc leave 291.5Sfvdl#else 301.5Sfvdl movsd %xmm0, -8(%rsp) 311.5Sfvdl fstcw -12(%rsp) 321.6Sfvdl movw -12(%rsp),%dx 331.5Sfvdl orw $0x0400,%dx 341.5Sfvdl andw $0xf7ff,%dx 351.5Sfvdl movw %dx,-16(%rsp) 361.5Sfvdl fldcw -16(%rsp) 371.5Sfvdl fldl -8(%rsp) 381.5Sfvdl frndint 391.5Sfvdl fldcw -12(%rsp) 401.5Sfvdl fstpl -8(%rsp) 411.5Sfvdl movsd -8(%rsp),%xmm0 421.5Sfvdl#endif 431.1Sjtc ret 44