# Project: VAM (Virtual Assembler Machine) # Description: A VAM program reading numbers and print them in reverse # Input: read numbers, until EOF # Output: write the read numbers in reverse order # Author: Dr. Jürgen Vollmer, # $Id: mirror.vam,v 1.3 2005/02/24 14:02:49 vollmer Exp $ s_in: "Please input integers until a non-integer is given\n" s_next: "Enter next number:" s_out: "Numbers in reverse order:\n" NL: "\n" start: write_s s_in copy R10, R1 # R10: a copy of the initial top-of-stack input: # read numbers and push them onto the stack write_s s_next read_i R4, R5 iffalse R5, output push R10, R4 goto input output: write_s s_out out_loop: # pop numbers from the stack, until stack is empty # "stack is empty" means R10 == R1 cmp_i R4, R1, R10 ifeq R4, end load R5, R10 write_i R5 write_s NL pop R10, 1 goto out_loop end: end