2004-06-02 01:22 AM
2004-05-26 08:06 PM
Hello All,
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, PraveenG2004-05-26 10:14 PM
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 sjo2004-05-26 11:05 PM
Hello sjo,
Thanks for your help I am attaching the workspace. I have declared two port registers PADR and PBDR using two different methods. Just see the difference in dissassembled code. I want to use declaration like PADR but it is consuming more code space. Memory model is Ml, device used is St72F521 Kindly help me in resolving this issue Thanks and Regards, PraveenG ________________ Attachments : Demo.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HzUz&d=%2Fa%2F0X0000000bTg%2F91DNf8AB4dojuX9ubtJgVlI2wb87QUVAqCFhmjU0KxQ&asPdf=false2004-05-27 04:12 AM
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 sjo2004-06-01 07:24 PM
Thanks a lot 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 PraveenG2004-06-02 01:22 AM
Hi praveenG,
just a hint: there is some good information in the Application Note ''Writing Optimized HIWARE C Language For ST7'' Regards WoRo