Joerg Schnyder

HC08 ASM freak needs some tips from C geeks!

Discussion created by Joerg Schnyder on Feb 18, 2007
Latest reply on Feb 25, 2007 by Joerg Schnyder
Hi there
as i am an oldie in ASM, but i would like to "convert" to C i need some tips.

The problem:
I would like to recycle my modules written in assembly. I tried to define a header file (xx.h) and i also have

modified the xx.asm module. his works fine, but how can i make my modules universal like i am used with asm.

Here the example:

Lets say the module uses a port for setting a bit. The port is named TST_PRT and the bits are defined in the

module. By including the module the TST_PRT is assigned in the main program, so the module is usable by

different programs and/or different MPU's.
The asm module could look like:

;tst.asm
XDEF TAST
XREF.B TST_PRT ;the port
XREF.B TST_z ;a counter

;TST_PRT ;the TAST port, defined in the main program
TST_C0 EQU 0 ;the bit definition for easyer access
TST_C1 EQU 1
TST_C2 EQU 2
TST_C3 EQU 4
;....and so on

TAST: ;the routine
BSET TST_C1,TST_PRT ;set the TST_C1 bit
INC Z_TST
TASTE: ;end of the routine
RTS

So far so good. I have now tried to write a tst.h header file looking like:

/*tst.h*/

#define TST_PRT PTAD

#pragma DATA_SEG __SHORT_SEG MY_ZEROPAGE

byte TST_z; / *the counter in the zero page */


void TAST(void); /*the entry point of the routine */



So and here my question: how do i have to define/redefine TST_PRT so it will be PTAD?
The above header does not work, the TST_PRT is not found by the linker. The rest of the header works this way.

Thanks for some advices

Joerg

Message Edited by CrasyCat on 2007-04-13 10:46 AM

Outcomes