Machine Language Tutorial?
deSilva
Posts: 2,967
Propeller Assembly: Intermediate Level Tutorial by deSilva (c) 2007
You always wanted to „learn microprocessors"? Now you have discovered the Prop and think: “Gee, this is a high-end device: 32 bits and 8 cores! I shall not start with anything less powerful.”
Although I appreciate your attitude, this tutorial is not the right one for you at the moment. You have to master 2 levels before:
- Become fluent with SPIN and discover its possibilities and its limits
- Know some of its I/O features and understand the general architecture of COGS and the HUB
You will profit most from this tutorial when you have already mastered both steps mentioned above and have some general idea how machine languages work. You will also profit, when you are fluent in another processor’s machine language and now have a hard time to apply this pre-knowledge to the Prop.
Edit:
This Tutorial has now got some stability and I have prepared a PDF of a reasonable size (300 k) so it can easily be downloaded http://forums.parallax.com/showthread.php?p=668559
As the postings here have become obsolete over the time I shall (or already have) remove(d) them.
Post Edited (deSilva) : 8/19/2007 12:17:00 PM GMT
You always wanted to „learn microprocessors"? Now you have discovered the Prop and think: “Gee, this is a high-end device: 32 bits and 8 cores! I shall not start with anything less powerful.”
Although I appreciate your attitude, this tutorial is not the right one for you at the moment. You have to master 2 levels before:
- Become fluent with SPIN and discover its possibilities and its limits
- Know some of its I/O features and understand the general architecture of COGS and the HUB
You will profit most from this tutorial when you have already mastered both steps mentioned above and have some general idea how machine languages work. You will also profit, when you are fluent in another processor’s machine language and now have a hard time to apply this pre-knowledge to the Prop.
Edit:
This Tutorial has now got some stability and I have prepared a PDF of a reasonable size (300 k) so it can easily be downloaded http://forums.parallax.com/showthread.php?p=668559
As the postings here have become obsolete over the time I shall (or already have) remove(d) them.
Post Edited (deSilva) : 8/19/2007 12:17:00 PM GMT
Comments
I just got done working through a very fundemental computer math and basic concept primer. rjo_ sparked some creative juices. It's way beneath this, but might apply. Looking for a review and commentary.
I'm thinking at building this up, at about this level of detail. Too simple, too tough, too wordy, what? I'm curious to hear feedback. This is a topic I would enjoy writing about.
deSilva, do you mind if I post that here? I didn't want to start just a thread on this, but you did, so maybe it makes sense?
(I'll toss it, or move it if this is not warranted!)
EDIT: WIP efforts removed. See Assembly Language Tutorial! Thread. Thanks for reading.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Propeller Wiki: Share the coolness!
Post Edited (potatohead) : 8/20/2007 1:27:53 AM GMT
It seems both our efforts will be perfectly complementary and will support one another.
I would completely disagree that one has to be fluent in and have mastered Spin to understand the COGs. Apart from knowing that there are read and write commands to the hub memory, and a few lines of Spin code are needed to get code into a COG and running to start with, everything else 'Spin' from a COG's perspective is irrelevant. One can write usable COG code without having to know any Spin at all beyond the one line needed to get the COG running.
Likewise I don't think that knowing about timing or intricacies of hub accesses and their timing is at all important until one comes to wanting to do timing based control of I/O or internal COG timing.
From the COG's perspective looking out, it's a very simple world, and I get the feeling that people may be having problems because they are trying to think of COGs in terms of Spin and that's wrong IMHO.
There are three parts to a Propeller -
COGs - eight of them, all the same from their programming perspective.
Spin - Of which up to eight concurrent Spin programs can be running at any time.
Data Structures - Through which Spin programs and COG programs interact with each other.
A COG program will do one or two things, and often both - Interact with I/O pins and control registers and/or interact with data structures held in the hub memory. I believe there would be good mileage to be had in ripping potential COG programmers away from Spin entirely to start with, then re-introduce how a COG and Spin program interacts through the shared hub memory later.
Initially I had problems understanding how the Propeller worked as a whole, but once I realised it was just eight processors and some shared memory on a single chip it all became crystal clear.
The only thing I can see which might require explanation for anyone new to COG programming is the mechanism of CALL which puts the return address at the RET instruction, but they wouldn't need to know how it works when starting off, just that it does.
Perhaps the real questions is, what difficulties are Propeller users having when it comes to Assembler programming ? Is it just that there are a lot of high level language ( Spin ) programmers who are quite simply unfamiliar with low-level Assembler programming ?
If you want any of your translations proof read let me know, I spotted a few bits that did not read so well. I think that might be better done within a word document or similar rather than from forum posts however.
Potatohead, I really like your document a lot excellent stuff, it reminds me of what I always say about mathematics, "its just adding up".
All of this might be compiled into an ebook with chapters written by different people.
Cheers,
Graham
Could be great !!. if you put all togheter in pdf's. [noparse]:)[/noparse]
Well done.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Regards.
Alberto.
But let me first have the other 5 chapters, as I might restructure things...Hippy made some remarks I have to think about.. It is tricky to find your audience...
@deSilva No kidding. I find it very helpful to write to someone. In this case, it just happened to be rjo_ who struck a chord on that other thread a while back. His comments triggered a lot of early learning memories. He wants to write some stuff too, and that got me in the mood.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Propeller Wiki: Share the coolness!
Post Edited (potatohead) : 8/13/2007 6:52:16 AM GMT
Want to make sure it's solid, with no best practice errors. (My code has a batch of this stuff that will get fixed while completing the pdf work I started.
Anyone have a pointer, or care to just knock one or two out?
I want to explain it, and that's easier coming from someone else.
Is it a big deal to nip examples and commentary from this forum?
The PDF will be left here for people to use. I'll also likely put it up on some publishing on demand site (lulu?), for those who want to get hard copy to be able to do so.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Propeller Wiki: Share the coolness!
Post Edited (potatohead) : 8/13/2007 3:20:27 PM GMT
Clears upper n Bits und reverses the sequence of the (32-n) lower bits of register “a”.
Reverse means what? Just invert (0->1, 1->=9) or bit0 -> bit n, bit1 -> bit n-1 ... ?
Post Edited (deSilva) : 8/13/2007 5:35:03 PM GMT
Yep. That will serve nicely!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Propeller Wiki: Share the coolness!
Post Edited (Fred Hawkins) : 8/15/2007 9:53:46 PM GMT
"notabene"??
I think it is a simple fact that immediate addressing is restricted to 9 bits and no need for any sarcasm. Maybe I have lived too long with much stronger constraints...
@Graham: O dear! I THINK I consulted www.leo.org a most reliable source of translation in and from many languages and used nearly as heavily as the wikipedia (in Germany i.e.) Nevertheless, I NOW consulted it, and is says this should be an English word
Basically it's Latin "nota bene" (which is nearly Italian) meaning: "mind you".
Post Edited (deSilva) : 8/15/2007 6:51:11 PM GMT
MOV·affects all 32 bits of its destination.
If you need a 32-bit source, you can always use a cog register; you don't have to use RDLONG.
·
I just realized I use it myself only I would write nb.
I also don't know what ie. stands for though I know it means that is
Graham
I made no systematic examples, as MOV and it's derivates are used in all examples in many ways.. I gave an example how to utilze NEG to enter -1 to -512.
Using some preset longs is a trade-off against a shift instruction following a MOV. It takes slightly longer but can be easier to understand
Microprocessor programmers are not used to shifts >1
It couldn't be easier: ID EST
which means - surprise, surprise! - that is
Sorry, it's not my fault I know such things: I had it in school for 6 years...
But my point that the maximum significance of an immediate value is limited to 9bits still stands.
This shows up often in the setting of output bits, where one line set ups a bit, another shifts it into position and finally a third mux's it.
ps. poster fixed
Post Edited (Fred Hawkins) : 8/15/2007 9:49:00 PM GMT
Beyond the debatable nature of efficency, and the merits and demerits of CPU architecture, what you want to do is absolutely possible as is. In essence what you are asking for is a MOV R1, #32 bit constant. You are thinking that this has to be done as two consecutive 32 bit locations in cog memory (MOV instruction followed by a 32 bit constant). But·these two locations dont·have to be consecutive. The following bit of code accomplishes the same thing with no loss of function or space:
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
Post Edited (Paul Baker (Parallax)) : 8/16/2007 4:22:53 AM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Propeller Wiki: Share the coolness!