Browse Prior Art Database

Method for Porting Assembler Code from Windows to Linux

IP.com Disclosure Number: IPCOM000014984D
Original Publication Date: 2001-Oct-04
Included in the Prior Art Database: 2003-Jun-20
Document File: 5 page(s) / 123K

Publishing Venue

IBM

Abstract

This invention is a method for porting assembler code written for the Microsoft Macro Assembler (MASM)(*) product on Windows to the Netwide Assembler (NASM)(**) product which generates code for Linux running on the Intel x86 series of processors. The technique for porting the code is to use an Assembler Translator to convert the MASM source to NASM source. The Assembler Translator is comprised of two components the Regular Expression (RegEx) Generator and the Language Rules and is written in Perl. Perl is an interpreted language popular on UNIX for its flexible text-processing capabilities, which made it a good choice for the translation phase of this project. The RegEx Generator creates Perl Regular Expressions from the Language Rules. The Language Rules define the translations in high-level terms such as comment, xlate, and rewrite, which will be explained later.

This text was extracted from a PDF file.
At least one non-text object (such as an image or picture) has been suppressed.
This is the abbreviated version, containing approximately 32% of the total text.

Page 1 of 5

Method for Porting Assembler Code from Windows to Linux

  This invention is a method for porting assembler code written for the Microsoft Macro Assembler (MASM)(*) product on Windows to the Netwide Assembler (NASM)(**) product which generates code for Linux running on the Intel x86 series of processors. The technique for porting the code is to use an Assembler Translator to convert the MASM source to NASM source. The Assembler Translator is comprised of two components - the Regular Expression (RegEx) Generator and the Language Rules - and is written in Perl. Perl is an interpreted language popular on UNIX for its flexible text-processing capabilities, which made it a good choice for the translation phase of this project. The RegEx Generator creates Perl Regular Expressions from the Language Rules. The Language Rules define the translations in high-level terms such as comment, xlate, and rewrite, which will be explained later.

A ssem bler Translator

Assembler Translator

The Assembler Translator provides the following functions:

Echo the original source to the output file as a comment

Read input for language rules and assembler source code from files or standard input.

Read multiple files for language rules

Write output to a file or standard output

Generate debugging information in varying degrees of detail (from none at all to painfully

verbose)

RegEx Generator

The RegEx Generator (RegExGen) provides a more human-friendly configuration syntax to the programmer using the Assembler Translator. The RegEx Generator reads the Language Rules, parses them, and generates Perl regular expressions.

RegExGen reduces the room for error in the Language Rules by isolating the definition of these rules from the actual Perl code.

1

Language R ules

"high level language"

R egE x G enerator


1.


2.


3.


4.


5.

[This page contains 1 picture or other non-text object]

Page 2 of 5

Language Rule s

The Language Rules define the behavior of the language translation. Language Rules consist of a Configuration keyword followed by either masm2nasm syntax (m2nSyntax) or a Perl regular expression (regexSyntax). The format of a Language Rule is:

<configuration keyword> {expression1}->{expression2}

M2nSyntax

When encountering m2nSyntax , RegExGen takes care of white space and comments allowing the Language Rules to concentrate on the tokens themselves. Each m2nSyntax element is surrounded by braces {} and has the general form:

{keyword [modifiers]}

The explanations of m2nSyntax keywords use the term word character . A word character refers to the Perl definition of word in a regular expression; a word character can be an alphanumeric or the underscore character.

RegexSyntax

RegexSyntax is the same as the syntax for Perl regular expressions. As in Perl, kept tokens are identified by a $ and an enumeration from 1 to n.

Implementation of the Technique

The following scenarioess illustrate the use of the Assembler Translator to solve specific problems in translating MASM synta...