def param_value(memory, position, mode):
    """Get the value of a param according to its mode"""
    if mode == 0:  # position mode
        return memory[memory[position]]
    elif mode == 1: # immediate mode
        return memory[position]
    else:
        raise ValueError("Unknown mode : ", mode)