com.github.croesch.micro_debug.console
Class MemoryInterpreter

java.lang.Object
  extended by com.github.croesch.micro_debug.commons.AbstractCodeContainer
      extended by com.github.croesch.micro_debug.console.MemoryInterpreter

public final class MemoryInterpreter
extends AbstractCodeContainer

Interpreter of a memory, can print code and stack read from the memory.

Since:
Date: Feb 13, 2012
Author:
croesch

Constructor Summary
MemoryInterpreter(Memory mem)
          Constructs an interpreter of a memory, can print code and stack read from the memory.
 
Method Summary
protected  int getFirstPossibleCodeAddress()
          Returns the address where the first possible code is stored.
 String getFormattedLine(int line)
          Returns the formatted line.
protected  int getLastPossibleCodeAddress()
          Returns the address where the last possible code is stored.
protected  int printCodeLine(int addr)
          Prints the line with the given number to the user.
 void printContent(int pos1, int pos2)
          Prints the content of the memory between the given addresses.
 void printStack(int elementsToHide)
          Prints the content of the stack.
 
Methods inherited from class com.github.croesch.micro_debug.commons.AbstractCodeContainer
formatIntToHex, printCode, printCode, printCodeAroundLine
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MemoryInterpreter

public MemoryInterpreter(Memory mem)
Constructs an interpreter of a memory, can print code and stack read from the memory.

Parameters:
mem - the memory to interprete
Since:
Date: Feb 13, 2012
Method Detail

printCodeLine

protected int printCodeLine(int addr)
Description copied from class: AbstractCodeContainer
Prints the line with the given number to the user. Returns the number of code lines to skip after this line, in case of reading arguments.

Specified by:
printCodeLine in class AbstractCodeContainer
Parameters:
addr - the line number of the code instruction to print
Returns:
the number of lines that can be skipped after printing this line

printContent

public void printContent(int pos1,
                         int pos2)
Prints the content of the memory between the given addresses.

Parameters:
pos1 - the address to start (inclusive)
pos2 - the address to end (inclusive)
Since:
Date: Jan 29, 2012

printStack

public void printStack(int elementsToHide)
Prints the content of the stack. Technical speaking it prints the content of the memory between the initial stack pointer value and the current value of the stack (inclusive edges).

Parameters:
elementsToHide - the number of elements to hide. The first possible element is the one the initial stack pointer points to.
Since:
Date: Feb 5, 2012

getFormattedLine

public String getFormattedLine(int line)
Returns the formatted line.

Parameters:
line - the number of line to fetch.
Returns:
the String representing the given line number
Since:
Date: Feb 3, 2012

getFirstPossibleCodeAddress

protected int getFirstPossibleCodeAddress()
Description copied from class: AbstractCodeContainer
Returns the address where the first possible code is stored.

Specified by:
getFirstPossibleCodeAddress in class AbstractCodeContainer
Returns:
the number of the first code line.

getLastPossibleCodeAddress

protected int getLastPossibleCodeAddress()
Description copied from class: AbstractCodeContainer
Returns the address where the last possible code is stored.

Specified by:
getLastPossibleCodeAddress in class AbstractCodeContainer
Returns:
the number of the last code line.


Copyright © 2012. All Rights Reserved.