Hi, Le Thu, 21 Sep 2006 20:39:10 +0900, "amrut h" <h.amrut@xxxxxxxxx> a écrit : > Can anybody please explain what the following piece of code does? > > http://lxr.linux.no/source/arch/i386/boot/compressed/head.S > > arch/i386/compressed/head.S (startup_32) > --------------- > 41 xorl %eax,%eax > 42 1: incl %eax # check that A20 really IS enabled > 43 movl %eax,0x000000 # loop forever if it isn't > 44 cmpl %eax,0x100000 > 45 je 1b > ------------- (Trying to find remembers from the times I was writing bootsectors for PC. Not sure I'll be right.) The A20 gate is a PC-hack that allows to access above 1 Mb. By default, an access above 1 Mb on PC is wrapped to an access at 0 Mb, because when protected mode was introduced, some applications relied on that behaviour. So this behaviour was kept by default. If you want to access memory above 1 Mb, you have to enable A20 (Address Line 20, because 2^20 = 1 Mb). What the code above does is: 41 set eax to 0 42 1: increment eax 43 store the contents of eax at address 0 44 compare eax with the contents of address 1 Mb 45 if equal, try again So, this code will loop forever until the double word written at address 0 is equal to the double word read from address 1 Mb. So it'll loop until A20 is correctly enabled. Is that more clear for you ? Sincerly, Thomas -- Thomas Petazzoni - thomas.petazzoni@xxxxxxxx http://{thomas,sos,kos}.enix.org - http://www.toulibre.org http://www.{livret,agenda}dulibre.org -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/