![]() If so, Continue to the next break point, doing this until you find that the current position is now not valid. At each break point, check registers and other memory areas to see that they are actually what they should be. Therefore, place this instruction at various places within your code and run the debugger again. ![]() The debugger will break at each of these instructions it encounters. For example, if we use the instruction xchg bx,bx (or xchg ebx,ebx in pmode/unreal mode), and give the following line in our bochrc.txt file: If we don't want to step through a lot of code, we can place magic break points within our code. We can continue to step though the code until we find something wrong. This tells us that at this point, our code is successful. This particular BIOS call clears the carry and the AX register on a successful call. See that the eflags register has the carry flag clear and the EAX register is zero. This is where we can look at the carry flag and other registers to see if the BIOS call was successful. Notice now that the current location is at the break point. Now to execute the BIOS call, but not have to single step through it, since we have the break point set, hit the "Continue" button or use the C command. Either double click on the wanted instruction or type lb 0x07c5b in the prompt at the bottom of the window. To do this, you can put a break point at the instruction just after the Int 13h instruction. I want to have the debugger execute the BIOS code, then stop when it returns at the next instruction after the Int 13h instruction. Therefore, I do want it to execute the Int 13h instruction and any neccassary BIOS code, but I don't want to step through it. If I step through it, it will actually go to the BIOS code. For example, if the step involves a jmp instruction and this new code is not shown in the second column, you might have to click on the " Refresh" button to update the instruction listing.) (Note: The Bochs Debugger has a few small quirks. For example, to step 10 instructions, use ' s 10'. I stepped through a few more instructions, either by pressing the 's' key or the Step button, or stepping through a few instructions using the ' s n' command or the " Step n" button. ( Red box was inserted for clarification) If we look, the address 0x7D88 is indeed, zero. Since our DS register is 0x07C0 and we are in real mode, we know that the address DS:0x0188 is physical address 0x7D88. If you wish to see that the value at this address actually was changed, you can do a physical dump of the memory, by using the View Menu, " Physical Dump", and placing a physical value of 0x07D00 in the prompt. Now I step through the next few instructions and past the instruction that stores the DL register into the byte at DS:0x0188. If the Interrupt Flag was not already clear, when we stepped through the "cli" instruction, the eflags register would now be red also. This is because it changed from the previous step. Notice that the IP register has now changed to red. If I click on the " Step (s)" button, or hit the ' s' key, it will step one instruction. The second column shows the actual code to be executed. ![]() The column on the left shows the values of all the registers. Sector, and now is ready to execute the instruction at 0x07C00 (0x07C0:0000). (an example of the bochsrc.txt file can be found at the source link aboveĤ) now with your floppy/hard-drive/ISO image and the bochsrc.txt file in the currentĭirectory, start the debugger with the following command line:ĥ) now you should have a window similar to the one shown below.Ħ) at the prompt, shown in the image below in red, type:Ĩ) you now will be at the point where the BIOS has done all of its tasks, loaded your boot I have started the emulator and debugger, I have created a break point at 0x07C00 (the start of my boot code), clicked the "Continue" button, and the debugger has stopped at this break point and is now waiting for a command.ġ) downloaded the bochs package from the first link above.Ģ) executed the installation, pointing it to an install folder similar to the path below.ģ) created a bochsrc.txt file making sure to have the following line:ĭisplay_library: win32, options="gui_debug" The following image shows the Bochs Debugger (in Windows XP). Well, the first thing to do is to see exactly what is going on at each stage of your code. You have looked at all of your code, and you just have no idea why it just doesn't work. Let's say that you have written a boot sector that should load a second stage loader and for some reason it just isn't. The purpose of this tutorial is to show how easy and neccassary a good debugger is, such as the one included with Bochs. A Quick Tutorial on the Bochs Debugger A Quick Tutorial on the Bochs Debugger This is a small and quick tutorial on the Bochs Debugger.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |