[048][x86汇编语言]第十五章 习题2解答:Bochs调试

2018-07-06  本文已影响23人  AkuRinbu

第十五章 习题2解答:切换任务 core->A->B->core

https://www.jianshu.com/p/659adf08e419

第十五章 习题2解答:完整源码

https://www.jianshu.com/p/81a518d918d8

准备文件.lst(.lst文件的汇编地址就是定断点时的段内偏移量)

c13_mbr.lst
ex15-2_core.lst
ex15-2_A.lst
ex15-2_B.lst

Bochs 调试命令(以及配置方法)

配置方法见 https://www.jianshu.com/p/e8eea9f2ceb5

调试思路

Bochs调试过程

<bochs:1> s
<bochs:2> b 0x7c00
<bochs:3> c
<bochs:4> b 0x7d38
<bochs:5> c
    (0) Breakpoint 2, 0x0000000000007d38 in ?? ()
    Next at t=17419248
    (0) [0x000000007d38] 0010:0000000000000138 (unk. ctxt): jmpf ds:[edi+16]          ; ff6f10
<bochs:6> s
    Next at t=17419249
    (0) [0x0000000416c6] 0038:00000000000003fa (unk. ctxt): mov ecx, 0x00000030       ; b930000000
<bochs:7> b 0x0038:0x057c
<bochs:8> c
    (0) Breakpoint 3, 0x0000000000041848 in ?? ()
    Next at t=17454245
(0) [0x000000041848] 0038:000000000000057c (unk. ctxt): jmpf es:[ecx+20]          ; 26ff6914
<bochs:9> s
    Next at t=17454246
(0) [0x000000104d1c] 000f:0000000000000000 (unk. ctxt): mov ax, ds                ; 8cd8
<bochs:10> b 0x000f:0x002f
<bochs:11> c
    (0) Breakpoint 4, 0x0000000000104d4b in ?? ()
    Next at t=17462166
    (0) [0x000000104d4b] 000f:000000000000002f (unk. ctxt): mov ebx, dword ptr fs:0x00000428 ; 648b1d28040000
<bochs:12> s
    Next at t=17462167
    (0) [0x000000104d52] 000f:0000000000000036 (unk. ctxt): callf fs:0x00000328       ; 64ff1d28030000

<bochs:13> s
    Next at t=17462168
    (0) [0x000000040249] 0028:0000000000000231 (unk. ctxt): mov eax, 0x00000008       ; b808000000
<bochs:14> s
    Next at t=17462169
    (0) [0x00000004024e] 0028:0000000000000236 (unk. ctxt): mov es, ax                ; 8ec0
<bochs:15> s
    Next at t=17462170
    (0) [0x000000040250] 0028:0000000000000238 (unk. ctxt): jmpf es:[ebx+20]          ; 26ff6b14
<bochs:16> s
    Next at t=17462171
    (0) [0x0000001005cc] 000f:0000000000000000 (unk. ctxt): mov ax, ds                ; 8cd8
<bochs:17> b 0x000f:0x002f
<bochs:18> c
    (0) Breakpoint 5, 0x00000000001005fb in ?? ()
    Next at t=17470091
    (0) [0x0000001005fb] 000f:000000000000002f (unk. ctxt): callf fs:0x00000128       ; 64ff1d28010000
<bochs:19> s
    Next at t=17470092
    (0) [0x000000040212] 0028:00000000000001fa (unk. ctxt): pushf                     ; 9c
<bochs:20> s
    Next at t=17470093
    (0) [0x000000040213] 0028:00000000000001fb (unk. ctxt): mov edx, dword ptr ss:[esp] ; 8b1424
<bochs:21> s
    Next at t=17470094
    (0) [0x000000040216] 0028:00000000000001fe (unk. ctxt): add esp, 0x00000004       ; 81c404000000
<bochs:22> s
    Next at t=17470095
    (0) [0x00000004021c] 0028:0000000000000204 (unk. ctxt): mov eax, 0x00000030       ; b830000000
<bochs:23>
    Next at t=17470096
    (0) [0x000000040221] 0028:0000000000000209 (unk. ctxt): mov ds, ax                ; 8ed8
<bochs:24> s
    Next at t=17470097
    (0) [0x000000040223] 0028:000000000000020b (unk. ctxt): test dx, 0x4000           ; 66f7c20040
<bochs:25> s
    Next at t=17470098
    (0) [0x000000040228] 0028:0000000000000210 (unk. ctxt): jnz .+18 (0x0004023c)     ; 7512
<bochs:26> s
    Next at t=17470099
    (0) [0x00000004022a] 0028:0000000000000212 (unk. ctxt): mov ebx, 0x00000ff1       ; bbf10f0000
<bochs:27> s
    Next at t=17470100
    (0) [0x00000004022f] 0028:0000000000000217 (unk. ctxt): callf 0x0028:00000000     ; 9a000000002800
<bochs:28> s
    Next at t=17470101
    (0) [0x000000040018] 0028:0000000000000000 (unk. ctxt): push ecx                  ; 51
<bochs:29> s
    Next at t=17470102
    (0) [0x000000040019] 0028:0000000000000001 (unk. ctxt): mov cl, byte ptr ds:[ebx] ; 8a0b
<bochs:30> s
    Next at t=17470103
    (0) [0x00000004001b] 0028:0000000000000003 (unk. ctxt): or cl, cl                 ; 08c9
    
<bochs:31> b 0x0028:0x021e
<bochs:32> c
    (0) Breakpoint 6, 0x0000000000040236 in ?? ()
    Next at t=17482903
    (0) [0x000000040236] 0028:000000000000021e (unk. ctxt): jmpf ds:0x00000e2d        ; ff2d2d0e0000
<bochs:33> s
    Next at t=17482904
    (0) [0x00000004184c] 0038:0000000000000580 (unk. ctxt): mov ebx, 0x00000f2f       ; bb2f0f0000
<bochs:34> s
    Next at t=17482905
    (0) [0x000000041851] 0038:0000000000000585 (unk. ctxt): callf 0x0028:00000000     ; 9a000000002800
<bochs:35> s
    Next at t=17482906
    (0) [0x000000040018] 0028:0000000000000000 (unk. ctxt): push ecx                  ; 51
<bochs:36> b 0x0038:0x058c
<bochs:37> c
    (0) Breakpoint 7, 0x0000000000041858 in ?? ()
    Next at t=17487518
    (0) [0x000000041858] 0038:000000000000058c (unk. ctxt): hlt                       ; f4

调试图解

1、完成 从core到A A通过调用门即将切换到任务B.png 2、顺利从A切换到B 现在从B直接返回到core.png 3、顺利从B返回到程序管理器core.png
上一篇下一篇

猜你喜欢

热点阅读