Need help with writing a byte of PASM data to the main ram
Ravenkallen
Posts: 1,057
So, after a long break i decided to jump back into learning assembly. Only problem i have run into so far is i have not figured out how to write/ read a byte of data to the hub ram. I have tried searching various places for the answer but i have not found anything good. I know somehow you have to pass the address of the cell of memory you are writing to, but i don't know how to do it...A brief piece of code or instructions on how to do this would be great....Thanks guys
Comments
Next, obtain a fine pointed soldering iron and very thin wire. Carefully follow the circuit paths until you reach the row and column lines of the HUB RAM. Using as little solder as possible, tack a segment of fine wire to each line, and run these wires out to the external pins of the chip.
Now, using simple OUTA, INA, and DIRA commands, experiment until you find the right combination of strobes to access the RAM locations you are interested in.
Oh wait! You wanted ASM access to them! That can't be done. Sorry.
I am glad you posted this Nick. That is the way I first learned to address spin variables, but didn't know if it was "proper" or not. I know it takes more memory in the cog addressing spin variables this way than just manipulating the PAR pointer. I guess if you got the longs to burn, it's OK.
Longs get burned either way, IMHO.
One can also hard-code some addresses in the upper HUB RAM for communication too.
The advantage of the PAR method comes when the PASM is going to be binary loaded. The cognew passes a single address, which the COG can then use to fetch, or operate on whatever HUB data it finds at that address.
PASM can then be built, written out to SD, or the EEPROM, or something. Another program can fetch it, build up the data needed for it to operate, then cognew, leaving the PASM program to do it's thing in the COG.
In reality, its amazing how easily variables are passed between SPIN and ASM. It is an ongoing effort to recognize typical Propeller constructs at a glance; C has held my brain captive for several years.
You're not the only one who has found it hard to break out of C captivity
Trying to be on topic now:
My own style has evolved to one where I usually specify a table of longs and pass the base address via PAR to the COG. That way, I can have as many parameters as necessary for communicating with the COG with what I call "spinners". A "spinner" is a routine that waits for something to happen with a variable. A spinner variable is usually a command and/or response mailbox.
--Steve
Con
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
Var
long val1, val2
obj
serio: "parallax serial terminal"
Pub main
waitcnt(clkfreq + cnt)
serio.startrxtx(31,30,0,250_000)
value1ptr := @val1
value2ptr := @val2
cognew(@entry,0)
repeat
serio.dec(val1)
serio.char(13)
Dat
entry
ORG 0
wrlong dummyvar, value1ptr
add dummyvar, #100
wrlong dummyvar, value2ptr
dummyvar long 100
value1ptr long 0-0
value2ptr long 0-0
Admittedly I don't know what exactly your PASM fragment is supposed to do but it's always bad style letting your program run into its data section. Either loop indefinitely or stop the cog. Not doing either may give you a headache later with more complicated code