Propeller Assembler vs. the TI MSP430
kt88seamp
Posts: 112
I want to start learning Prop assembler.
Im my microcomputers class my professor is teaching us how to program the MSP430 series of microcontrollers. I find that unit neat. Only 27 native instructions and 24 emulated. Does the prop have emulated or are they all native?
What about general purpose registers? The MSP430 has 16 of them R0-R3 are reserved. R0 for the program counter, R1 for the stack pointer, R2 for the status register, and R3 for the constant generator. R4 - R15 are for general purpose use. How is the propeller in respect related?
What about initialization? In the MSP430 you need to specify with ORG directives to specify the beginning of ram, the reset vector, and the beginning of the code, etc. Are there templates for beginners like my teacher provides us?
Finally, what about the stack and the stack pointer. Does the prop use one?
Im my microcomputers class my professor is teaching us how to program the MSP430 series of microcontrollers. I find that unit neat. Only 27 native instructions and 24 emulated. Does the prop have emulated or are they all native?
What about general purpose registers? The MSP430 has 16 of them R0-R3 are reserved. R0 for the program counter, R1 for the stack pointer, R2 for the status register, and R3 for the constant generator. R4 - R15 are for general purpose use. How is the propeller in respect related?
What about initialization? In the MSP430 you need to specify with ORG directives to specify the beginning of ram, the reset vector, and the beginning of the code, etc. Are there templates for beginners like my teacher provides us?
Finally, what about the stack and the stack pointer. Does the prop use one?
Comments
- All native instructions
- 496 usable user registers (that also contain the program code)
- No stack
It's a good idea to specify ORG. All assembly programs run in their own separate cog and all start from location 0.
Plenty of code examples in the forum, obex and accompanying the Propeller Tool.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Life may be "too short", but it's the longest thing we ever do.
IMHO, the set of core Propeller instructions necessary to write effective programs is not all that large. There are quite a number of permutations, due to the conditional execution bits and instruction effect bits. Each can be executed on a variety of cases, if_Z, if_NZ, etc... and each can either write the result and or flags as needed. This makes for some dense code, when properly applied. It is possible to ease into this aspect of the chip however.
Propellers do not have many addressing modes. There is basically implied addressing (where value in instruction is used directly), direct addressing, and indirect addressing.
One unique element is the two memory spaces. Propeller assembly language executes on a COG, and there are 8 of them. The COG addressing is really simple, with each 9 bit address being either an instruction to execute or data, as determined by the programmer. There is no addressing other than LONG (32 bit addressing)
When a COG interacts with the HUB (shared memory), addressing is on a byte, word, or long basis, with alignment being the least significant bits set to 0.
You will find "registers" to be an interesting topic!!
Propellers are not a load, operate, store design. There are NO designated general purpose registers that are directly addressable, other than the PC. All operations are memory to memory direct, meaning the entire 9 bit address space of the COG is either registers or program memory as you the programmer deem appropriate. The upper COG memory addresses are shared with shadow registers that control the on-chip facilities provided by each COG, and manage the pin directional states, which are all "or"ed together electrically. The pins are shared among all COGs, meaning programs can run on the different COGs, directly interacting with the state of the pins set by themselves, or other programs.
There are no vectors, as there are no interrupts.
Initialization is simple. Propeller powers up, finds EEPROM, loads it's shared memory with the program image, then starts executing SPIN code in COG 0. All propeller assembly programs start with a minimum of one SPIN instruction, which can simply be a call to start running assembly language. If that's confusing, know that Propellers contain an on-chip high level, tokenized SPIN language intrepeter, that can be used to run lower speed, non-assembly language programs in tandem with lower level assembly programs.
These can be mixed and matched on any of the 8 COG's, meaning they can be running SPIN code, or assembly code. A common example would be a video driver running on one COG, where a SPIN program running on another one can write to the frame buffer to display something, not having to interact directly with the video driver, which would look like hardware to the SPIN program being discussed.
There is no stack. Programmers are free to create one, and calling subroutines involves self-modifying code. On that note, indexing within the COG memory space also involves self-modify code as well. This isn't as bad as one would think, and in fact ends up making a lot of sense after you've coded a bit, and this is why:
When a COG is directed to run assembly language code, it's own 2K of memory is loaded from the shared 32K HUB memory, then program execution begins. COGs run in their own memory space, not related to the HUB. The program is copied from the HUB, which can be over-written, or not, depending on the programmer intent. The result of this is the self-modify code ends up being an ordinary and easy to do thing.
You will have a lot of fun on this chip, if you are willing to give up a few things that we all would take for granted [noparse]:)[/noparse]
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Propeller Wiki: Share the coolness!
8x8 color 80 Column NTSC Text Object
Safety Tip: Life is as good as YOU think it is!
-Phil
Not really. Registers are kinda a hybrid of global variables and code. Incredibly versatile. It can get a little unwieldy if you want to write re-entrant code, but it can be done. Once you get your head around it, it's an absolute pleasure to write for.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Life may be "too short", but it's the longest thing we ever do.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Propeller Wiki: Share the coolness!
8x8 color 80 Column NTSC Text Object
Safety Tip: Life is as good as YOU think it is!
The thing is, those _device_ (interrupts, vectors, stacks...) are all hacks put in place to work around limitations in traditional architectures. Have a closer look into the multi-processing aspect and you will see the requirement for most of those things just falls away.
Simple, fast, powerful.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Life may be "too short", but it's the longest thing we ever do.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon McPhalen
Hollywood, CA
Most of us here have programmed a variety of CPUs. The Propeller is highly distinctive. The design elements you consider "dumbed down" actually present you many new options, not available on the CPU you are using, that is what we are telling you really.
Either those are worth learning, or not.
The only real comparisons are those ordinary computing operations common in assembly language. Those carry forward, as do other basic things. Beyond that, it's a new CPU. Comparing instruction sets, features, lack of, etc... doesn't mean much, until you've worked through some projects.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Propeller Wiki: Share the coolness!
8x8 color 80 Column NTSC Text Object
Safety Tip: Life is as good as YOU think it is!
Post Edited (potatohead) : 1/28/2010 6:03:42 AM GMT
I don't think anyone here would claim that the Propeller is the be-all, end-all solution to every problem. And you're right: the MSP430 (a 16-bit controller) enjoys a well-deserved reputation for its energy sipping performance. Every micro has its niche. You just have to select the one that's right for the app a hand. And the more micros you have under your belt, the more valuable you will be as a developer. I'm glad that you're trying the Propeller. I know you'll like it. And I've got a little MSP430 RF-enabled wristwatch I'd like to get more acquainted with, from a developer's standpoint.
-Phil
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
cmapspublic3.ihmc.us:80/servlet/SBReadResourceServlet?rid=1181572927203_421963583_5511&partName=htmltext
Hello Rest Of The World
Hello Debris
Install a propeller and blow them away
Best not to compare no matter what, like learning a new language you have to immerse yourself into it and the culture to make it really click....n boy, has the Prop got some culture.
Thank goodness it doesn't have those traditional kludges that have burdened every processor since year dot such as interrupts, vectors, working register sets, machine stacks etc. On many manufacturer's datasheets these are called features, don't be fooled though, look at what the basic "V1.00" Prop has accomplished without all those features and the evidence is undeniable. It may not be mainstream but that has never been the measure of what is better anyway.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
*Peter*
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
24 bit LCD Breakout Board now in. $24.99 has backlight driver and touch sensitive decoder.
If you have not already. Add yourself to the prophead map
Doug
Here is the resultant Spin byte code (using BST)
The read and write operations are single-ended in that they only have a source or destination which implies a stack is used and of course it is.
So really the Spin compiler generates Spin machine code and so you could have your own "assembler" that outputs this high-level "machine" code so:
Gee, that's almost like Forth using local variables!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
*Peter*
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Life may be "too short", but it's the longest thing we ever do.