Shop OBEX P1 Docs P2 Docs Learn Events
Objects in SPIN and ASM - Can use in C program? - Page 2 — Parallax Forums

Objects in SPIN and ASM - Can use in C program?

2»

Comments

  • idbruceidbruce Posts: 6,197
    edited 2014-06-01 22:31
    Convincing school admins that programming skills can be communicated regardless of the language chosen

    So true.

    To me, the biggest reward in programming is seeing results quickly, regardless of the language chosen. One programming language is a doorway to another, providing the person has a sincere interest to learn.

    I started programming in HTML many moons ago, back when Geocities was a thriving community on the internet. Geocities allowed the creation of your own website on their servers and it was pretty cool back then.

    Anyhow, it was exciting to make a few alterations to the code, upload it, and see instant results :) Many years and several languages later, I am still at it and I still want instant results :)
  • GenetixGenetix Posts: 1,754
    edited 2014-06-01 22:36
    You are right about one thing, Jazzed, Andy is the man! Now if only Chip could come up with a way to make another Andy or 2.

    Andy's PE Kit is awesome. I love having not just working code but an understanding of what that code it doing, especially at the hardware level
    I know more about the Cog Counters from Andy's text than is stated in the Propeller Manual.
  • GenetixGenetix Posts: 1,754
    edited 2014-06-05 16:18
    One solution to programs not existing for devices would be to include generic algorithms in the documentation that could be coded in any language.

    Does Parallax currently have a process for certifying forum-generated programs so they can be added to the product download pages?
    It might also be time to have a C and possibly an Arduino forum.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2014-06-05 16:22
    Genetix wrote:
    It might also be time to have a C and possibly an Arduino forum.
    There already is a C forum: http://forums.parallax.com/forumdisplay.php/93-Propeller-GCC

    -Phil
  • GenetixGenetix Posts: 1,754
    edited 2014-06-05 16:30
    I was thinking more of a general C forum on the main forum page where it's easy to find. I didn't even know there was GCC forum until now.
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2014-06-05 19:08
    John said
    But there is no C code example on the catalog page and only source of code is in OBEX is Spin/ASM. That cancels the sale.

    and followup comments...

    There is a lot more on C now. http://learn.parallax.com/C/propeller-c-reference and especially http://learn.parallax.com/propeller-c-tutorials makes it much simpler to work through examples.

    Some quick observations:
    1) Scanning through a few random pages of the Obex, there still doesn't seem to be much C code. I am not sure why - is it that C coders are not posting to the obex, or there are not many C coders using the propeller, or (my theory), porting objects to C is a bit tedious and maybe there isn't much kudos for posting something that was already done in Spin years ago?
    2) A lot of C code needs some rather essential libraries, and these quickly use up hub ram. There are so many solutions to external memory but the one that really seems to strike a balance of simplicity, cost and minimum pins is to add a micro SD card and run code off this.
    3) For tinkerers, the first step is to get something working. The second step is to pull it all to bits and see how it works, and then change something and make it do something new and cool. Spin/pasm is kind of easy to see how things are done because the raw pasm is there in most objects. It is a mass of unknowable code initially but it piques the curiosity and eventually the temptation is to change a line or two and see what happens. I was trying to find an example of C with Pasm by drilling down into the C tutorials, then the code, and I can't seem to find any. Some years back I was writing C and Pasm in one file and then parsing it through a program to split the code and compile the code separately - I would be interested to see what solutions people came up with as the other 'hack' is to include pasm as an array of hex bytes, but that doesn't really encourage tinkering.

    Maybe it is just me, wanting to pull things to bits and hack stuff together to do new things!
  • GenetixGenetix Posts: 1,754
    edited 2014-06-05 21:29
    I noticed that the Microcontroller Kickstarts on Learn have diagrams for the Propeller BOE.
    The Kickstarts page might be a good place to place C code for devices, especially for someone like a student who just wants to try the device.

    Currently there is not one central location for functioning code. Some of it is on the Parallax website, some in a forum message, and some on Learn.
    Since Parallax wants Learn to be the go to place then why not have a process for getting code certified and place it on Learn in an easy to find place.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2014-06-06 00:05
    I tend to strongly sympathize with what Phil is trying to say about C being inappropriate in many educational situations. It as if someone is trying to learn to swim and the instructor decides everyone must start in the deep end of the swimming pool.

    The problem is simply not providing a full range of curriculum and claiming that even a beginner needs to start with C. Basic historically got the focus on the minimal kit of concepts to get a program working. And then the learner would pick up all the underlying systems support as they progressed toward more ambitious projects.

    A lot of brilliant programmers seem to think that new learners should be able to intuitively sort through a maze of topics and contexts. They may program exceedingly well and fully know their material, but they are not teaching well.

    C or C++ may be a valid and necessary destination in learning to program, but it is NOT always the ideal starting point. And we have far too many enterprises claiming to be educational without any real awareness of the bigger picture of what a computer programing education or other forms of education should be.

    The problem is NOT just in computer programing. Teaching English in Taiwan has a long history of being exploited by enterprises that just want something to sell. As a result, there is a lot of beginner material, and advanced exam preparation being touted with nothing in between. Most learners hit a plateau and quit.

    +++++++++++++++
    In sum, where is the curriculum? Does it provide a progressive level of knowledge development or does it just jump around?

    And the issue of providing C code for every item sold is really more of a Sales issue than an educational issue. But it seems that Parallax has fallen behind in doing that.

    Fortunately, there are a few good alternatives for converting or using Spin code in a GCC compiled context. For now, those are very useful.
  • GenetixGenetix Posts: 1,754
    edited 2014-06-06 01:50
    I agree with you Loopy that C Is not the perfect language but a considerable amount of programming is done with C so it's understandable that schools what to meet the need.
    My first language was BASIC and later I learned PASCAL which teaches not only proper program structure but is similar to C.
    After learning Pascal I found C to be very similar but some of the syntax is awkward.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2014-06-06 02:18
    I suspect there really is no perfect computer language, and there is a huge tendency for users to proclaim that the one they use the most is the best.

    C is widely accepted as it was academcially accepted early on with Unix.

    The only problem I have with GCC is it is a rather 'slippery slope' with C++. The C++ features tend to slip into code without any explaination and I am left wondering what I don't understand. It doesn't help that the textbook and tutorials for C++ all seem to be no less than 600-700 pages long. To make matters worse, the C++ Standard Library document is now available at 1100 pages.

    It you really want to daunt new learners, just hand them 15 kilos of reading material to get started. I am not sure how modern technology got to this point, but I see the same situation over and over again -- a lot of free short introductory material that isn't really very good, and then a set of big lengthy documents that are not only hard to read... they are heavy to carry. The middle ground is a gap of next to nothing published.

    Nobody seems able to write a clear overview in 100 to 200 pages these days. These shorter texts do have an important role into introducing technical subjects. Without overview, the big books are awash with jargon that is difficult to decypher. Personally, I have managed to overcome a lot of the problem by sheer persistence..... but it has taken more years than I would like. In other words, good publications and a good curriculum should be easily appreciated for making learning easier and actually take less time.

    In some cases, jargon terms, such as the LMM, CMM, XMM, XMMC and so on are difficult for the new learn. One might assign them names: such as, vanilla, strawberry, chocolate, and rocky-road, so that the learner has some association with how they can get progressively more complex. This kind of creativity appeals to younger audiences. There is way too much formality in most computer text these days.. and it just makes it harder to prioritize the details presented.

    New users can then see that they want to start out learning 'vanilla', and progress toward finally learning 'rocky-road'. Good teachers create these kind of presentations all the time to keep a class engaged and moving forward.
  • frank freedmanfrank freedman Posts: 1,983
    edited 2014-06-06 09:23
    Personally, I would not consider C for the beginning learner. Yes, it is powerful, and yes everyone seems to want it. But BASIC and SPIN should be the choice, SPIN on the prop especially simply because they are easy to follow and implement with. C can be more cryptic and confusing. And like a very sharp tool with no guards to speak of, very easy to get cut up with (discouraged or put off in student speak).

    Basic, SPIN, heck even FORTRAN and many assemblers seem easier to me to use than C to start. That will change as I get more time and practice; kind of like any other learner. This gets in the way of learning how to tell a computer what to do, how to do it, and the "joy" of learning just how far down a task may need to be broken up to get the expected results. And that is just with the easy tasks. Forget the high end comp sci stuff, that can come later if the interest and proper foundation is there. But to trying to use C in a beginner / hobby course gets in the way of the foundational learning.

    Go back to SPIN or BASIC until the underlying concepts are mastered. There are a ton of threads and code in and out of OBEX and other sites that clearly exemplifies these missing concepts. For those that would argue for C using Arduino as an example, I have started to play with that a bit. It may even be C, but it is wrapped so tight to protect the user that it may as well be BASIC or SPIN. Prebuilt code with simple interfaces at the beginning levels (like SPIN and BASIC), but written in a snap together fashion like the old Radio Shack 65-in-1 project kits etc.

    I could be wrong in my outlook here, But concepts first. Then get out the power tools. A language is just a tool. Understanding how the program written to use a particular device means that the reader should then have enough knowledge to rewrite the function in the language of their choice provided it supports access to the hardware level which goes back to the original posters request. If the concepts are there, his students can rewrite the objects on their own; once they achieve the mastery of C to do so. Long after they have sat in his class. For now, he should concentrate on understanding what process is needed to use the device, not what it was written in.

    IM(ns)HO

    Frank
  • Dave HeinDave Hein Posts: 6,347
    edited 2014-06-06 10:05
    The problem with learning any language is that a newbie needs to learn the whole language to understand code from other programmers. I started out as a Fortran programmer, and when I first started working with C I only learned a subset that matched the features of Fortran. I picked up the concept of structs pretty quickly, but the first time I saw code containing x->y I had no idea what that was. And then I learned about struct pointers, and then function pointers, and then the various odd library functions. It probably took me a year to feel like I had mastered the language.

    The Spin language is much easier to master because it is a very simple language. It took me about a month to fully learn it. Now C++ is a different animal. I wonder if anybody ever feels that they've mastered that language.
  • jazzedjazzed Posts: 11,803
    edited 2014-06-06 10:19
    Dave Hein wrote: »
    Now C++ is a different animal. I wonder if anybody ever feels that they've mastered that language.

    Bjarne Stroustrup?


    It is dangerous for people who don't know enough about C/C++ to be dangerous .... ;-)

    How much is enough?

    * Understands the difference between *(s++) and *(s)++
    * Understands the difference between array and &array[0]
    * Understands the consequences of malloc and free
    * Can whip out a moderately complex program without syntax errors without compiling
    * Can whip out a moderately complex program without functional errors without testing
    * Doesn't despise the language
    * Actually uses the language on a regular basis
    * Others ....
  • Dave HeinDave Hein Posts: 6,347
    edited 2014-06-06 12:08
    Yes, I have to admit there are still "simple" things in C that trip me up sometimes. I just wrote some code that uses (*s)++, but now you have me thinking with *(s++) and *(s)++. I better double check that code. I've also run into problems in the past when I used a global pointer in one file and an array in another file.
  • ersmithersmith Posts: 6,054
    edited 2014-06-06 12:22
    Dr_Acula wrote: »
    Some years back I was writing C and Pasm in one file and then parsing it through a program to split the code and compile the code separately - I would be interested to see what solutions people came up with as the other 'hack' is to include pasm as an array of hex bytes, but that doesn't really encourage tinkering.

    GCC supports inline assembly. The syntax is slightly odd (the inline assembly has to be in a string) but it is possible to use it. spin2cpp with the --gas option will output inline assembly instead of compiling to hex.
  • GenetixGenetix Posts: 1,754
    edited 2014-06-06 16:21
    Clearly C is not a beginners language.

    Maybe a GUI interface similar to what the Scribbler uses might be better suited for beginners.
  • Dave HeinDave Hein Posts: 6,347
    edited 2014-06-06 17:34
    Genetix wrote: »
    Clearly C is not a beginners language.
    I don't think that's an accurate statement. Many people learn programming for the first time using C. There are many online tutorials where someone can teach themselves C by following a systematic progression through the language. I believe most universities teach C as an introduction to programming. It takes longer to master C than it does Spin or Basic, but a novice programmer can produce useful original C code very early in the learning process.
  • David BetzDavid Betz Posts: 14,516
    edited 2014-06-06 17:37
    Dave Hein wrote: »
    I don't think that's an accurate statement. Many people learn programming for the first time using C. There are many online tutorials where someone can teach themselves C by following a systematic progression through the language. I believe most universities teach C as an introduction to programming. It takes longer to master C than it does Spin or Basic, but a novice programmer can produce useful original C code very early in the learning process.
    My son is an example of someone who learned C as a first language. He's not living near me at the moment so he's done it mostly using a book and online tutorials.
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2014-06-06 20:58
    @ersmith "GCC supports inline assembly. The syntax is slightly odd (the inline assembly has to be in a string) but it is possible to use it. spin2cpp with the --gas option will output inline assembly instead of compiling to hex. "

    Ah, now that is clever.

    Ok, our OP is looking to use spin/pasm objects in C. So thinking as simply as possibly, grab a typical object in Spin, run it through Spin2C and then use it in C. Does that process leave the Pasm code as a string, or does it convert it into an array of hex bytes?
Sign In or Register to comment.