This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

2812 instruction MOVZ vs. MOVW

(SPRU430e, pg. 6-226)

I see that the MOVZ instruction clears the top 10 bits of the DP register while the MOVW does not.

(SPRU430e, pg. 2-10)

I also see that Data Page pointer is a 22 bit pointer with the range 0x0-0x3FFFFF (4 Meg). The DP itself is really just the upper 16 bits. The lower 6 bits are utilized as an offset to access the 64 words in that page.

 

So, as I interpret it, the MOVZ and MOVW instructions load the upper 16 bits of the 22 bit value, that is the upper 16 ARE THE DP. I am curious though why MOVZ instruction clears the upper bits (15:10). This leaves the lower 10 programmed with a value. This is basically a 1K block of space (0x0-0xFFC0) that can be accessed this way (+64 words) for a total of 0x0-0xFFFF. Looking at the memory map, this seems that it would only be useful accessing all areas up to and including L1 SARAM. This includes Zone 0 & 1. It could not access Zone 2 or higher.

 

So, if I am correct, is this instruction just a shortcut to get back to lower RAM? Just a shortcut rather than loading in the upper zeros with MOVW? OR, is there another reason for the MOVZ?

 

Regards,

Jim

  • Jim,

    the MOVW - Instruction is a 2 word instruction to load a new 16-bit number into DP.  The MOVZ - instruction is a 1 word instruction to load a new 10 bit - number into the lower 10 bits of DP, while the upper 6 bits of DP are zeroed.  This means that the MOVZ is an optimal instruction to set the DP in the region of the lower 64k. A following direct addressing instrution can use any of the data in this area, e.g. the registers.

    Regards

     

     

  • Thanks Frank.

    So the 10-bit boundary is probably just an artifact of the largest payload that could be carried in the 1-word instruction?

    OR, 64k is a nice user-friendly boundary?

     

    But, in any case, I see that the primary intent is to have a 1-word instruction option (less cycles). That makes sense.

    I wasn't looking at it from that angle. I was trying to understand from "why the 0xFFFF boundary?" The answer is not there; I was looking from the wrong place. The boundary is NOT the driving force, the expedience of the instruction IS!

     

    Regards,

    Jim

  • Jim,

    yes, the driving force in the C2000 is always speed. If you can setup the  DP in a 1 word instruction, it helps to execute time critical code sections faster.  The MOVZ was directly designed to have a 1 word instruction to set the DP to the lower 64K, where all peripheral registers are located. Btw, the 3rd instruction of the tripel of  DP instructions is the MOV DP,#imm instruction, which is also a 1 word instruction. It loads a 10 bit number into DP and leaves the upper 6 bits of DP unchanged. 

    Regards, Frank

     

     

  • Note that this is not an instruction time issue as they both execute in 1 cycle.  This is purely to do with code space.  There are a variety of instructions littered throughout the set which have slight variants which reduce the number of words in common situations to increase code efficiency.

    Thanks,

    Tim

  • Thanks Tim,

    OK. I checked, and yes, 1 cycle for either. So, this is a code space case.

     

    Others may be speed driven cases, where cycles are different.

     

    Regards,

    Jim