星期二

Bochs的bebug工具

補充一下,上次的2個function,以及Bochs的bebug工具:

1. Print character in text mode (PrintChar)
很簡單,螢幕及memory之間有一個mapping,只要改變memory特定位置的數值,螢幕就會立即反映。

例如,Address: 0xB8000是第1個character,螢幕的左上角,第1個byte(即0xB8000)是character的ascii code,第2個byte(即0xB8001)是其屬性,如下:
Bits 0 - 2: Foreground color (0: Red, 1: Green, 2: Blue)
Bit 3: Foreground Intensity
Bits 4 - 6: Background color (4: Red, 5: Green, 6: Blue)
Bit 7: Blinking or background intensity

2. Set cursor position (SetCursor):
1) 先計算好cursor location ( = row * screen width + column )
2) 告訴CRT Controller我要放cursor location的low byte (OUT 0x03D4, 0x0F)
3) 真的放入data (OUT 0x03D5, cursor location的low byte)
4) 告訴CRT Controller我要放cursor location的high byte (OUT 0x03D4, 0x0E)
5) 真的放入data (OUT 0x03D5, cursor location的high byte)

Bochs有一bebug工具叫bochsdbg,可在Bochs的install directory找到。常用指令:
- b 0x1000 (在0x1000位置set breakpoint)
- c (continue直到breakpoint)
- s (逐個指令行)
- r (列出所有register)
- x 0xb8000 (列出這個memory address的數值)
- q (quit)

2 則留言:

Unknown 說...

一个专为操作系统开发者與及汇编高手而设的x86-ia32调试器

http://code.google.com/p/peter-bochs/

bonep 說...

great! thx ^^