Skip to main content

CONVERT

Set the left register to the value of the right register with a different size.

OpcodeBytesCyclesFormExample
$4833CONVERT B:_, P:_CONVERT B:1, P:2
$4933CONVERT B:_, I:_CONVERT B:1, I:4
$4A33CONVERT UNSIGNED P:_, B:_CONVERT UNSIGNED P:2, B:4
$4B33CONVERT SIGNED P:_, B:_CONVERT SIGNED P:2, B:4
$4C33CONVERT P:_, I:_CONVERT P:2, I:4
$4D33CONVERT UNSIGNED I:_, B:_CONVERT UNSIGNED I:4, B:8
$4E33CONVERT SIGNED I:_, B:_CONVERT SIGNED I:4, B:8
$4F33CONVERT UNSIGNED I:_, P:_CONVERT UNSIGNED I:4, P:8
$5033CONVERT SIGNED I:_, P:_CONVERT SIGNED I:4, P:8
Condition flagOutput
zero (ZF)If the result is zero, this flag is 1; otherwise it is 0.
negative (NF)If the signed result is a negative number, this flag is 1; otherwise it is 0.
overflow (OF)If the result exceeds the target register's signed range, this flag is 1; otherwise it is 0.
carry (CF)If the result exceeds the target register's unsigned range, this flag is 1; otherwise it is 0.

Notes

  • For narrowing conversions (for example, CONVERT B:1, P:2), you can use FAIL IF OVERFLOW to trap overflows.

  • The CARRY and OVERFLOW flags will always be 0 for widening conversions.

  • For widening conversions (for example, CONVERT P:2, SBYTE B:4), you must include a type specifier such as BYTE or SBYTE to indicate whether the value is unsigned or signed. For example, if $FE means -2, then its PAIR value should be $FFFE. Whereas if $FE means 254, then its PAIR value should be $00fE.