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.

Error While Loading a 32 bit constant intuitively into ACC



I was trying to load a 32 bit const into ACC. For example, to load the 60 MHz clock value  intuitively (is there a better way to do it?) , the coding has to be as below:

  MOV AH, #(60000000L & 0xFFFF0000) >> 16 ; error: why?

  MOV AL, #(60000000L & 0xFFFF)

I get the following error. Can someone explain why?

 "testasm.asm", ERROR!   at line 35: [E0000] Expecting operand delimiter

MOV AH, #(60000000L & 0xFFFF0000) >> 16

 

"testasm.asm", ERROR!   at line 35: [E0003] Syntax error - Operand 4

MOV AH, #(60000000L & 0xFFFF0000) >> 16

Thanks
Sayee

  • Sayee,

    First off the reason the operand did not work is that it only allows shifts from 0-15, not 16. 

    Secondly the way to do this is to precalculate the high and low parts of 60Meg yourself, rather than let the compiler and/or processor do it.  Then your code becomes:

     

    MOV AH, #(high part 60Meg)

    MOV AL, #(low part 60Meg)

    I would suggest using defines or equates (.equ) to make it neater, but basically that is the quickest (in terms of processing time) that I can see way to load a 32 bit variable. There isn't a MOVL ACC, #32bit probably due to the fact that this would have too long an opcode.

    On a side note, if the immediate value you want to load is less than 22bits in length but greater than 16 bits (between 65k and approx 4million), then this code will work:

    MOVL XARn, #value

    MOVL ACC, @XARn

     

    Thanks

     

    Tim

  • This seems like a really common situation. Is there an established method for loading a 32b constant without having to split it by hand as suggested above? I would like to be able to do this with an address at assemble time.
  • Actually, this seems to work fine.

    _lit .macro x
    MOV AL, #x
    MOV AH, #(x>>16)
    .endm