Advertisement
Zeda

Concat Grammer Module

Feb 9th, 2019
531
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "ti83plus.inc"
  2. #include "grammer.inc"
  3. #include "grammer2.5.inc"
  4. safearea = 8000h
  5. .db "Gram"
  6. .dw 0
  7. .dw 1
  8. .dw func0
  9. .org 0
  10. func0:
  11. ;=============================
  12. ;  String Concatration
  13. ;  Syntax:
  14. ;  $CC(String1,String2,...
  15. ;=============================
  16.     .db "CC",$10 ; String Concat
  17.     .dw func0_end-func0_start
  18. func0_start:
  19.  
  20. ;Get the first string
  21.     call ParseFullArg
  22.     cp 2Bh
  23.   ret nz
  24.   ld (TempWord1),bc   ;pointer to first
  25.   ld h,b
  26.   ld l,c
  27.   call GetGrammerStr
  28.   ld (TempWord2),bc   ;size of first
  29.  
  30. ;Destroy the existing tempvar
  31.     ld hl,saveSScreen+CONCATname-func0_start
  32.     rst rMov9ToOP1
  33.   bcall(_ChkFindSym)
  34.   jr c,+_   ;doesn't exist, so don't delete!
  35.   bcall(_DelVar)
  36. _:
  37.  
  38.  
  39. ;Get the second string
  40.     call ParseNextFullArg
  41.   ld (TempWord3),bc   ;pointer to second
  42.   ld h,b
  43.   ld l,c
  44.   call GetGrammerStr
  45.   ld (TempWord4),bc   ;size of second
  46.  
  47. ;Create the temp var with the size of both strings combined
  48.     ld hl,saveSScreen+CONCATname-func0_start
  49.     rst rMov9ToOP1
  50.   ld hl,(TempWord2)
  51.   ld bc,(TempWord4)
  52.   add hl,bc   ;Total size
  53.   inc hl      ;Will need to end with a null byte
  54.     ld a,16h    ;temp prog
  55.     bcall(_CreateVar) ; Current stack {size1,size2,ptr2,ptr1}
  56.   inc de
  57.   inc de
  58.  
  59. ;Now copy the first string
  60.   push de     ;gonna return this in BC, save for later
  61.   ld hl,(TempWord1)
  62.   ld bc,(TempWord2)
  63.   ld a,b      ;make sure size is non-zero!
  64.   or c
  65.   jr z,+_
  66.   ldir
  67. _:
  68. ;Now copy the second string
  69.   ld hl,(TempWord3)
  70.   ld bc,(TempWord4)
  71.   ld a,b      ;make sure size is non-zero!
  72.   or c
  73.   jr z,+_
  74.   ldir
  75. _:
  76.  
  77. ;Append a null byte
  78.   xor a
  79.   ld (de),a
  80.  
  81. ;Return
  82.   pop bc      ;BC is the pointer to both
  83.   ret
  84.  
  85. CONCATname:
  86.     .db 16h,"_concat_"
  87.  
  88. func0_end:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement