Author Topic: Help working with estack  (Read 3414 times)

0 Members and 1 Guest are viewing this topic.

Offline lxman

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 19
  • Rating: +2/-0
    • View Profile
Help working with estack
« on: May 12, 2011, 07:17:41 pm »
Hello all,

I am in the process of developing a flash app for TI89 using TI Flash Studio.  I would like to get familiar with the estack, so I can use the AMS calculation abilities.  Things don't seem to be working for me so far, though.  If someone could help I would be most appreciative.

Here's what I am currently struggling with.

I want to place a matrix on the estack, execute an rref (reduced row echelon format) on it, and retrieve the result.

I have tried the following:

Code: [Select]
char matx_str[255];
EStackIndex orig_top;

strcpy(matx_str, "rref([[3,6,4][5,9,2][-9,5,-2]])");
orig_top = top_estack;
push_zstr(matx_str);
push_str_to_expr(top_estack); // Receive a syntax error when executing this line of code
delete_between(orig_top, top_estack);


If someone is familiar with how to properly use the estack, I would appreciate it.

Thank you.

Offline Lionel Debroux

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2135
  • Rating: +290/-45
    • View Profile
    • TI-Chess Team
Re: Help working with estack
« Reply #1 on: May 13, 2011, 01:30:13 am »
Hi :)
First of all, you don't need to use a FlashApp for EStack programming.

Pushing text (in external form) to be interpreted, and executing it, is usually through push_parse_text + NG_approxESI / NG_rationalESI (/ NG_execute if there are other TI-BASIC statements).
If you're into more manual things for building that matrix and triggering the rref computation, a combination of push_LIST_TAG, push_END_TAG, push_quantum_as_nonnegative_int / push_(u)long_to_integer, push_negate_quantum_as_negint / push_long_to_integer, and push_red_row_ech, will do the job.

GCC4TI Git (a long-lasting temporary measure until the GCC4TI server is transferred to a newer server with a less flaky HDD), https://github.com/debrouxl/GCC4TI , provides several dozens of previously unknown / unexported functions, and documentation for a number of functions previously documented only in TIFS's documentation (sdk8992pguide.pdf). Updated headers at https://github.com/debrouxl/gcc4ti/tree/next-doc/trunk/tigcc/include/C , updated HTML documentation at https://github.com/debrouxl/gcc4ti/tree/next-doc/trunk/tigcc/doc/System/WebFiles .

Hope that this helps :)
Member of the TI-Chess Team.
Co-maintainer of GCC4TI (GCC4TI online documentation), TILP and TIEmu.
Co-admin of TI-Planet.

Offline lxman

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 19
  • Rating: +2/-0
    • View Profile
Re: Help working with estack
« Reply #2 on: May 13, 2011, 02:39:26 am »
Quote
Hi  :)

Well, hello, good to hear from you Lionel  :)

Quote
First of all, you don't need to use a FlashApp for EStack programming.

Yes, I realize that.  I am going this route simply for the integration into the AMS OS.  Until GCC4TI or some other community package tackles the issue of flash apps, I guess I am stuck with working with the TI crapware.

Quote
If you're into more manual things for building that matrix and triggering the rref computation . . .

I am :)

The sdk8992pguide.pdf has been my primary source of info to this point, though I have GCC4TI as well as a number of other tools but through them all, I have been unable as of yet to find a simple understandable (to me anyway) example of how to work with this estack.

I'll pop over to the latest docs on your git server and see if there's anything more enlightening to me there.

How about a specific example, though?

Let me give a simple matrix, and if you (or someone else) would, provide me a code snippet to accomplish this, I would be grateful.

Given the matrix:

[[2,4][5,-6]] I wish to push it onto the estack, execute an rref and retrieve the result to be parsed out by my code so that I can use the numbers.

Would somebody be so kind as to do this for me?  :)

Offline Lionel Debroux

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2135
  • Rating: +290/-45
    • View Profile
    • TI-Chess Team
Re: Help working with estack
« Reply #3 on: May 13, 2011, 02:57:58 am »
Well, what level of integration do you need exactly ? ASM programs can be used in expressions just like BASIC programs ;)
On AMS 2.xx and 3.xx, this requires nullifying the Invalid Program Reference silliness, but KerNO and PreOS, between others, do that. One can also use amspatch'ed OS: removing the Invalid Program Reference silliness is the sixth patch, out of 15, performed by amspatch.

GCC4TI does not contain more EStack examples than TIGCC does; I only focused on actually making examples work (removing name clashes, compilation errors and toolchain bugs found by merely trying to compile the examples for the first time in years).

Quote
retrieve the result to be parsed out by my code so that I can use the numbers.
For best results, it ought to be the other way round: make your code work natively on the internal representation, instead of parsing the external form ;)

Pushing the [2,4;5,-6] matrix can be done through e.g.
Code: [Select]
push_END_TAG();
push_END_TAG();
push_negate_quantum_as_negint(6);
push_quantum_as_nonnegative_int(5);
push_LIST_TAG();
push_quantum_as_nonnegative_int(4);
push_quantum_as_nonnegative_int(2);
push_LIST_TAG();
push_LIST_TAG();

Executing the rref of that matrix should be push_red_row_ech(top_estack, <possibly NULL if that works, or the saved value of top_estack after e.g. a push_Float(1e-13); executed before the code posted above>);
Member of the TI-Chess Team.
Co-maintainer of GCC4TI (GCC4TI online documentation), TILP and TIEmu.
Co-admin of TI-Planet.