Example of a C file

A C source code file ( mixc.c) has the main() function which calls the AddVar() function. See the following listing. (Compile it with the -Cc compiler option when using the HIWARE Object File Format.)

Listing: Example C source code file: mixc.c

static int Error          = 0;
const unsigned char CData = 12;

#include "mixasm.h"

void main(void) {

  AddVar(10);

  if (ASMData != CData + 10){

    Error = 1;

  } else {

    Error = 0;

  }

  for(;;); // wait forever

}
CAUTION:
Be careful, as the Assembler will not make any checks on the number and type of the function parameters.

The application must be correctly linked.

For these C and *.asm files, a possible linker parameter file is shown in the following listing.

Listing: Example of linker parameter file: mixasm.prm

LINK mixasm.abs
NAMES

  mixc.o mixasm.o

END

SECTIONS

  MY_ROM   = READ_ONLY  0x4000 TO 0x4FFF;

  MY_RAM   = READ_WRITE 0x2400 TO 0x2FFF;

  MY_STACK = READ_WRITE 0x2000 TO 0x23FF;

END

PLACEMENT

  DEFAULT_RAM    INTO MY_RAM;

  DEFAULT_ROM    INTO MY_ROM;

  SSTACK         INTO MY_STACK;

END

INIT main
Note: We recommend that you use the same memory model and object file format for all the generated object files.