done ex1.jas
This commit is contained in:
parent
c570dc6b24
commit
bae4fb3f26
3 changed files with 29 additions and 0 deletions
BIN
Homework 9/ex1.ijvm
Normal file
BIN
Homework 9/ex1.ijvm
Normal file
Binary file not shown.
24
Homework 9/ex1.jas
Normal file
24
Homework 9/ex1.jas
Normal file
|
@ -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
|
5
Homework 9/ex1.py
Normal file
5
Homework 9/ex1.py
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
def even(x):
|
||||||
|
if x & 0x01 == 0:
|
||||||
|
return 1 // even
|
||||||
|
else:
|
||||||
|
return 0 // odd
|
Reference in a new issue