.method main
.args   1
.define OBJREF = 42
	bipush OBJREF
	invokevirtual readhex
	ireturn
           
.method readhex
.args 1
.define OBJREF = 51
.locals 4
.define num = 1
.define digit = 2
.define i = 3
.define c = 4

bipush 3
bipush 0
istore num
istore i

while:
	iload i
	iflt end_while
	bipush OBJREF
        invokevirtual getchar
        istore c                // c = getchar();
Taltest:
	bipush 47
	iload c
	if_icmplt Taltest2     
	goto error 
Taltest2:
	iload c
	bipush 58
	if_icmplt Tal
	goto lbtest1
lbtest1:
	bipush 96
	iload c
	if_icmplt lbtest2
        goto error
lbtest2:
	iload c
	bipush 103
	if_icmplt bogstav
	goto error

bogstav:	
	iload c
	bipush 87
	goto common
Tal:
	iload c
	bipush 48
	goto common
common:
	isub 
	istore digit
	iload num
	bipush 4
	ishl
	iload digit
	iadd
	istore num 		
	iload i
	bipush 1
	isub
	istore i
	goto while


error:
	bipush -1
	ireturn
	goto while 

end_while:
	iload num
	ireturn
