;(saferam1 = saveSScreen)
name_str = saferam1
size = saferam1+2
code_start = saferam1+4
start:
bcall(_RclAns) ;set pointer into OP1
cp 4
ret nz
ld hl,$55 ;ASCII for 'U'
ld (name_str),hl ;save zero terminated string name
ld (OP1+1),hl
ld hl,code_start
ex de,hl ;de = code_start, hl = ans ptr?
ld c,(hl) ;i assume bc = size of Ans
inc hl
ld b,(hl)
inc hl
ld (size),bc
ldir ;copy code in Ans into saferam
bcall(_ChkFindSym)
jr c,not_found
bcall(_DelVarArc) ;del prgmU if it existed
not_found:
ld a,5 ;5 = non-protected program
ld hl,saferam1
bcall(_ExecuteNewPrgm) ;a = var type, hl = pointer to structure (zero terminated string, size (word), program data)
ret
I feel like the problem is probably with how ExecuteNewPrgm works. Though that's a really roundabout way of doing it, why don't you use the _CreateRList (http://wikiti.brandonw.net/index.php?title=83Plus:BCALLs:4315) bcall? Also, how will you write to/read from the list later?
Though that's a really roundabout way of doing it, why don't you use the _CreateRList bcall? Also, how will you write to/read from the list later?I already said, I don't know any ASM so _CreateRList bcall means nothing for me.
Hmm... I cant imagine what makes the program stop (in fact I only found out that removing the ret/C9... guess what...:) Doesn't crash, it still completely stops the program!)... Is there any other way to do that?What is happening here is that all of the memory after the data is being executed as code. It may be exiting properly if it comes across an RET instruction, but it may also instead be jumping into the middle of an OS routine that makes it appear to exit without any problems. I've done this a number of times when I was first experimenting-- the program exited fine, it seemd like everything was alright, then a while later there was a crash or I would look through the memory menu and see lots of glitchy things. Presumably the data executed as code managed to jump around RAM, editing things to unknown values.
What I need is just a text editor which stores the documents in lists... And the lists' names are the document names.
Wait, doesn't it mean it just fails executing and stops before that?
#include "includes/ti83plus.inc"
.db t2ByteTok,tasmCmp ;the AsmPrgm token
.org $9D95 ;progstart, all asm programs are loaded to this address in RAM
saferam1 =$86EC ;saveSScreen=768
name_str = saferam1
size = saferam1+7
code_start = saferam1+9
start:
bcall(_RclAns) ;de = start of data, first two bytes are size bytes
cp 4 ;if ans is a string, a = 4
ret nz
ex de,hl
ld e,(hl)
inc hl
ld d,(hl) ;de = size of Ans
inc hl
ld a,(hl) ;a = action # (1 or 2)
inc hl ;hl = start of string name
dec de ;the first byte is the action number
dec de
dec de
dec de
dec de
dec de ;-5 for the string name
ld (size),de
dec hl
ld (hl),AppVarObj
ld de,name_str ;copy name in Ans to name_str
ld bc,6
ldir
ld (code_start),hl
ex de,hl
ld (hl),0
ld hl,name_str
rst 20h ;_Mov9ToOP1, copy 9 bytes from (hl) to OP1 (copies our AppVar name)
sub '1' ;$31
jr z,write_appvar
dec a
ret nz
read_appvar:
bcall(_ChkFindSym)
ret c
ex de,hl
ld c,(hl) ;first two bytes are the size bytes
inc hl
ld b,(hl) ;bc = size of Ans
inc hl
ld (size),bc
ld de,code_start
ldir ;copy the whole string to code_start
bcall(_AnsName)
bcall(_ChkFindSym)
bcall(_DelVar)
bcall(_AnsName)
bcall(_ChkFindSym)
ld a,StrngObj
ld hl,(size)
bcall(_CreateVar)
ld bc,(size)
inc bc
inc bc ;rewrite the size bytes
ld hl,size
ldir
ret
write_appvar:
ld hl,(size)
bcall(_EnoughMem) ;check if we've got enough space to create the AppVar
ret c
ex de,hl
push hl
push hl
bcall(_ChkFindSym) ;OP1 = name of variable to find
jr c,$+5
bcall(_DelVarArc) ;delete AppVar if it already exists
pop hl
bcall(_CreateAppVar) ;OP1 = name, hl = size
pop bc
inc de
inc de ;skip size word
ld hl,(code_start)
ldir ;copy Ans into AppVar
ret
RclVarSym will recall the contents of the variable to OP1 if it is real, to OP1 and OP2 if the variable is complex and otherwise leaves the name as is in OP1 and returns HL as the symbol table pointer and DE as the data pointer as in ChkFindSym.