We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I have: 1. ext_port.a51 file, that contains some variables. 2. ext_port.inc file, that contains some macros, that use variables from ext_port.a51. 3. some files, that use macros from ext_port.inc. In my case I want use EQU to use this variables, but this variables is external and I take error A20. I tried include all this in one file(#include or $include), but in this case debug information is lost. ********************************************* ext_port.a51
?PR?EXT_PORT SEGMENT DATA RSEG ?PR?EXT_PORT public P5Buf public P6Buf P5Buf: DS 1 P6Buf: DS 1
#ifndef _EXT_PORT_INC #define _EXT_PORT_INC #include "set.inc" #define P7A_ADDR f_ad0512 #define P7B_ADDR F_DAT512 #define P7C_ADDR f_ad1512 #define P7CTL_ADDR f_ctl512 #define _P0 0x00 #define _P1 0x10 #define _P2 0x20 #define _P3 0x30 #define _P4 0x40 #define _P5 0x50 #define _P6 0x60 #define _P7A 0x70 #define _P7B 0x71 #define _P7C 0x72 #define _P7CTL 0x73 P_0x00 EQU P0 P_0x10 EQU P1 P_0x20 EQU P2 P_0x30 EQU P3 P_0x40 EQU P4 P_0x50_ADDR EQU P5_HIGH_ADDR P_0x60_ADDR EQU P6_HIGH_ADDR P_0x70_ADDR EQU P7A_ADDR P_0x71_ADDR EQU P7B_ADDR P_0x72_ADDR EQU P7C_ADDR P_0x73_ADDR EQU P7CTL_ADDR ;---------------------------------------------------------------------------- extrn DATA (P5Buf) extrn DATA (P6Buf) P_0x50_Buf EQU P5Buf P_0x60_Buf EQU P6Buf ;---------------------------------------------------------------------------- ; xxx_m - state format is mask ; xxx_c - state is constant ; xxx_sb - state is variable.bit ;---------------------------------------------------------------------------- #define PORTS_ExSpec _P7A, _P7B, _P7C #define PORTS_Ex _P5, _P6 #define PORTS_x _P0, _P1, _P2, _P3, _P4 _PXXX_CALL macro p, pl, fc, ft, prm irp px, <pl> if p == px fc&ft prm endif endm endm ;---------------------------------------------------------------------------- Px_set_c macro p, b, s if s setb p.b else clr p.b endif endm Px_c macro p, b, s Px_set_c P_&p, b, s endm PxEx_select_set_c_m macro paddr, pbuf mov DPTR, #paddr if s orl pbuf, #bm else anl pbuf, #NOT bm endif endm PxEx_c_m macro p, bm, s PxEx_select_set_c_m P_&p&_ADDR, P_&p&_Buf, bm, s mov A, pbuf movx @DPTR, A endm PxEx_c macro p, b, s PxEx_c_m p, (1 SHL b), s endm Px_OUT_BIT_c macro p, b, s _PXXX_CALL p, <PORTS_x>, Px, _c, <p, b, s> _PXXX_CALL p, <PORTS_Ex>, PxEx, _c, <p, b, s> endm ;---------------------------------------------------------------------------- Px_set_sb macro p, b, vp, vb mov A, vp mov C, ACC.vb mov p.b, C endm Px_sb macro p, b, vp, vb Px_set_sb P_&p, b, vp, vb endm PxEx_out_C macro paddr, pbuf, b mov DPTR, #paddr mov A, pbuf mov ACC.b, C mov pbuf, A movx @DPTR, A endm PxEx_sb macro p, b, vp, vb mov A, vp mov C, ACC.vb PxEx_out_C P_&p&_ADDR, P_&p&_Buf, b endm Px_OUT_BIT_sb macro p, b, vp, vb _PXXX_CALL p, <PORTS_x>, Px, _sb, <p, b, vp, vb> _PXXX_CALL p, <PORTS_Ex>, PxEx, _sb, <p, b, vp, vb> endm ;---------------------------------------------------------------------------- Px_OUT_ macro p, v mov P_&p, v endm PxEx_OUT_ macro p, v mov DPTR, #P_&p&_ADDR mov A, v mov P_&p&_Buf, A movx @DPTR, A endm PxExSpec_OUT_ macro p, v mov DPTR, #P_&p&_ADDR mov A, v movx @DPTR, A endm Px_OUT macro p, v _PXXX_CALL p, <PORTS_x>, Px_OUT, _, <p, v> _PXXX_CALL p, <PORTS_Ex>, PxEx_OUT, _, <p, v> _PXXX_CALL p, <PORTS_ExSpec>, PxExSpec_OUT, _, <p, v> endm ;---------------------------------------------------------------------------- #endif
#include "ex_port.inc" Px_OUT _P5, #0
#include "ex_port.inc" Px_OUT _P5, #1
You don't provide any information about where you get that assembler error. In case of doubt, look in the assembler listing. The error message will be in there, too.
+1 2095 extrn DATA (P5Buf) +1 2096 extrn DATA (P6Buf) +1 2097 P_0x50_Buf EQU P5Buf *** _________________________________________________^ *** ERROR #A20 IN 2097 (ext_port.inc, LINE 58): INVALID SIMPLE RELOCATABLE EXPRESSION +1 2098 P_0x60_Buf EQU P6Buf *** _________________________________________________^ *** ERROR #A20 IN 2098 (ext_port.inc, LINE 59): INVALID SIMPLE RELOCATABLE EXPRESSION
Well, the manual states "Segment and external symbols are not allowed in simple relocatable expressions.
Dan Henry Yes, I think that. But I want find way to bypass this problem. One way - include all files in one file: a.a51
#include "ext_port.inc" #include "ext_port.a51" #include "1.a51" #include "2.a51"
You may have to get rid of those EQU, then, and replace them by SET, or #define a macro.
SET same as EQU I can use #define, but it not worked in macro constructions. -----------------------------------
#define P_P5_Buf P5Buf TEST macro px mov P_&px&_Buf, A endm TEST P5