You might like to print out this page, or open it in a new window, so that you can refer to it as you take the tour.
Relogix would translate the assembler file on the previous page to produce a small header file sample.h and a C source file sample.c, as shown below.
Note that this is a 100% automatic translation, with no hand-tuning or provision of user-supplied header files. (This translation was produced from the 68K version of the example; the x86 version would be very similar except that the comments would refer to different register names).
sample.h
/*
**********************************************************
* Include file for sample *
**********************************************************
*/
#ifndef __TYPE_TOK_DEFINED
#define __TYPE_TOK_DEFINED
struct tok {
char tokchar;
char tokalt;
unsigned long *tokbuf;
long tokctr;
};
#endif
/* Prototypes for public routines translated to C */
void movetok (struct tok *tok_ptr, unsigned long *ptr);
sample.c
/***************************************************************
* *
* "sample.c" - Translated from file "sample.sa" *
* *
*--------------------------------------------------------------*
* *
* Relogix Code Translator Copyright (c) MicroAPL 1990-2017 *
* All Rights Reserved Worldwide *
* *
****************************************************************
*
* Translated on Fri Mar 17 11:30:04 2017 by Relogix version 1.8.1
*
* Relogix Licence Number #10000
*
* Non-default options specified:
* NONE
*/
#include "rlx68k.h"
#include "sample.h"
#define ENDMARK 0x80000000
/*
****************************************************************
* movetok *
****************************************************************
*
* Routine to move token block to buffer
*
* Parameters:
*
* struct tok *tok_ptr [Originally in a0; In]
* unsigned long *ptr [Originally in a1; In]
*/
void movetok (struct tok *tok_ptr, unsigned long *ptr)
{
long i; /* [Originally in d0] */
unsigned long *p; /* [Originally in a0] */
unsigned long token; /* [Originally in d1] */
i = tok_ptr->tokctr;
if (i != 0 && tok_ptr->tokbuf != NULL) {
p = tok_ptr->tokbuf;
do {
token = *p++; /* Get token */
/* Hit end marker? */
if (token == ENDMARK)
break;
*ptr++ = token; /* Move into destination */
} while (--i != 0);
}
}
Although this is a very simple example, it illustrates a number of important points about the way in which Relogix translates assembler code to C. We'll look at each of these in turn, starting from the beginning of the generated C file.