MOV or RDLONG
T Chap
Posts: 4,223
I am trying to understand the difference.
Are these the same?
MOV temp1, accel
RDLONG Temp1, accel
accel RES 1 'local to asm, Why are not local variables specified as long, word, byte etc. I assume you ONLY have longs in ASM.
So far I think that for Longs set in the Main program (the caller of the ASM method), you would pass the address of the long in main
to the method with a parameter. Then if that variable needs to be accessed, you RDLONG the pointer to acceess the 'outside world'. But if you are working with local
declared variables in the ASM object/method, you just mov them.
Post Edited (TChapman) : 8/17/2009 5:15:10 PM GMT
Are these the same?
MOV temp1, accel
RDLONG Temp1, accel
accel RES 1 'local to asm, Why are not local variables specified as long, word, byte etc. I assume you ONLY have longs in ASM.
So far I think that for Longs set in the Main program (the caller of the ASM method), you would pass the address of the long in main
to the method with a parameter. Then if that variable needs to be accessed, you RDLONG the pointer to acceess the 'outside world'. But if you are working with local
declared variables in the ASM object/method, you just mov them.
Post Edited (TChapman) : 8/17/2009 5:15:10 PM GMT
Comments
RDLONG moves a 32-bit word from a hub memory location to a cog memory location. The source operand value specifies the hub address. In your case, "RDLONG temp,accel" takes the hub address contained in cog location "accel" and uses that to read a 32-bit long from hub memory into cog location "temp".
In ASM there are only 32-bit memory locations. You can pack 16-bit words and 8-bit bytes into these locations using the assembler, but there are no instructions to directly manipulate them. It's all 32-bit values.
A real world scenario, are these the same?
Post Edited (TChapman) : 8/17/2009 5:49:36 PM GMT
RDLONG ctmp1, newposition
MOV ctmp2, currentposition
RDLONG ctmp2, ctmp2
CMPS ctmp1, ctmp2
Why don't you just write
RDLONG ctmp1, newposition
RDLONG ctmp2, currentposition
CMPS ctmp1, ctmp2
Also this statement:
CMPS newposition, currentposition WC
Will compare only the pointer locations and not the values from Hub memory.
RDLONG temp1, pointer1 'get the values into local vars
RDLONG temp2, pointer2 'get the values
CMPS temp1, temp2 compare