num conversion

This commit is contained in:
Folkert 2023-04-27 11:36:56 +02:00
parent 1dd4b470dd
commit d10ae2412a
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
2 changed files with 63 additions and 216 deletions

View file

@ -2966,7 +2966,8 @@ impl<
}
} else {
match (source, target) {
(U8, U16 | U32 | U64) => {
// -- CASTING UP --
(I8 | U8, U16 | U32 | U64) => {
// zero out the register
ASM::xor_reg64_reg64_reg64(buf, dst_reg, dst_reg, dst_reg);
@ -2987,19 +2988,25 @@ impl<
// move the 32-bit integer
ASM::mov_reg_reg(buf, RegisterWidth::W32, dst_reg, src_reg);
}
(U64, U32) => {
(I8, I16 | I32 | I64) => {
// zero out the register
ASM::xor_reg64_reg64_reg64(buf, dst_reg, dst_reg, dst_reg);
// move the 8-bit integer
ASM::mov_reg_reg(buf, RegisterWidth::W8, dst_reg, src_reg);
}
// -- CASTING DOWN --
(U64 | I64, I32 | U32) => {
// move as a 32-bit integer (leaving any other bits behind)
ASM::mov_reg_reg(buf, RegisterWidth::W32, dst_reg, src_reg);
}
(U64, U16) => {
(U64 | I64 | U32 | I32, I16 | U16) => {
// move as a 16-bit integer (leaving any other bits behind)
ASM::mov_reg_reg(buf, RegisterWidth::W16, dst_reg, src_reg);
}
(U64, I8) => {
//
(U64 | I64 | U32 | I32 | U16 | I16, I8 | U8) => {
// move as an 8-bit integer (leaving any other bits behind)
ASM::mov_reg_reg(buf, RegisterWidth::W8, dst_reg, src_reg);
// TODO extension?
}
_ => todo!("int cast from {source:?} to {target:?}"),
}