LZ: new debugger program
[Prev][Next][Index][Thread]
LZ: new debugger program
-
Subject: LZ: new debugger program
-
From: David Kristensen <dkristensen@cctr.umkc.edu>
-
Date: Wed, 24 Jul 1996 22:26:59 +0200
-
In-Reply-To: <>
If you liked the debug program, you'll love debugger. I have added some new
features, such as displaying the registers a, b, c, d, e, h, and l as hex,
binary, and decimal, as well as displaying all the flags in binary. I
haven't tested it much, although I know all the registers work, I just
haven't tested the flags yet. I have also attached an example program that
should show how it works. Like the debug program, pressing clear will exit
the program. NOTE, however, that this will only work if you include the
support for it (see the define at the top of the try program). You can
disable this by changing the debugging program, although I do not recommend
it. Sometimes you can get caught in a loop (which normally would crash your
calc), but now you can get out of it by pressing clear. You still have to be
careful to not exit the program if you have a register pushed or popped, or
your calc will crash (or at least do something weird).
Disclaimer: you know the drill, I am not responsible for any damage this
causes, etc. If used right, it will cause none, and if used wrong, you
should have a backup anyway ...
It would be nice if you use this program for a game or something that you
release to say: "Tested by David Kristensen's Debugger program" or something
like that.
Even if you never use this program, I advise non-expert programmers to look
at it. I know I learned a lot just by writing it. (Like you can push af,
then pop bc, then examine the c register to see the flags, I also learned a
good way to display hex numbers).
Enjoy!
DEBUG:
push af
push bc
push de
push hl
push hl
push de
ld hl, $0000
ld (CURSOR_ROW), hl
ld hl, data
ld de, (PROGRAM_ADDR)
add hl, de
ROM_CALL(D_ZT_STR)
ld hl, $0802
ld (CURSOR_ROW), hl
CALL_(TEST)
ld hl, $0800
ld (CURSOR_ROW), hl
ld c, a
CALL_(TEST)
ld hl, $0801
ld (CURSOR_ROW), hl
ld c, b
CALL_(TEST)
ld hl, $0803
ld (CURSOR_ROW), hl
pop de
ld c, d
CALL_(TEST)
ld hl, $0804
ld (CURSOR_ROW), hl
ld c, e
CALL_(TEST)
ld hl, $0805
ld (CURSOR_ROW), hl
pop hl
ld c, h
CALL_(TEST)
ld c, l
ld hl, $0806
ld (CURSOR_ROW), hl
CALL_(TEST)
ld hl, $0807
ld (CURSOR_ROW), hl
push af
pop bc
CALL_(TEST)
pop hl
pop de
pop bc
pop af
push af
push bc
push de
push hl
push hl
push af
push hl
push hl
ld hl, $1000
ld (CURSOR_ROW), hl
ld l, a
CALL_(TESTDEC)
ld hl, $1001
ld (CURSOR_ROW), hl
ld l, b
CALL_(TESTDEC)
ld hl, $1002
ld (CURSOR_ROW), hl
ld l, c
CALL_(TESTDEC)
ld hl, $1003
ld (CURSOR_ROW), hl
ld l, d
CALL_(TESTDEC)
ld hl, $1004
ld (CURSOR_ROW), hl
ld l, e
CALL_(TESTDEC)
ld hl, $1005
ld (CURSOR_ROW), hl
pop hl
ld l, h
CALL_(TESTDEC)
ld hl, $1006
ld (CURSOR_ROW), hl
pop hl
CALL_(TESTDEC)
ld hl, $0400
ld (CURSOR_ROW), hl
pop af
CALL_(TESTHEX)
ld hl, $0401
ld (CURSOR_ROW), hl
ld a, b
CALL_(TESTHEX)
ld hl, $0402
ld (CURSOR_ROW), hl
ld a, c
CALL_(TESTHEX)
ld hl, $0403
ld (CURSOR_ROW), hl
ld a, d
CALL_(TESTHEX)
ld hl, $0404
ld (CURSOR_ROW), hl
ld a, e
CALL_(TESTHEX)
ld hl, $0405
ld (CURSOR_ROW), hl
pop hl
ld a, h
CALL_(TESTHEX)
ld a, l
ld hl, $0406
ld (CURSOR_ROW), hl
CALL_(TESTHEX)
Loopz:
call GET_KEY
or a
jr z, Loopz
pop hl
pop de
pop bc
cp $F
jr z, nooo
pop af
ret
nooo: pop bc
ret
TEST: push bc
ld b, 8
TESTBIN:
push af
ld a, '1'
bit 7, c
CALL_Z(z0)
ROM_CALL(TX_CHARPUT)
rlc c
pop af
djnz TESTBIN
pop bc
ret
z0: ld a, '0'
ret
TESTDEC:
push de
ld h, 0
ROM_CALL(D_HL_DECI)
pop de
ret
TESTHEX: ; note: I got the idea for the following routine from the
hexview.85s program
push af
push bc
push de
ld b, a
and $F0
rrca
rrca
rrca
rrca
add a, $30
cp $3A
jr c, dec
sub $30
dec:
ROM_CALL(TX_CHARPUT)
ld a, b
and $0F
add a, $30
cp $3A
jr c, deci
sub $30
deci:
ROM_CALL(TX_CHARPUT)
pop de
pop bc
pop af
ret
data: .db ":a $ %",$D6,"b $ %",$D6,"c $ %",$D6
.db "d $ %",$D6,"e $ %",$D6,"h $ %",$D6
.db "l $ %",$D6,"flags %", 0
And the "try" program:
#include "ti-85.h"
#DEFINE debug CALL_(DEBUG) \ cp $F \ jr z, Exit
.org 0
.db "try programs", 0
ROM_CALL(CLEARLCD)
ld bc, $0000
push bc
pop af
ld bc, $0102
ld de, $0304
ld hl, $0506
debug
ld bc, $0700
push bc
pop af
ld bc, $0809
ld de, $0A0B
ld hl, $0C0D
debug
ld bc, $0E00
push bc
pop af
ld bc, $0F10
ld de, $1112
ld hl, $1314
debug
ld bc, $1500
push bc
pop af
ld bc, $1617
ld de, $1819
ld hl, $1A1B
debug
ld bc, $1C00
push bc
pop af
ld bc, $1D1E
ld de, $1F20
ld hl, $AAFF
debug
ret
Exit:
ld hl,$8C40
set 1,(hl)
ret
#include "debugger.asm"
.End
David Kristensen at the University of Missouri - Kansas City
dkristensen@cctr.umkc.edu
The Mind conquers All...