def push_variable_on_stack(assembler, stack_offset,
                           value, value_array):
    """Push a value on a specified location on stack

    Args:
        assembler (Assembler): the assembler to use
        stack_offset (int): the offset relative to the current stack pointer
        value (bytearray): the byte array to append the machine code to
        value_array (bytearray): the bytearray to push to stack

    Returns:
        bytearray: the array with the added machine code
        int: the stackoffset
    """

    number_of_words = int((len(value_array) - 1) / 4) + 1
    for i in range(number_of_words):
        part_of_array = value_array[i * 4:(i + 1) * 4]
        stack_offset -= 4
        value += assembler.push_value_to_stack(part_of_array, stack_offset)

    # if multiple words are used, move the offset a word further
    if number_of_words > 1:
        stack_offset -= 4
    return value, stack_offset