Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "ti83plus.inc"
- #include "grammer.inc"
- #include "grammer2.5.inc"
- safearea = 8000h
- .db "Gram"
- .dw 0
- .dw 1
- .dw func0
- .org 0
- func0:
- ;=============================
- ; String Concatration
- ; Syntax:
- ; $CC(String1,String2,...
- ;=============================
- .db "CC",$10 ; String Concat
- .dw func0_end-func0_start
- func0_start:
- ;Get the first string
- call ParseFullArg
- cp 2Bh
- ret nz
- ld (TempWord1),bc ;pointer to first
- ld h,b
- ld l,c
- call GetGrammerStr
- ld (TempWord2),bc ;size of first
- ;Destroy the existing tempvar
- ld hl,saveSScreen+CONCATname-func0_start
- rst rMov9ToOP1
- bcall(_ChkFindSym)
- jr c,+_ ;doesn't exist, so don't delete!
- bcall(_DelVar)
- _:
- ;Get the second string
- call ParseNextFullArg
- ld (TempWord3),bc ;pointer to second
- ld h,b
- ld l,c
- call GetGrammerStr
- ld (TempWord4),bc ;size of second
- ;Create the temp var with the size of both strings combined
- ld hl,saveSScreen+CONCATname-func0_start
- rst rMov9ToOP1
- ld hl,(TempWord2)
- ld bc,(TempWord4)
- add hl,bc ;Total size
- inc hl ;Will need to end with a null byte
- ld a,16h ;temp prog
- bcall(_CreateVar) ; Current stack {size1,size2,ptr2,ptr1}
- inc de
- inc de
- ;Now copy the first string
- push de ;gonna return this in BC, save for later
- ld hl,(TempWord1)
- ld bc,(TempWord2)
- ld a,b ;make sure size is non-zero!
- or c
- jr z,+_
- ldir
- _:
- ;Now copy the second string
- ld hl,(TempWord3)
- ld bc,(TempWord4)
- ld a,b ;make sure size is non-zero!
- or c
- jr z,+_
- ldir
- _:
- ;Append a null byte
- xor a
- ld (de),a
- ;Return
- pop bc ;BC is the pointer to both
- ret
- CONCATname:
- .db 16h,"_concat_"
- func0_end:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement