From bae4fb3f26c8b2329bb231875706be53c93d3817 Mon Sep 17 00:00:00 2001 From: tommi27 Date: Thu, 29 Nov 2018 20:44:57 +0100 Subject: [PATCH] done ex1.jas --- Homework 9/ex1.ijvm | Bin 0 -> 55 bytes Homework 9/ex1.jas | 24 ++++++++++++++++++++++++ Homework 9/ex1.py | 5 +++++ 3 files changed, 29 insertions(+) create mode 100644 Homework 9/ex1.ijvm create mode 100644 Homework 9/ex1.jas create mode 100644 Homework 9/ex1.py diff --git a/Homework 9/ex1.ijvm b/Homework 9/ex1.ijvm new file mode 100644 index 0000000000000000000000000000000000000000..d2b9c0d7ac27f69295315a6658a7768a0af10fea GIT binary patch literal 55 zcmb1rb$=}bBLfI<0I>rQa{@64NDDJC2>jf}!1$kmiGe|sQGl^-CIg!Q!x{m`H2~%D B2$BE* literal 0 HcmV?d00001 diff --git a/Homework 9/ex1.jas b/Homework 9/ex1.jas new file mode 100644 index 0000000..bf0750c --- /dev/null +++ b/Homework 9/ex1.jas @@ -0,0 +1,24 @@ +.constant +OBJREF 0x40 +.end-constant + +.main + LDC_W OBJREF + BIPUSH 0xF9 + INVOKEVIRTUAL even + HALT +.end-main + +.method even(x) +.var +.end-var + ILOAD x + BIPUSH 0x01 + IAND + IFEQ even + BIPUSH 0x00 + IRETURN // odd +even: + BIPUSH 0x01 + IRETURN // even +.end-method diff --git a/Homework 9/ex1.py b/Homework 9/ex1.py new file mode 100644 index 0000000..37d49aa --- /dev/null +++ b/Homework 9/ex1.py @@ -0,0 +1,5 @@ +def even(x): + if x & 0x01 == 0: + return 1 // even + else: + return 0 // odd