Author Topic: Need help with ExecAns//NikProgrammer  (Read 7440 times)

0 Members and 1 Guest are viewing this topic.

Offline NikProgrammer

  • LV3 Member (Next: 100)
  • ***
  • Posts: 50
  • Rating: +0/-0
  • Calc's are the most handy thing ever invented :D
    • View Profile
Need help with ExecAns//NikProgrammer
« on: June 16, 2014, 06:25:42 pm »
So...
ExecAns is a Hex Program, it takes a string in Ans as Input, deletes prgmU, creates it again, copies Ans to prgmU and runs it... I use it to crate/edit a custom named list. Ans equals "matr>list(|F|,Lxxxxx)". I use 'matr>list()' because I can't use the -> sign in strings without some help of the user... But, well, this is not important in the problem (I think). The problem is when I call ExecAns as subprogram from prgmNFTEXT it creates a fine prgmU with a fine 'matr>list(|F|,Lxxxxx)' but intstead of running it and returning to the prgmNFTEXT it returns to the OS.



Codes:


PrgmNFTEXT

:;Much code, not important. The name of the list is alteady in Str0
:"matr>list(|F|,L"+Str0 ;Input for ExecAns
:Asm(prgmExecAns
:Pause ;I will work on here when the problem is solved. The pause is only to check if the program reached it but is doesn't.


Prgm ExecAns

AsmPrgm
EFD74A
FE04C0
215500
22EC86227984
21F086
EB4E234623
ED43EE86
EDB0
3E05327884
EFF142
3803EFC64F
3E0521EC86
EF3C4C
C9
Well, I'm not english or american so if anything posted by me is not correct just say or ignore...
And please don't set me back because I live in germay... Though I speak german I am still from UA!
––––––––––––––––––––––––––––––––––––––––––––––––––––
It may sound weird but:
'The teapot cools down long.'
and
'The teapot does not cool down long.'
means the same.

What for do we live? - To think of why we do live.
––––––––––––––––––––––––––––––––––––––––––––––––––––
Loving chess- If you know any good chess programs for TI-83+ please PM me- thanks!
Working on Remakes for all of my programs to optimize them and add more user friendliness... And most important: Graphics. I'm not good at graphics, every help is welcome... -Please PM too.

Offline ben_g

  • Hey cool I can set a custom title now :)
  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +125/-4
  • Asm noob
    • View Profile
    • Our programmer's team: GameCommandoSquad
Re: Need help with ExecAns//NikProgrammer
« Reply #1 on: June 16, 2014, 06:38:26 pm »
I can't really help you with the HEX program, sorry, but maybe there is an other way of doing what you want to do.
For what do you need custom-named lists? They are hard to create, and it's hard to know which ones are used by your program. If you need to remember names or other text, then you might want to save it in a different way than in custom-named lists.
If you really need them though, then you should try running it in an emulator that has a debugger. (an example of this is wabbitemu)Then you can see what the program does step by step, and track down the orgin of your problem. To make debugging easier, you can add F376 to the start of the (assembly) program (ONLY WHEN YOU4RE EMULATING IT) which basically freezes the calc, but you can disable the halt mode of the CPU from within the debugger to make it continue executing the program.
My projects
 - The Lost Survivors (Unreal Engine) ACTIVE [GameCommandoSquad main project]
 - Oxo, with single-calc multiplayer and AI (axe) RELEASED (screenshot) (topic)
 - An android version of oxo (java)  ACTIVE
 - A 3D collision detection library (axe) RELEASED! (topic)(screenshot)(more recent screenshot)(screenshot of it being used in a tilemapper)
Spoiler For inactive:
- A first person shooter with a polygon-based 3d engine. (z80, will probably be recoded in axe using GLib) ON HOLD (screenshot)
 - A java MORPG. (pc) DEEP COMA(read more)(screenshot)
 - a minecraft game in axe DEAD (source code available)
 - a 3D racing game (axe) ON HOLD (outdated screenshot of asm version)

This signature was last updated on 20/04/2015 and may be outdated

Offline chickendude

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 817
  • Rating: +90/-1
  • Pro-Riot Squad
    • View Profile
