I added token definitions to the end of tice.h in the latest toolchain:

https://github.com/CE-Programming/toolchain/releases/latest

Hopefully this helps Smile
Ok this seems like a question I probably should have asked first, but... compiler. I noticed the SDK Mateo made provides a compiler. XDS, I think it is? But that's a Windows program. Is there a Linux version? Can gcc be used?

As an aside, I downloaded the Code Composer Studio by TI, but it is incredibly complicated and asks for target device sets and stuff, with it defaulted to "Generic ARM7 device". What exactly would I select here? Anyone familiar with it?
Bumb. Never mind on above. I do have a few other questions tho.

1. The int data type. I read that it inherits the size of the processor. Meaning that on the ez80, int is a 24-bit number, correct?

2. I read that there is no "byte" type, its just char. Lets say I want a data type that I can use similarly to the 8.8 fixed point type in assembly. Would I declare an array[2] of chars, or would i use the "unsigned short" type?
1) Yes

2) Use the stdint.h defines, such as uint8_t.
Ah yes, I keep forgetting about those included data types. Sorry. lol.
On a note about your libraries... and maybe this is better posted in your thread, but could the libraries be placed into one group file (by you) and the code to reference them altered to be able to pull them from within the group? Not really a big thing, just a curiousity I have.
I have no idea what you are trying to say Smile
MateoConLechuga wrote:
I have no idea what you are trying to say Smile
It seemed pretty straightforward to me, to be slightly snarky. He wants the AppVars in a Group, so instead of having 5 separate AppVars on your calculator, you have a single Group. Then libload would just pull the requisite data from inside the group instead of finding the requisite AppVar(s).
KermMartian wrote:
MateoConLechuga wrote:
I have no idea what you are trying to say Smile
It seemed pretty straightforward to me, to be slightly snarky. He wants the AppVars in a Group, so instead of having 5 separate AppVars on your calculator, you have a single Group. Then libload would just pull the requisite data from inside the group instead of finding the requisite AppVar(s).

Nope Smile I could make it a single transferable file that will auto ungroup on the calc, but groups can only be 64kb in size which isn't very modular Smile
That is what I meant, and fair enough. As an aside, I've spent some time looking into the include files (stdio/stdlib/etc) and I found some printf and putchar and getchar. So my question is, I know how printf and putchar and getchar work in normal C, but since you've included them, is it safe to assume they will work for I/O on the calculator? Could I use getchar() instead of os_getCSC(), and would that return the actual character input, and avoid me having to do a hexcode lookup?

Edit: Is this a string input routine?

Code:
char *gets(char * s);


Edit 2: To create buffers to store an array of floating point numbers, would I declare

Code:
float tempBuffer[size];
Hello! printf, putchar and getchar haven't been in the toolchain for ages, and gets() should never ever be used. Smile To answer your second question, yes, exactly Smile
Seriously about gets()? Darn. Well I can always loop getchar() then.

Secondly, let me just run some code by you. Sorry if these seem like dumb questions, but it's one thing to read info and another to understand how to use it, but im getting there. The function of the below code is to create a 400 item array of floats, then set up a pointer to the first half of it and the second half of it. Is this correct?


Code:
float operandBuffers[400];
char* Operand1Buff = operandBuffers, Operand2Buff = operandBuffers+200;
No, use a float* not a char*. I meant before that you haven't updated the toolchain in ages. There is no point behind having getchar and the others.
Ah, I thought I had been, but apparently the script wasn't pulling the right version. So it seems that now the only thing to do is use the keypad stuff? Unless I completely missed a string input routine.
Just use a lookup string

Code:
const char chars[] = "\0\0\0\0\0\0\0\0\0\0\"WRMH\0\0?[VQLG\0\0:ZUPKFC\0 YTOJEB\0\0XSNIDA\0\0\0\0\0\0\0\0";
uint8_t key, i = 0;
char buffer[50];

while((key = os_GetCSC()) != sk_Enter) {
        if(chars[key]) {
                buffer[i++] = chars[key];
        }
}
Wow, I didnt realize how simple that would be, but I'll have to modify that for letters, operations, and parentheses. I havent yet created the lookup string, but I did create normal/alpha toggle and i added a character limiter to your code.


Code:
uint8_t inputMode = 0;  /* 0 = normal, 1 = alpha */
const char charsAlpha[] = "\0\0\0\0\0\0\0\0\0\0\"WRMH\0\0?[VQLG\0\0:ZUPKFC\0 YTOJEB\0\0XSNIDA\0\0\0\0\0\0\0\0";
const char charsNorm[] = "";
uint8_t key, i = 0;

while((key = os_GetCSC()) != sk_Enter) {
    if(key == sk_Alpha) {
        inputMode = (inputMode == 0);
    }
    if(chars[key] and i<257) {
        if(inputMode == 0){
            inputBuffer[i++] = charsNorm[key];
        }
        if(inputMode == 1){
            inputBuffer[i++] = charsAlpha[key];
        }
    }
}


As an aside I HAD been updating properly, but XCode doesnt update files added to the project. You have to add the folder. Its weird. :p

Edit: I compiled the normal char list. The issue with this is some of these tokens are two bytes. Did I do this right, or do I have to declare the number tokens too?

Code:
const char charsNorm[] = "\0\0\0\0\0\0\0\0\0\0+-*/^\0" + tChs + "\0369)" + tTan + "\0\0.258(" + tCos + "\0\00147\0" + tSin + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";


