/* * Created on Oct 19, 2004 * * TODO To change the template for this generated file go to * Window - Preferences - Java - Code Style - Code Templates */ /** * @author Administrator * * TODO To change the template for this generated type comment go to * Window - Preferences - Java - Code Style - Code Templates */ public class AsmPgm { String[] demo = { "demo.as", "0", "20010", "12011", "21012", "56999", "0", "0", "0", "0", "0", "0", "123", "456", "0", "0", "0", "0" }; String[] sum = { "sum.as", "0", "55999 0 in ax", "21020 1 copy x, ax", "55999 2 in ax", "21021 3 coy y, ax", "20020 4 copy ax, x", "12021 5 add ax, y", "21022 6 copy z, ax", "20022 7 copy ax, z", "56999 8 out ax", "00000 9", "00000 10", "00000 11", "00000 12", "00000 13", "00000 14", "00000 15", "00000 16", "00000 17", "00000 18", "00000 19", "00000 20 x 0", "00000 21 y 0", "00000 22 z 0", "00000 23 ", "00000 24" }; String[] largest = { "largest.as", "0", "55000 0 in ax", "21020 1 copy r, ax", "55000 2 in ax", "21021 3 copy s, ax", "20021 4 copy ax, s", "15020 5 cmp ax, r", "41010 6 jnb there", "20020 7 copy ax, r", "56000 8 out ax", "40012 9 jmp quit", "20021 10 there copy ax, s", "56000 11 out ax", "00000 12 quit halt", "00000 13", "00000 14", "00000 15", "00000 16", "00000 17", "00000 18", "00000 19 ", "00000 20 r 0", "00000 21 s 0", "00000" }; String[] summer = { "summer.as", "0", "20041 0 copy ax, #c0", "21040 1 copy limit, ax", "20041 2 copy ax, #c0", "21042 3 copy sum, ax", "55000 4 in ax", "21043 5 copy x, ax", "99000 6 #l0 no-op", "20040 7 copy ax, limit", "15043 8 cmp ax, x", "41016 9 jnb #l1", "20042 10 copy ax, sum", "12043 11 add ax, x", "21042 12 copy sum, ax", "55000 13 in ax", "21043 14 copy x, ax", "40006 15 jmp #l0", "99000 16 #l1 no-op", "20042 17 copy ax, sum", "56000 18 out ax", "00000 19 ", "00000 20 ", "00000 21 ", "00000 22 ", "00000 23 ", "00000 24 ", "00000 25 ", "00000 26 ", "00000 27 ", "00000 28 ", "00000 29 ", "00000 30 ", "00000 31 ", "00000 32 ", "00000 33 ", "00000 34 ", "00000 35 ", "00000 36 ", "00000 37 ", "00000 38 ", "00000 39 ", "00000 40 limit 0", "00000 41 #c0 0", "00000 42 sum 0", "00000 43 x 0", "00000 44 #l0 6", "00000 45 #l1 18", "00000" }; String[] fact = { "fact.as", "1", "00000 0", "55000 1 in ax", "21040 2 copy n, ax", "20042 3 copy ax, #c1", "21041 4 copy i, ax", "21043 5 copy fact, ax", "20040 6 #l0 copy ax, n", "12042 7 add ax, #c1", "21044 8 copy _e0, ax", "20041 9 copy ax, i", "15044 10 cmp ax, _e0", "41019 11 jnb #l1", "20043 12 copy ax, fact", "35041 13 mult ax, i", "21043 14 copy fact, ax", "20041 15 copy ax, i", "12042 16 add ax, #c1", "21041 17 copy i, ax", "40006 18 jmp #l0", "20043 19 #l1 copy ax, fact", "56000 20 out ax", "00000 21 halt", "00000 22", "00000 23", "00000 24", "00000 25", "00000 26", "00000 27", "00000 28", "00000 29", "00000 30", "00000 31", "00000 32", "00000 33", "00000 34", "00000 35", "00000 36", "00000 37", "00000 38", "00000 39", "00000 40 n 0", "00000 41 i 0", "00001 42 #c1 1", "00000 43 fact 0", "00000 44 _e0 0", "00000 ", "00000" }; String[] listsum = { "listsum.as ", "10 ", "0 0", "0 1", "0 2", "0 3", "0 4", "0 5", "0 6", "0 7", "0 8", "0 9", "20030 10 copy ax, zero", "21032 11 copy sum, ax", "21033 12 copy count, ax", "15040 13 loop cmp ax, size", "41025 14 jnb done", "20032 15 copy ax, sum", "12041 16 inst add ax, list", "21032 17 copy sum, ax", "20016 18 copy ax, inst", "12031 19 add ax, one", "21016 20 copy inst, ax", "20033 21 copy ax, count", "12031 22 add ax, one", "21033 23 copy count, ax", "40013 24 jmp loop", "20032 25 done copy ax, sum", "56000 26 out ax", "00000 27 halt", "00000 28", "00000 29", "00000 30 zero 0", "00001 31 one 1", "00000 32 sum 0", "00000 33 count 0", "00000 34", "00000 35", "00000 36", "00000 37", "00000 38", "00000 39", "9 40 size listend-list+1", "32 41 list 32", "11 42 11", "4 43 4", "-8 44 -8", "66 45 66", "15 46 15", "-5 47 -5", "22 48 22", "-12 49 listend -12" }; String[][] all = {demo, sum, largest, summer, fact, listsum}; String[] names; public AsmPgm(){ names = new String[all.length]; for (int k = 0; k < all.length; k++) names[k] = all[k][0]; } public String[] getNames(){ return names; } public String[] getPgm(int n){ return all[n]; } }