Wednesday, October 28, 2015

Disassembler in Action

I have a mechanism for attaching the disassembler to the breakpoint prompt. The applet in bank 1 has to have the disassember code because it's too big to fit with everything in bank 0. So, the address of the function is placed at 0x0024 and if that location is not 0, it is called. This has to be registered in main, so when the breakpoint occurs at the beginning of main, the disassember is not hooked up yet. But, see the output below. Once the debugger gets to 4074 disassembly is possible. The command is 'z' with optional number of instructions and then an optional start address. I still have a lot of diagnostic stuff in the breakpoint code that I'm ready to remove (e.g. "Set BP0 @ 4062 (6-0)" and "RST 20 to dd @ 4066").

Mark Hamann's Z80 Computer
App Build: 20:59:21 Oct  1 2015
BSP Build: 20:59:19 Oct  1 2015
C Lib Build: 20:08:20 Sep 30 2015
Menu
 1: dir
 2: run applet
 3: program intel hex
 4: utils menu
 5: drivers menu
> 3
In IHX program mode. Ensure that HW flow control is on.
Flash bank to program (0-f)? 4
Is this an applet (y/n)? n
Not erased. Erase (y/n)? y
Now, paste the .ihx contents
The mode will end on the :00000001FF
ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffDone!
> 2
Applet bank? (2-f)? c
Loading C vector bank 4 and applet bank c for version 0103 (ok=0)
Flash to RAM...
Prepping banks...
About to jump...
Set BP0 @ 4060 (6-0)
RST 20 to dd @ 4060
Breaking at main()
4060 e7
RST 20 from dd @ 4060
(brk @ 4060)> n
branch 00
Set BP0 @ 4062 (6-0)
RST 20 to dd @ 4062
RST 20 from dd @ 4062
(brk @ 4062)>
(brk @ 4062)> n
branch 00
Set BP0 @ 4066 (6-0)
RST 20 to dd @ 4066
RST 20 from dd @ 4066
(brk @ 4066)> n
branch 00
Set BP0 @ 4068 (6-0)
RST 20 to 21 @ 4068
RST 20 from 21 @ 4068
(brk @ 4068)> n
branch 00
Set BP0 @ 406b (6-0)
RST 20 to 39 @ 406b
RST 20 from 39 @ 406b
(brk @ 406b)> n
branch 00
Set BP0 @ 406c (6-0)
RST 20 to f9 @ 406c
RST 20 from f9 @ 406c
(brk @ 406c)> n
branch 00
Set BP0 @ 406d (6-0)
RST 20 to 21 @ 406d
RST 20 from 21 @ 406d
(brk @ 406d)> n
branch 00
Set BP0 @ 4070 (6-0)
RST 20 to e5 @ 4070
RST 20 from e5 @ 4070
(brk @ 4070)> z
(brk @ 4070)> n
branch 00
Set BP0 @ 4071 (6-0)
RST 20 to cd @ 4071
RST 20 from cd @ 4071
(brk @ 4071)> z
(brk @ 4071)> n
branch 18
Set BP0 @ 4074 (6-0)
RST 20 to 21 @ 4074
RST 20 from 21 @ 4074
(brk @ 4074)> z
4074: ld hl, 8080h
4077: ex (sp), hl
4078: call 3f23h
407b: pop af
407c: call 3f1dh
407f: ld hl, 007fh
4082: push hl
4083: call 3f11h
(brk @ 4074)> z 10 0
0: jp 0069h
3: rst 38h
4: rst 38h
5: rst 38h
6: rst 38h
7: rst 38h
8: jp 0db1h
b: rst 38h
c: rst 38h
d: rst 38h
e: rst 38h
f: rst 38h
10: jp 0dc2h
13: rst 38h
14: rst 38h
15: rst 38h
(brk @ 4074)> n
branch 00
Set BP0 @ 4077 (6-0)
RST 20 to e3 @ 4077
RST 20 from e3 @ 4077
(brk @ 4077)> z
4077: ex (sp), hl
4078: call 3f23h
407b: pop af
407c: call 3f1dh
407f: ld hl, 007fh
4082: push hl
4083: call 3f11h
4086: pop af
(brk @ 4077)> n
branch 00
Set BP0 @ 4078 (6-0)
RST 20 to cd @ 4078
RST 20 from cd @ 4078
(brk @ 4078)> n
branch 18
Set BP0 @ 407b (6-0)
RST 20 to f1 @ 407b
RST 20 from f1 @ 407b
(brk @ 407b)> z
407b: pop af
407c: call 3f1dh
407f: ld hl, 007fh
4082: push hl
4083: call 3f11h
4086: pop af
4087: ld hl, 0000h
408a: add hl, sp
(brk @ 407b)> c
branch 00
Set BP0 @ 407c (a-1)
RST 20 to cd @ 407c
RST 20 from cd @ 407c

OK, I cleaned up the diagnostic stuff. Here is what it looks like now:

Menu
 1: dir
 2: run applet
 3: program intel hex
 4: utils menu
 5: drivers menu
> 3
In IHX program mode. Ensure that HW flow control is on.
Flash bank to program (0-f)? 4
Is this an applet (y/n)? n
Not erased. Erase (y/n)? y
Now, paste the .ihx contents
The mode will end on the :00000001FF
fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffDone!
> 2
Applet bank? (2-f)? c
Loading C vector bank 4 and applet bank c for version 0103 (ok=0)
Flash to RAM...
Prepping banks...
About to jump...
Breaking at main()
4060 e7
(brk @ 4060)> n
(brk @ 4062)> n
(brk @ 4066)> n
(brk @ 4068)> n
(brk @ 406b)> n
(brk @ 406c)> n
(brk @ 406d)> n
(brk @ 4070)> n
(brk @ 4071)> n
(brk @ 4074)> n
(brk @ 4077)> z
4077: ex (sp), hl
4078: call 3f23h
407b: pop af
407c: call 3f1dh
407f: ld hl, 007fh
4082: push hl
4083: call 3f11h
4086: pop af
(brk @ 4077)> n
(brk @ 4078)> n
(brk @ 407b)> n
(brk @ 407c)> n
(brk @ 407f)> n
(brk @ 4082)> n
(brk @ 4083)> n
(brk @ 4086)> z
4086: pop af
4087: ld hl, 0000h
408a: add hl, sp
408b: ld d, l
408c: ld e, h
408d: ld bc, 40c7h
4090: push hl
4091: push de
(brk @ 4086)>

No comments:

Post a Comment