Pennington / Example

XTRAN Demonstration:  Translating VAX MACRO Problem Operands

In translating VAX MACRO to C, a number of types of assembler operands can cause problems.  These include:

XTRAN has the ability to handle numeric and expression offsets and expression addresses automatically, by generating appropriate address arithmetic in C.  However, the tradeoff is C code that is less readable and not as easily maintained.  So it is usually better to identify the problems and fix them than to let XTRAN translate them.

XTRAN's VAX MACRO analysis version can be used to find and report all occurrences of these types of operands in a body of VAX MACRO code, using standard rule sets.  The analysis output shows all occurrences of each instance of each of the problem operands, in all analyzed source files.  Click here for such an analysis example.

Once the problem operands have been identified by such an analysis, and suitable fixes have been determined, XTRAN has facilities to automate the cleanup as part of the translation process.

The input to and output from XTRAN are untouched, except that rules are elided and described.



* Input to XTRAN:

<Rule to declare the following to XTRAN in C:>

	typedef struct str
	    {
	    long memb;
	    long memb2;
	    long memb3;
	    }
	    Str;

	Str str1;

<Rules to replace all MEMB+4 with MEMB2 and all MEMB+8 with MEMB3 in VAX
MACRO before translation>

	MOVL	MEMB+4(R2),R1		;MOVL MEMB+4(R2),R1
	MOVL	4+MEMB(R2),R1		;MOVL 4+MEMB(R2),R1
	MOVL	MEMB+4+STR1,R1		;MOVL MEMB+4+STR1,R1
	MOVL	4+MEMB+STR1,R1		;MOVL 4+MEMB+STR1,R1
	MOVL	STR1+<MEMB+4>,R1	;MOVL STR1+<MEMB+4>,R1
	MOVL	STR1+<4+MEMB>,R1	;MOVL STR1+<4+MEMB>,R1

	MOVL	MEMB+8(R2),R1		;MOVL MEMB+8(R2),R1
	MOVL	8+MEMB(R2),R1		;MOVL 8+MEMB(R2),R1
	MOVL	MEMB+8+STR1,R1		;MOVL MEMB+8+STR1,R1
	MOVL	8+MEMB+STR1,R1		;MOVL 8+MEMB+STR1,R1
	MOVL	STR1+<MEMB+8>,R1	;MOVL STR1+<MEMB+8>,R1
	MOVL	STR1+<8+MEMB>,R1	;MOVL STR1+<8+MEMB>,R1


* Output from XTRAN:

	extern long r1;
	extern Str *r2;

	Str str1;

	r1 = r2->memb2;				/*movl memb+4(r2),r1*/
	r1 = r2->memb2;				/*movl 4+memb(r2),r1*/
	r1 = str1.memb2;			/*movl memb+4+str1,r1*/
	r1 = str1.memb2;			/*movl 4+memb+str1,r1*/
	r1 = str1.memb2;			/*movl str1+<memb+4>,r1*/
	r1 = str1.memb2;			/*movl str1+<4+memb>,r1*/
	r1 = r2->memb3;				/*movl memb+8(r2),r1*/
	r1 = r2->memb3;				/*movl 8+memb(r2),r1*/
	r1 = str1.memb3;			/*movl memb+8+str1,r1*/
	r1 = str1.memb3;			/*movl 8+memb+str1,r1*/
	r1 = str1.memb3;			/*movl str1+<memb+8>,r1*/
	r1 = str1.memb3;			/*movl str1+<8+memb>,r1*/


COPYRIGHT 2008; reproduction prohibited without permission.  Revised 2006-11-27

XTRAN is a trademark of Pennington Systems Incorporated, VAX and VAX MACRO of Hewlett-Packard.

Pennington Systems Incorporated
8655 East Via de Ventura, Suite G200
Scottsdale, Arizona 85258-3321

Phone:  +1(480)626-5503
Fax:  +1(480)626-7618
Email:  Info@Pennington.com
Web:  http://WWW.Pennington.com

[home] Home