How do I place data at a specific HUB location ?
Bean
Posts: 8,129
I tried
Bean
DAT
ORG $7000
LONG $5555_AAAA
But it says "Origin Exceed $1F0 limit"Bean

Comments
except in code ... long[$7000] := $5555_AAAA
ORG does just work for PASM and even there it will not do what you think it does.
It will change the instruction coding as if the code is at ORG xxx. But will leave it where it is. So you have complete garbage.
P2 SPIN/PASM has ORGH for HUB. possible doing what you think ORG does.
Enjoy!
Mike
But who knows what that might trample upon. What is your ultimate objective?
-Phil
Bean
So I am using...
When the pointer reaches $7400 the "and" instruction moves it back to $7000.
Bean
The prop uses only 16 bits for the address, ignoring the upper 16 bits. This lets you cheat by having an augmented address and delta address, i.e. an address where adding adr += del will wrap the number negative. Once the number is negative, a signed mins statement will restore the augmented pointer to the initial value. And all the rd/wr-long/word/byte commands will kindly ignore the upper 16 bits for you.
Here is some test code in Spin:
PUB test_address_wrap | lo, N, del, hi, vmin, vadd, v ' buffer address, length, step (would usually be 1, 2, or 4, but just testing a weird number) lo := 1765 N := 61 del := 3 ' computed hi := lo + (N-1) * del ' hub addresses are 16 bits (32768 RAM, then 32768 ROM), and the upper 16 bits are ignored vadd := (1 << 16) | del 'vmin := ((posx >> 16 << 16) - ((N-1)<<16)) | lo ' easier to understand vmin := (((-1 >> 17) + 1 - N) << 16) | lo ' easier to translate to PASM ' now test it start_serial_link v := vmin repeat waitcnt( clkfreq / 10 + cnt ) term.tx( 13 ) term.dec( lo ) term.tx( " " ) term.dec( v & 65535 ) term.tx( " " ) term.dec( hi ) ' next point v += vadd v #>= vmin if v == vmin term.tx( 13 )So, all you need are 2 instructions: add, then mins.Jonathan
It's inelegant and wasteful, but if you have the extra space, just create a DAT or VAR array that's 5120 ($1000 + $400) bytes long. Then you can dynamically redefine the beginning of the array as:
and be assured that there are still 1024 bytes in the array after that, inclusive.
-Phil
EDIT: The "-16" is used to adjust for the object offset, so this technique will only work in the top object.
I thought I was missing something because I could have sworn you could specify a HUB location, but I guess I was wrong.
Thanks anyways,
Bean
Actually, a $800 alignment will work if you AND with $FBFF. So in my suggestion above, you'd be wasting a lot less RAM by making the size of the array $800 + $400 bytes long.
-Phil
Until the code reaches 30K in size I would Spin copy array to the upper locations (but the total Hub used will be 3Kb so pretty much similar to Phil above, unless you can find use for the upper 1Kb)
When completely done programming could write the table to eeprom at this location as a final step, as the Prop will always read the full 32K of the eeprom
So your pasm code will look like this
rdlong mydata,pointer
add pointer,#4
and pointer,_7BFF
pointer long $7800
_7BFF long $7BFF
org _RUNMOD ' Compile for RUNMOD area in cog _PWM32 movi ctrb, #%0_11111_000 ' LOGIC.always mov frqb, tos+1 ' table base address shr frqb, #1{/2} ' divided by 2 (expected to be 4n) mov cnt, #5{14}+2*4+23 ' minimal entry delay add cnt, cnt mov phsb, #0 ' preset (not optional, 8n) pwmlp32 [COLOR="#FFA500"]and phsb, wrap32[/COLOR] ' $0400 to $0000 transition | rdlong X, phsb ' read from index + 2*table/2 | need to be back-to-back waitcnt cnt, tos ' | mov outa, X ' update outputs [COLOR="#FFA500"]add phsb, #4[/COLOR] ' update read ptr | rdlong X, phsb ' read from index + 2*table/2 | need to be back-to-back add phsb, #4 ' update read ptr waitcnt cnt, tos ' | mov outa, X ' update outputs jmp #pwmlp32 wrap32 long 256 * 4 -1