Edit 2: Is there a fast way in C so do a copy of bytes from a location to location+1 for a certain range of bytes?
Check out memcpy and memmove.
MateoConLechuga wrote:
Check out memcpy and memmove.

I had a feeling it would involve that. As for my charsNormal string, will I need to make 2-byte tokens? Some of them are two bytes? And for the other ones that have token defines, do I need to specify the token values, or can I leave them in string like that?

Edit: Unless I have to do something more with the charsNormal string, the string input routine seems to be done. Ya'll can scan for some obvious mistakes, let me know how i did :p. This and processing that string into an array of polynomial coefficients might be the hardest part of the entire program. (Yes, this is a re-write of Polynomials AIO for the CE).


Code:
getString(&polyIn){
    uint8_t inputMode = 0;  /* 0 = normal, 1 = alpha */
    uint8_t insertMode = 0; /* 0 = insert off, 1 = insert on */
    const char charsAlpha[] = "\0\0\0\0\0\0\0\0\0\0\"WRMH\0\0?[VQLG\0\0:ZUPKFC\0 YTOJEB\0\0XSNIDA\0\0\0\0\0\0\0\0";
    const char charsNorm[] = "\0\0\0\0\0\0\0\0\0\0+-*/^\0" + tChs + "\0369)" + tTan + "\0\0.258(" + tCos + "\0\00147\0" + tSin + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
    uint8_t key, i = 0;

    while((key = os_GetCSC()) != sk_Enter) {
        if(key == sk_Alpha) {
            inputMode = (inputMode == 0);
        }
        if(key == sk_Mode){
            insertMode = (insertMode == 0);
        }
        if(key == sk_Left){
            i--;
        }
        if(key == sk_Right){
            i++;
        }
        if(key == sk_Del) {
            polyIn[i--] = "\0";
        }
        if(key == sk_Clear) {
            memset(polyIn, 0, 257);
            i = 0;
        }
        if(chars[key] and i<257) {
            if(insertMode == 1){
                memmove(polyIn[i], polyIn[i+1], 256-i);
            }
            if(inputMode == 0){
                polyIn[i++] = charsNorm[key];
            }
            if(inputMode == 1){
                polyIn[i++] = charsAlpha[key];
            }
        }
    }
}
bump/update:

Next step in this program is an order of operations parser. For this I understand the concept of shunting yard, but I need some suggestions/advice.

1. First, in places like 4x + 7x^2, can I write in the whole term (like 4x) for instance, and save myself the computations involved in splitting 4x into 4*x? With polynomials, you kinda dont even need to split up terms.

I'm going to work on an OOP and as I do, post snippets for checking. Smile
Assuming that code was supposed to be C and not pseudocode or something, it has some errors:


Code:
getString(&polyIn){

First, all functions need a return type. If there is no returned value, then use void. Second the polyIn argument needs a type (maybe a uint8_t *?), and also, & can't be used in C types anyway (it is used for C++ references though).


Code:
const char charsNorm[] = "\0\0\0\0\0\0\0\0\0\0+-*/^\0" + tChs + "\0369)" + tTan + "\0\0.258(" + tCos + "\0\00147\0" + tSin + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";

You can't use + with strings in C. The most readable fix for this is to use array initialization syntax:

Code:
const char charsNorm[] = { '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '+', '-', '*', '/', '^', '\0', tChs, '\0', '3', '6', '9', ')', tTan, '\0', '\0', '.', '2', '5', '8', '(', tCos, '\0', '\0', '0', '1', '4', '7', '\0', tSin, '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0' };

Note that these are all 1-byte tokens, but if you ever needed 2-byte tokens, you would need to use uint16_t instead of char.


Code:
memmove(polyIn[i], polyIn[i+1], 256-i);

polyIn[i] loads the uint8_t at index i from memory, at which point it doesn't make sense as an argument to memmove. Two equivalent ways to do this correctly are &polyIn[i] and polyIn + i, both of which get the address of the ith element of polyIn.


Code:
if(chars[key] and i<257) {

You need to use && for and in C (unless you #include <iso646.h>).

Also, this isn't a bug but

Code:
inputMode = (inputMode == 0);

is more readable if you do

Code:
inputMode = !inputMode;
Thanks for that! As far as the below quoted bit, if any of the tokens are two bytes, I'm assuming the entire string needs to be 2-byte, and that any one byte tokens within it would then need padding?
jacobly wrote:


Code:
const char charsNorm[] = "\0\0\0\0\0\0\0\0\0\0+-*/^\0" + tChs + "\0369)" + tTan + "\0\0.258(" + tCos + "\0\00147\0" + tSin + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";

You can't use + with strings in C. The most readable fix for this is to use array initialization syntax:

Code:
const char charsNorm[] = { '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '+', '-', '*', '/', '^', '\0', tChs, '\0', '3', '6', '9', ')', tTan, '\0', '\0', '.', '2', '5', '8', '(', tCos, '\0', '\0', '0', '1', '4', '7', '\0', tSin, '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0' };

Note that these are all 1-byte tokens, but if you ever needed 2-byte tokens, you would need to use uint16_t instead of char.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
» Goto page Previous  1, 2, 3, 4, 5, 6  Next
» View previous topic :: View next topic  
Page 2 of 6
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement