essential-contributions / essential-base

Core items shared by both the intent language and protocol.
https://essential.builders
Apache License 2.0
2 stars 0 forks source link

Add other ALU and predicate ops to ASM #165

Open freesig opened 4 weeks ago

freesig commented 4 weeks ago

Pred

Xor:
  description: Logical XOR of two bools
  stack_in: [lhs, rhs]
  stack_out: [lhs as bool ^ rhs as bool]

ShiftLeft:
  description: Shift the value word left by number of bits.
  stack_in: [value, number_of_bits]
  stack_out: [left_shifted_value]

ShiftRight:
  description: Shift the value word right by number of bits.
  stack_in: [value, number_of_bits]
  stack_out: [right_shifted_value]

ALU

Exp:
  description: lhs to the power of the rhs
  stack_in: [lhs, rhs]
  stack_out: [lhs ** rhs]
freesig commented 4 weeks ago

@mohammadfawaz I think this is all the missing arithmetic and logic ops. Can you think of any others?

mohammadfawaz commented 4 weeks ago

This is good! Let's start with this and we'll add more as we see more applications. I suspect logarithms will come in handy at some point.

freesig commented 4 weeks ago

Note to self, make room at end of arithmetic byte for more ops

freesig commented 3 weeks ago

@mohammadfawaz I was thinking maybe we want a bitwise AND for words? The left and right shift only seem useful if you can combine two words into one after shifting things around.

mohammadfawaz commented 3 weeks ago

@mohammadfawaz I was thinking maybe we want a bitwise AND for words?

Yeah those are standard I suppose.. wouldn't hurt to have them. They could be useful for various optimizations as well.