@mcstar
(1) I am doing my best to write a sequel
(2) It is best NEVER to think of bytes when inside a COG. It is of little importance how many "bytes" there are - there are 512 cells (I call them "words" out of habit, but that somtimes confuses people)
(3) All cells in the COG (upto #495) can of course be used! But they are not neccessarily zero; it depends on what had been allocated in the HUB. This can also be changeable variables.
In fact this is a convenient way to "parametrize" a COG
I just read the assemblers for idiots, Thanx much for getting me started Silva. Then I read that another person understands pops and pushes. I didn't see that in your assembly06.pdf. Are there more instructions that I have missed? Where do I go now?
Don
P.S. I have been trying to learn this for 20yrs now. If I had known it was this easy I would have done it along time ago. Thank God for the internet.
New User 2nd Day
Assembly06 is the very beginner one I wrote. It's here on Desilva's thread because we both thought his intermediate tutorial and this one belonged in the same place. In the very near future, I've got some more example programs to incorporate into the beginner document. (Real Life is taking it's toll right now!!)
I would collect the Propeller Assembly referrence, found in the Propeller Manual, DeSilva's Intermediate document, and the Propeller Data Sheet together and start working on your own small programs.
---and it's assembler for BEGINNERS, not idiots! [noparse]:)[/noparse]
Do keep that in mind as you have a great time telling your prop what you want it to do!
deSilva,
Your tutorial on propeller assembly language has been extremely useful. It took me 2 years to stop the evasion of PASM in my Spin code, I have some experience in 80386, 68000 from univ and 8085, 809 from when I was a kid - however your tutorial got me running within 2 hours by reading to page 12. My first P8X32A machine language is attached.
I especially like your analogy of the "cell" for the 512 32-bit registers that aids in understanding self modifying code, and also the fact that MAX is really MIN.
thank you very much
/ Michael O'Brien
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
VAR
' shared display RAM for the 4 display cogs
long buffer[32]
long Stack0[64] ' Stack Space
byte Cog[7] ' Cog ID
long range
long aCounter
OBJ
SER : "Parallax Serial Terminal.spin" ' part of the IDE library
STR : "STREngine.spin" ' in the current directory
PUB main | milestone,start,number,index, lRec,x,i, mIndex, mValue, path,height, maxPath, maxHeight
' wait for user to switch to terminal
waitcnt((clkfreq * 5) + cnt)
maxPath := 0
maxHeight := 0
milestone := 0 ' track whether we got a path or max height hit
range := 1 << 17
ser.Start(115_200)'31,30,0,38400)
ser.Home
ser.Clear
ser.Str(string("Collatz Conjecture", ser#NL))
aCounter := 27
_nextVal := @aCounter ' pass word to assembly via hub ram
ser.Str(string("Max Value for "))
ser.Str(STR.numberToDecimal(aCounter,8))
ser.Str(string(" is "))
Cog[1] := cognew(@entry, @aCounter) + 1
waitcnt((clkfreq * 2) + cnt) ' it takes 100ms to load a core
ser.Str(STR.numberToDecimal(aCounter,8))
DAT
org 0
entry ' iterate the collatz sequence for _nextVal
RDLONG _nextVal, PAR ' read from shared ram (7-22 cycles)
:iterate
ADD _path, #1 ' increment path
MOV _bit0, #1 ' create mask
AND _bit0, _nextVal WZ ' check bit 0 - affect zero flag
IF_NE JMP #:mul3x1
:div2 ' if even we divide by 2
SHR _nextVal, #1 ' divide by 2
CMP _nextVal, #1 WZ ' check for 1 value == finished
IF_E JMP #:finish
JMP #:iterate ' return to top of loop
:mul3x1 ' if odd we transform by 3n + 1
MOV _3rdVal, _nextVal
SHL _nextVal, #1 ' multiply by 2
ADD _nextVal, _3rdVal ' add to multiply by 3
ADD _nextVal, #1 ' add 1
:maxValue ' check for maximum value
MIN _maxVal, _nextVal ' VERY ODD (max is actually min)
JMP #:iterate ' return to top of loop
:finish
SUB _path, #1 ' we discount the first path count
'MOV _nextVal, _path ' copy path to return val
MOV _nextVal, _maxVal ' copy maxVal to return value
WRLONG _nextVal, PAR ' write back to hub ram (thank you deSilva for reverse flow explanation)
' WRLONG _path, PAR
:endlessLoop
JMP #:endlessLoop ' keep the cog running
_3rdVal long $00000000
_nextVal long $00000000
_maxVal long $00000000
_path long $00000000
_bit0 long $00000000
FIT 496 ' deSilva (16 I/O registers in 496-511)
'' http://forums.parallax.com/showthread.php?96594-Machine-Language-Tutorial!&p=668559
Comments
(1) I am doing my best to write a sequel
(2) It is best NEVER to think of bytes when inside a COG. It is of little importance how many "bytes" there are - there are 512 cells (I call them "words" out of habit, but that somtimes confuses people)
(3) All cells in the COG (upto #495) can of course be used! But they are not neccessarily zero; it depends on what had been allocated in the HUB. This can also be changeable variables.
In fact this is a convenient way to "parametrize" a COG
Thanks
Rich
It is quite a cooincidence that 2 guys named Doug who really like SGI's end up on an unrelated forum '^)
Anyway, I like your assembly pdf. It starts low enough that it will help tech my 10yearold boy after he gets through the boebot kit.
I have a couple of corrections for you. Page 8, it should read "(15 x 4096)", top of page 10, "1024 bytes = 2^10"
Take Care,
Doug
I'll fold those in, and have another coupla examples to add very soon.
SGI machines (the older IRIX models) are the best computers ever made. Saw your user name, and just knew ..another IRIX head. Sweet!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Propeller Wiki: Share the coolness!
Don
P.S. I have been trying to learn this for 20yrs now. If I had known it was this easy I would have done it along time ago. Thank God for the internet.
New User 2nd Day
Assembly06 is the very beginner one I wrote. It's here on Desilva's thread because we both thought his intermediate tutorial and this one belonged in the same place. In the very near future, I've got some more example programs to incorporate into the beginner document. (Real Life is taking it's toll right now!!)
I would collect the Propeller Assembly referrence, found in the Propeller Manual, DeSilva's Intermediate document, and the Propeller Data Sheet together and start working on your own small programs.
---and it's assembler for BEGINNERS, not idiots! [noparse]:)[/noparse]
Do keep that in mind as you have a great time telling your prop what you want it to do!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Propeller Wiki: Share the coolness!
Your tutorial on propeller assembly language has been extremely useful. It took me 2 years to stop the evasion of PASM in my Spin code, I have some experience in 80386, 68000 from univ and 8085, 809 from when I was a kid - however your tutorial got me running within 2 hours by reading to page 12. My first P8X32A machine language is attached.
I especially like your analogy of the "cell" for the 512 32-bit registers that aids in understanding self modifying code, and also the fact that MAX is really MIN.
thank you very much
/ Michael O'Brien
I concur that his short PASM tutorial is excellent.
32 bit asm instructions, especially as well thought out as the Propeller's, are
very powerful and you can do a lot in the 2kb of cog space.