PASM question
port513
Posts: 50
entry movd :par,#_dpin 'load input parameters _dpin/_cpin/_locks/_auto mov x,par add x,#11*4 mov y,#4 :par rdlong 0,x add :par,dlsb add x,#4 djnz y,#:par
The above code is from Keyboard.spin
What dows the movd [noparse]:p[/noparse]ar, #_dpin do?
What I'm trying to understand is how the input parameters are sent to PASM code.
/Henke
Comments
now they increas by
add [noparse]:p[/noparse]ar, dlsb why?
dlsb = 1<<9
/Henke
If possible give me an explaination of the adress in Cog RAM and the 1<<9 operation.
Remember I'm new to Propeller [noparse];)[/noparse]
/Henke
Post Edited (port513) : 9/26/2008 7:21:37 PM GMT
Cog RAM consists of 32-bit long words and each long has an address (0, 1, ..., 511)
Hub RAM consists of 8-bit bytes and each byte has an address (0, 1, ..., 32767).
The bytes can be grouped into 16-bit words and 32-bit long words (longs) on appropriate
2-byte and 4-byte boundaries. Hub ROM works the same for addresses 32768 to 65535.
RDLONG transfers a long from a Hub address that's on a 4-byte boundary to a location in
cog RAM. It ignores the least significant 2 bits of the Hub address.
The cog address field of the RDLONG instruction is in bits 17-9. There are no index registers
so, if you want to access successive cog memory locations, you have to change the address
in the instruction itself. The 1<<9 is used to add a 1 to the destination field of the RDLONG
instruction.
I did read the manual but it's Friday night soo·[noparse];)[/noparse]
/Henke
/Henke
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
And that tells me that this is a byte aligned word sized data and a byte aligned long sized data. So where should I find the requirements of a word sized being word aligned?
I can't really find the requirements.
/Henke
( For some reason that's not displaying in my browser within your code-quote )
I'm not entirely sure where the requirements are stated for word and long alignment but you do have to distinguish between data storage ( where alignment and non-alignment is a matter of your own decision making ) and how such data is accessed using word[noparse]/noparse or long[noparse]/noparse in Spin and using rd/wrword and rd/wrlong in PASM where data should be aligned to suit those commands.
For such word accesses the lsb is treated as zero, for long accesses two lsb's are treated as zero, so if the data is not correctly aligned what is accessed will likely not be as expected.
It's not so much that word and long data must be aligned in anyway, but that data should be aligned to meet the expectations of commands which implicitly expect such alignment.
You could for example align a long however you wanted, but you might not then be able to simply use rdlong to retrieve its value. You could however use four rdbyte commands or (sometimes ) two rdword commands.
Now it's much clearer [noparse];)[/noparse]
/Henke