I am working on a project in which earlier I was declaring my hardware registers as #pragma DATA_SEG SHORT PA volatile unsigned char PADR; and then placing PA segment in .prm file at the right address. when I use the following code and see the dissassembly PADR = 1; code generated is B700 which is using short addressing mode for LD instruction. In my new code I have changed the register file as volatile unsigned char PADR @0x00; Now the dissassembly for same code (PADR = 1) shows machine code C70000 which is using [long.w] addressing for LD instruction which increases the code size by 1 byte. Could anybody help me in using the same short addressing mode without using segments and *.prm file declaration Thanks in advance, Best Regards, PraveenG
I have just tried reproducing your problem - using each of the memory models, everytime I get short addressing mode - as you would expect.
I use the volatile unsigned char PADR @ 0x00; style of decalaring registers. Why not use the mapfiles available on this site ? Could you post your project, or part of it? Regards sjo
I think your problem is related to the fact you are using a c file to declare your registers and no telling the compiler about the memeory size.
I would recommend declaring all your registers in the header file,eg. in st7272f521_reg.h volatile unsigned char PADR @0x00; and not use a c file - this is how cosmic does it. If you want to use a c file then just add the folowing to the c file: #pragma DATA_SEG SHORT PORTA volatile unsigned char PADR @0x00; and to the header file #pragma DATA_SEG SHORT PORTA extern volatile unsigned char PADR; Regards sjo
I can't avoid using .c file. The problem is solved by adding address information in .h file reg.h extern unsigned char volatile PADR @0x00; reg.c unsigned char volatile PADR @0x00; This results in short address generation for register access PraveenG