this can be used as a helper function, but comments placed suggest to copy paste and then eliminate cases which aren't used in each opcode