38 lines
706 B
Plaintext
38 lines
706 B
Plaintext
|
// 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
|