// reverse_in_stack.iml (c) 1997 - 2000 Kari Laitinen // The following program is similar to "reverse_in_memory.iml". // It reads a text from keyboard as a string of ASCII characters. // After receiving a space, it displays the characters // in reverse order. This program puts the characters into the // stack. In the end it reads the characters away from the stack. // Due to the nature of stack as a data storage, the characters // will automatically come out in reverse order. beginning_of_program: load_register_a_with_value 0 push_register_a_to_stack read_character: call_subroutine read_and_echo_a_character push_register_a_to_stack load_register_b_with_value ' ' // code for space jump_if_registers_equal print_characters_from_stack jump_to_address read_character print_characters_from_stack: pop_register_a_from_stack jump_if_register_a_zero all_characters_printed output_byte_from_register_a jump_to_address print_characters_from_stack all_characters_printed: stop_processing read_and_echo_a_character: jump_if_input_not_ready read_and_echo_a_character input_byte_to_register_a output_byte_from_register_a return_to_calling_program