Re: Need help with ExecAns//NikProgrammer
« Reply #2 on: June 16, 2014, 11:47:11 pm »
I already posted the mnemonics version in the other thread. There are very few people here who can look at the hex codes and understand it easily without having to look them up. Here're the mnemonics:
Code: [Select]
;(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 bcall? Also, how will you write to/read from the list later?

Offline NikProgrammer

  • LV3 Member (Next: 100)
  • ***
  • Posts: 50
  • Rating: +0/-0
  • Calc's are the most handy thing ever invented :D
    • View Profile
Re: Need help with ExecAns//NikProgrammer
« Reply #3 on: June 18, 2014, 02:40:49 am »
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.
And the second answer, to edit a list I do:

:List>matr(Lxxxxx,|F|)  ;Like creating the list. I will use ExecAns for that
:                                  ;Blahblah, editing |F|
:Matr>List(|F|,Lxxxxx)  ;Again with ExecAns


I know, the code is a bit weird but it should work if ExecAns would not stop the main program... Or if there is another way, TI-Basic or ASM, I'd be very happy to find it.
Well, I'm not english or american so if anything posted by me is not correct just say or ignore...
And please don't set me back because I live in germay... Though I speak german I am still from UA!
––––––––––––––––––––––––––––––––––––––––––––––––––––
It may sound weird but:
'The teapot cools down long.'
and
'The teapot does not cool down long.'
means the same.

What for do we live? - To think of why we do live.
––––––––––––––––––––––––––––––––––––––––––––––––––––
Loving chess- If you know any good chess programs for TI-83+ please PM me- thanks!
Working on Remakes for all of my programs to optimize them and add more user friendliness... And most important: Graphics. I'm not good at graphics, every help is welcome... -Please PM too.

Offline Runer112

  • Moderator
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Need help with ExecAns//NikProgrammer
« Reply #4 on: June 18, 2014, 08:41:35 am »
If you don't know what a B_CALL does, look for it on WikiTI or in TI's official documentation. Most of the important ones are documented, including _CreateRList. It's actually documented in both, but I can only directly link to WikiTI's documentation (which is slightly better anyways).

Offline NikProgrammer

  • LV3 Member (Next: 100)
  • ***
  • Posts: 50
  • Rating: +0/-0
  • Calc's are the most handy thing ever invented :D
    • View Profile
Re: Need help with ExecAns//NikProgrammer
« Reply #5 on: June 22, 2014, 05:17:50 pm »
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 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?
« Last Edit: June 22, 2014, 05:37:13 pm by NikProgrammer »
Well, I'm not english or american so if anything posted by me is not correct just say or ignore...
And please don't set me back because I live in germay... Though I speak german I am still from UA!
––––––––––––––––––––––––––––––––––––––––––––––––––––
It may sound weird but:
'The teapot cools down long.'
and
'The teapot does not cool down long.'
means the same.

What for do we live? - To think of why we do live.
––––––––––––––––––––––––––––––––––––––––––––––––––––
Loving chess- If you know any good chess programs for TI-83+ please PM me- thanks!
Working on Remakes for all of my programs to optimize them and add more user friendliness... And most important: Graphics. I'm not good at graphics, every help is welcome... -Please PM too.

Offline chickendude

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 817
  • Rating: +90/-1
  • Pro-Riot Squad
    • View Profile
Re: Need help with ExecAns//NikProgrammer
« Reply #6 on: June 23, 2014, 07:08:37 pm »
It would be easier to use _CreateRList and pass the information in the list. But why not just use an AppVar instead? I don't think lists can hold strings, so you'd have to break your strings down into different entries and it'd just be complex. With an AppVar you can just store your string directly since it's essentially just a block of memory, and as a bonus you don't have to worry about people editing them except with your program.

Offline NikProgrammer

  • LV3 Member (Next: 100)
  • ***
  • Posts: 50
  • Rating: +0/-0
  • Calc's are the most handy thing ever invented :D
    • View Profile
Re: Need help with ExecAns//NikProgrammer
« Reply #7 on: June 24, 2014, 12:01:46 pm »
Hmm... I don't want to store strings, I use 5 ASCII characters in a number and get a pretty compact way of storage. And I just have to repeat I am programming in Basic and don't know any ASM.
Well, I'm not english or american so if anything posted by me is not correct just say or ignore...
And please don't set me back because I live in germay... Though I speak german I am still from UA!
––––––––––––––––––––––––––––––––––––––––––––––––––––
It may sound weird but:
'The teapot cools down long.'
and
'The teapot does not cool down long.'
means the same.

What for do we live? - To think of why we do live.
––––––––––––––––––––––––––––––––––––––––––––––––––––
Loving chess- If you know any good chess programs for TI-83+ please PM me- thanks!
Working on Remakes for all of my programs to optimize them and add more user friendliness... And most important: Graphics. I'm not good at graphics, every help is welcome... -Please PM too.

Offline chickendude

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 817
  • Rating: +90/-1
  • Pro-Riot Squad
    • View Profile
Re: Need help with ExecAns//NikProgrammer
« Reply #8 on: June 25, 2014, 11:11:38 am »
That number probably takes up 1 byte per letter, anyway, plus any overhead for a new list entry. If you store them directly as strings in an AppVar i think it'd be easier and more efficient. I could write something that takes the string in Ans and writes it to a certain AppVar. It wouldn't be too hard.
« Last Edit: June 25, 2014, 11:14:27 am by chickendude »

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Need help with ExecAns//NikProgrammer
« Reply #9 on: June 25, 2014, 11:31:36 am »
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 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?
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.

Offline NikProgrammer

  • LV3 Member (Next: 100)
  • ***
  • Posts: 50
  • Rating: +0/-0
  • Calc's are the most handy thing ever invented :D
    • View Profile
Re: Need help with ExecAns//NikProgrammer
« Reply #10 on: June 25, 2014, 12:06:16 pm »
These two last replies where the mist helpful...
So @xeda Maybe you are right but I tried everything you can do with this program on an emilator and got no problems... The weirdest thing was if you temove the code line by line and execute it after each change it will do exactly the same thing until you remove the AsmPrgm- then it throws an error. (Yes, this means that I got a program with only AsmPrgm inside and it created a prgmU with a string inside :D) I also once just removed the C9 (probably you read it)but nothing else not-normal.
And @Chickendude, this would be probably the best way... But this will be harder than you think because I need to edit these appvars. That's why I use lists, for me it's the easiest way to make editable appvars and if I did not want to name them like the document there were no problems... So IF you can write a short program to create, edit, read and delete appvars (maybe even supporting lists and strings)- this would be VERY good and I would be very thankful... But else you don't ever have to try, this would be just spent-for-nothing time... Maybe it really shouldn't be appvars, only something like ExecAns that doesn't stop. I can handle the rest with the program...

Is there anything new?
« Last Edit: June 28, 2014, 10:24:15 am by NikProgrammer »
Well, I'm not english or american so if anything posted by me is not correct just say or ignore...
And please don't set me back because I live in germay... Though I speak german I am still from UA!
––––––––––––––––––––––––––––––––––––––––––––––––––––
It may sound weird but:
'The teapot cools down long.'
and
'The teapot does not cool down long.'
means the same.

What for do we live? - To think of why we do live.
––––––––––––––––––––––––––––––––––––––––––––––––––––
Loving chess- If you know any good chess programs for TI-83+ please PM me- thanks!
Working on Remakes for all of my programs to optimize them and add more user friendliness... And most important: Graphics. I'm not good at graphics, every help is welcome... -Please PM too.

Offline chickendude

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 817
  • Rating: +90/-1
  • Pro-Riot Squad
    • View Profile
Re: Need help with ExecAns//NikProgrammer
« Reply #11 on: June 28, 2014, 03:17:57 pm »
I just wrote a program (151 bytes) that takes the following format: [1:NAME_OF_APPVAR:STRING_TO_STORE] to store a string to an AppVar or [2:NAME_OF_APPVAR] to store the contents of the AppVar into Ans. Here's the assembly:
Code: [Select]
#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

The AppVar name must be 5 characters long, if you don't want to use 5 characters just fill them with spaces. There isn't very much error checking since that would increase the size of the program a bit. I'd recommend sending the .8xp to your calc, but here's the hex codes just in case. Be careful, if you give the wrong inputs (for example, not giving it any data making it try to create an AppVar of size 0) you risk clearing your RAM.

Optimizations are welcome ;)

