Hello My problem is that i want to create a file that contains some subroutine and call these routines from an other files that contains the main program. So in the main file i write this lines
NbMod EQU 2 SRC EQU 1000H DST EQU 1100H PUBLIC NbMod PUBLIC SRC PUBLIC DST
in the other file i write
EXTRN Number(NbMod) EXTRN Number(SRC) EXTRN Number(DST) XSEG AT Source ; Error absolute expression required SRC_RAM: DS 16 * NbMod ; Error Relocatable expression XSEG AT DST ; Error absolute expression required DST_RAM: DS 16 * NbMod ; Error Relocatable expression
you can show the message error in the right of each line but when i do these lines
NbMod EQU 2 SRC EQU 1000H DST EQU 1100H
in the same file ( i mean the file that contains the subroutine) i haven't this problem i don't understand why since i declare the Public in the main and EXTRN in the subroutine files
Thank you
Please read up on the EQU keyword.
It does _not_ declare any variable. It just defines a constant - basically an alias.
If NbMod had been a variable, you would not have been able to write "16 * NbMod" since the assembler can't compute an expression containing a variable. Variables are evaluated during runtime (by assembler instructions) while constants are evaluated during assembly time by the assembler.
So there isn't a symbol accessible for the linker to make use of.
Thank you for the response but
NbMod is not a variable it's a constant and after DS it can be an expression as i see in the macro assembler manual the proof is that when i declare this constant in the same module i haven't any error the problem is when i declare the constant in an extern module
Have you thought about include files...?
@Andy Neil thank you The constant are declared in the main module (externe module) with the keyword PUBLIC that means that the constant can be used in all modules in the modules when i need to use this constant i should declare it as EXTERN NUMBER(the constant) so i don't need include files
From the linker's perspective, I believe that your public symbol is treated as a relocatable item.
What you can do in an expression is limited when it comes to having a component of that expression which is relocatable.
The expression can have simple addition and subtraction but not multiplication of a relocatable item.
Refer to:
www.keil.com/.../a51_wp_simplerelocatable.htm
"The constant are declared in the main module (externe module) with the keyword PUBLIC that means that the constant can be used in all modules"
Are you sure that works with constants?
is it not the case that EQU in assembler is equivalent to #define in 'C' - so it doesn't work with PUBLIC/EXTERN...?
"is it not the case that EQU in assembler is equivalent to #define in 'C' - so it doesn't work with PUBLIC/EXTERN...?"
No. With the original Intel A51 assembler (and Keil's modern equivalent), equates can be made public and can be accessed from other modules by extern.
See my above comment with regards to relocatable expressions.
The manual: http://www.keil.com/support/man/docs/a51/a51_st_equ.htm http://www.keil.com/support/man/docs/a51/a51_st_extrn.htm does show the use of PUBLIC with an EQU and EXTRN and NUMBER(xx) for a symbol that matches any memory class.
But as IB Shy's links shows, there's often a lot of special cases involved in things.