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 (CF) and overflow (OF) 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.