Assembly help
Circuitbuilder9
Posts: 85
Hi, newbie again.
I would like to know how to change the "par" register in order to store it into more than one variable. thnx
I would like to know how to change the "par" register in order to store it into more than one variable. thnx
Comments
The PAR register can not be expanded. I've always thought of it/treated it as a memory address that you get to set when you launch PASM code. If you put all the HUB items you'd like to have access to in order and pass the address of the first one, as the developer you know where everything else is relative to the address you passed in PAR. By adding 4 to the PAR value you can rdlong, adding 2 allows you to rdword, and adding one will increment to the next rdbyte in HUB.
As has been said, the PAR is a read only register that is set by the coginit/cognew routine. You should examine this in the Propeller Manual (both in spin and in pasm) for ways it is set.
Usually we use this as an address pointer to hub where a set of parameters reside.
And the attached program -- yep, a blinky LED thing -- shows you how this works. You pass the address of the first of a group of longs. Knowing that the variables are longs the PASM code adds 4 to par (actually a copy of it as par is read-only from PASM) for each element after.
One more question (sorry if this is a dumb question; I am a freshman in high school): registers such as add and adds; what is a signed value? thnx.
as the code is in hubram before it get sent away to cogram,
you could modify the code with the pointers you want.
I'm not sure which is the preferred method as both works.
This example does both, pass a value in PAR and also selfmod the pin used.
When I reserve 3 longs in the way I do it for hub1,hub2,hub3
they all will be after each others in hub ram
So I make PAR point to the first one.
--- the spin code--
PUB DisplayDemo | hub1,hub2,hub3
LED.Display(@hub1, 0{←the pin to use})
--- the spin part of cognew that gets the pointers---
PUB Display (hub1,pin) 'the values @hub1,Pin from Demo
CLKpin := |<pin 'set the pin with selfmod
cognew(@asm_entry, hub1) 'launch assembly program in a COG, PAR will point to hub1 address.
DAT
org 0
asm_entry mov dira,CLKpin 'make only clk pin an output
mov hubadrs,par 'reset (par=hub address of @hub1)
...
if_nz add hubadrs,#4 'next long hub adress
...
CLKpin long 0-0
hubadrs res 1
One last thing (about hardware this time): where do you insert the capacitor for servos with very long wire extensions? Or do you not need one? If it is possible, i would like to see a schematic.
One you quesion... the Propeller only puts out 3.3v which is fine if your servos are close, not so good if they're a long way (I have a client who just went through this when he extended his connections). It's a good idea to put some kind of buffer between the Propeller and the servos. In my client's case there is only two servos so we're using a TC4427 because it allows him to select the output voltage for the servo pulse.