edu.ustc.cs.compile.arch
类 AssemblyElement

java.lang.Object
  继承者 edu.ustc.cs.compile.arch.AssemblyElement
直接已知子类:
Directive, Instruct, Label

public abstract class AssemblyElement
extends java.lang.Object

The root class of the assembly element hierarchy.

A complete assembly language program consists of three kinds of assembly elements: the directive (represented by Directive), the label (represented by Label), and the instruct (represented by Instruct).
For example,
.text
.align 2
.globl main
.ent main
main:
add $sp,$sp,-8

where, the statements begining with a dot are directives, the statements ended with a colon are labels, and the others are instructs.
To represent above mips assembly codes by AssemblyElement, the following codes are used:
// create an AssemblySequence object
AssemblySequence sequence = new AssemblySequence();

// .text
Directive direct = new Directive(MIPSDirector.TEXT, null);
sequence.add(direct);

// .align 2
ArrayList<Directive.Argument> args = new ArrayList();
args.add(new Directive.Argument(new Integer(2)));
direct = new Directive(MIPSDirector.ALIGN, args);
sequence.add(direct);

// .globl main
args = new ArrayList();
args.add(new Directive.Argument(new Label("main")));
direct = new Directive(MIPSDirector.GLOBL, args);
sequence.add(direct);

// .ent main
args = new ArrayList();
args.add(new Directive.Argument(new Label("main")));
direct = new Directive(MIPSDirector.ENT, args);
sequence.add(direct);

// main:
Label label = new Label("main");
sequence.add(label);

// add $sp,$sp,-8
ArrayList<Instruct.Operand> operands = new ArrayList();
operands.add(new Instruct.Operand(MIPSRegister.SP));
operands.add(new Instruct.Operand(MIPSRegister.SP));
operands.add(new Instruct.Operand(new Integer(-8)));
Instruct inst = new Instruct(MIPSOpcode.ADD, operands);
sequence.add(inst);

You can represent x86 assembly language in the same way.


构造函数摘要
AssemblyElement()
           
 
方法摘要
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

构造函数详细信息

AssemblyElement

public AssemblyElement()