hades.models.mcore
Class DcoreDecoder

java.lang.Object
  extended byhades.models.mcore.DcoreDecoder
All Implemented Interfaces:
InstructionDecoder
Direct Known Subclasses:
i4001Decoder

public class DcoreDecoder
extends java.lang.Object
implements InstructionDecoder

DcoreDecoder - decode and optionally disassemble D*CORE instructions.

This class also contains some disassembler support. To disassemble an instruction, first call decode( opcode ), then disassamble().

     0010 0000 yyyy xxxx &   R[x] = R[y]
     0010 0001 yyyy xxxx &   R[x] = R[x] + R[y] 
     0010 0010 yyyy xxxx &   R[x] = R[x] + R[y] + C, update C
     0010 0011 yyyy xxxx &   R[x] = R[x] - R[y] 
     0010 0100 yyyy xxxx &   R[x] = R[x] AND R[y] 
     0010 0101 yyyy xxxx &   R[x] = R[x] OR  R[y] 
     0010 0110 yyyy xxxx &   R[x] = R[x] XOR R[y] 
     0010 0111 **** xxxx &   R[x] = NOT R[x] 

     0010 0100 yyyy xxxx &   R[x] = R[x] << R[y].<3:0> 
     0010 0101 yyyy xxxx &   R[x] = R[x] >> R[y].<3:0> 
     0010 0110 yyyy xxxx &   R[x] = R[x] >>> R[y].<3:0> 

     0010 1100 **** xxxx &   R[x] = R[x] << 1, C = R[x].15
     0010 1101 **** xxxx &   R[x] = R[x] >> 1, C = R[x].0
     0010 1110 **** xxxx &   R[x] = R[x] >>> 1, C = R[x].0

     0011 0000 yyyy xxxx &   C = (R[x] == R[y]) 
     0011 0001 yyyy xxxx &   C = (R[x] != R[y]) 
     0011 0010 yyyy xxxx &   C = (R[x] > R[y]) 
     0011 0011 yyyy xxxx &   C = (R[x] < R[y]) 

     0011 0100 iiii xxxx &   R[x] = imm4
     0011 0101 iiii xxxx &   R[x] = R[x] + imm4
     0011 0110 iiii xxxx &   R[x] = R[x] - imm4
     0011 0111 iiii xxxx &   R[x] = R[x] AND imm4

     0011 1000 iiii xxxx &   R[x] = R[x] << imm4
     0011 1001 iiii xxxx &   R[x] = R[x] >> imm4
     0011 1010 iiii xxxx &   R[x] = bit set i
     0011 1011 iiii xxxx &   R[x] = bit clear i

     0100 cccc yyyy xxxx &   R[x] = MEM( R[y] + cccc<<1 ) 
     0101 cccc yyyy xxxx &   MEM( R[y] + cccc<<1 ) = R[x]

     1000 iiii iiii iiii &   PC   = PC+2+imm12 
     1001 iiii iiii iiii &   R[15] = PC+2; PC = PC+2+imm12 (call) 
     1010 iiii iiii iiii &   if (C=1) then PC = PC+2+imm12 else PC=PC+2
     1011 iiii iiii iiii &   if (C=0) then PC = PC+2+imm12 else PC=PC+2 
     1100 **** **** xxxx &   PC   = R[x] 

     1101 **** **** xxxx &   trap x
     1110 **** **** **** &   rfi (return from interrupt)

     1111 **** **** **** &   halt 
   


Field Summary
(package private)  int address
           
(package private)  int aluopc
           
(package private)  int cccc
           
(package private)  int imm12
           
(package private)  int instruction
           
(package private)  java.util.Hashtable labelTable
           
(package private)  int opcode
           
(package private)  int x
           
(package private)  int y
           
 
Constructor Summary
DcoreDecoder()
           
 
Method Summary
 void addLabel(int addr, java.lang.String name)
           
 void clearAllLabels()
           
 void decode(int _instruction)
          decode the D*CORE _instruction word into the opcode, aluopc, register X/Y adress, and immediate fields.
 void decode(int _instruction, int _address)
          decode the D*CORE _instruction word into the opcode, aluopc, register X/Y adress, and immediate fields.
 java.lang.String disassemble()
           
 int getAddress()
           
 int getAluOpc()
           
 int getCCCC()
           
 int getIMM12()
           
 int getInstruction()
           
 java.lang.String getLabel(int addr)
           
 int getOpcode()
           
 int getX()
           
 int getY()
           
static void main(java.lang.String[] argv)
           
static void msg(java.lang.String s)
           
static void usage()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

instruction

int instruction

address

int address

opcode

int opcode

x

int x

y

int y

cccc

int cccc

imm12

int imm12

aluopc

int aluopc

labelTable

java.util.Hashtable labelTable
Constructor Detail

DcoreDecoder

public DcoreDecoder()
Method Detail

decode

public void decode(int _instruction)
decode the D*CORE _instruction word into the opcode, aluopc, register X/Y adress, and immediate fields.


decode

public void decode(int _instruction,
                   int _address)
decode the D*CORE _instruction word into the opcode, aluopc, register X/Y adress, and immediate fields. This method also sets the address field to _address, useful in combination with a cross-reference file to resolve label adresses in jump instructions.

Specified by:
decode in interface InstructionDecoder

getInstruction

public int getInstruction()

getOpcode

public int getOpcode()

getX

public int getX()

getY

public int getY()

getAluOpc

public int getAluOpc()

getCCCC

public int getCCCC()

getIMM12

public int getIMM12()

getAddress

public int getAddress()

disassemble

public java.lang.String disassemble()
Specified by:
disassemble in interface InstructionDecoder

addLabel

public void addLabel(int addr,
                     java.lang.String name)
Specified by:
addLabel in interface InstructionDecoder

getLabel

public java.lang.String getLabel(int addr)
Specified by:
getLabel in interface InstructionDecoder

clearAllLabels

public void clearAllLabels()
Specified by:
clearAllLabels in interface InstructionDecoder

msg

public static void msg(java.lang.String s)

usage

public static void usage()

main

public static void main(java.lang.String[] argv)