#!/usr/bin/python3

with open("kernel/arch/vectors.s", "w") as f:
	f.write("; vectors.s - generated by vectors.py\n");
	f.write("; Michael Lazear 2016, adapted from xv6-public\n")
	f.write("extern trap_handler\n\n")
	for i in range(0, 256):
		f.write("global vector{0}\n".format(i))
		f.write("vector{0}:\n".format(i))
		if (i not in [8, 10, 11, 12, 13, 14, 16]):
			f.write("\tpush 0\n")
		f.write("\tpush {0}\n".format(i))
		f.write("\tjmp trap_handler\n")

	f.write("global vectors\n")
	f.write("vectors:\n")
	for i in range(0, 256):
		f.write("\tdd vector{0}\n".format(i))
