From 9f9dbb4807771f7d900504638b3877543655ed57 Mon Sep 17 00:00:00 2001 From: tommi27 Date: Mon, 26 Nov 2018 17:20:14 +0100 Subject: [PATCH] started mic1 --- Homework 8/ex3.ijvm | Bin 0 -> 70 bytes Homework 8/ex3.jas | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 Homework 8/ex3.ijvm create mode 100644 Homework 8/ex3.jas diff --git a/Homework 8/ex3.ijvm b/Homework 8/ex3.ijvm new file mode 100644 index 0000000000000000000000000000000000000000..e1ed6eaf744434f6fd4f3cffce8bf565237a8a25 GIT binary patch literal 70 zcmb1rb$=}bBLfI<0I>rQa|1C5XbCeg2#5-BZew8l&%n&UD8OLGEXp*KK}3{MlsUnS RS>V4YQ;HeW^8atw002m(3-SN} literal 0 HcmV?d00001 diff --git a/Homework 8/ex3.jas b/Homework 8/ex3.jas new file mode 100644 index 0000000..e899207 --- /dev/null +++ b/Homework 8/ex3.jas @@ -0,0 +1,37 @@ +// product.jas +.constant +OBJREF 0x40 // needed for method invokation - see S.C.O. chapter 4 +.end-constant + +.main // start of program + LDC_W OBJREF // do not forget to push OBJREF on stack! + BIPUSH 0x15 // paramater n (i.e., n = 21) + BIPUSH 0x09 // paramater m (i.e., m = 9) + INVOKEVIRTUAL product + HALT // stops program execution +.end-main + +.method product(n,m) // takes two arguments ("n" and "m") +.var +temp // change variable names as needed +.end-var + + // just some code example: + BIPUSH 0x00 + ISTORE temp +loop: + ILOAD m + IFEQ end + ILOAD n + ILOAD temp + IADD + ISTORE temp + BIPUSH 0xFF + ILOAD m + ISUB + ISTORE m + GOTO loop +end: + // this is obviously very useful + IRETURN +.end-method