Spoiler For Hex codes:
Code: [Select]
EFD74A
FE04
C0
EB
5E
23
56
23
7E
23
1B
1B
1B
1B
1B
1B
ED53F386
2B
3615
11EC86
010600
EDB0
22F586
EB
3600
21EC86
E7
D631
2837
3D
C0
EFF142
D8
EB
4E
23
46
23
ED43F386
11F586
EDB0
EF524B
EFF142
EF5143
EF524B
EFF142
3E04
2AF386
EF704E
ED4BF386
03
03
21F386
EDB0
C9
2AF386
EFFD42
D8
EB
E5
E5
EFF142
3803
EFC64F
E1
EF6A4E
C1
13
13
2AF586
EDB0
C9
« Last Edit: June 28, 2014, 05:19:54 pm by chickendude »

Offline NikProgrammer

  • LV3 Member (Next: 100)
  • ***
  • Posts: 50
  • Rating: +0/-0
  • Calc's are the most handy thing ever invented :D
    • View Profile
Re: Need help with ExecAns//NikProgrammer
« Reply #12 on: June 28, 2014, 04:14:01 pm »
Wow, thanks!!! But how do I translate to hex? I can download this but I found a table how to toggle options with ASM and want to try this on an emulator (:P)
Haha, I learned/understood a bit more ASM than from ASM in 28 days:) Thank you for the comments too!
« Last Edit: June 28, 2014, 04:30:10 pm by NikProgrammer »
Well, I'm not english or american so if anything posted by me is not correct just say or ignore...
And please don't set me back because I live in germay... Though I speak german I am still from UA!
––––––––––––––––––––––––––––––––––––––––––––––––––––
It may sound weird but:
'The teapot cools down long.'
and
'The teapot does not cool down long.'
means the same.

