uk.co.javagear
Class Flag

java.lang.Object
  extended by uk.co.javagear.Flag

public final class Flag
extends java.lang.Object

Zilog Z80 CPU flag emulation.

Version:
18th January 2003
Author:
Copyright (C) 2002-2003 Chris White
See Also:
"JavaGear Final Project Report"

Field Summary
private  int f
          Register.
private static int F_BIT3
          Bit3 (usually a copy of bit 3 of the result).
private static int F_BIT5
          Bit5 (usually a copy of bit 5 of the result).
private static int F_CARRY
          Carry (set when a standard carry occurred).
private static int F_HALFCARRY
          Half carry (set when a carry occured between bit 3 / 4 of result - used for BCD).
private static int F_NEGATIVE
          Negative (set when instruction is subtraction, clear when addition).
private static int F_PARITY
          True indicates even parity in the result, false for 2s complement sign overflow.
private static int F_SIGN
          Sign (set when a result is negative).
private static int F_ZERO
          Zero (set when a result is zero).
private  int f2
          The register's second bank.
private static boolean[] PARITY
          Pre-calculated flag settings.
 
Constructor Summary
Flag()
          Flag Constructor.
 
Method Summary
 boolean bit3()
          Returns true if the bit 3 flag (F_BIT3) is set and false otherwise.
 void bit3Off()
          Sets the bit 3 flag Off (F_BIT3).
 void bit3On()
          Sets the bit 3 flag On (F_BIT3).
 boolean bit5()
          Returns true if the bit 5 flag (F_BIT5) is set, and false otherwise.
 void bit5Off()
          Sets the bit 5 flag Off (F_BIT5).
 void bit5On()
          Sets the bit 5 flag On (F_BIT5).
 boolean carry()
          Returns true if carry flag (F_CARRY) is set.
 void carryOff()
          Carry Flag Off.
 void carryOn()
          Carry Flag On.
 void clear()
          Clear register.
 void ex()
          Exchange register banks.
 int get()
          Get value of flag register.
 boolean halfcarry()
          Returns true if the half carry flag (F_HALFCARRY) is set, and false otherwise.
 void halfCarryOff()
          Sets the half carry flag Off (F_HALFCARRY).
 void halfCarryOn()
          Sets the half carry flag On (F_HALFCARRY).
 boolean negative()
          Returns true if the negative flag (F_NEGATIVE) is set.
 void negativeOff()
          Negative Flag Off.
 void negativeOn()
          Negative Flag On.
 boolean parity()
          Returns true if the parity flag (F_PARITY) is set.
 void parityOff()
          Sets the parity flag Off (F_PARITY).
 void parityOn()
          Sets the parity flag On (F_PARITY).
 void set(int value)
          Set flag register.
 void setBit3(int v)
           
 void setBit5(int v)
           
 void setParity(int n)
          Set parity.
 boolean sign()
          Returns true if the sign flag (F_SIGN) is set, and false otherwise.
 void signOff()
          Sets the sign flag Off (F_SIGN).
 void signOn()
          Sets the sign flag On (F_SIGN).
 boolean zero()
          Returns true if the zero flag (F_ZERO) is set, and false otherwise.
 void zeroOff()
          Sets the zero flag Off (F_ZERO).
 void zeroOn()
          Sets the zero flag On (F_ZERO).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PARITY

private static final boolean[] PARITY
Pre-calculated flag settings.


F_CARRY

private static final int F_CARRY
Carry (set when a standard carry occurred).

See Also:
Constant Field Values

F_NEGATIVE

private static final int F_NEGATIVE
Negative (set when instruction is subtraction, clear when addition).

See Also:
Constant Field Values

F_PARITY

private static final int F_PARITY
True indicates even parity in the result, false for 2s complement sign overflow.

See Also:
Constant Field Values

F_BIT3

private static final int F_BIT3
Bit3 (usually a copy of bit 3 of the result).

See Also:
Constant Field Values

F_HALFCARRY

private static final int F_HALFCARRY
Half carry (set when a carry occured between bit 3 / 4 of result - used for BCD).

See Also:
Constant Field Values

F_BIT5

private static final int F_BIT5
Bit5 (usually a copy of bit 5 of the result).

See Also:
Constant Field Values

F_ZERO

private static final int F_ZERO
Zero (set when a result is zero).

See Also:
Constant Field Values

F_SIGN

private static final int F_SIGN
Sign (set when a result is negative).

See Also:
Constant Field Values

f

private int f
Register.


f2

private int f2
The register's second bank.

Constructor Detail

Flag

public Flag()
Flag Constructor.

Method Detail

get

public int get()
Get value of flag register.

Returns:
value stored in flag register.

set

public void set(int value)
Set flag register.

Parameters:
value - value to set register (0 - 0xFF).

clear

public void clear()
Clear register.


carryOn

public void carryOn()
Carry Flag On.


carryOff

public void carryOff()
Carry Flag Off.


carry

public boolean carry()
Returns true if carry flag (F_CARRY) is set.

Returns:
true if set.

negativeOn

public void negativeOn()
Negative Flag On.


negativeOff

public void negativeOff()
Negative Flag Off.


negative

public boolean negative()
Returns true if the negative flag (F_NEGATIVE) is set.

Returns:
true if set.

parityOn

public void parityOn()
Sets the parity flag On (F_PARITY).


parityOff

public void parityOff()
Sets the parity flag Off (F_PARITY).


setParity

public void setParity(int n)
Set parity.

Parameters:
n - value to test (0 - 0xFF).

parity

public boolean parity()
Returns true if the parity flag (F_PARITY) is set.

Returns:
true if set.

setBit3

public void setBit3(int v)

bit3On

public void bit3On()
Sets the bit 3 flag On (F_BIT3).


bit3Off

public void bit3Off()
Sets the bit 3 flag Off (F_BIT3).


bit3

public boolean bit3()
Returns true if the bit 3 flag (F_BIT3) is set and false otherwise.

Returns:
true if set.

halfCarryOn

public void halfCarryOn()
Sets the half carry flag On (F_HALFCARRY).


halfCarryOff

public void halfCarryOff()
Sets the half carry flag Off (F_HALFCARRY).


halfcarry

public boolean halfcarry()
Returns true if the half carry flag (F_HALFCARRY) is set, and false otherwise.

Returns:
true if set.

setBit5

public void setBit5(int v)

bit5On

public void bit5On()
Sets the bit 5 flag On (F_BIT5).


bit5Off

public void bit5Off()
Sets the bit 5 flag Off (F_BIT5).


bit5

public boolean bit5()
Returns true if the bit 5 flag (F_BIT5) is set, and false otherwise.

Returns:
true if set.

zeroOn

public void zeroOn()
Sets the zero flag On (F_ZERO).


zeroOff

public void zeroOff()
Sets the zero flag Off (F_ZERO).


zero

public boolean zero()
Returns true if the zero flag (F_ZERO) is set, and false otherwise.

Returns:
true if set.

signOn

public void signOn()
Sets the sign flag On (F_SIGN).


signOff

public void signOff()
Sets the sign flag Off (F_SIGN).


sign

public boolean sign()
Returns true if the sign flag (F_SIGN) is set, and false otherwise.

Returns:
true if set.

ex

public void ex()
Exchange register banks.



Copyright © 2007 JavaGear. All Rights Reserved.