Shop OBEX P1 Docs P2 Docs Learn Events
Help in understanding different Programming — Parallax Forums

Help in understanding different Programming

jason0627jason0627 Posts: 17
edited 2014-02-02 12:18 in General Discussion
Hello thanks for reading my post.

this post is to help me try to understand the different programming languages. I am using the basic stamp (2) currently so I am learning Basic . I am also interested in using PIC microcontrollers so I am reading up on picbasic (lucky not that different).

I started looking for a good microcontroller module (basically what i want is a good board i can plug my microcontroller in and be able to connect and program easy because previous attempts at soldering a serial connection ending .... not well ). I wanted to get the arduino uno but then i saw it works off of some form of C++. Maybe one day i can get into C but i am not there yet.

So my question is

1. can i plug a basic stamp or pic microcontrollers into a arduino uno and start programming it in basic/picbasic. I have the software to send but i am thinking the arduino has a compiler that would not be compatible.

2. Can I purchase a microcontroller and choose the language i want as long as i have the compiler to put it on the microcontroller. for example if i purchased this guy http://www.fujitsu.com/downloads/MICRO/fma/mcu/n712635.pdf ... and all i wanted it to do was simple program can i do that?




You can probably tell by the question that I am new to this so help is appreciated.

Thanks

Comments

  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2014-01-31 10:18
    In a perfect world, everything would be interchangeable and possible. But we aren't there yet.

    Microcontrollers all come with their resident machine code that the manufacturers support with a set of Assembler Mnemonics for assembly language programing.

    Plugging a non-Arduino CPU into an Arduino UNO board will likely be a disaster. Different chips do different things with different pins. Just try to compare where the crystal is located and the power connections -- often not the same.

    Cross-compiling is when you use a different computer to write code and then load it to the target device. The market place for cross-compilers was historically full of extremely expensive software ... before Parallax came along with the BasicStamp and offer a free compiler.

    The Propeller has a free compiler in SPIN and PASM. Others have created free compilers for C and a few other languages. And the Propeller even has interpreted languages, such as Forth (also for Free).

    But if you want a different product, compilers and languages can get expensive. Mostly, C is the only cross-compiler that sneaks in a free version due to Linux gnomes generating code for such. But it is pretty much a 'play, you pay' world outside of Parallax, Linux, and Arduino.

    Finding a board that will allow a BasicStamp or a PIC to plug into Arduino shields might be possible. But I am not sure there is much to be gained by doing so. Arduino dedicates i/o pins to specific tasks and creates a significant limit to how much i/o is available. The chips you mention can do more with more i/o pins, if you build your own boards.

    ++++++++++
    In other words, you have started on what is rather a long journey and want to skip way ahead of where you are. Every time you change to a different brand of microcontroller, you will be introduced to a different way of doing business and a different way of programing. I am not sure why you want to use Fujitsu 8bit microcontrollers when PICs are about the same level of usefulness.

    Try not to get ahead of yourself. Try to learn C (it will save you $$$). And enjoy the fact that Parallax offers a lower entry cost with good support for learning. Parts of the world out there are brutal.
  • jason0627jason0627 Posts: 17
    edited 2014-01-31 12:29
    Thanks for the feedback

    I think i will stick with basic and picbasic and when i get good at those i will go onto C.

    sounds like i am going back to the soldering board. :)
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2014-02-01 01:54
    C, not the C++ or other newer versions of C is not as complicated as later versions of the language. It has everything that Basic has, and a little bit more. But it also has libraries that offer useful extensions according to whatever you want to do.

    Here is a link to Mr. Kernighan's classic C tutorial.

    http://www.lysator.liu.se/c/bwk-tutor.html

    I printed this out and found the first 16 or 17 headings of about 28 heading were everything that PBasic included in core programing functions - loops, branches, basic maths, etc. After 16 or so, is the additional stuff that C includes to provide more power.

    Modern C on the Propeller will have some differences, but the core will be there. Try to not get mixed up about C and C++. The Propeller supports both.

    If that tutorial makes you want to read more. Try learning C in Linux on a real PC with a modern tutorial. (I suggest LInux over Windows as all the software and books are available for free, and you will find better help from others on-line).

    You can use Puppy Linux on a Windows computer from a Live CD or USB stick without affecting Windows.

    And read the complete classic ANSI C text by Richie and Kernighan. There are free downloads available.

    +++++++++++++++++++++++++++++++++

    C on the Arduinio is NOT what a user would expect generic C to be.

    Arduinio has created its own world of Wiring and Sketches and hidden the most important Main( ) from the user in order to disguise the fact that it is really generic C under-the-hood.

    Being generic C and pretending to not be can get confusing and actually create an unnecessary dependency on Arduino code and its resources. C on the Propeller is pretty much the real thing, without the nonsense.

    You can use generic C with the Arduino Uno, by buying a programming device and NOT using the Arduino Boot Loader/usb port. But that might be a wee bit too advanced for you at this point.

    Arduino wants you to stay loyal to Arduino, so 'going the other, more generic way' is not supported.

    You would have to work with an OpenAVR community to learn to do things without Wiring and Sketches... the way real programmers work.
  • mindrobotsmindrobots Posts: 6,506
    edited 2014-02-01 06:35
    Jason,

    First off, welcome to the forums!

    Second, don't give up on C or Parallax so easily. Parallax is very much into building an education program around their Propeller Activity Board and C. Check out these tutorials, they will take you through general C programming concepts and then get into building circuits and writing C to control those circuits. The site for learning C is here.

    The whole process isn't nearly as dreadful as some make it out to be and the Parallax forums are very helpful to beginners that show they want to learn.

    Check out the Parallax Learn site for C and you'll probably start to understand C very quickly before you even have a Propeller to program!!
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2014-02-01 07:23
    You can use generic C with the Arduino Uno, by buying a programming device and NOT using the Arduino Boot Loader/usb port. But that might be a wee bit too advanced for you at this point.

    Any Arduino can be programmed using only C (utilising none of the Arduino functions) via their IDE.
    Arduino wants you to stay loyal to Arduino, so 'going the other, more generic way' is not supported.

    People hit up the knowledge base that is their Forum for problems with all manner of breadboarduinos, PLA-duinos du jour and "DIYduinos".
    Their site shows how to make your own on a breadboard.
  • jazzedjazzed Posts: 11,803
    edited 2014-02-01 07:47
    PBASIC is a great language.

    Buy the Activity (WAM) kit: http://www.parallax.com/product/90005
    Or the BOEBOT kit: http://www.parallax.com/product/28832

    Sometimes the pages show a big blank area. Scroll down to see more info. What's up with that anyway?
  • PublisonPublison Posts: 12,366
    edited 2014-02-01 08:18
    Pages showing up OK in Chrome.
  • prof_brainoprof_braino Posts: 4,313
    edited 2014-02-01 08:32
    Another consideration is what you intend to create programs for.
    If you intend to do workstation type applications, C is the ideal choice.
    If you intend to focus on embedded, as in time critical, you can also use C, but FORTH is considered by many a more focused and streamlined tool for embedded.
    If you just want to get your feet wet and try stuff, basic is great, but you often we run into basic's speed and size limitation rather quickly.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2014-02-01 08:54
    Forth needs a certain amount of RAM for a Dictionary space, and a few other items. It is wonderful on the Propeller with 32k of HubRam. Anything less is likely not a Forth microcontroller.

    Of course the BS2 with a mere 32 bits of RAM space would never work.

    There will come a time when you want to do more and the Propeller really is where to go. The QuickStart board has a USB interface. The ProtoBoard can use a simple RS232 interface or a USB to RS232 adapter.

    If you desire to avoid soldering, that is what the little white breadboards are for. And the Propeller does have a board available that can adapt to using Arduino shields in some cases.
  • mklrobomklrobo Posts: 420
    edited 2014-02-01 09:10
    Forth needs a certain amount of RAM for a Dictionary space, and a few other items. It is wonderful on the Propeller with 32k of HubRam. Anything less is likely not a Forth microcontroller.

    Of course the BS2 with a mere 32 bits of RAM space would never work.

    There will come a time when you want to do more and the Propeller really is where to go. The QuickStart board has a USB interface. The ProtoBoard can use a simple RS232 interface or a USB to RS232 adapter.

    If you desire to avoid soldering, that is what the little white breadboards are for. And the Propeller does have a board available that can adapt to using Arduino shields in some cases.

    I could use that on the archiver! gets past the whole interpreter thing!
  • eventsevents Posts: 27
    edited 2014-02-01 09:26
    If you have logical mind, learn assembler. The high-level languages​​, are very good for rapid prototypes. Nothing more. The same problems that have in assembler has in other languages​​, or worse. I program in assembler, for thirty-six years and is the best language. For PIC is the best. (assember). Sure "humanize" programming is best. The big problem with assembler, is the software support. Of course, to open a gate, and close ... perfect.
  • jason0627jason0627 Posts: 17
    edited 2014-02-01 12:11
    Thanks all in the great feedback a lot to go over and learn.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2014-02-02 03:37
    The only major trick in assembler is to create Loops.

    You find only tests and branches in machine code, so how do you get a loop? A loop is a backward branch (to a lower memory address). That is really all there is too it.

    The rest of the stuff is pretty straight forward if you take each Basic instruction and try to imagine a way to do it in Assembler.
  • Heater.Heater. Posts: 21,230
    edited 2014-02-02 04:34
    events,
    If you have logical mind, learn assembler.
    I do agree that anyone interested in computers and programming should learn how to program in assembler. Even if one never uses it in 99.9% of ones programming it is useful and interesting experience for many reasons.

    The Propellers assembly language is especially nice for this as it is simple, elegant, regular and very easy to play with from Spin programs in the Prop Tool.

    However our opening poster is obviously just starting out with micro-controllers and I don't think starting with assembler is a good idea. Sounds like what he needs is a ready to run system like a Propeller board, or an Arduino, etc. With that experience under his belt he will know what possibilities there are to explore.
    The high-level languages​​, are very good for rapid prototypes. Nothing more.
    This is certainly not true. I keep seeing statements like this re: assembler recently on various forums. What's going on?

    Are you suggesting that pretty much every program anybody ever uses is still only a prototype?
    (Don't answer that, I believe that is true but not because they are written in a HLL)

    Assembler programs compared to HLL are:

    a) Bigger, source code wise, for any given functionality.
    b) Harder to write, takes longer and is more error prone.
    c) Harder to read and takes longer to understand.
    d) Harder to maintain/modify.
    e) Not portable across machine architectures / operating systems.
    f) Often not much better performing than equivalent compiled code.
    g) Often not much smaller binaries than equivalent compiled code.

    In short there is no reason to use assembler unless there is a very pressing need to, mostly relating to extremely limited resources like speed and code size or needing to use instructions that compilers don't typically generate.
    I program in assembler, for thirty-six years and is the best language.
    All assembler, all the time? !

    I'm really curious to know what sorts of applications you have worked on that demand this.

    Loopy,
    The only major trick in assembler is to create Loops.
    Major? What is so major about:
    loop:   add a, b
            jmp #loop
    
    Even a complete beginner who had never seen a program before might guess what that is supposed to do.
    Hardly more obscure than looping in BASIC.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2014-02-02 05:11
    @ Heater,
    Interesting example in a nonsensical way. You use a JMP, not a Branch to create an infinite loop that will perpetually add a and b. I should have mentioned jumps as well as branches.

    My point is that studying the Mnemonics for Assembler will never show you how to create a loop. And so, a BasicStamp2 programer trying to take a PBasic list and compare it to what a microcontroller's PDF might list as an instruction set would come up short.

    Your example relies on the Assembly language compiler to create a name called "Loop" and then to return to it.

    I stand corrected, "A Loop is a backward Branch, or a backward Jmp."

    Of course, that implies that forward Branches and forward jumps have different uses... And your example demonstrates how my we all depend on the IDE for the Assembler to make Assembly language easier.

    Might guess, or might not. That is a 50/50 chance.
  • Heater.Heater. Posts: 21,230
    edited 2014-02-02 05:47
    Loopy,

    "nonsensical"? You ordered a loop, you got a loop.

    A jump and a branch are the same thing. Whether they are conditional or not is another matter.
    ...studying the Mnemonics for Assembler will never show you how to create a loop.
    Perhaps true.
    Your example relies on the Assembly language compiler to create a name called "Loop" and then to return to it.
    Yes, where are we going with this?

    Programs that convert assembly language source into binary are called "assemblers". "Compiler" is generally used to describe
    translators of high level languages.
    And your example demonstrates how my we all depend on the IDE for the Assembler to make Assembly language easier.
    How so? A simple text editor will do.
  • mindrobotsmindrobots Posts: 6,506
    edited 2014-02-02 06:39
    Assemblers just put together the machine language you describe to them and help keep track of addresses by letting you use labels - they should do this with the least amount of surprises (a horse we beat to death in another thread).

    Take this example from the Propeller Manual:
    {{ AssemblyToggle.spin }}
    CON
      _clkmode = xtal1 + pll16x
      _xinfreq = 5_000_000
    PUB Main
    {Launch cog to toggle P16 endlessly}
      cognew(@Toggle, 0) 'Launch new cog
    DAT
    {Toggle P16}
            org   0         'Begin at Cog RAM addr 0
    Toggle  mov   dira, Pin 'Set Pin to output
            mov   Time, cnt 'Calculate delay time
            add   Time, #9  'Set minimum delay here
    :loop   waitcnt Time, Delay 'Wait
            xor   outa, Pin 'Toggle Pin
            jmp   #:loop 'Loop endlessly
    Pin     long  |< 16 'Pin number
    Delay   long  6_000_000 'Clock cycles to delay
    Time    res   1 'System Counter Workspace 
    


    Now, let's throw out everything that isn't relevant to the assembler program (all the Spin wrappings, which are important to make the example run but not to this discussion):
    org   0         'Begin at Cog RAM               addr 0
    Toggle  mov   dira, Pin 'Set Pin to output              addr 0
            mov   Time, cnt 'Calculate delay time           addr 1
            add   Time, #9  'Set minimum delay here         addr 2
    :loop   waitcnt Time, Delay 'Wait                       addr 3
            xor   outa, Pin 'Toggle Pin                     addr 4
            jmp   #:loop 'Loop endlessly                    addr 5
    Pin     long  |< 16 'Pin number                         addr 6
    Delay   long  6_000_000 'Clock cycles to delay          addr 7
    Time    res   1 'System Counter Workspace               addr 8
    

    I took the liberty of adding the COG address of each register for reference. That's essentially what the assembler does with label, just makes a note as to what address it was generating contents for when it sees a label so it can use it later.

    Next step, remove all the labels that the assembler keeps track of.
            org   0         'Begin at Cog RAM               addr 0
            mov   dira, 6 'Set Pin to output                addr 0
            mov   8, cnt 'Calculate delay time              addr 1
            add   8, #9  'Set minimum delay here            addr 2
            waitcnt 8, 7 'Wait                              addr 3
            xor   outa, 7 'Toggle Pin                       addr 4
            jmp   #3 'Loop endlessly                        addr 5
            long  |< 16 'Pin number                         addr 6
            long  6_000_000 'Clock cycles to delay          addr 7
            res   1 'System Counter Workspace               addr 8
    
    Still runnable code when put back inside the Spin wrapper, it still assembles in the Propeller tool (actually, you get an error because I removed Toggle but that's a Spin issue not an assembler issue).

    EDIT: I just had to replace the above code after I tried to run it on a Propeller board - I had some addresses wrong. Thus the reason we let assemblers do our bookkkeeping!! Hand assembly is error prone!

    Now, if you want to ease the work your assembler does one more step, you can replace dira, cnt, outa with their register addresses. It will still work.

    The assembler/ide/whatver isn't doign anythign magic, just helping with the bookkeepping of addresses. The next step is to decode the instruction mnemonics into the actual bits that make up each instruction....we'll leave that for another example.

    The point is, the assembler isn't magic jsut a simple aid to the programmer it doesn't generate any code on its own and only does what you tell it to do.

    I'm sure most old assembly programmers have at one time or another sat down with a pad of yellow paper and started writing a program and doen what the assembler does, track addressed and generate the binary contents of words.

    I think it is a good skillfor any programmer to have, especially if involved in embedded systems or any other system level code. When you understand the assembly language for a machine, you can even get along fine without real hardware, you just "play computer" and step by step go through each instruction and follow the changes it causes in the hardware.

    I'm currently burshing up on my PASM and finding that often I am overthinkig it and just need to remember it literally is one instruction at a time and isn't complicated as long as you keep track of teh things that are going on in the hardware.

    For me, addressing modes usually cause trouble. The Propeller has few, so it is very nice in that respect. Loops via jumps, branches, etc, you are just changing where the hardware takes teh next instruction from - forward, backward, conditional or unconditional, it doesn't matter - just go there and execute that memory content as an instruction.



  • mindrobotsmindrobots Posts: 6,506
    edited 2014-02-02 06:45
    My point is that studying the Mnemonics for Assembler will never show you how to create a loop.

    No, it won't but once you learn how to do it and the basic idea behind creating a loop in assembler, you know pretty much how ANY other computer language creates loops at the very heart of its operation and you understand why some loops are better than others. Down deep, everything comes to individual instruction running on the hardware.
    Your example relies on the Assembly language compiler to create a name called "Loop" and then to return to it.
    That's the beauty of it, the assembler doesn't CREATE anything! You as the programmer, creates everything, teh assembler just helps you remember by letting you put a label on that memory cell you want to be the beginning of your creations (and only that cell).
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2014-02-02 07:12
    Heater. wrote: »
    Loopy,

    Yes, where are we going with this?

    Where is this all going? It is helping a rank begineer that depends on Basic see how to make a move over to using assembly language programing. What may seem obvious to you as a seasoned programmer can easily be a source of frustration to a rank beginner.

    Teaching is NOT about clever debate, it is about helping others to notice what they have overlooked or can't seem to grasp.

    For instance, it may be quite obvious to you what code on the Propeller in PASM resides in a cog and what code ends up residing in the Hubram and how they interact. But actually teaching this to a begineer is all about helping them to notice the differences between code that is intended for the two desiginations, and how the PAR register works. None of which is taught in the Propeller Manual. (It is explained in terms that presume the reader knows how to envision what is going on.)

    What may seen pedantic to you, can be quite difficult for others.

    Those "Spin Wrappings" are a must have item. Throwing them out is likely to put a novice into a complete tail spin. Face it the Propeller is special about loading PASM. It doesn't just start a a low address and go forward. It requires a CogNew or a CogInit to get any of the processors running.

    Teaching is all about helping the learn to notice ALL that is required.
  • mindrobotsmindrobots Posts: 6,506
    edited 2014-02-02 07:22
    Ok, this is officially too much fun!

    The above loop example is basically an endless loop like a "repeat" with nothing after it in Spin or a "while (1) { do stuff}" construct in C (see, if you understand the assembler, you can pretty much figure out the basics of how other languages REALLY loop down deep.

    Loopy, how about a "for" loop or a "repeat n" looping construct?
    {{ Toggle2-djnz.spin }}
    CON
      _clkmode = xtal1 + pll16x
      _xinfreq = 5_000_000
    PUB Main
    {Launch cog to toggle P16 endlessly}
      cognew(@Toggle, 0) 'Launch new cog
    DAT
    {Toggle P16}
                  org       0                       'Begin at Cog RAM addr 0
    Toggle        mov       dira, Pin               'Set Pin to output
                  mov       Time, cnt               'Calculate delay time
                  add       Time, #9                'Set minimum delay here
    :loop         waitcnt   Time, Delay             'Wait
                  xor outa, Pin                     'Toggle Pin
                  djnz      Count, #:loop           'Loop until teh counter hits 0
                  jmp       $                       'Loop forever 
    Pin           long      |< 15                   'Pin number
    Delay         long      10_000_000              'Clock cycles to delay
    Count         long      40                      'Number of times to go through the loop
    Time          res       1                       'System Counter Workspace 
    

    The interesting little bits here?

    1) Added a new "variable" Count which will hold the number of times you want to loop (the number of times you want to blink * 2)
    2) changed the "jmp #:loop" to a "djnz Count, #:loop" - in this case this instruction will decrement Count, check if it is non-zero and take the jump if it is. If it is zero, the cog just falls through to the next instruction.
    3) added a 'jmp $' after the djnz just to stop the cog from running through its data as instructions (it will happily do that) - 'jmp $' just jumps to itself, $ is what the assembler uses for the address it is currently at.

    So these changes made the loop into a "repeat 40" or 'for (i:=0;i<=40,i++)" type loop.

    Loops aren't that tricky!!
  • mindrobotsmindrobots Posts: 6,506
    edited 2014-02-02 07:46
    Where is this all going? It is helping a rank begineer that depends on Basic see how to make a move over to using assembly language programing. What may seem obvious to you as a seasoned programmer can easily be a source of frustration to a rank beginner.

    Teaching is NOT about clever debate, it is about helping others to notice what they have overlooked or can't seem to grasp.

    For instance, it may be quite obvious to you what code on the Propeller in PASM resides in a cog and what code ends up residing in the Hubram and how they interact. But actually teaching this to a begineer is all about helping them to notice the differences between code that is intended for the two desiginations, and how the PAR register works. None of which is taught in the Propeller Manual. (It is explained in terms that presume the reader knows how to envision what is going on.)

    What may seen pedantic to you, can be quite difficult for others.

    Those "Spin Wrappings" are a must have item. Throwing them out is likely to put a novice into a complete tail spin. Face it the Propeller is special about loading PASM. It doesn't just start a a low address and go forward. It requires a CogNew or a CogInit to get any of the processors running.

    Teaching is all about helping the learn to notice ALL that is required.

    Ok, I went and update my original examples to not the importance of Spin ndthe wrapper.

    Your comment:
    Your example relies on the Assembly language compiler to create a name called "Loop" and then to return to it.
    [

    Is even a bigger disservice to learning in my opinion. As Heater pointed out, it is an assembler and does what any assembler does, not a compiler because those do different things. May seem a trivial distinction for a rank beginner but it is an important concept that if misunderstood will haunt later learning.

    It is very misleading to say it will create a label then return to it. Assemblers shouldn't create anything and will not generate the code to return to anything which is how I read your statement. If you go into writing assembler of any kind thinking it will create the jump that returns to some place, you will execute a lot of data as instructions before you figure out that the PROGRAMMER IS IN CONTROL and must cause the code path to return to some place.
    Those "Spin Wrappings" are a must have item. Throwing them out is likely to put a novice into a complete tail spin. Face it the Propeller is special about loading PASM. It doesn't just start a a low address and go forward. It requires a CogNew or a CogInit to get any of the processors running.
    [/code]

    Yes, the Spin wrapper is important but you can give someone a standard wrapper:
    CON
      _clkmode = xtal1 + pll16x
      _xinfreq = 5_000_000
    PUB Main
      cognew(@MyPasm, 0) 'Launch new cog
    DAT
    
            org   0         'Begin at Cog RAM               addr 0
    MyPasm
    {insert your PASM code here}
    
    
    
            fit
    

    and tell them to start working through examples or work through the PASM manual instruction by instruction or however else they want to play with PASM and they have 495 registers (Longs, instructions, words, etc. this in itself can be confusing) in which they can write PASM code and not worry one bit about what the HUB is doing, what the other cogs are doing or how to pass things between Spin and PASM. They are just directly programming one little cog. It kind of brings a tear to the eye! :smile:

    Because of how Spin and PASM blend together so well, once PASM is learned, teach Spin will actually be easy. Understanding the rest of the propeller will be easier. And from working in this safe little wrapper, they can learn many things that will apply to many other processors.

    When I learned IBM360 assembler, I didn't have to learn JCL first, we were given cards to put around our assembler programs - a JCL wrapper, I never really learned JCL to any significant degree, it was always just wrappers but I went on to program in many different assemblers.
    Teaching is all about helping the learn to notice ALL that is required.

    True, but they don't need to eat the entire elephant at once sitting, teach in little pieces the things that need to be known to get to the next piece. But do;t gloss over or misrepresent how an assembler really handles labels.
  • Heater.Heater. Posts: 21,230
    edited 2014-02-02 08:21
    Loop,


    I agree with pretty much all of that.


    That's why I was being annoyingly picky over definitions. Best not to confuse beginners with incorrect info. It's not just "clever debate".


    You are right to say that what is obvious to old hands can be clear as mud to a beginner.For this reason an introduction to assembler perhaps should not start with mnemonics but rather with architectural concepts. What is memory? What is RAM vs ROM? What is a memory location and how can be seen as place to store a variable? What's a variable here, better discuss binary numbers. What is an instruction? What does it mean to execute an instruction? What actually is the CPU? And so on and so on.


    All of this is perhaps off topic given that does not mention but programming languages, presumably higher level, like BASIC, PICBASIC, C, C++.


    My advice here is really to get a dev board that is ready to run and become master of that. Then perhaps master another one. The Jason will understand why one cannot plug a basic stamp or pic microcontrollers into a arduino uno and start programming it in basic/picbasic.


    Of course being a Propeller forum I would suggest getting a Propeller board and getting to grips with Spin. An easy step up from BASIC and a lot more powerful and interesting machine than the STAMP or most PICs and Arduinos.
  • eventsevents Posts: 27
    edited 2014-02-02 08:46
    The high-level languages ​​exist only because there are good assembler programmers. After all, the assembler is the beginning of everything. And from this moment, you only lose performance.
  • Heater.Heater. Posts: 21,230
    edited 2014-02-02 09:38
    The high-level languages ​​exist only because there are good assembler programmers.
    Very true. But perhaps not in the way you think.

    I guess originally high level languages were written in assembler and hence required good assembler programmers. A nice example of this is Leor Zolman's BDS C compiler for the CP/M systems.

    This is no longer generally true. Those machine architecture and assembler experts today write their compilers in high level languages. GCC is written in C, Clang is written in C++, for example. Then we find that language parser experts or optimization experts may not even know anything about target architecture of the finished compiler. That's down to the guys that write the code generator back ends.

    This is the only sensible way to do it because a compiler is a complex thing and you need all the high level language support you can get. It's essential if you want your compiler to be usable on many different architectures.
    After all, the assembler is the beginning of everything
    Not quite. I started out programming microprocessors in HEX. We had to do all the assembling manually :)
    And from this moment, you only lose performance.
    Perhaps true but the loss is not so as great as to make it worth worrying about in the vast majority of code. If we had to use assembler for everything we would not have a fraction of a percent of all the useful software we have now. It would just take too long to create.

    In fact it is quite possible for a compiler to out perform hand crafted assembler. For example by using OMP (Open Multi-Processing) it is possible to fairly easily spread your codes work load over many CPU's. For example:
        #pragma omp parallel for
        for (i = 0; i < N; i++)
            a[i] = 2 * i;
    
    will spread that array operation over as many CPU's as you have. I suggest doing this in assembler is not so straight forward.

    Of course HLL programs can gain a lot of performance by being recompiled for a new improved or totally different architecture. Assembler programs would need a rewrite.
  • eventsevents Posts: 27
    edited 2014-02-02 11:11
    Speed, ​​performance. This is the purpose of programming. With all these programming alternatives, there is no objective.
  • Heater.Heater. Posts: 21,230
    edited 2014-02-02 11:34
    events,
    Speed, ​​performance. This is the purpose of programming. With all these programming alternatives, there is no objective.
    I think you are winding me up now.
    The purpose of programming is to do work for us that we would rather not do ourselves. Or indeed cannot do ourselves.
    Out and out performance is not the only requirement, or even the primary requirement.
    Clearly high level languages have objectives, as outlined above.

    If your statement were true then all programs for all super computers would be written in assembler. I think you will find they are not.

    That python script that I create in an hour and gives me results in seconds is seriously outperforming that assembler equivalent program that you have spent a month writing and debugging and gives the same results in milliseconds. The whole project from idea to results can be thousands of times faster than assembler.
  • mindrobotsmindrobots Posts: 6,506
    edited 2014-02-02 12:18
    So, Jason...not to get back to your original question or anything, but........

    You said you have a Basic Stamp 2 and are interested in a Pic (Picaxe). What carrier do you have for your Basic Stamp? Have you worked through the What's a Microcontroller book mentioned in another post?

    Why are you interested in a Pic or Picaxe (I forgot which). What do you wnat to do with it that your BS2 can't do?

    What kind of projects do you have in mind? Are you a student? Are you a hobbyist? Are you looking into this for career teasons?

    I think we've given you a number of ideas and a long detour into assembly language programming (sorry for helping wkth that derail). All of this was based on us guessing what you want to do.

    Sadly, the answer was no to your first two questions. Hopefully you have a bit better understanding now of why that is.

    We can try and help more if we have a better idea of what you want.

    You have to excuse, sometimes things come up on threads that we find interesting or good matefial for debating and we get distracted!
Sign In or Register to comment.