What for do we live? - To think of why we do live.
––––––––––––––––––––––––––––––––––––––––––––––––––––
Loving chess- If you know any good chess programs for TI-83+ please PM me- thanks!
Working on Remakes for all of my programs to optimize them and add more user friendliness... And most important: Graphics. I'm not good at graphics, every help is welcome... -Please PM too.

Offline chickendude

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 817
  • Rating: +90/-1
  • Pro-Riot Squad
    • View Profile
Re: Need help with ExecAns//NikProgrammer
« Reply #13 on: June 28, 2014, 05:24:56 pm »
The hex codes should be in the spoiler at the bottom of the post, so you should be able to use those. The program is pretty long, though, so it'd be much more convenient just to load the .8xp. If you've got any questions about the code feel free to ask, it appears that the information on some of those BCALLs at WikiTI isn't complete, _RclAns for example will also load the pointer to its data if Ans isn't a number, basically just like _ChkFindSym. From the 83 Plus System Routines Guide:
Quote
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.

If there's anything else you'd like added (or if you find something that doesn't work), let me know and i'll see what i can do to add/fix it :)

Offline NikProgrammer

  • LV3 Member (Next: 100)
  • ***
  • Posts: 50
  • Rating: +0/-0
  • Calc's are the most handy thing ever invented :D
    • View Profile
Re: Need help with ExecAns//NikProgrammer
« Reply #14 on: June 29, 2014, 02:23:35 am »
Now I think: Is there any user protection? Because I do not think it will be good if somebody tries to run this interesting, small program ZASM10 to see what things it may do and have his RAM cleared or even worse...

And even more questions: Can I post this at 'Assembly Hex Codes' in TI-Basic developer?
« Last Edit: June 29, 2014, 06:44:38 am by NikProgrammer »
Well, I'm not english or american so if anything posted by me is not correct just say or ignore...
And please don't set me back because I live in germay... Though I speak german I am still from UA!
––––––––––––––––––––––––––––––––––––––––––––––––––––
It may sound weird but:
'The teapot cools down long.'
and
'The teapot does not cool down long.'
means the same.

What for do we live? - To think of why we do live.
––––––––––––––––––––––––––––––––––––––––––––––––––––
Loving chess- If you know any good chess programs for TI-83+ please PM me- thanks!
Working on Remakes for all of my programs to optimize them and add more user friendliness... And most important: Graphics. I'm not good at graphics, every help is welcome... -Please PM too.