Shop OBEX P1 Docs P2 Docs Learn Events
ASM ref to Main memory OTHER than PAR passing address ? — Parallax Forums

ASM ref to Main memory OTHER than PAR passing address ?

Phillip Y.Phillip Y. Posts: 62
edited 2006-06-08 06:01 in Propeller 1
This program is a outline of my program that works, but why can't I set AddressOfCtrAsmMainMem LONG @CtrAsmMainMem·in DAT area instead of using PAR ?

VAR
·· LONG CtrAsmMainMem··· 'used by SPIN program to display on VGA monitor

PUB VgaTextDemoStart | i
· cognew(@asm_entry, @CtrAsmMainMem) 'launch assembly program into a seperate COG , send memory pointer for CtrAsmMainMem·to the cog parameter
· repeat
··· text.str(string($A,1,$B,4,8)) 'set location
··· text.bin(CtrAsmMainMem,32) 'display counter in binary

DAT
··············· ··· org
·asm_entry···· mov ·AddressOfCtrAsmMainMem,PAR·· [url=mailto:'PAR=@CtrAsmMainMem]'PAR=@CtrAsmMainMem[/url] was sent via, cognew(@asm_entry, @CtrAsmMainMem) .
·loop·············add AsmCounterCog,#1
···· ············· wrlong··· AsmCounterCog,AddressOfCtrAsmMainMem 'hub instruction to send data to main memory for spin pgm access in another cog
·················· jmp··loop

AddressOfCtrAsmMainMem LONG @CtrAsmMainMem··'the·SPIN program has its variables in·MAIN memory,·compile ERROR="expected a DAT symbol"
AsmCounterCog··· res······ 1······························· 'the·ASM program has its variables in·COG memory

Comments

  • Paul BakerPaul Baker Posts: 6,351
    edited 2006-06-07 16:38
    @ is a run time operator, as such its value cannot be obtained at compile time in order to be assigned to a constant. However theres is nothing preventing you from setting the value in your spin program _before_ calling cognew. So you could do the following:

    PUB VgaTextDemoStart | i
    · AddressOfCtrAsmMainMem := @CtrAsmMainMem
    · cognew(@asm_entry, 0) 'launch assembly program into a seperate COG
    · repeat
    ··· text.str(string($A,1,$B,4,8)) 'set location
    ··· text.bin(CtrAsmMainMem,32) 'display counter in binary

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Life is one giant teacup ride.
  • CJCJ Posts: 470
    edited 2006-06-08 02:19
    just define your long(don't use RES) that will be loaded into the cog then at runtime before launching the cog, put in a line that goes something like this

    before launching the cog
    dat_long := @variable

    in the DAT section
    dat_long LONG 0

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Who says you have to have knowledge to use it?

    I've killed a fly with my bare mind.

    Post Edited (CJ) : 6/8/2006 2:33:39 AM GMT
  • Phillip Y.Phillip Y. Posts: 62
    edited 2006-06-08 02:31
    If I use AddressOfCtrAsmMainMem res 1
    Error "expected an instruction or a variable"

    If I use AddressOfCtrAsmMainMem long 0
    no compile error and program works fine
    and after comenting out the line to transfer via PAR, program works fine.

    As far as I under stand the only difference is that the ** Long 0 is initalised and the ** RES is not initalised
    and in either case "AddressOfCtrAsmMainMem" should be in the COG memory after the ASM program code.

    Core docs, hub instructions p7, "WRLONG D,S 'Write D into long at S"
    D points to the COG memory with the data to write
    S points to the COG memory with the pointer to the main memory address that the data will be moved to.

    So how can the spin program do AddressOfCtrAsmMainMem := @CtrAsmMainMem before the asm COG is launched in the next line ?
    I thought that spin running in a COG can't store in to another COG if that is where "AddressOfCtrAsmMainMem" is located.

    Revised program is atached.

    I just saw the other post

    just define your long(don't use RES) that will be loaded into the cog then at runtime before launching the cog, put in a line that goes something like this

    dat_long := @variable

    This is becoming more confusing, just what is done by compiler and spin and when and where ?

    At least the revised program works.

    Phillip Y.
  • CJCJ Posts: 470
    edited 2006-06-08 02:43
    from what I can tell, RES just names a cog register beyond what the asm program takes up (name access rather than by address, compiler handles translation), whereas LONG creates spin accessible data that is also convieniently loaded into the cog at launch(name accessible from spin and assembly)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Who says you have to have knowledge to use it?

    I've killed a fly with my bare mind.
  • Phillip Y.Phillip Y. Posts: 62
    edited 2006-06-08 06:01
    I finaly understand how it works, using the VGA display helped, by displaying addresses and data untill I could figure it out.

    PUB VgaTextDemoStart | i
    · AddressOfCtrAsmMainMem := @CtrAsmMainMem ' overwrites DAT AsmMainMem long 0 in MAIN memory
    · cognew(@asm_entry, 0) 'launch assembly program into a seperate COG, this cog loads a copy of the MODIFIED AddressOfCtrAsmMainMem long 0.

    DAT 'remember this DAT is in MAIN mem, it is copied to the new cog by "cognew(@asm_entry, 0)"
    ·AddressOfCtrAsmMainMem long 0· 'SPIN code "AddressOfCtrAsmMainMem := @CtrAsmMainMem" overwrites the 0 with @CtrAsmMainMem

    Thus there are 2 places labled "AsmMainMem", the become seperate and independant,
    1st, The SPIN code refers to the MAIN memory for AsmMainMem in the DAT area
    2nd, The ASM· code refers to its COG· memory for AsmMainMem, that was copied from the DAT area with COGNEW.

    Since all SPIN code uses main mem there is no problem exchanging PUB variables between SPIN programs,
    BUT all ASM·cogs need to·use WRLONG and RDLONG to exchange data with each other or SPIN code via MAIN memory.

    NOW this ASM code works ,·"WRLONG· AsmCounterLong,AddressOfCtrAsmMainMem 'hub instruction to send data to main memory for spin pgm to display".

    Phillip Y.
Sign In or Register to comment.