MOVS

Instruction: Set a register's source field to a value.

MOVS Destination, < # > Value


Result: Value is stored in Destination' s-field (bits 8..0).

  • Destination (d-field) is the register whose source field (bits 8..0) is set to Value's value.
  • Value (s-field) is a register or a 9-bit literal whose value is stored into Destination's source field.

Opcode Table:

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

Z Result

C Result

Result

Clocks

  010100    001i    1111    ddddddddd    sssssssss

Result = 0

Written

4

Concise Truth Table:

In

Out

Destination

Source

Z

C

Effects

Destination

Z

C

$0000_0000; 0

$0000_0000; 0

-

-

wz wc

$0000_0000; 0

1

0

$0000_0000; 0

$0000_01FF; 511

-

-

wz wc

$0000_01FF; 511

0

1

$FFFF_FFFF; -1

$0000_01FF; 511

-

-

wz wc

$FFFF_FFFF; -1

0

0

$FFFF_FFFF; -1

$0000_0000; 0

-

-

wz wc

$FFFF_FE00; -512

0

0

Explanation

MOVS copies the 9-bit value of Value into Destination's source field (s-field) bits 8..0. Destination's other bits are left unchanged. This instruction is handy for setting certain registers like CTRA and VCFG, and for updating the source field of instructions in self-modifying code.

For self-modifying code, ensure that at least one other instruction is executed between a MOVS instruction and the target instruction that MOVS modifies. This gives the cog time to write MOVS's result before it fetches the target instruction for execution; otherwise, the as-yet-unmodified version of the target instruction would be fetched and executed.

If the WZ effect is specified, the Z flag is set (1) if Value equals zero. The result is written to Destination 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.