Advertisement
Guest User

Untitled

a guest
Feb 8th, 2019
98
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.     call ParseFullArg
  20.     cp 2Bh ; check for comma
  21.     ret z ; need more than 1 argu
  22.     push bc \ pop hl \ push hl ; save string pointer/load it to hl
  23.     call saveSScreen+GetGrammerStr-func0_start
  24.     pop hl ; grab string pointer. BC is now a size of the tokens.
  25.     push hl
  26.     push bc ; save size and string pointer
  27.     ld hl,saveSScreen+CONCATname-func0_start-1
  28.     rst 10h ; rMov9ToOP1
  29.     pop hl ; load byte size to hl
  30.     push hl
  31.     ld a,16h ; I want to create a temp prog
  32.     bcall(_CreateVar) ; Current stack {sizebyte,pointer to tokens}
  33.     pop bc
  34.     pop hl
  35.     push de
  36.     push bc ; Current stack {sizebyte,pointer to prgmCC}
  37.     inc de
  38.     inc de ; calibrate location for ldir
  39.     ldir ; prgmCC now contains the initial string
  40. grabrest:
  41.     call ParseNextFullArg
  42.     cp 2Bh
  43.     ret z
  44.     push bc \ pop hl \ push hl
  45.     call saveSScreen+GetGrammerStr-func0_start
  46.     pop hl ; grab string pointer. BC is now a size of the tokens.
  47.     push hl
  48.     push bc ; save size and string pointer
  49.     ld hl,saveSScreen+TEMPname-func0_start-1
  50.     rst 10h ; rMov9ToOP1
  51.     pop hl ; load byte size to hl
  52.     push hl
  53.     ld a,16h ; I want to create a temp prog
  54.     bcall(_CreateVar) ; Current stack {sizebyte,pointer to tokens,totalsizebye,pointer to prgmCC}
  55.     pop bc
  56.     pop hl
  57.     push de
  58.     push bc ; Current stack {sizebyte of TEMP,pointer to TEMP,totalsizebyte,pointer to prgmCC}
  59.     inc de
  60.     inc de ; calibrate location for ldir
  61.     ldir ; prgmTEMP now contains the next string
  62.     pop bc \ pop de \ pop hl \ pop ix
  63.     push ix \ push hl
  64.     add hl,bc
  65.     ld (ix),l
  66.     ld (ix+1),h ; change size data
  67.     dec ix
  68.     dec ix
  69.     pop hl
  70.     add ix,hl ; calibrate to last byte of CC
  71.     push hl \ push de \ push bc
  72.     push bc \ pop hl
  73.     push ix \ pop de
  74.     bcall(_InsertMem) ; CC size should be increased now
  75.     inc de ; calibrate for ldir
  76.     pop bc ; TEMP size
  77.     pop hl ; TEMP loc
  78.     push hl ; save TEMP loc
  79.     inc hl
  80.     inc hl ; calibrate for ldir
  81.     pop ix
  82.     add ix,bc
  83.     push ix ; stores new size for CC
  84.     ldir ; concat happens Stack: {TEMP loc, totalsize, CC loc}
  85.     ; code to delete prgmTEMP
  86.     ; code will end with Stack: {totalsize, CC loc}
  87.     jr grabrest
  88.     pop hl
  89.     pop bc
  90.     inc bc
  91.     inc bc 
  92.     ret
  93. func0_end:
  94.  
  95. TEMPname:
  96.     .db "TEMP"
  97. CONCATname:
  98.     .db "CC"
  99. GetGrammerStr:
  100.   ld bc,0
  101. _:
  102.   inc hl
  103.   inc bc
  104.   ld a,(hl)
  105.   cp 4 \ ret z
  106.   cp 3Fh \ ret z
  107.   cp 2Ah \ jr nz,-_
  108.   inc hl
  109.   ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement