Author Topic: What C commands are not supported?  (Read 5310 times)

0 Members and 1 Guest are viewing this topic.

Offline willrandship

  • Omnimagus of the Multi-Base.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2953
  • Rating: +98/-13
  • Insert sugar to begin programming subroutine.
    • View Profile
What C commands are not supported?
« on: May 15, 2010, 01:58:08 am »
I was just wondering, as someone mentioned that some of them do not work compared to x86 C.

Also, is there anything special I need to know about creating Nspire C programs? I've got Yagarto with Eclipse (on-site tutorial, I used the old version so it is the arm-elf-gcc one, not arm-gcc-eabi or whatever)

I read something in the ndless readme about independent variables and executables need to start with PRG/0. Can someone elaborate on those?

I've never worked with C before, but I've worked with Processing, which is C-like structure, I believe.

Thanks for all the help! I couldn't do it without your help!

Offline yoshi13

  • LV2 Member (Next: 40)
  • **
  • Posts: 36
  • Rating: +0/-0
    • View Profile
Re: What C commands are not supported?
« Reply #1 on: May 15, 2010, 02:32:03 am »
If you read on it says that MakeTNS is used to add this to binary files. So when you compile it calls MakeTNS and adds the header while changing it into a .tns file readable by the calculator.

I think you can also just add this
Code: [Select]
asm(".string \"PRG\"\n"); to the top of your file just below the included headers as shown in the demo program.
« Last Edit: May 15, 2010, 02:33:51 am by yoshi13 »
What happens when no one is listening on #omnimaga:
http://netham45.org/irc/EfNet/view.php?log=omnimaga.20100513

Never use /beep 9999 1000 on irc..

Offline bwang

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 634
  • Rating: +30/-11
    • View Profile
Re: What C commands are not supported?
« Reply #2 on: May 15, 2010, 02:48:32 am »
It is best to start your coding by editing the demo. If you just change the contents of main(), everything should work.
All the built-in C commands (loops, control flow) are supported.
Most of the standard library is not. Look at headers/os_*.h to see what is supported (* depends on whether you are coding for the CAS or non-CAS).
« Last Edit: May 15, 2010, 02:53:53 am by bwang »

Offline willrandship

  • Omnimagus of the Multi-Base.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2953
  • Rating: +98/-13
  • Insert sugar to begin programming subroutine.
    • View Profile
Re: What C commands are not supported?
« Reply #3 on: May 15, 2010, 04:03:01 pm »
OK, thanks! So, just to check:
If, then, function loops, while, for, that stuff is supported, but

Disp, PrintL, Print, Input-ish commands are not, as they're hardware specific.

Does that sound about right? Thanks for the help!

Offline bwang

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 634
  • Rating: +30/-11
    • View Profile
Re: What C commands are not supported?
« Reply #4 on: May 15, 2010, 04:16:53 pm »
Yes. That is correct.

Offline willrandship

  • Omnimagus of the Multi-Base.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2953
  • Rating: +98/-13
  • Insert sugar to begin programming subroutine.
    • View Profile
Re: What C commands are not supported?
« Reply #5 on: May 16, 2010, 07:29:00 pm »
BTW, I started out just peeking at the common.h, and found something I thought was rather irritating. They only set black and white as color values beforehand, so I wrote in 16 new #define lines.

The original BLACK and WHITE commands are intact, so it should be 100% compatible with old stuff while making grayscale easier to write. I simply defined COLOR0 through COLORA for Black to White and gray in between.

Like so:
Original:
#define BLACK                   0x0
#define WHITE                   0xF
New, improved:
#define BLACK                   0x0
#define WHITE                   0xF
#define COLOR0               0x0
#define COLOR1               0x1
#define COLOR2               0x2
#define COLOR3               0x3
#define COLOR4               0x4
#define COLOR5               0x5
#define COLOR6               0x6
#define COLOR7               0x7
#define COLOR8               0x8
#define COLOR9               0x9
#define COLORA               0xA
#define COLORB               0xB
#define COLORC               0xC
#define COLORD               0xD
#define COLORE               0xE
#define COLORF               0xF

Like it?

Offline bwang

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 634
  • Rating: +30/-11
    • View Profile
Re: What C commands are not supported?
« Reply #6 on: May 16, 2010, 09:48:51 pm »
Not much reason to do that, since, for example COLORA is just 0xA (or 10 in decimal). The integer values allow you to do arithmetic on them. If you wanted to increase readability, you could give them names like GRAY, LIGHT_GRAY, DARK_GRAY, etc.
If you wanted to start doing some header stuff, you could fill in the rest of the key codes in common.h and post that. They'll come in handy later.

Offline willrandship

  • Omnimagus of the Multi-Base.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2953
  • Rating: +98/-13
  • Insert sugar to begin programming subroutine.
    • View Profile
Re: What C commands are not supported?
« Reply #7 on: May 16, 2010, 10:16:33 pm »
that's true......how exactly are the nspire keys mapped? Are the alpha keys on a separate matrix, or is it just 5-key then 6-key then 5 again on the matrix?

Also, do you know anything about the keys at the top? how are their addresses configured, as well as the pad itself?

Offline bwang

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 634
  • Rating: +30/-11
    • View Profile
Re: What C commands are not supported?
« Reply #8 on: May 16, 2010, 10:35:08 pm »
Keypad map is here: http://hackspire.unsads.com/wiki/index.php/Memory-mapped_I/O_ports#900E0000_-_Keypad

You define keys like so:
Code: [Select]
#define KEY_NSPIRE_[KEYNAME]  KEY_(offset, 2^bit)
where the ^ indicates exponentiation.

You can post your work here when you finish. That way we can collect everything into one place.
« Last Edit: May 16, 2010, 10:36:49 pm by bwang »