MAX

Instruction: Limit maximum of unsigned value to another unsigned value.

MAX Value1, < # > Value2


Result: Lesser of unsigned Value1 and unsigned Value2 is stored in Value1.

  • Value1 (d-field) is the register containing the value to compare against Value2 and is the destination in which to write the lesser of the two.
  • Value2 (s-field) is a register or a 9-bit literal whose value is compared against Value1.

Opcode Table:

–INSTR–  ZCRI  –CON–    –DEST–         –SRC–

Z Result

C Result

Result

Clocks

  010011    001i    1111    ddddddddd    sssssssss

S = 0

Unsigned (D < S)

Written

4

Concise Truth Table:

In

Out

Destination1

Source1

Z

C

Effects

Destination

Z

C

$0000_0001; 1

$0000_0000; 0

-

-

wz wc

$0000_0000; 0

1

0

$0000_0001; 1

$0000_0001; 1

-

-

wz wc

$0000_0001; 1

0

0

$0000_0001; 1

$0000_0002; 2

-

-

wz wc

$0000_0001; 1

0

1

$0000_0000; 0

$0000_0001; 1

-

-

wz wc

$0000_0000; 0

0

1

$0000_0001; 1

$0000_0001; 1

-

-

wz wc

$0000_0001; 1

0

0

$0000_0002; 2

$0000_0001; 1

-

-

wz wc

$0000_0001; 1

0

0

1 Both Source and Destination are treated as unsigned values.

Explanation

MAX compares the unsigned values of Value1 and Value2 and stores the lesser of the two into the Value1 register, effectively limiting Value1 to a maximum of Value2.

If the WZ effect is specified, the Z flag is set (1) if Value2 is zero (0). If the WC effect is specified, the C flag is set (1) if the unsigned Value1 is less than the unsigned Value2. The lesser of the two values is written to Value1 unless the NR effect is specified.

Unless otherwise noted, content on this site is licensed under the
Creative Commons Attribution-ShareAlike 4.0 International License.