Day 19: Debugging

It dawned on me yesterday this whole silliness would be a lot easier if I had a debugger.  And of course I’ve made everything more complicated by insisting on using Z80 mnemonics, because the stock debugger, DDT, only speaks 8080.  I downloaded ZDT, which doesn’t have a manual, works mostly like DDT, and while it uses 8080 mnemonics, it at least recognizes the additional Z80 commands that DDT just misses (like the extended MOV commands).

The T command lets us single-step through the program

-T A=00 B=0000 D=015B H=0000 X=0000 Y=0000 S=01B8 P=0131 MVI C,09*0133 -T A=00 B=0009 D=015B H=0000 X=0000 Y=0000 S=01B8 P=0133 CALL 0005*0005

Note that MVI C,09 is 8080, in Z80, it’s LD C,09.  Also note that the B register listed above is the BC register, so the 09 is seen in the second byte.

Below we’re entering our CHARIN routine. The Call to 0005 is the call to BDOS. After that we end up jumping up to to that routine in high memory, and then it locks up. Dunno if that’s because it’s actually waiting for a character, but the whole thing locks up, and I’ve got to reboot.

Z E A=00 B=0000 D=015B H=0000 X=0000 Y=0000 S=01C0 P=0109 CALL 0145*0145 -t Z E A=00 B=0000 D=015B H=0000 X=0000 Y=0000 S=01BE P=0145 PUSH B*0146 -t Z E A=00 B=0000 D=015B H=0000 X=0000 Y=0000 S=01BC P=0146 PUSH D*0147 -t Z E A=00 B=0000 D=015B H=0000 X=0000 Y=0000 S=01BA P=0147 PUSH H*0148 -t Z E A=00 B=0000 D=015B H=0000 X=0000 Y=0000 S=01B8 P=0148 MVI C,01*014A -t Z E A=00 B=0001 D=015B H=0000 X=0000 Y=0000 S=01B8 P=014A CALL 0005*0005 -t Z E A=00 B=0001 D=015B H=0000 X=0000 Y=0000 S=01B6 P=0005 JMP BF00*BF00 -t Z E A=00 B=0001 D=015B H=0000 X=0000 Y=0000 S=01B6 P=BF00 JMP C8F2*C8F2 -t Z E A=00 B=0001 D=015B H=0000 X=0000 Y=0000 S=01B6 P=C8F2 XTHL *C8F3 -t Z E A=00 B=0001 D=015B H=014D X=0000 Y=0000 S=01B6 P=C8F3 SHLD D5C8*C8F6 -t Z E A=00 B=0001 D=015B H=014D X=0000 Y=0000 S=01B6 P=C8F6 XTHL *C8F7 -t Z E A=00 B=0001 D=015B H=0000 X=0000 Y=0000 S=01B6 P=C8F7 JMP D806

This entry was posted in Blinking Lights. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *