- 论坛徽章:
- 0
|
在内核代码中有这样的测试A20是否开启的代码
xorl %eax,%eax
1: incl %eax #
check that A20 really IS enabled
movl %eax,0x000000 # loop forever if it isn't
cmpl %eax,0x100000
je 1b
movl %eax,0x000000将ax的内容赋给内存地址为0x000000的内存单元,
cmpl %eax,0x100000比较0x100000内存单元的内容和eax是否相等
如果A20没有使能,则0x100000和0x000000指向相同的内存位置,是同一个内存单元,当然自己和自己相比较永远相等,故程序是个死循环。
如果A20使能的,则0x100000和0x000000指向不同的内存位置,但0x100000和0x000000内存单元中的内容有可能相同,但也只有一次相同,故用incl %eax来对内存单元0x000000写入不同的数,来与0x100000比较。
可以用同样的反法测试某条内存地址线损坏。
.section .data
output:
.ascz “The adrress line ‘%d’ is good \n”
str:
.ascz “A ll
are good\n”
.section .text
.globl _start
_start:
movl $1,%ecx
movl $1,%ebx
1: xorl %eax,%eax
2: incl %eax
movl %eax,0x00000000
shll %ecx,%ebx
cmpl %eax,%ebx
je 2b
pushl %ecx
pushl $output
call printf
addl $8,%esp
incl %ecx
cmpl $32,%ecx
jne 1b
pushl $31
pushl $output
call printf
addl $8,%esp
xorl %eax,%eax
3: incl %eax
movl %eax,0x00000000
cmpl %eax,0x1
je 3b
pushl $str
call printf
addl $4,%esp
pushl $0
call exit
如果进入死循环说明此时的地址线损坏了,根据打印的信息分析可得具体损坏的地址,上面的程序只是说明个大概意思,需大量修改。
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/23070/showart_179553.html |
|