← Back to context

Comment by 10000truths

3 days ago

> Tomorrow you need to pass a 128 bit int into two registers and your fancy syntax then also becomes a messy bunch of hacks.

There are no 128-bit integer registers in x64 or arm64 or riscv64. There are operations that represent 128-bit scalar operands/results by storing the top and bottom halves in two 64-bit registers. From what I can gather, it would look something like this in Odin for x64:

  my_asm_mul :: asm(a: u64, b: u64) -> (c, d: u64) [
      a -> d = %rax,
      c = %rdx,
  ] {
      mul b
  }

  my_mul :: proc(a: u64, b: u64) -> u128 {
      hi, lo := my_asm_mul(a, b)
      result := (u128(hi) << 64) | u128(lo)
      return result
  }