Questions - deSilva's machine code PDF
Zap-o
Posts: 452
I am starting to program the propeller in assembly. And while reading deSilva's fine PDF. I come to a misunderstanding. On page 3 he mentions:
I am not so sure there are 496 instructions perhaps 30-40 but almost 500 that's insane. Now to me a instruction would be IF_A, AND, CNT, etc... I am sure I am interpreting this incorrectly. Some one shed some light on this please and be prepared for more questions...
http://forums.parallax.com/attachment.php?attachmentid=48819
deSilva said...
Let’s talk about processors – called “COGs” in Propeller lingo.
What do they do? There is an always correct answer: They execute
instructions! A standard processor gets these instructions from a
globally addressed memory (in a so called “von-Neumannarchitecture”[noparse];)[/noparse]
or from a dedicated instruction memory (in a so
called “Harvard-architecture” – this is the way PICs and AVRs are
organized!). Having two memories allows to “tune” them according
to specific needs (e.g. non-volatile, read-only, fast access
time), and also to access them in parallel!
A Propeller processor gets its instructions from its internal COGmemory,
space limited to 496 instructions!
I am not so sure there are 496 instructions perhaps 30-40 but almost 500 that's insane. Now to me a instruction would be IF_A, AND, CNT, etc... I am sure I am interpreting this incorrectly. Some one shed some light on this please and be prepared for more questions...
http://forums.parallax.com/attachment.php?attachmentid=48819
Comments
When a program executes it has to read instructions from some where, find out what the instruction is, ADD, SUB, etc, read the data required for that instruction from somewhere, perform the required operation and write the result somewhere. You will from time to time see mention of "fetch", "decode" "execute" and such phases of a CPU cycle.
What deSilva is talking about here is the first part, where to read the instructions from. Well they can only be in the COG memory and there is only 512 possible addresses in that space. 16 of those slots are used for special purpose registers, INA, OUTA, etc leaving 496.
So normally that is the maximum size of a PASM program for a COG. Unless you get into creating a PASM program that fetches instructions from HUB first and then executes them. So called Large Memory Model. Let's not get into that just now.
As for the ambiguity in "A Propeller processor gets its instructions from..." I like that, ultimately all Propellers got there instructions from Chip Gracey who designed them that way.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.
An 'instruction' consists of one 'word', or 4 bytes. Some of your code might be instructions, and some might be text, and you have 4x the number of bytes if you want to access stored data.
Or looking at it another way, if a byte stores an ascii character like "A" then an instruction can store "ABCD". Sometimes you can do cunning things like storing new data in old instruction space that isn't needed any more (eg startup code) or storing new code to instruction space. And you can get new data from Hub ram as you need it. Or even from external memory.
And you have 8 of these microprocessors all humming along together.
I like assembly. The hardest part is the building blocks you need to start, eg ORG 0 at the beginning, tables at the end of the code, using FIT to check it fits, and the way cogs are started and stopped. It helps to copy some existing code, eg from the keyboard or vga text driver objects. I found that once I had the template working, Assembly was actually easier than Spin.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.smarthome.viviti.com/propeller
Post Edited (Dr_Acula) : 12/30/2009 12:04:44 PM GMT
...can one write code in spin and in areas where speed is needed can machine code run. For example: say I am already running all cogs and in cog 0 I have the bulk of the code running spin - I also want to run machine code in that same cog.
Is this possiable?
Because in one of the examples it states this
Do you realize what an incredible statement that is? Perhaps for the first time in history of programming we have a device were programming in assembler is easier than the provided high level language. And Spin is quite a simple HLL as they go. That is one of the major attractions of the Prop for me.
As compared to this from a certain other processor I've been looking at:
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.
If a cog executes SPIN, all 496longs are occupied by the SPIN interpreter. There is no space left for PASM.
Maybe there is a possability if you use the improved interpreter. But EVERY time you change the code you would have to fiddle around the adresses
where is SPIN and where is PASM.
@Bean Hitt: I know PropBasic can be mixed with pure PASM.
Is it possible to mix PropBasic with SPIN ? (as PropBasic is compiled to PASM and therefore pretty fast).
best regards
Stefan
Unlike the Propeller, the XMOS chip was designed for efficient execution of compiled languages - assembler isn't needed very often. The XMOS assembler also uses a linker, which complicates matters. Using a linker has the advantage that separately compiled modules (XC, C and assembler) can be used, and libraries can be created.
Leon
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Amateur radio callsign: G1HSM
Post Edited (Leon) : 12/30/2009 1:18:23 PM GMT
You are right though, it's a different world over there.
Thing is I like torturing my brain with assembler coding occasionally. Strangely enough I did have some fun programming Windows once. In assembler. Windows, dialog boxes etc. Seemed that the explanations in the book I had about how it all worked were clearer than those in the C++ equivalents.
Can't remember exactly now but it could have been from this book: www.amazon.com/Windows-Assembly-Language-Systems-Programming/dp/087930474X
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.
Leon
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Amateur radio callsign: G1HSM
Post Edited (Leon) : 12/30/2009 1:47:26 PM GMT
can't disagree with you. I·started on the 6502 then migrated to the Intel 80xxxx series·but I've got to say, it took me a while to get my head out·wrapped around·working without a stack.
Jim-
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Signature space for rent!
Send $1 to CannibalRobotics.com.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Signature space for rent!
Send $1 to CannibalRobotics.com.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.
I was writing some 6809 yesterday. God, I love that chip. It is the best of the 8 bitters, and has a multiply. Anyway, I'm wanting to do a little math to obtain a screen address...
WHERE DID ALL MY REGISTERS GO, and HOW COME I CAN'T JUST USE ALL OF THEM HOW I WANT TO?
LOL!!
That stack came in very handy, because the number of registers isn't high enough to operate without it!
Back on Prop, I find it so easy to just write assembler. Not that I can just knock it out or anything. It's all a struggle for me. But, the difference was in addition to just sorting out the problem, which is my main Propeller problem as I'm an amateur, I had to also sort out the registers and do that planning too!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Propeller Wiki: Share the coolness!
8x8 color 80 Column NTSC Text Object
Safety Tip: Life is as good as YOU think it is!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.
Color Computer has always been one of my favorite computers. It's possible to really expand one and do some fairly serious computing on it, yet it can be broken down to just a computer, maybe a disk, and do simple, fun things too. The basic language interfaces to machine code nicely, and it's I/O and memory map overall are sane, and not a mess.
One nice thing about 6809 is external devices, like video, can operate on the last phase of it's clock, meaning no DMA is needed, allowing the chip to run deterministically, timing wise, and achieve full though put no matter what the video system is doing. Most other 8 bit computers, but for the Apple, are a mess of timing, cycles, interrupts and such.
Maybe OS/9 in multi-user mode will be possible someday on Propeller... Just a day ago, some guy put his on the net so others could telnet in. Was fun to browse around "dir -e" ftp a "thanks for letting me play" text file, and see what some of the other users were doing.
So, yeah. I was a fan straight away, having cut my assembly language teeth on the 6502. At the time 6809 seemed so much more powerful and elegant. It still is, if you look at 8 bit computing, and even some of the bastardized 16 bitters out there. 6809 punched well above it's weight. But... after doing prop, it seemed so constraining. Funny how perceptions change, isn't it?
Edit: And I bought a spare 6809, when I picked up 6502 stuff, just on the off chance I might end up hooking it to a Prop. Maybe after seeing success on my 6502 build, that chip can be done for testing illegals and such. What is hard to get is the Hitachi 6803...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
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) : 12/30/2009 5:04:20 PM GMT
It's hard to know with one to play with, but I like my demo board the best!
Jim
members.optusnet.com.au/jekent/system09/index.html
Leon
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Amateur radio callsign: G1HSM