new_learner 发表于 2011-03-11 14:12

[X86]为啥我不能设置FPU中的控制寄存器?

代码如下:
      1 .section .data
      2 newvalue:
      3         .byte 0x7f, 0x00
      4 output:
      5         .asciz "The control register is 0x%x\n"
      6 .section .bss
      7
      8         .lcomm control, 2
      9
   10 .section .text
   11 .global _start
   12 _start:
   13         nop
   14         fstcw control
   15         movl control, %eax
   16         pushl %eax
   17         pushl $output
   18         call printf
   19         addl $8, %esp
   20
   21         fldcw newvalue
   22         fstcw control
   23         movl control, %eax
   24         pushl %eax
   25         pushl $output
   26         call printf
   27         addl $8, %esp
   28
   29         movl $1, %eax
   30         movl $0, %ebx
   31         int $0x80
   32
编译命令:
as -gstabs -o mysetprec.o mysetprec.s
ld -o mysetprec -dynamic-linker /lib/ld-linux.so.2 -lc mysetprec.o
查看结果:

# ./mysetprec
The control register is 0x37f
The control register is 0x7f /*这里说明已经设置好了*/
# ./mysetprec
The control register is 0x37f /*为什么这里读出来还是原始的值,而不是上面设置好的0x7f??*/
The control register is 0x7f
#


有什么地方没理解对?
望指正,谢谢!

smalloc 发表于 2011-03-11 15:24

`想起你以前问的那个 内核关中断 用户态仍开
想来这个进程结束 无论回内核还是其它进程都重新来过吧

cjaizss 发表于 2011-03-13 12:42

都换了一个进程了,对于这个进程来说,这些寄存器都重新设过啦

new_learner 发表于 2011-03-14 12:38

低级错误了:oops:
忘了FPU也属于task context的一部分。。。
页: [1]
查看完整版本: [X86]为啥我不能设置FPU中的控制寄存器?