- commandblockguy tries ez80 assembly
- 07 Sep 2018 04:53:26 pm
- Last edited by commandblockguy on 08 Sep 2018 05:51:51 pm; edited 1 time in total
This week I wrote my first "real" assembly program. It's a CE cursor hook which prints the If, While, Repeat, or For statement that corresponds to each End statement.
It supports both ICE and TI-BASIC, and handles inline If statements (but not control statements inside inline if statements).
And the source, which is probably about twice as long as it need to be:
Code:
I'm using SPASM because I modified ICEHOOKS instead of making my own hook loader.
This still isn't super complete yet (Else statements do nothing, and the battery indicator is overwritten if the string is too long), but if you want to try it, a download is available here. This is an appvar, run ICE after transferring to install it.
It supports both ICE and TI-BASIC, and handles inline If statements (but not control statements inside inline if statements).
And the source, which is probably about twice as long as it need to be:
Code:
CursorHook_start:
.db 83h
cp a, 24h
jr nz, +_
inc a
ld a, b
ret
_: cp a, 22h
ret nz
ld a, (cxCurApp)
cp a, cxPrgmEdit
ret nz
ld hl, (editCursor)
ld a, (hl)
cp a, tSum
jr z, DrawDetText
cp a, tDet
jr z, DrawDetText
cp a, tEnd
ret nz
push hl
ld hl, DrawEndTextBegin
ld de, (rawKeyHookPtr)
add hl, de
jp (hl)
DrawDetText:
; Regular ICE hook stuff...
_: inc a
ret
DrawEndTextBegin:
pop hl
ld b, 1
DrawEndTextLoop:
ld de, (editTop)
scf
sbc hl, de
jr c, -_
add hl, de
ld a, (hl)
cp a, tIf
jr nz, +_
push hl
ld hl, (editTop)
ld a, (hl)
pop hl
cp a, tii
ld a, (hl)
jr z, ++_
_: cp a, tThen
jr z, +_
cp a, tWhile
jr z, +_
cp a, tRepeat
jr z, +_
cp a, tFor
jr z, +_
cp a, tEnd
jr nz, DrawEndTextLoop
inc b
jr DrawEndTextLoop
_: dec b
jr nz, DrawEndTextLoop
DrawEndTextEnd:
cp a, tThen
jr nz, ++_
_: ld de, (editTop)
scf
sbc hl, de
jr c, DrawEndTextExit
add hl, de
ld a, (hl)
cp a, tIf
jr nz, -_
_:
ld de, 000E71Ch
ld.sis (drawFGColor & 0FFFFh), de
ld.sis de, (statusBarBGColor & 0FFFFh)
ld.sis (drawBGColor & 0FFFFh), de
ld a, 14
ld (penRow),a
ld de, 2
ld.sis (penCol & 0FFFFh), de
DrawEndTextPrint:
push hl
call _Get_Tok_Strng
ld hl, OP3
call _VPutS
pop hl
ld a, (hl)
call _Isa2ByteTok
jr nz, +_
inc hl
_: inc hl
ld a, (hl)
cp a, tEnter
jr nz, DrawEndTextPrint
DrawEndTextExit:
or a, a
ret
I'm using SPASM because I modified ICEHOOKS instead of making my own hook loader.
This still isn't super complete yet (Else statements do nothing, and the battery indicator is overwritten if the string is too long), but if you want to try it, a download is available here. This is an appvar, run ICE after transferring to install it.