This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

CSEG AT 0x400 karray: DS (8*16)

I reserve memory space in starup.a51 file as follow
{

CSEG AT KARRAYDATADDR ;0x017c
karray:

DS (8*16)
} And then,when I use asm Compiler directly in a c file as follow
{

#pragma asm

MOV R1,#HIGH (karray)

MOV R1,#LOW (karray)

#pragma endasm
}

I receive the following error message:
.\obj\cprm.src(4095): error A14: BAD RELOCATABLE EXPRESSION

I find that the src file(cprm.src) have replace the expression as follow
{

; MOV R1,#HIGH (karray)

MOV R1,# (karray>>8)

; MOV R1,#LOW (karray)

MOV R1,# (karray)
}

What is going on and how can I fix it?

Parents
  • I find that the src file(cprm.src) have replace the expression as follow
    {
    
    ; MOV R1,#HIGH (karray)
    
    MOV R1,# (karray>>8)
    
    ; MOV R1,#LOW (karray)
    
    MOV R1,# (karray)
    }
    
    What is going on and how can I fix it?
    

    HIGH(x) means the upper 8 bits of a 16-bit value. So the address of karray shifted right 8 steps.
    LOW(x) means the lower 8 bits of a 16-bit value.

    So the compiler haven't changed anything - it has just expressed the same thing but in a different way.

    But why assign both the high 8 bits and the low 8 bits to the same 8-bit register?

Reply
  • I find that the src file(cprm.src) have replace the expression as follow
    {
    
    ; MOV R1,#HIGH (karray)
    
    MOV R1,# (karray>>8)
    
    ; MOV R1,#LOW (karray)
    
    MOV R1,# (karray)
    }
    
    What is going on and how can I fix it?
    

    HIGH(x) means the upper 8 bits of a 16-bit value. So the address of karray shifted right 8 steps.
    LOW(x) means the lower 8 bits of a 16-bit value.

    So the compiler haven't changed anything - it has just expressed the same thing but in a different way.

    But why assign both the high 8 bits and the low 8 bits to the same 8-bit register?

Children