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.
-
ALU()
-
-
add(Word, Word)
- The ALU addition is implemented using Java's ints.
-
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.
-
dec(Word)
- The ALU decrement is implemented using Java's ints.
-
fetchEQ()
- Returns the current contents of the EQ flag.
-
fetchGT()
- Returns the current contents of the GT flag.
-
fetchLT()
- Returns the current contents of the EQ flag.
-
inc(Word)
- The ALU increment is implemented using Java's ints.
-
sub(Word, Word)
- The ALU subtraction is implemented using Java's ints.
ALU
public ALU()
fetchGT
public boolean fetchGT()
- Returns the current contents of the GT flag.
fetchEQ
public boolean fetchEQ()
- Returns the current contents of the EQ flag.
fetchLT
public boolean fetchLT()
- Returns the current contents of the EQ flag.
add
public Word add(Word w1,
Word w2)
- The ALU addition is implemented using Java's ints. It works modulo
32 bits.
sub
public Word sub(Word w1,
Word w2)
- The ALU subtraction is implemented using Java's ints. It works modulo
32 bits.
inc
public Word inc(Word w)
- The ALU increment is implemented using Java's ints. It works modulo
32 bits.
dec
public Word dec(Word w)
- The ALU decrement is implemented using Java's ints. It works modulo
32 bits.
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