Long aligned string
iammer
Posts: 4
Hi all,
Quick question maybe someone can help with. I would like to put a long-aligned string in hub memory with each character taking a byte. In my DAT block, if I do:
If I do:
I see per the manual you can override alignment, but it looks like you can only do that with a smaller type. i.e.
Does anyone have an idea how to do this?
Quick question maybe someone can help with. I would like to put a long-aligned string in hub memory with each character taking a byte. In my DAT block, if I do:
label long "string"I get the string long aligned, but it uses 1 long per character.
If I do:
label byte "string"I get a byte per character, but the string is not long aligned.
I see per the manual you can override alignment, but it looks like you can only do that with a smaller type. i.e.
label byte long "string"This still aligns to a byte, what I would like to do is something like
label long byte "string"but, this does not seem to be valid syntax
Does anyone have an idea how to do this?
Comments
You really should use a byte array to define a string. Why do you need a long aligned character?
I'm pretty sure there are other ways to do this but I don't recall how.
Thanks.
seems to be the same thing as
What I am looking for is for the characters to be bytes but the string itself to be long-aligned (i.e. the first character starts at a memory address divisible by 4)
Looks like Duane's idea worked perfectly. Thanks.
I'm a little confused though, what is the difference between
and simply
both are byte data types...
My interpretation of the problem was just to get the first character "s" long aligned. As you say, the other characters (or 3/4 of them) will not be long aligned.
I imagine iammer wants to pass the start of the string to a cog running PASM using the "par" register.
Beau showed another way (IMO better) to long align the first character of a string of bytes.
Yes, I want to pack 4 characters into a long. What I am looking to do is read 4 bytes of a string at a time using a rdlong instruction. To do that I need the first byte of the string to be long aligned, as rdlong can only read from long aligned addresses. Org is used to set a reference point for symbols in cog memory. And it looks like it long-aligns as well since pasm code must be long aligned.
I ended up doing it like Beau's example, since that is a lot cleaner.
Thanks for the note on the endianess. Little endian is what I want.