# Project: VAM (Virtual Assembler Machine) # Description: A VAM program computing square numbers # Input: read a number # Output: write square numbers 1 .... n^2 # Author: Dr. Jürgen Vollmer, # $Id: square.vam,v 1.2 2005/02/24 11:29:51 vollmer Exp $ s_in: "Please input an integer: " s_out: "^2 = " NL: "\n" start: write_s s_in read_i R4, R4 # R4: n write_s NL cload_i R5, 1 # R5: i = 1 loop: cmp_i R6, R5, R4 # if (i > n) goto end ifgt R6, end mult_i R6, R5, R5 # i * i write_i R5 # printf ("%d^2 = %d\n", i, i*i); write_s s_out write_i R6 write_s NL add_c R5, R5, 1 # i = i + 1 goto loop # and loop end: end