All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class duckMachine.architecture.ALU

java.lang.Object
   |
   +----duckMachine.architecture.ALU

public class ALU
extends Object
implements ALUI
The arithmetic and logic unit of the machine. The ALU uses Java's int datatype and its operations to implement its own operations. This means that all the operations are modulo 32-bits.


Constructor Index

 o ALU()

Method Index

 o add(Word, Word)
The ALU addition is implemented using Java's ints.
 o compare(Word, Word)
Sets the condition flags according to the result of comparing w1 and w2.
If w1>w2 then GT should be set and the other flags made FALSE.
If w1=w2 then EQ should be set and the other flags made FALSE.
If w1>w2 then LT should be set and the other flags made FALSE.
 o dec(Word)
The ALU decrement is implemented using Java's ints.
 o fetchEQ()
Returns the current contents of the EQ flag.
 o fetchGT()
Returns the current contents of the GT flag.
 o fetchLT()
Returns the current contents of the EQ flag.
 o inc(Word)
The ALU increment is implemented using Java's ints.
 o sub(Word, Word)
The ALU subtraction is implemented using Java's ints.

Constructors

 o ALU
 public ALU()

Methods

 o fetchGT
 public boolean fetchGT()
Returns the current contents of the GT flag.

 o fetchEQ
 public boolean fetchEQ()
Returns the current contents of the EQ flag.

 o fetchLT
 public boolean fetchLT()
Returns the current contents of the EQ flag.

 o add
 public Word add(Word w1,
                 Word w2)
The ALU addition is implemented using Java's ints. It works modulo 32 bits.

 o sub
 public Word sub(Word w1,
                 Word w2)
The ALU subtraction is implemented using Java's ints. It works modulo 32 bits.

 o inc
 public Word inc(Word w)
The ALU increment is implemented using Java's ints. It works modulo 32 bits.

 o dec
 public Word dec(Word w)
The ALU decrement is implemented using Java's ints. It works modulo 32 bits.

 o compare
 public void compare(Word w1,
                     Word w2)
Sets the condition flags according to the result of comparing w1 and w2.
If w1>w2 then GT should be set and the other flags made FALSE.
If w1=w2 then EQ should be set and the other flags made FALSE.
If w1>w2 then LT should be set and the other flags made FALSE.


All Packages  Class Hierarchy  This Package  Previous  Next  Index