asm
Class AsmFile

java.lang.Object
  |
  +--asm.AsmFile

public class AsmFile
extends java.lang.Object

Represents a file of assembly code. Basically contains a list of instructions, and some tables that are used to generate the object file (a Module).

Version:
$Id: AsmFile.java,v 1.14 2003/01/22 05:35:08 dugan Exp $
See Also:
AsmIns, Module

Field Summary
(package private)  java.util.Map dataMap
          Maps data label -> data item.
(package private)  java.util.ArrayList instructions
           
(package private)  java.util.Map labelMap
          Maps instruction label -> integer (instruction index)
(package private)  java.util.Map refMap
          Maps symbol -> List[integer] (instruction indeces)
(package private)  java.lang.String refTabString
          A string representation of the reference table.
(package private)  java.lang.String symTabString
          A string representation of the symbol table.
 
Constructor Summary
AsmFile()
           
 
Method Summary
 void add(AsmIns i)
          Add an assembly instruction.
 void addData(java.lang.String label, AsmData data)
          Add a data item with this label
 void addLabel(java.lang.String label)
          Add a label for the current location.
 void asm(java.io.DataOutputStream w, boolean bare, boolean opt)
          Assemble the file.
 void buildRefMap()
          Build a reference table.
 void dumpData(java.io.DataOutputStream w)
          Dump the data segment.
 void dumpText(java.io.DataOutputStream w)
          Dump the text segment.
 int getDataSize()
          Right now just tallies up the size of the strings (padded).
 void optimize()
           
 void print()
          Print the contents of the file.
 void printData()
          Dump the data to standard output.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

instructions

java.util.ArrayList instructions

labelMap

java.util.Map labelMap
Maps instruction label -> integer (instruction index)


dataMap

java.util.Map dataMap
Maps data label -> data item.


refMap

java.util.Map refMap
Maps symbol -> List[integer] (instruction indeces)


symTabString

java.lang.String symTabString
A string representation of the symbol table.


refTabString

java.lang.String refTabString
A string representation of the reference table.

Constructor Detail

AsmFile

public AsmFile()
Method Detail

addData

public void addData(java.lang.String label,
                    AsmData data)
Add a data item with this label


printData

public void printData()
Dump the data to standard output.


add

public void add(AsmIns i)
Add an assembly instruction.


addLabel

public void addLabel(java.lang.String label)
Add a label for the current location.


print

public void print()
Print the contents of the file. Useful for debugging.


getDataSize

public int getDataSize()
Right now just tallies up the size of the strings (padded).


asm

public void asm(java.io.DataOutputStream w,
                boolean bare,
                boolean opt)
         throws java.io.IOException
Assemble the file. This means patching the local labels, if necessary, figuring out all of the data offsets, converting the symbol table and reference table to strings and then dumping it all in the object file format.

java.io.IOException

optimize

public void optimize()

dumpData

public void dumpData(java.io.DataOutputStream w)
              throws java.io.IOException
Dump the data segment.

java.io.IOException

dumpText

public void dumpText(java.io.DataOutputStream w)
              throws java.io.IOException
Dump the text segment.

java.io.IOException

buildRefMap

public void buildRefMap()
Build a reference table. For each instruction, if it makes a reference to a label, add that instruction's index to the entry in the reference map.